Provide a method to obtain the computed discount

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6911 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins
2002-05-24 21:19:45 +00:00
parent 2aa7caf1a1
commit b9575c340f
6 changed files with 40 additions and 15 deletions

View File

@@ -404,7 +404,8 @@ GncEntry * gncEntryLookup (GNCBook *book, const GUID *guid)
void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
gnc_numeric tax, gint tax_type,
gnc_numeric discount, gint discount_type,
gnc_numeric *value, gnc_numeric *tax_value)
gnc_numeric *value, gnc_numeric *tax_value,
gnc_numeric *discount_value)
{
gnc_numeric subtotal;
gnc_numeric this_value;
@@ -423,6 +424,11 @@ void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
if (discount_type & GNC_ENTRY_PRETAX_FLAG)
subtotal = this_value;
/* Save the discount and value return values */
if (discount_value != NULL)
*discount_value = discount;
if (value != NULL)
*value = this_value;
@@ -441,7 +447,7 @@ void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
}
void gncEntryGetValue (GncEntry *entry, gnc_numeric *value,
gnc_numeric *tax_value)
gnc_numeric *tax_value, gnc_numeric *discount_value)
{
if (!entry) return;
@@ -451,14 +457,14 @@ void gncEntryGetValue (GncEntry *entry, gnc_numeric *value,
gncEntryGetTaxType (entry),
gncEntryGetDiscount (entry),
gncEntryGetDiscountType (entry),
value, tax_value);
value, tax_value, discount_value);
}
gnc_numeric gncEntryReturnValue (GncEntry *entry)
{
gnc_numeric val = gnc_numeric_zero ();
if (!entry) return val;
gncEntryGetValue (entry, &val, NULL);
gncEntryGetValue (entry, &val, NULL, NULL);
return val;
}
@@ -466,7 +472,15 @@ gnc_numeric gncEntryReturnTaxValue (GncEntry *entry)
{
gnc_numeric val = gnc_numeric_zero ();
if (!entry) return val;
gncEntryGetValue (entry, NULL, &val);
gncEntryGetValue (entry, NULL, &val, NULL);
return val;
}
gnc_numeric gncEntryReturnDiscountValue (GncEntry *entry)
{
gnc_numeric val = gnc_numeric_zero ();
if (!entry) return val;
gncEntryGetValue (entry, NULL, NULL, &val);
return val;
}

View File

@@ -69,16 +69,19 @@ void gncEntryCopy (const GncEntry *src, GncEntry *dest);
gnc_numeric gncEntryReturnValue (GncEntry *entry);
gnc_numeric gncEntryReturnTaxValue (GncEntry *entry);
gnc_numeric gncEntryReturnDiscountValue (GncEntry *entry);
/* Compute the Entry value and tax-value numbers, based on the
* quantity, price, discount, tax, and discount/tax types
/* Compute the Entry value, tax-value, and discount_value, based on the
* quantity, price, discount, tax, and discount/tax types. Note that
* the value is the after-discount value.
*/
void gncEntryGetValue (GncEntry *entry, gnc_numeric *value,
gnc_numeric *tax_value);
gnc_numeric *tax_value, gnc_numeric *discount);
void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
gnc_numeric tax, gint tax_type,
gnc_numeric discount, gint discount_type,
gnc_numeric *value, gnc_numeric *tax_value);
gnc_numeric *value, gnc_numeric *tax_value,
gnc_numeric *discount_value);
gint gncEntryGetTypeFromStr (const char *type);

View File

@@ -466,7 +466,7 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
Account *this_acc;
/* Obtain the Entry Value and TaxValue */
gncEntryGetValue (entry, &value, &tax);
gncEntryGetValue (entry, &value, &tax, NULL);
/* add the value for the account split */
this_acc = gncEntryGetAccount (entry);

View File

@@ -373,7 +373,7 @@
'<gnc:numeric>
"gncEntryReturnValue"
'((<gnc:GncEntry*> entry))
"Return the Entry's Value")
"Return the Entry's computed Value (after discount)")
(gw:wrap-function
ws
@@ -381,7 +381,15 @@
'<gnc:numeric>
"gncEntryReturnTaxValue"
'((<gnc:GncEntry*> entry))
"Return the Entry's Tax Value")
"Return the Entry's computed Tax Value")
(gw:wrap-function
ws
'gnc:entry-get-discount-value
'<gnc:numeric>
"gncEntryReturnDiscountValue"
'((<gnc:GncEntry*> entry))
"Return the Entry's computed Discount Value")
(gw:wrap-function
ws

View File

@@ -452,7 +452,7 @@ gnc_entry_ledger_compute_value (GncEntryLedger *ledger,
tax_type = gnc_entry_ledger_get_type (ledger, ENTRY_TAXTYPE_CELL);
gncEntryComputeValue (qty, price, tax, tax_type, discount, disc_type,
value, tax_value);
value, tax_value, NULL);
}
gboolean

View File

@@ -337,7 +337,7 @@ static const char * get_value_entry (VirtualLocation virt_loc,
if (entry == gnc_entry_ledger_get_blank_entry (ledger))
return NULL;
gncEntryGetValue (entry, &value, NULL);
gncEntryGetValue (entry, &value, NULL, NULL);
}
return xaccPrintAmount (value, gnc_default_print_info (TRUE));
}
@@ -360,7 +360,7 @@ static const char * get_taxval_entry (VirtualLocation virt_loc,
if (entry == gnc_entry_ledger_get_blank_entry (ledger))
return NULL;
gncEntryGetValue (entry, NULL, &value);
gncEntryGetValue (entry, NULL, &value, NULL);
}
return xaccPrintAmount (value, gnc_default_print_info (TRUE));