static void test_bool_fcn (QofBook *book, const char *message, void (*set) (GncCustomer *, gboolean), gboolean (*get) (const GncCustomer *)) { GncCustomer *customer = gncCustomerCreate (book); gboolean num = get_random_boolean (); do_test (!gncCustomerIsDirty (customer), "test if start dirty"); gncCustomerBeginEdit (customer); set (customer, FALSE); set (customer, TRUE); set (customer, num); /* Customer record should be dirty */ do_test (gncCustomerIsDirty (customer), "test dirty later"); gncCustomerCommitEdit (customer); /* Customer 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 (!gncCustomerIsDirty (customer), "test dirty after commit"); do_test (get (customer) == num, message); gncCustomerSetActive (customer, 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; } }
static void gnc_ui_to_customer (CustomerWindow *cw, GncCustomer *cust) { GtkTextBuffer* text_buffer; GtkTextIter start, end; gchar *text; GncAddress *addr, *shipaddr; addr = gncCustomerGetAddr (cust); shipaddr = gncCustomerGetShipAddr (cust); gnc_suspend_gui_refresh (); gncCustomerBeginEdit (cust); if (cw->dialog_type == NEW_CUSTOMER) qof_event_gen(QOF_INSTANCE(cust), QOF_EVENT_ADD, NULL); gncCustomerSetID (cust, gtk_editable_get_chars (GTK_EDITABLE (cw->id_entry), 0, -1)); gncCustomerSetName (cust, gtk_editable_get_chars (GTK_EDITABLE (cw->company_entry), 0, -1)); gncAddressSetName (addr, gtk_editable_get_chars (GTK_EDITABLE (cw->name_entry), 0, -1)); gncAddressSetAddr1 (addr, gtk_editable_get_chars (GTK_EDITABLE (cw->addr1_entry), 0, -1)); gncAddressSetAddr2 (addr, gtk_editable_get_chars (GTK_EDITABLE (cw->addr2_entry), 0, -1)); gncAddressSetAddr3 (addr, gtk_editable_get_chars (GTK_EDITABLE (cw->addr3_entry), 0, -1)); gncAddressSetAddr4 (addr, gtk_editable_get_chars (GTK_EDITABLE (cw->addr4_entry), 0, -1)); gncAddressSetPhone (addr, gtk_editable_get_chars (GTK_EDITABLE (cw->phone_entry), 0, -1)); gncAddressSetFax (addr, gtk_editable_get_chars (GTK_EDITABLE (cw->fax_entry), 0, -1)); gncAddressSetEmail (addr, gtk_editable_get_chars (GTK_EDITABLE (cw->email_entry), 0, -1)); gncAddressSetName (shipaddr, gtk_editable_get_chars (GTK_EDITABLE (cw->shipname_entry), 0, -1)); gncAddressSetAddr1 (shipaddr, gtk_editable_get_chars (GTK_EDITABLE (cw->shipaddr1_entry), 0, -1)); gncAddressSetAddr2 (shipaddr, gtk_editable_get_chars (GTK_EDITABLE (cw->shipaddr2_entry), 0, -1)); gncAddressSetAddr3 (shipaddr, gtk_editable_get_chars (GTK_EDITABLE (cw->shipaddr3_entry), 0, -1)); gncAddressSetAddr4 (shipaddr, gtk_editable_get_chars (GTK_EDITABLE (cw->shipaddr4_entry), 0, -1)); gncAddressSetPhone (shipaddr, gtk_editable_get_chars (GTK_EDITABLE (cw->shipphone_entry), 0, -1)); gncAddressSetFax (shipaddr, gtk_editable_get_chars (GTK_EDITABLE (cw->shipfax_entry), 0, -1)); gncAddressSetEmail (shipaddr, gtk_editable_get_chars (GTK_EDITABLE (cw->shipemail_entry), 0, -1)); gncCustomerSetActive (cust, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cw->active_check))); gncCustomerSetTaxIncluded (cust, cw->taxincluded); text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(cw->notes_text)); gtk_text_buffer_get_bounds (text_buffer, &start, &end); text = gtk_text_buffer_get_text (text_buffer, &start, &end, FALSE); gncCustomerSetNotes (cust, text); /* Parse and set the currency, terms, discount, and credit amounts */ gncCustomerSetCurrency (cust, gnc_currency_edit_get_currency (GNC_CURRENCY_EDIT (cw->currency_edit))); gncCustomerSetTerms (cust, cw->terms); gncCustomerSetDiscount (cust, gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (cw->discount_amount))); gncCustomerSetCredit (cust, gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (cw->credit_amount))); gncCustomerSetTaxTableOverride (cust, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cw->taxtable_check))); gncCustomerSetTaxTable (cust, cw->taxtable); gncCustomerCommitEdit (cust); gnc_resume_gui_refresh (); }