Bug 734183
Geert Janssens
janssens-geert at telenet.be
Wed Aug 6 09:49:08 EDT 2014
On Wednesday 06 August 2014 10:25:12 Mike Evans wrote:
> Hi All
>
> I'm having a little trouble tracking this down, (some of) the code for
> creating an entry with discount is shown below:
>
> entry = gncEntryCreate (book);
> gncEntryBeginEdit(entry);
> // More code here...
> gnc_exp_parser_parse (discount, &n, NULL);
> gncEntrySetInvDiscount (entry, n);
> gncEntrySetInvDiscountType (entry, text2disc_type
> (disc_type)); gncEntrySetInvDiscountHow (entry, text2disc_how
> (disc_how)); gncEntryCommitEdit(entry);
> n = gncEntryGetDocDiscountValue (entry, FALSE, TRUE, FALSE);
> DEBUG( "Discount Value: %.2f\n",gnc_numeric_to_double(n));
> gncInvoiceAddEntry (invoice, entry);
>
> Having set the Discount, How and Type, the DEBUG line outputs -
> Discount Value: 0.000000 it should be the actual calculated discount.
>
> Why isn't the discount being set. calculated? Is there a step I've
> missed?
>
> Looking through gnc_entry_ledger_save_cells(...) in
> gncEntryLedgerModel.c I can't see anything else that needs to be done
> to set the required values.
>
> Code is in: src/plugins/bi_import/dialoc-bi-import.c
>
> Mike
Mike,
I have ran the the master branch as of July 4 through gdb. It doesn't have all the code exactly
as you pasted in your mail, but it's similar enough IMO.
The line
gnc_exp_parser_parse (discount, &n, NULL);
sets n to 0 (more strictly {0, 1}, a gnc_numeric). That doesn't seem correct, or at least not what
you are expecting since discount has a value of "25.0". Maybe you should set an error variable
instead of NULL in that function call and check its value for more clues.
Geert
More information about the gnucash-devel
mailing list