[report-utilities] fix overpayments calc

overpayment is lot->balance rather than split->amount.
This commit is contained in:
Christopher Lam
2020-01-27 06:38:33 +08:00
parent 3fd7f19f62
commit 00d00a4650

View File

@@ -1169,15 +1169,14 @@ flawed. see report-utilities.scm. please update reports.")
TXN-TYPE-PAYMENT) TXN-TYPE-PAYMENT)
(let* ((txn (xaccSplitGetParent (car splits))) (let* ((txn (xaccSplitGetParent (car splits)))
(splitlist (xaccTransGetAPARAcctSplitList txn #f)) (splitlist (xaccTransGetAPARAcctSplitList txn #f))
(payment (apply + (map xaccSplitGetAmount splitlist)))
(overpayment (overpayment
(fold (fold
(lambda (a b) (lambda (a b)
(if (null? (gncInvoiceGetInvoiceFromLot (xaccSplitGetLot a))) (if (null? (gncInvoiceGetInvoiceFromLot (xaccSplitGetLot a)))
(- b (xaccSplitGetAmount a)) (- b (gnc-lot-get-balance (xaccSplitGetLot a)))
b)) b))
0 splitlist))) 0 splitlist)))
(gnc:msg "next " (gnc:strify (car splits)) " payment " payment (gnc:msg "next " (gnc:strify (car splits))
" overpayment " overpayment) " overpayment " overpayment)
(addbucket! (1- num-buckets) (if receivable? (- overpayment) overpayment)) (addbucket! (1- num-buckets) (if receivable? (- overpayment) overpayment))
(lp (cdr splits)))) (lp (cdr splits))))