[aging] update error reporting

This error handling was for transactions in APAR accounts whereby
Transaction Currency != Owner Currency. An example is a manually
entered transaction, then assigned as payment to a customer with a
different currency. Update to modern API calls. Show the culprit
split details.

Fixed example output:

IGNORING TRANSACTION!
Invoice Owner: [None:]
Transaction:Txn<d:28/10/19>
Splits are:
Split<d:28/10/19,acc:Current,amt:$150.00,val:£150.00>
Split<d:28/10/19,acc:AR,amt:$0.00,val:-£150.00>
Transaction Currency:GBP
Client Currency:AUD
This commit is contained in:
Christopher Lam 2019-10-28 23:41:11 +08:00
parent 2e1b87e01f
commit e83938fdc2

View File

@ -29,6 +29,9 @@
(use-modules (gnucash utilities)) (use-modules (gnucash utilities))
(use-modules (gnucash gnc-module)) (use-modules (gnucash gnc-module))
(use-modules (gnucash gettext)) (use-modules (gnucash gettext))
(eval-when (compile load eval expand)
(load-extension "libgncmod-gnome-utils" "scm_init_sw_gnome_utils_module"))
(use-modules (sw_gnome_utils))
(gnc:module-load "gnucash/report/report-system" 0) (gnc:module-load "gnucash/report/report-system" 0)
@ -214,15 +217,18 @@
(if (not (gnc-commodity-equiv (if (not (gnc-commodity-equiv
this-currency this-currency
(company-get-currency company-info))) (company-get-currency company-info)))
(let ((error-str (let ((error-str
(string-append "IGNORING TRANSACTION!\n" "Invoice Owner: " (gncOwnerGetName owner) (string-append "IGNORING TRANSACTION!\n" "Invoice Owner: " (gnc:strify owner)
"\nTransaction GUID:" (gncTransGetGuid transaction) "\nTransaction:" (gnc:strify transaction)
"\nTransaction Currency" (gnc-commodity-get-mnemonic this-currency) "\nSplits are:\n"
"\nClient Currency" (gnc-ommodity-get-mnemonic(company-get-currency company-info))))) (string-join
(gnc-error-dialog '() error-str) (map gnc:strify (xaccTransGetSplitList transaction))
(gnc:error error-str) "\n")
(cons #f (format "\nTransaction Currency:" (gnc:strify this-currency)
(_ "Transactions relating to '~a' contain \ "\nClient Currency:" (gnc:strify (company-get-currency company-info)))))
(gnc-error-dialog '() error-str)
(gnc:error error-str)
(cons #f (format #f (_ "Transactions relating to '~a' contain \
more than one currency. This report is not designed to cope with this possibility.") (gncOwnerGetName owner)))) more than one currency. This report is not designed to cope with this possibility.") (gncOwnerGetName owner))))
(begin (begin
(gnc:debug "it's an old company") (gnc:debug "it's an old company")