gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Tue Nov 12 09:13:48 EST 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/c4a19b9b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0b8bfe66 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a63ba726 (commit)
	from  https://github.com/Gnucash/gnucash/commit/346d2e24 (commit)



commit c4a19b9b5a7d6abb65c853051a90befee81fa980
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Nov 12 16:27:43 2019 +0800

    [new-owner-report] fix: Payment links to payment split
    
    Previously owner-report "Payment" links to APAR payment split. Best
    link to the transfer account split thereby showing original
    payment. Also creates a link for each transfer split although
    theoretically there should only be one. e.g. if 2 non-APAR split in
    payment transaction, it'll show "Payment Payment" in the "Type"
    column.

diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm
index 2c0ed474d..543f9b823 100644
--- a/gnucash/report/business-reports/new-owner-report.scm
+++ b/gnucash/report/business-reports/new-owner-report.scm
@@ -395,10 +395,12 @@
           (gnc:invoice-anchor-text invoice)
           (gncInvoiceGetTypeString invoice))))
        ((txn-is-payment? txn)
-        (gnc:make-html-text
-         (gnc:html-markup-anchor
-          (gnc:split-anchor-text split)
-          (_ "Payment"))))
+        (apply gnc:make-html-text
+               (map (lambda (pmt-split)
+                      (gnc:html-markup-anchor
+                       (gnc:split-anchor-text pmt-split)
+                       (_ "Payment")))
+                    (xaccTransGetPaymentAcctSplitList txn))))
        (else (_ "Unknown")))))
 
   (define (invoice->sale invoice)

commit 0b8bfe668331f4cd9982c4d6171c4a7c7efe7741
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Nov 12 15:01:46 2019 +0800

    [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.

diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm
index 2987db118..2c0ed474d 100644
--- a/gnucash/report/business-reports/new-owner-report.scm
+++ b/gnucash/report/business-reports/new-owner-report.scm
@@ -305,36 +305,42 @@
              currency total #f #f #f #f (list (make-list link-cols #f))))
 
   (define (make-invoice->payments-table invoice invoice-splits currency txn)
-    (append
-     (map
-      (lambda (pmt-split)
-        (list
-         (qof-print-date
-          (xaccTransGetDate
-           (xaccSplitGetParent pmt-split)))
-         (let ((text (gnc-get-num-action
-                      (xaccSplitGetParent pmt-split)
-                      pmt-split)))
-           (if (string-null? text)
-               (_ "Payment")
-               text))
-         (make-cell
-          (gnc:make-html-text
-           (gnc:html-markup-anchor
-            (gnc:split-anchor-text pmt-split)
-            (gnc:make-gnc-monetary
-             currency (- (xaccSplitGetAmount pmt-split))))))))
-      (filter (lambda (s) (not (equal? (xaccSplitGetParent s) txn)))
-              invoice-splits))
-     (if (gncInvoiceIsPaid invoice)
-         '()
-         (list
-          (list (gnc:make-html-table-cell/size 1 2 (_ "Outstanding"))
-                (make-cell
-                 (gnc:make-gnc-monetary
-                  currency
-                  (gnc-lot-get-balance
-                   (gncInvoiceGetPostedLot invoice)))))))))
+    (let lp ((invoice-splits invoice-splits) (result '()))
+      (cond
+       ((null? invoice-splits)
+        (reverse
+         (if (gncInvoiceIsPaid invoice)
+             result
+             (cons (list (gnc:make-html-table-cell/size 1 2 (_ "Outstanding"))
+                         (make-cell
+                          (gnc:make-gnc-monetary
+                           currency (gnc-lot-get-balance
+                                     (gncInvoiceGetPostedLot invoice)))))
+                   result))))
+       (else
+        (let* ((lot-split (car invoice-splits))
+               (lot-txn (xaccSplitGetParent lot-split))
+               (tfr-splits (xaccTransGetPaymentAcctSplitList lot-txn)))
+          (let lp1 ((tfr-splits tfr-splits) (result result))
+            (cond
+             ((equal? lot-txn txn) (lp (cdr invoice-splits) result))
+             ((null? tfr-splits) (lp (cdr invoice-splits) result))
+             (else
+              (let* ((tfr-split (car tfr-splits))
+                     (tfr-acct (xaccSplitGetAccount tfr-split))
+                     (tfr-curr (xaccAccountGetCommodity tfr-acct))
+                     (tfr-amt (xaccSplitGetAmount tfr-split)))
+                (lp1 (cdr tfr-splits)
+                     (cons (list
+                            (qof-print-date (xaccTransGetDate lot-txn))
+                            (let ((num (gnc-get-num-action lot-txn lot-split)))
+                              (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)
     (list

commit a63ba726241d04080d762a93f5dbc40955208b54
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Nov 12 14:50:51 2019 +0800

    [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.

diff --git a/gnucash/report/report-system/report-utilities.scm b/gnucash/report/report-system/report-utilities.scm
index 1cc84bad0..36237a4b4 100644
--- a/gnucash/report/report-system/report-utilities.scm
+++ b/gnucash/report/report-system/report-utilities.scm
@@ -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)))



Summary of changes:
 .../report/business-reports/new-owner-report.scm   | 76 ++++++++++++----------
 gnucash/report/report-system/report-utilities.scm  |  4 +-
 2 files changed, 44 insertions(+), 36 deletions(-)



More information about the gnucash-changes mailing list