Make the net price option better compatible with master

Create one gncEntryGetPrice function which can create given price or
net price for both invoices and bills based on option parameters.
The master version of taxinvoice.eguile.scm needs this for bills too.
This commit is contained in:
hcrohland 2017-03-01 18:22:02 +01:00 committed by Geert Janssens
parent 78c5203d8c
commit 3445ef8845
3 changed files with 27 additions and 18 deletions

View File

@ -1423,17 +1423,19 @@ static gnc_numeric gncEntryGetIntDiscountValue (GncEntry *entry, gboolean round,
return (is_cust_doc ? entry->i_disc_value : gnc_numeric_zero());
}
gnc_numeric gncEntryGetInvNetPrice (const GncEntry *entry)
{
gnc_numeric result = gnc_numeric_zero();
if (entry)
gnc_numeric gncEntryGetPrice (const GncEntry *entry, gboolean cust_doc, gboolean net)
{
gnc_numeric result;
int denom;
if (!entry) return gnc_numeric_zero();
if (!net) return (cust_doc ? entry->i_price : entry->b_price);
/* Determine the commodity denominator */
denom = get_entry_commodity_denom (entry);
/* Compute the invoice values */
/* Compute the net price */
if (cust_doc)
gncEntryComputeValueInt (entry->quantity, entry->i_price,
(entry->i_taxable ? entry->i_tax_table : NULL),
entry->i_taxincluded,
@ -1441,7 +1443,14 @@ gnc_numeric gncEntryGetInvNetPrice (const GncEntry *entry)
entry->i_disc_how,
denom,
NULL, NULL, NULL, &result);
}
else
gncEntryComputeValueInt (entry->quantity, entry->b_price,
(entry->b_taxable ? entry->b_tax_table : NULL),
entry->b_taxincluded,
gnc_numeric_zero(), GNC_AMT_TYPE_VALUE, GNC_DISC_PRETAX,
denom,
NULL, NULL, NULL, &result);
return result;
}

View File

@ -182,7 +182,7 @@ gnc_numeric gncEntryGetDocQuantity (const GncEntry *entry, gboolean is_cn);
@{ */
Account * gncEntryGetInvAccount (const GncEntry *entry);
gnc_numeric gncEntryGetInvPrice (const GncEntry *entry);
gnc_numeric gncEntryGetInvNetPrice (const GncEntry *entry);
gnc_numeric gncEntryGetPrice (const GncEntry *entry, const gboolean cust_doc, const gboolean net);
gnc_numeric gncEntryGetInvDiscount (const GncEntry *entry);
GncAmountType gncEntryGetInvDiscountType (const GncEntry *entry);
GncDiscountHow gncEntryGetInvDiscountHow (const GncEntry *entry);

View File

@ -311,7 +311,7 @@
(inv-total (gnc:make-commodity-collector)))
(for entry in entries do
(let ((qty (gncEntryGetDocQuantity entry credit-note?))
(each (if opt-netprice (gncEntryGetInvNetPrice entry) (gncEntryGetInvPrice entry)))
(each (gncEntryGetPrice entry #t opt-netprice))
(action (gncEntryGetAction entry))
(rval (gncEntryGetDocValue entry #t #t credit-note?))
(rdiscval (gncEntryGetDocDiscountValue entry #t #t credit-note?))