Bug 734183

Mike Evans mikee at saxicola.co.uk
Wed Aug 6 11:00:21 EDT 2014


On Wed, 06 Aug 2014 15:49:08 +0200
Geert Janssens <janssens-geert at telenet.be> wrote:

> 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

HiGeert.


n is set to 25 using gnc_exp_parser_parse (discount, &n, NULL); just after it's set to gnc_numeric_zero ();  Taking the zeroing line out doesn't change the behaviour though.

Where discount is read from the file.  When the invoice is opened after import the 25.00 is shown in the discount column but the price hasn't been discounted, the line total is still at original price.

The gncEntryGetDocDiscountValue () function calls the gncEntry::gncEntryRecomputeValues() function which should set he discount to be applied.
 
 


-- 
Anti NSA?  Use PGP.
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x00CDB13500D7AB53  


More information about the gnucash-devel mailing list