[new-owner-report] fix: invoice->payments renders full amount

For payments spanning multiple invoices, previously it would render
partial payment amount. But this info duplicates the invoice
details.

By rendering the full payment amount, it will ease tracking with other
invoices paid with same payment.

If the payment transaction originates from a different currency, the
invoice->payments table will render it in the originating currency.
This commit is contained in:
Christopher Lam 2019-11-12 15:01:46 +08:00
parent a63ba72624
commit 0b8bfe6683

View File

@ -305,36 +305,42 @@
currency total #f #f #f #f (list (make-list link-cols #f)))) currency total #f #f #f #f (list (make-list link-cols #f))))
(define (make-invoice->payments-table invoice invoice-splits currency txn) (define (make-invoice->payments-table invoice invoice-splits currency txn)
(append (let lp ((invoice-splits invoice-splits) (result '()))
(map (cond
(lambda (pmt-split) ((null? invoice-splits)
(list (reverse
(qof-print-date (if (gncInvoiceIsPaid invoice)
(xaccTransGetDate result
(xaccSplitGetParent pmt-split))) (cons (list (gnc:make-html-table-cell/size 1 2 (_ "Outstanding"))
(let ((text (gnc-get-num-action (make-cell
(xaccSplitGetParent pmt-split) (gnc:make-gnc-monetary
pmt-split))) currency (gnc-lot-get-balance
(if (string-null? text) (gncInvoiceGetPostedLot invoice)))))
(_ "Payment") result))))
text)) (else
(make-cell (let* ((lot-split (car invoice-splits))
(gnc:make-html-text (lot-txn (xaccSplitGetParent lot-split))
(gnc:html-markup-anchor (tfr-splits (xaccTransGetPaymentAcctSplitList lot-txn)))
(gnc:split-anchor-text pmt-split) (let lp1 ((tfr-splits tfr-splits) (result result))
(gnc:make-gnc-monetary (cond
currency (- (xaccSplitGetAmount pmt-split)))))))) ((equal? lot-txn txn) (lp (cdr invoice-splits) result))
(filter (lambda (s) (not (equal? (xaccSplitGetParent s) txn))) ((null? tfr-splits) (lp (cdr invoice-splits) result))
invoice-splits)) (else
(if (gncInvoiceIsPaid invoice) (let* ((tfr-split (car tfr-splits))
'() (tfr-acct (xaccSplitGetAccount tfr-split))
(list (tfr-curr (xaccAccountGetCommodity tfr-acct))
(list (gnc:make-html-table-cell/size 1 2 (_ "Outstanding")) (tfr-amt (xaccSplitGetAmount tfr-split)))
(make-cell (lp1 (cdr tfr-splits)
(gnc:make-gnc-monetary (cons (list
currency (qof-print-date (xaccTransGetDate lot-txn))
(gnc-lot-get-balance (let ((num (gnc-get-num-action lot-txn lot-split)))
(gncInvoiceGetPostedLot invoice))))))))) (if (string-null? num) (_ "Payment") num))
(make-cell
(gnc:make-html-text
(gnc:html-markup-anchor
(gnc:split-anchor-text tfr-split)
(gnc:make-gnc-monetary tfr-curr tfr-amt)))))
result)))))))))))
(define (make-payment->invoices-list invoice payment-splits) (define (make-payment->invoices-list invoice payment-splits)
(list (list