[report-utilities] fix: gnc:owner-splits->aging-list uses APAR splits

... instead of payment splits to calculate payment amount, because
payment splits may be in a different currency. using APAR split total
minus invoice amounts is guaranteed to produce correct overpayment
amount in APAR currency.
This commit is contained in:
Christopher Lam
2019-11-12 14:50:51 +08:00
parent 346d2e24da
commit a63ba72624

View File

@@ -1147,14 +1147,14 @@ flawed. see report-utilities.scm. please update reports.")
TXN-TYPE-PAYMENT)
(let* ((txn (xaccSplitGetParent (car splits)))
(payment (apply + (map xaccSplitGetAmount
(xaccTransGetPaymentAcctSplitList txn))))
(xaccTransGetAPARAcctSplitList txn #f))))
(overpayment
(fold
(lambda (inv-and-splits payment-left)
(if (member txn (map xaccSplitGetParent (cdr inv-and-splits)))
(- payment-left (gncInvoiceGetTotal (car inv-and-splits)))
payment-left))
(if receivable? payment (- payment)) invoices-and-splits)))
(if receivable? (- payment) payment) invoices-and-splits)))
(gnc:pk 'payment (car splits) payment "->" overpayment)
(when (positive? overpayment)
(addbucket! (1- num-buckets) (- overpayment)))