示例#1
0
/* for each invoice, check the bill terms.  If the bill terms are
 * grandchildren, then fix them to point to the most senior child
 */
static void
billterm_scrub_invoices (QofInstance * invoice_p, gpointer ht_p)
{
    GHashTable *ht = ht_p;
    GncInvoice *invoice = GNC_INVOICE(invoice_p);
    GncBillTerm *term, *new_bt;
    gint32 count;

    term = gncInvoiceGetTerms(invoice);
    if (term)
    {
        if (billterm_is_grandchild(term))
        {
            gchar guidstr[GUID_ENCODING_LENGTH+1];
            guid_to_string_buff(qof_instance_get_guid(QOF_INSTANCE(invoice)),guidstr);
            PWARN("Fixing i-billterm on invoice %s\n", guidstr);
            new_bt = billterm_find_senior(term);
            gncInvoiceBeginEdit(invoice);
            gncInvoiceSetTerms(invoice, new_bt);
            gncInvoiceCommitEdit(invoice);
            term = new_bt;
        }
        if (term)
        {
            count = GPOINTER_TO_INT(g_hash_table_lookup(ht, term));
            count++;
            g_hash_table_insert(ht, term, GINT_TO_POINTER(count));
        }
    }
}
示例#2
0
static gboolean
invoice_terms_handler (xmlNodePtr node, gpointer invoice_pdata)
{
    struct invoice_pdata* pdata = static_cast<decltype (pdata)> (invoice_pdata);
    GncGUID* guid;
    GncBillTerm* term;

    guid = dom_tree_to_guid (node);
    g_return_val_if_fail (guid, FALSE);
    term = gnc_billterm_xml_find_or_create (pdata->book, guid);
    g_assert (term);
    g_free (guid);
    gncInvoiceSetTerms (pdata->invoice, term);

    return TRUE;
}