static gboolean customer_currency_handler (xmlNodePtr node, gpointer customer_pdata) { struct customer_pdata *pdata = customer_pdata; gnc_commodity *com; com = dom_tree_to_commodity_ref(node, pdata->book); g_return_val_if_fail (com, FALSE); gncCustomerSetCurrency (pdata->customer, com); return TRUE; }
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 (); }
static void gnc_plugin_business_cmd_test_init_data (GtkAction *action, GncMainWindowActionData *data) { QofBook *book = gnc_get_current_book(); GncCustomer *customer = gncCustomerCreate(book); GncAddress *address = gncCustomerGetAddr(customer); GncInvoice *invoice = gncInvoiceCreate(book); GncOwner *owner = gncOwnerNew(); GncJob *job = gncJobCreate(book); Account *root = gnc_book_get_root_account(book); Account *inc_acct = xaccMallocAccount(book); Account *bank_acct = xaccMallocAccount(book); Account *tax_acct = xaccMallocAccount(book); Account *ar_acct = xaccMallocAccount(book); Timespec now; // Create Customer gncCustomerSetID(customer, "000001"); gncCustomerSetName(customer, "Test Customer"); gncCustomerSetCurrency(customer, gnc_default_currency()); gncAddressSetName(address, "Contact Person"); gncAddressSetAddr1(address, "20 Customer Lane"); gncAddressSetAddr2(address, "Customer M/S"); gncAddressSetAddr3(address, "Addr3, XXX 12345"); // Create the Owner gncOwnerInitCustomer(owner, customer); // Create the Invoice timespecFromTime64(&now, time(NULL)); gncInvoiceSetID(invoice, "000012"); gncInvoiceSetOwner(invoice, owner); gncInvoiceSetDateOpened(invoice, now); gncInvoiceSetCurrency(invoice, gnc_default_currency()); // Create the Job gncJobSetID(job, "000025"); gncJobSetName(job, "Test Job"); gncJobSetReference(job, "Customer's ref#"); gncJobSetOwner(job, owner); // MODIFY THE OWNER gncOwnerInitJob(owner, job); // Create the A/R account xaccAccountSetType(ar_acct, ACCT_TYPE_RECEIVABLE); xaccAccountSetName(ar_acct, "A/R"); xaccAccountSetCommodity(ar_acct, gnc_default_currency()); gnc_account_append_child(root, ar_acct); // Create the Income account xaccAccountSetType(inc_acct, ACCT_TYPE_INCOME); xaccAccountSetName(inc_acct, "Income"); xaccAccountSetCommodity(inc_acct, gnc_default_currency()); gnc_account_append_child(root, inc_acct); // Create the Bank account xaccAccountSetType(bank_acct, ACCT_TYPE_BANK); xaccAccountSetName(bank_acct, "Bank"); xaccAccountSetCommodity(bank_acct, gnc_default_currency()); gnc_account_append_child(root, bank_acct); // Create the Tax account xaccAccountSetType(tax_acct, ACCT_TYPE_LIABILITY); xaccAccountSetName(tax_acct, "Tax-Holding"); xaccAccountSetCommodity(tax_acct, gnc_default_currency()); gnc_account_append_child(root, tax_acct); // Launch the invoice editor gnc_ui_invoice_edit (GTK_WINDOW (data->window), invoice); }