Hi List,
I am in the process of upgrading to the latest version of GnuCash, but
have found a bug in the Tax Invoice Report file "taxinvoice.eguile.scm.
This effects both the standard Tax Invoice and Australian Tax Invoice as
they both use the same scm file.
The Discount Total on the report always equates to ZERO.
I have tried googling, but have not found any other reports of this
error, although I do seem to recall running into it a few years ago.
I have been running GnuCash 2.6 (yes, I know, VERY old, but it works for
me) where the report worked fine. I'm not sure about the 3.x release,
but so far all of the 4.x releases I've tried all have the same issue.
The report in 2.6 actually calculated the Discount Total by adding each
Discount line item amount together. The report line (310) was:
(dsc-total (gnc:make-commodity-collector))
The report has been updated some time ago that it now calculates the
Discount Total, but the equation is wrong as it always equates to zero.
Unfortunately BOTH files state it is:
- Version 0.03
- Modified Date: 16 Feb 2012
Surely other people are using the Invoice report to send Invoices with
discounts? This bug couldn't have been around unnoticed since 2012, or
is there a setting that I've missed?
Line 301 in the "new" file now has the following calculation:
(dsc-total (- inv-total tax-total sub-total))
However, The Invoice Total - Tax Total - Sub-Total will always equal
Zero and does not equate to any discount as those numbers are AFTER the
discount has been applied.
Example:
Charge : $100
Discount: $10
Invoice Total: $90
Tax Total : $1
Sub Total : $89 (Sub Total is the Total Invoice
amount Pre-Tax in this report)
So Invoice Total ($100) - Tax Total ($1) - Sub-Total ($89) = $0
Nowhere does the Discount Total come into it.
I have reverted back the calculation to be based on adding each line
item, and it seems to work. I have attached a PatchFile, just in case
this issue has been affecting others and they wish to apply the patch,
or if a maintainer wishes to apply it to the main branch.
I have just based the changes on a 5 minute scheme crash course, mostly
by looking at the older report file, so there has not been any rigorous
testing, but it seems to work.
If there is any setting that I should be using that will make the change
redundant I'd be happy if someone could point it out to me.
Regards,
Jeff.
--- taxinvoice.eguile.scm_ORIG 2023-02-18 12:08:18.238227981 +1100
+++ taxinvoice.eguile.scm 2023-02-18 12:08:18.228227981 +1100
@@ -298,7 +298,7 @@
(let* ((inv-total (gncInvoiceGetTotal opt-invoice))
(tax-total (gncInvoiceGetTotalTax opt-invoice))
(sub-total (gncInvoiceGetTotalSubtotal opt-invoice))
- (dsc-total (- inv-total tax-total sub-total))
+ (dsc-total (gnc:make-commodity-collector))
(total-col (gnc:make-commodity-collector)))
(total-col 'add currency inv-total)
(for-each
@@ -314,6 +314,8 @@
(acc (if cust-doc? (gncEntryGetInvAccount
entry)(gncEntryGetBillAccount entry)))
(taxable (if cust-doc? (gncEntryGetInvTaxable
entry)(gncEntryGetBillTaxable entry)))
(taxtable (if cust-doc? (gncEntryGetInvTaxTable
entry)(gncEntryGetBillTaxTable entry))))
+ (dsc-total 'add currency rdiscval)
+
?>
<tr valign="top">
<?scm (if opt-col-date (begin ?>
@@ -362,7 +364,7 @@
(if (and discount?) 1 0)
) ?>"><strong><?scm:d opt-subtotal-heading ?></strong></td>
<?scm (if discount? (begin ?>
- <td align="right" class="subtotal"><strong><?scm:d (fmtmoney currency
dsc-total) ?></strong></td>
+ <td align="right" class="subtotal"><strong><?scm
(display-comm-coll-total dsc-total #f) ?></strong></td>
<?scm )) ?>
<?scm (if tax? (begin ?>
<td align="right" class="subtotal"><strong><?scm:d (fmtmoney
currency sub-total) ?></strong></td>
_______________________________________________
gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
-----
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.