static void test_bool_fcn (QofBook *book, const char *message, void (*set) (GncEmployee *, gboolean), gboolean (*get) (const GncEmployee *)) { GncEmployee *employee = gncEmployeeCreate (book); gboolean num = get_random_boolean (); do_test (!gncEmployeeIsDirty (employee), "test if start dirty"); gncEmployeeBeginEdit (employee); set (employee, FALSE); set (employee, TRUE); set (employee, num); /* Employee record should be dirty */ do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); /* Employee record should be not dirty */ /* Skip, because will always fail without a backend. * It's not possible to load a backend in the engine code * without having circular dependencies. */ // do_test (!gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (get (employee) == num, message); gncEmployeeSetActive (employee, FALSE); count++; }
static void gnc_ui_to_employee (EmployeeWindow *ew, GncEmployee *employee) { GncAddress *addr; addr = gncEmployeeGetAddr (employee); gnc_suspend_gui_refresh (); gncEmployeeBeginEdit (employee); if (ew->dialog_type == NEW_EMPLOYEE) qof_event_gen(QOF_INSTANCE(employee), QOF_EVENT_ADD, NULL); gncEmployeeSetID (employee, gtk_editable_get_chars (GTK_EDITABLE (ew->id_entry), 0, -1)); gncEmployeeSetUsername (employee, gtk_editable_get_chars (GTK_EDITABLE (ew->username_entry), 0, -1)); gncAddressSetName (addr, gtk_editable_get_chars (GTK_EDITABLE (ew->name_entry), 0, -1)); gncAddressSetAddr1 (addr, gtk_editable_get_chars (GTK_EDITABLE (ew->addr1_entry), 0, -1)); gncAddressSetAddr2 (addr, gtk_editable_get_chars (GTK_EDITABLE (ew->addr2_entry), 0, -1)); gncAddressSetAddr3 (addr, gtk_editable_get_chars (GTK_EDITABLE (ew->addr3_entry), 0, -1)); gncAddressSetAddr4 (addr, gtk_editable_get_chars (GTK_EDITABLE (ew->addr4_entry), 0, -1)); gncAddressSetPhone (addr, gtk_editable_get_chars (GTK_EDITABLE (ew->phone_entry), 0, -1)); gncAddressSetFax (addr, gtk_editable_get_chars (GTK_EDITABLE (ew->fax_entry), 0, -1)); gncAddressSetEmail (addr, gtk_editable_get_chars (GTK_EDITABLE (ew->email_entry), 0, -1)); gncEmployeeSetActive (employee, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ew->active_check))); gncEmployeeSetLanguage (employee, gtk_editable_get_chars (GTK_EDITABLE (ew->language_entry), 0, -1)); /* Parse and set the workday and rate amounts */ gncEmployeeSetWorkday (employee, gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (ew->workday_amount))); gncEmployeeSetRate (employee, gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (ew->rate_amount))); gncEmployeeSetCurrency (employee, gnc_currency_edit_get_currency (GNC_CURRENCY_EDIT (ew->currency_edit))); /* Fill in the CCard Acct */ gncEmployeeSetCCard (employee, (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ew->ccard_acct_check)) ? gnc_account_sel_get_account (GNC_ACCOUNT_SEL (ew->ccard_acct_sel)) : NULL)); gncEmployeeCommitEdit (employee); gnc_resume_gui_refresh (); }
static gboolean employee_active_handler (xmlNodePtr node, gpointer employee_pdata) { struct employee_pdata *pdata = employee_pdata; gint64 val; gboolean ret; ret = dom_tree_to_integer(node, &val); if (ret) gncEmployeeSetActive(pdata->employee, (gboolean)val); return ret; }
static void test_gint_fcn (QofBook *book, const char *message, void (*set) (GncEmployee *, gint), gint (*get) (GncEmployee *)) { GncEmployee *employee = gncEmployeeCreate (book); gint num = 17; do_test (!gncEmployeeIsDirty (employee), "test if start dirty"); gncEmployeeBeginEdit (employee); set (employee, num); do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); do_test (!gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (get (employee) == num, message); gncEmployeeSetActive (employee, FALSE); count++; }
static void test_numeric_fcn (QofBook *book, const char *message, void (*set) (GncEmployee *, gnc_numeric), gnc_numeric (*get)(const GncEmployee *)) { GncEmployee *employee = gncEmployeeCreate (book); gnc_numeric num = gnc_numeric_create (17, 1); do_test (!gncEmployeeIsDirty (employee), "test if start dirty"); gncEmployeeBeginEdit (employee); set (employee, num); do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); do_test (gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (gnc_numeric_equal (get (employee), num), message); gncEmployeeSetActive (employee, FALSE); count++; }
static void test_string_fcn (QofBook *book, const char *message, void (*set) (GncEmployee *, const char *str), const char * (*get)(const GncEmployee *)) { GncEmployee *employee = gncEmployeeCreate (book); char const *str = get_random_string (); do_test (!gncEmployeeIsDirty (employee), "test if start dirty"); gncEmployeeBeginEdit (employee); set (employee, str); do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); do_test (gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (safe_strcmp (get (employee), str) == 0, message); gncEmployeeSetActive (employee, FALSE); count++; }
static void test_bool_fcn (QofBook *book, const char *message, void (*set) (GncEmployee *, gboolean), gboolean (*get) (const GncEmployee *)) { GncEmployee *employee = gncEmployeeCreate (book); gboolean num = get_random_boolean (); do_test (!gncEmployeeIsDirty (employee), "test if start dirty"); gncEmployeeBeginEdit (employee); set (employee, FALSE); set (employee, TRUE); set (employee, num); do_test (gncEmployeeIsDirty (employee), "test dirty later"); gncEmployeeCommitEdit (employee); do_test (gncEmployeeIsDirty (employee), "test dirty after commit"); do_test (get (employee) == num, message); gncEmployeeSetActive (employee, FALSE); count++; }
void gncOwnerSetActive (const GncOwner *owner, gboolean active) { if (!owner) return; switch (owner->type) { case GNC_OWNER_CUSTOMER: gncCustomerSetActive (owner->owner.customer, active); break; case GNC_OWNER_VENDOR: gncVendorSetActive (owner->owner.vendor, active); break; case GNC_OWNER_EMPLOYEE: gncEmployeeSetActive (owner->owner.employee, active); break; case GNC_OWNER_JOB: gncJobSetActive (owner->owner.job, active); break; case GNC_OWNER_NONE: case GNC_OWNER_UNDEFINED: default: break; } }