GnuCash c935c2f+
Loading...
Searching...
No Matches
Files | Macros | Functions

Files

file  gncEmployee.h
 Employee Interface.
 

Macros

#define GNC_ID_EMPLOYEE   "gncEmployee"
 
#define GNC_TYPE_EMPLOYEE   (gnc_employee_get_type ())
 
#define GNC_EMPLOYEE(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_EMPLOYEE, GncEmployee))
 
#define GNC_EMPLOYEE_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_EMPLOYEE, GncEmployeeClass))
 
#define GNC_IS_EMPLOYEE(o)    (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_EMPLOYEE))
 
#define GNC_IS_EMPLOYEE_CLASS(k)    (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_EMPLOYEE))
 
#define GNC_EMPLOYEE_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_EMPLOYEE, GncEmployeeClass))
 
#define EMPLOYEE_ID   "id"
 
#define EMPLOYEE_USERNAME   "username"
 
#define EMPLOYEE_NAME   "name"
 
#define EMPLOYEE_ADDR   "addr"
 
#define EMPLOYEE_LANGUAGE   "native language"
 
#define EMPLOYEE_ACL   "acl"
 
#define EMPLOYEE_WORKDAY   "workday"
 
#define EMPLOYEE_RATE   "rate"
 
#define EMPLOYEE_CC   "credit_card_account"
 
#define gncEmployeeGetGUID(E)   qof_entity_get_guid(QOF_INSTANCE(E))
 deprecated routines
 
#define gncEmployeeGetBook(E)   qof_instance_get_book(QOF_INSTANCE(E))
 
#define gncEmployeeRetGUID(E)   (E ? *(qof_entity_get_guid(QOF_INSTANCE(E))) : *(guid_null()))
 
#define gncEmployeeLookupDirect(G, B)   gncEmployeeLookup((B),&(G))
 

Functions

GType gnc_employee_get_type (void)
 
gboolean gncEmployeeEqual (const GncEmployee *e1, const GncEmployee *e2)
 Test support function, used by test-dbi-business-stuff.c.
 
gboolean gncEmployeeIsDirty (const GncEmployee *employee)
 

Create/Destroy Functions

GncEmployee * gncEmployeeCreate (QofBook *book)
 
void gncEmployeeDestroy (GncEmployee *employee)
 
void gncEmployeeBeginEdit (GncEmployee *employee)
 
void gncEmployeeCommitEdit (GncEmployee *employee)
 
int gncEmployeeCompare (const GncEmployee *a, const GncEmployee *b)
 

Set Functions

void gncEmployeeSetID (GncEmployee *employee, const char *id)
 
void gncEmployeeSetUsername (GncEmployee *employee, const char *username)
 
void gncEmployeeSetName (GncEmployee *employee, const char *name)
 
void gncEmployeeSetLanguage (GncEmployee *employee, const char *language)
 
void gncEmployeeSetAcl (GncEmployee *employee, const char *acl)
 
void gncEmployeeSetWorkday (GncEmployee *employee, gnc_numeric workday)
 
void gncEmployeeSetRate (GncEmployee *employee, gnc_numeric rate)
 
void gncEmployeeSetCurrency (GncEmployee *employee, gnc_commodity *currency)
 
void gncEmployeeSetActive (GncEmployee *employee, gboolean active)
 
void gncEmployeeSetCCard (GncEmployee *employee, Account *ccard_acc)
 
void qofEmployeeSetAddr (GncEmployee *employee, QofInstance *addr_ent)
 

Get Functions

QofBookgncEmployeeGetBook (GncEmployee *employee)
 
const char * gncEmployeeGetID (const GncEmployee *employee)
 
const char * gncEmployeeGetUsername (const GncEmployee *employee)
 
const char * gncEmployeeGetName (const GncEmployee *employee)
 
GncAddressgncEmployeeGetAddr (const GncEmployee *employee)
 
const char * gncEmployeeGetLanguage (const GncEmployee *employee)
 
const char * gncEmployeeGetAcl (const GncEmployee *employee)
 
gnc_numeric gncEmployeeGetWorkday (const GncEmployee *employee)
 
gnc_numeric gncEmployeeGetRate (const GncEmployee *employee)
 
gnc_commodity * gncEmployeeGetCurrency (const GncEmployee *employee)
 
gboolean gncEmployeeGetActive (const GncEmployee *employee)
 
AccountgncEmployeeGetCCard (const GncEmployee *employee)
 

Detailed Description

Macro Definition Documentation

◆ EMPLOYEE_ACL

#define EMPLOYEE_ACL   "acl"

Definition at line 127 of file gncEmployee.h.

◆ EMPLOYEE_ADDR

#define EMPLOYEE_ADDR   "addr"

Definition at line 125 of file gncEmployee.h.

◆ EMPLOYEE_CC

#define EMPLOYEE_CC   "credit_card_account"

Definition at line 130 of file gncEmployee.h.

◆ EMPLOYEE_ID

#define EMPLOYEE_ID   "id"

Definition at line 122 of file gncEmployee.h.

◆ EMPLOYEE_LANGUAGE

#define EMPLOYEE_LANGUAGE   "native language"

Definition at line 126 of file gncEmployee.h.

◆ EMPLOYEE_NAME

#define EMPLOYEE_NAME   "name"

Definition at line 124 of file gncEmployee.h.

◆ EMPLOYEE_RATE

#define EMPLOYEE_RATE   "rate"

Definition at line 129 of file gncEmployee.h.

◆ EMPLOYEE_USERNAME

#define EMPLOYEE_USERNAME   "username"

Definition at line 123 of file gncEmployee.h.

◆ EMPLOYEE_WORKDAY

#define EMPLOYEE_WORKDAY   "workday"

Definition at line 128 of file gncEmployee.h.

◆ GNC_EMPLOYEE

#define GNC_EMPLOYEE (   o)     (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_EMPLOYEE, GncEmployee))

Definition at line 48 of file gncEmployee.h.

117{
118 QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_EMPLOYEE, GncEmployee);
119}
120
121
122#define EMPLOYEE_ID "id"
123#define EMPLOYEE_USERNAME "username"
124#define EMPLOYEE_NAME "name"
125#define EMPLOYEE_ADDR "addr"
126#define EMPLOYEE_LANGUAGE "native language"
127#define EMPLOYEE_ACL "acl"
128#define EMPLOYEE_WORKDAY "workday"
129#define EMPLOYEE_RATE "rate"
130#define EMPLOYEE_CC "credit_card_account"
131
133#define gncEmployeeGetGUID(E) qof_entity_get_guid(QOF_INSTANCE(E))
134#define gncEmployeeGetBook(E) qof_instance_get_book(QOF_INSTANCE(E))
135#define gncEmployeeRetGUID(E) (E ? *(qof_entity_get_guid(QOF_INSTANCE(E))) : *(guid_null()))
136#define gncEmployeeLookupDirect(G,B) gncEmployeeLookup((B),&(G))
137
139gboolean gncEmployeeEqual(const GncEmployee* e1, const GncEmployee* e2);
140gboolean gncEmployeeIsDirty (const GncEmployee *employee);
141
142#ifdef __cplusplus
143}
144#endif
145
146#endif /* GNC_EMPLOYEE_H_ */
#define QOF_BOOK_RETURN_ENTITY(book, guid, e_type, c_type)
Encapsulates all the information about a dataset manipulated by QOF.
Definition qofbook.h:101
gboolean gncEmployeeEqual(const GncEmployee *e1, const GncEmployee *e2)
Test support function, used by test-dbi-business-stuff.c.

◆ GNC_EMPLOYEE_CLASS

#define GNC_EMPLOYEE_CLASS (   k)     (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_EMPLOYEE, GncEmployeeClass))

Definition at line 50 of file gncEmployee.h.

◆ GNC_EMPLOYEE_GET_CLASS

#define GNC_EMPLOYEE_GET_CLASS (   o)     (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_EMPLOYEE, GncEmployeeClass))

Definition at line 56 of file gncEmployee.h.

◆ GNC_ID_EMPLOYEE

#define GNC_ID_EMPLOYEE   "gncEmployee"

Definition at line 44 of file gncEmployee.h.

◆ GNC_IS_EMPLOYEE

#define GNC_IS_EMPLOYEE (   o)     (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_EMPLOYEE))

Definition at line 52 of file gncEmployee.h.

◆ GNC_IS_EMPLOYEE_CLASS

#define GNC_IS_EMPLOYEE_CLASS (   k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_EMPLOYEE))

Definition at line 54 of file gncEmployee.h.

◆ GNC_TYPE_EMPLOYEE

#define GNC_TYPE_EMPLOYEE   (gnc_employee_get_type ())

Definition at line 47 of file gncEmployee.h.

◆ gncEmployeeGetBook

#define gncEmployeeGetBook (   E)    qof_instance_get_book(QOF_INSTANCE(E))

Definition at line 134 of file gncEmployee.h.

◆ gncEmployeeGetGUID

#define gncEmployeeGetGUID (   E)    qof_entity_get_guid(QOF_INSTANCE(E))

deprecated routines

Definition at line 133 of file gncEmployee.h.

◆ gncEmployeeLookupDirect

#define gncEmployeeLookupDirect (   G,
 
)    gncEmployeeLookup((B),&(G))

Definition at line 136 of file gncEmployee.h.

◆ gncEmployeeRetGUID

#define gncEmployeeRetGUID (   E)    (E ? *(qof_entity_get_guid(QOF_INSTANCE(E))) : *(guid_null()))

Definition at line 135 of file gncEmployee.h.

Function Documentation

◆ gncEmployeeBeginEdit()

void gncEmployeeBeginEdit ( GncEmployee *  employee)

Definition at line 694 of file gncEmployee.c.

695{
696 qof_begin_edit(&employee->inst);
697}
gboolean qof_begin_edit(QofInstance *inst)
begin_edit

◆ gncEmployeeCommitEdit()

void gncEmployeeCommitEdit ( GncEmployee *  employee)

Definition at line 718 of file gncEmployee.c.

719{
720 if (!qof_commit_edit (QOF_INSTANCE(employee))) return;
721 qof_commit_edit_part2 (&employee->inst, gncEmployeeOnError,
722 gncEmployeeOnDone, emp_free);
723}
gboolean qof_commit_edit_part2(QofInstance *inst, void(*on_error)(QofInstance *, QofBackendError), void(*on_done)(QofInstance *), void(*on_free)(QofInstance *))
part2 – deal with the backend
gboolean qof_commit_edit(QofInstance *inst)
commit_edit helpers

◆ gncEmployeeCompare()

int gncEmployeeCompare ( const GncEmployee *  a,
const GncEmployee *  b 
)

Definition at line 728 of file gncEmployee.c.

729{
730 if (!a && !b) return 0;
731 if (!a && b) return 1;
732 if (a && !b) return -1;
733
734 return(strcmp(a->username, b->username));
735}

◆ gncEmployeeCreate()

GncEmployee * gncEmployeeCreate ( QofBook book)

Definition at line 428 of file gncEmployee.c.

429{
430 GncEmployee *employee;
431
432 if (!book) return NULL;
433
434 employee = g_object_new (GNC_TYPE_EMPLOYEE, NULL);
435 qof_instance_init_data (&employee->inst, _GNC_MOD_NAME, book);
436
437 employee->id = CACHE_INSERT ("");
438 employee->username = CACHE_INSERT ("");
439 employee->language = CACHE_INSERT ("");
440 employee->acl = CACHE_INSERT ("");
441 employee->addr = gncAddressCreate (book, &employee->inst);
442 employee->workday = gnc_numeric_zero();
443 employee->rate = gnc_numeric_zero();
444 employee->active = TRUE;
445 employee->balance = NULL;
446
447 if (empl_qof_event_handler_id == 0)
448 empl_qof_event_handler_id = qof_event_register_handler (empl_handle_qof_events, NULL);
449
450 qof_event_gen (&employee->inst, QOF_EVENT_CREATE, NULL);
451
452 return employee;
453}
gint qof_event_register_handler(QofEventHandler handler, gpointer user_data)
Register a handler for events.
Definition qofevent.cpp:73
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition qofevent.cpp:231
void qof_instance_init_data(QofInstance *inst, QofIdType type, QofBook *book)
Initialise the settings associated with an instance.

◆ gncEmployeeDestroy()

void gncEmployeeDestroy ( GncEmployee *  employee)

Definition at line 455 of file gncEmployee.c.

456{
457 if (!employee) return;
458 qof_instance_set_destroying(employee, TRUE);
459 gncEmployeeCommitEdit(employee);
460}

◆ gncEmployeeEqual()

gboolean gncEmployeeEqual ( const GncEmployee *  e1,
const GncEmployee *  e2 
)

Test support function, used by test-dbi-business-stuff.c.

Definition at line 737 of file gncEmployee.c.

738{
739 if (a == NULL && b == NULL) return TRUE;
740 if (a == NULL || b == NULL ) return FALSE;
741
742 g_return_val_if_fail(GNC_IS_EMPLOYEE(a), FALSE);
743 g_return_val_if_fail(GNC_IS_EMPLOYEE(b), FALSE);
744
745 if (g_strcmp0(a->id, b->id) != 0)
746 {
747 PWARN("IDs differ: %s vs %s", a->id, b->id);
748 return FALSE;
749 }
750
751 if (g_strcmp0(a->username, b->username) != 0)
752 {
753 PWARN("Usernames differ: %s vs %s", a->username, b->username);
754 return FALSE;
755 }
756
757 if (!gncAddressEqual(a->addr, b->addr))
758 {
759 PWARN("Addresses differ");
760 return FALSE;
761 }
762
763 if (!gnc_commodity_equal(a->currency, b->currency))
764 {
765 PWARN("Currencies differ");
766 return FALSE;
767 }
768
769 if (a->active != b->active)
770 {
771 PWARN("Active flags differ");
772 return FALSE;
773 }
774
775 if (g_strcmp0(a->language, b->language) != 0)
776 {
777 PWARN("Languages differ: %s vs %s", a->language, b->language);
778 return FALSE;
779 }
780
781 if (g_strcmp0(a->acl, b->acl) != 0)
782 {
783 PWARN("ACLs differ: %s vs %s", a->acl, b->acl);
784 return FALSE;
785 }
786
787 if (!xaccAccountEqual(a->ccard_acc, b->ccard_acc, TRUE))
788 {
789 PWARN("Accounts differ");
790 return FALSE;
791 }
792
793 if (!gnc_numeric_equal(a->workday, b->workday))
794 {
795 PWARN("Workdays differ");
796 return FALSE;
797 }
798
799 if (!gnc_numeric_equal(a->rate, b->rate))
800 {
801 PWARN("Rates differ");
802 return FALSE;
803 }
804
805 return TRUE;
806}
gboolean xaccAccountEqual(const Account *aa, const Account *ab, gboolean check_guids)
Compare two accounts for equality - this is a deep compare.
Definition Account.cpp:1666
gboolean gncAddressEqual(const GncAddress *a, const GncAddress *b)
Deeply compare two addresses.
Definition gncAddress.c:577
gboolean gnc_commodity_equal(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equal.
#define PWARN(format, args...)
Log a warning.
Definition qoflog.h:250
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b represent the same number.

◆ gncEmployeeGetAcl()

const char * gncEmployeeGetAcl ( const GncEmployee *  employee)

Definition at line 651 of file gncEmployee.c.

652{
653 if (!employee) return NULL;
654 return employee->acl;
655}

◆ gncEmployeeGetActive()

gboolean gncEmployeeGetActive ( const GncEmployee *  employee)

Definition at line 675 of file gncEmployee.c.

676{
677 if (!employee) return FALSE;
678 return employee->active;
679}

◆ gncEmployeeGetAddr()

GncAddress * gncEmployeeGetAddr ( const GncEmployee *  employee)

Definition at line 639 of file gncEmployee.c.

640{
641 if (!employee) return NULL;
642 return employee->addr;
643}

◆ gncEmployeeGetCCard()

Account * gncEmployeeGetCCard ( const GncEmployee *  employee)

Definition at line 681 of file gncEmployee.c.

682{
683 if (!employee) return NULL;
684 return employee->ccard_acc;
685}

◆ gncEmployeeGetCurrency()

gnc_commodity * gncEmployeeGetCurrency ( const GncEmployee *  employee)

Definition at line 669 of file gncEmployee.c.

670{
671 if (!employee) return NULL;
672 return employee->currency;
673}

◆ gncEmployeeGetID()

const char * gncEmployeeGetID ( const GncEmployee *  employee)

Definition at line 616 of file gncEmployee.c.

617{
618 if (!employee) return NULL;
619 return employee->id;
620}

◆ gncEmployeeGetLanguage()

const char * gncEmployeeGetLanguage ( const GncEmployee *  employee)

Definition at line 645 of file gncEmployee.c.

646{
647 if (!employee) return NULL;
648 return employee->language;
649}

◆ gncEmployeeGetName()

const char * gncEmployeeGetName ( const GncEmployee *  employee)

Definition at line 633 of file gncEmployee.c.

634{
635 if (!employee) return NULL;
636 return gncAddressGetName ( gncEmployeeGetAddr (employee));
637}

◆ gncEmployeeGetRate()

gnc_numeric gncEmployeeGetRate ( const GncEmployee *  employee)

Definition at line 663 of file gncEmployee.c.

664{
665 if (!employee) return gnc_numeric_zero();
666 return employee->rate;
667}

◆ gncEmployeeGetUsername()

const char * gncEmployeeGetUsername ( const GncEmployee *  employee)

Definition at line 622 of file gncEmployee.c.

623{
624 if (!employee) return NULL;
625 return employee->username;
626}

◆ gncEmployeeGetWorkday()

gnc_numeric gncEmployeeGetWorkday ( const GncEmployee *  employee)

Definition at line 657 of file gncEmployee.c.

658{
659 if (!employee) return gnc_numeric_zero();
660 return employee->workday;
661}

◆ gncEmployeeIsDirty()

gboolean gncEmployeeIsDirty ( const GncEmployee *  employee)

Definition at line 687 of file gncEmployee.c.

688{
689 if (!employee) return FALSE;
690 return (qof_instance_get_dirty_flag(employee)
691 || gncAddressIsDirty (employee->addr));
692}
gboolean qof_instance_get_dirty_flag(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object has been modified.

◆ gncEmployeeSetAcl()

void gncEmployeeSetAcl ( GncEmployee *  employee,
const char *  acl 
)

Definition at line 528 of file gncEmployee.c.

529{
530 if (!employee) return;
531 if (!acl) return;
532 SET_STR(employee, employee->acl, acl);
533 mark_employee (employee);
534 gncEmployeeCommitEdit (employee);
535}

◆ gncEmployeeSetActive()

void gncEmployeeSetActive ( GncEmployee *  employee,
gboolean  active 
)

Definition at line 569 of file gncEmployee.c.

570{
571 if (!employee) return;
572 if (active == employee->active) return;
573 gncEmployeeBeginEdit (employee);
574 employee->active = active;
575 mark_employee (employee);
576 gncEmployeeCommitEdit (employee);
577}

◆ gncEmployeeSetCCard()

void gncEmployeeSetCCard ( GncEmployee *  employee,
Account ccard_acc 
)

Definition at line 579 of file gncEmployee.c.

580{
581 if (!employee) return;
582 if (ccard_acc == employee->ccard_acc) return;
583 gncEmployeeBeginEdit (employee);
584 employee->ccard_acc = ccard_acc;
585 mark_employee (employee);
586 gncEmployeeCommitEdit (employee);
587}

◆ gncEmployeeSetCurrency()

void gncEmployeeSetCurrency ( GncEmployee *  employee,
gnc_commodity *  currency 
)

Definition at line 557 of file gncEmployee.c.

558{
559 if (!employee || !currency) return;
560 if (employee->currency &&
561 gnc_commodity_equal (employee->currency, currency))
562 return;
563 gncEmployeeBeginEdit (employee);
564 employee->currency = currency;
565 mark_employee (employee);
566 gncEmployeeCommitEdit (employee);
567}

◆ gncEmployeeSetID()

void gncEmployeeSetID ( GncEmployee *  employee,
const char *  id 
)

Definition at line 489 of file gncEmployee.c.

490{
491 if (!employee) return;
492 if (!id) return;
493 SET_STR(employee, employee->id, id);
494 mark_employee (employee);
495 gncEmployeeCommitEdit (employee);
496}

◆ gncEmployeeSetLanguage()

void gncEmployeeSetLanguage ( GncEmployee *  employee,
const char *  language 
)

Definition at line 519 of file gncEmployee.c.

520{
521 if (!employee) return;
522 if (!language) return;
523 SET_STR(employee, employee->language, language);
524 mark_employee (employee);
525 gncEmployeeCommitEdit (employee);
526}

◆ gncEmployeeSetName()

void gncEmployeeSetName ( GncEmployee *  employee,
const char *  name 
)

Definition at line 512 of file gncEmployee.c.

513{
514 if (!employee) return;
515 if (!name) return;
516 gncAddressSetName (gncEmployeeGetAddr (employee), name);
517}

◆ gncEmployeeSetRate()

void gncEmployeeSetRate ( GncEmployee *  employee,
gnc_numeric  rate 
)

Definition at line 547 of file gncEmployee.c.

548{
549 if (!employee) return;
550 if (gnc_numeric_equal (rate, employee->rate)) return;
551 gncEmployeeBeginEdit (employee);
552 employee->rate = rate;
553 mark_employee (employee);
554 gncEmployeeCommitEdit (employee);
555}

◆ gncEmployeeSetUsername()

void gncEmployeeSetUsername ( GncEmployee *  employee,
const char *  username 
)

Definition at line 498 of file gncEmployee.c.

499{
500 if (!employee) return;
501 if (!username) return;
502 SET_STR(employee, employee->username, username);
503 mark_employee (employee);
504 gncEmployeeCommitEdit (employee);
505}

◆ gncEmployeeSetWorkday()

void gncEmployeeSetWorkday ( GncEmployee *  employee,
gnc_numeric  workday 
)

Definition at line 537 of file gncEmployee.c.

538{
539 if (!employee) return;
540 if (gnc_numeric_equal (workday, employee->workday)) return;
541 gncEmployeeBeginEdit (employee);
542 employee->workday = workday;
543 mark_employee (employee);
544 gncEmployeeCommitEdit (employee);
545}

◆ qofEmployeeSetAddr()

void qofEmployeeSetAddr ( GncEmployee *  employee,
QofInstance addr_ent 
)

Definition at line 590 of file gncEmployee.c.

591{
592 GncAddress *addr;
593
594 if (!employee || !addr_ent)
595 {
596 return;
597 }
598 addr = (GncAddress*)addr_ent;
599 if (addr == employee->addr)
600 {
601 return;
602 }
603 if (employee->addr != NULL)
604 {
605 gncAddressBeginEdit(employee->addr);
606 gncAddressDestroy(employee->addr);
607 }
608 gncEmployeeBeginEdit(employee);
609 employee->addr = addr;
610 mark_employee (employee);
611 gncEmployeeCommitEdit(employee);
612}