Exemplo n.º 1
0
static void gnc_ui_to_job (JobWindow *jw, GncJob *job)
{
    gnc_suspend_gui_refresh ();
    gncJobBeginEdit (job);

    qof_event_gen(QOF_INSTANCE(job), QOF_EVENT_ADD, NULL);

    gncJobSetID (job, gtk_editable_get_chars (GTK_EDITABLE (jw->id_entry),
                 0, -1));
    gncJobSetName (job, gtk_editable_get_chars (GTK_EDITABLE (jw->name_entry),
                   0, -1));
    gncJobSetReference (job, gtk_editable_get_chars
                        (GTK_EDITABLE (jw->desc_entry), 0, -1));
    gncJobSetActive (job, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
                     (jw->active_check)));
    {
        GncOwner * old = gncJobGetOwner (job);
        gnc_owner_get_owner (jw->cust_edit, &(jw->owner));
        if (! gncOwnerEqual (old, &(jw->owner)))
            gncJobSetOwner (job, &(jw->owner));
    }

    gncJobCommitEdit (job);
    gnc_resume_gui_refresh ();
}
Exemplo n.º 2
0
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);
}