gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Sat Feb 8 21:41:32 EST 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/3be42beb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/18acb423 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/09d3e953 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6e64a378 (commit)
	from  https://github.com/Gnucash/gnucash/commit/19db1dae (commit)



commit 3be42bebb859dfad7158cd18b689f9f0807cd557
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Feb 9 09:55:25 2020 +0800

    [test-new-owner-report] refine test to target exact table row

diff --git a/gnucash/report/business-reports/test/test-new-owner-report.scm b/gnucash/report/business-reports/test/test-new-owner-report.scm
index f28676b65..8f292bb2f 100644
--- a/gnucash/report/business-reports/test/test-new-owner-report.scm
+++ b/gnucash/report/business-reports/test/test-new-owner-report.scm
@@ -226,18 +226,12 @@
     (let* ((options (default-testing-options owner-1 (get-acct "AR-USD")))
            (sxml (options->sxml options "new-customer-report basic")))
       (test-equal "line 1"
-        '("Customer History" "Linked Details" "1980-01-13" "1980-01-13"
-          "Invoice" "$11.50" "$11.50" "1980-03-18" "Payment" "inv >90 payment"
-          "$11.50" "pay only $1.50" "$1.50" "$1.50" "Pre-Payment" "Current"
-          "0-30 days" "31-60 days" "61-90 days" "91+ days" "Total" "$20.00"
-          "$0.00" "$0.00" "$0.00" "$0.00" "$11.75" "$31.75")
-        ((sxpath `(// (table 3) // (tr 1) // *text*)) sxml))
+        '("1980-01-13" "1980-01-13" "Invoice" "$11.50" "$11.50" "1980-03-18"
+          "Payment" "inv >90 payment" "$11.50" "pay only $1.50" "$1.50" "$1.50")
+        ((sxpath `(html body (table 3) tbody (tr 1) // *text*)) sxml))
       (test-equal "line 2"
-        '("Date" "Due Date" "Reference" "Type" "Description" "Invoice"
-          "Payment" "Balance" "Date" "Reference" "Type" "Description"
-          "Partial Amount" "Amount" "1980-03-20" "Payment" "inv >90 payment"
-          "pay only $2.00" "$2.00" "$2.00")
-        ((sxpath `(// (table 3) // (tr 2) // *text*)) sxml))
+        '("1980-03-20" "Payment" "inv >90 payment" "pay only $2.00" "$2.00" "$2.00")
+        ((sxpath `(// (table 3) // tbody // (tr 2) // *text*)) sxml))
       (test-equal "line 3"
         '("UNPAID" "$8.00")
         ((sxpath `(// (table 3) // (tr 3) // *text*)) sxml))

commit 18acb42344c2f57ef6c9950e2d9a3a43a2c02983
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Feb 9 10:27:36 2020 +0800

    [new-owner-report] clarify payment-txn processor
    
    use unique varnames

diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm
index 87e013ec1..ec67270c7 100644
--- a/gnucash/report/business-reports/new-owner-report.scm
+++ b/gnucash/report/business-reports/new-owner-report.scm
@@ -629,15 +629,15 @@
          (let ((lot (xaccSplitGetLot split)))
            (define (equal-to-split? s) (equal? s split))
            (match (gncInvoiceGetInvoiceFromLot lot)
-             (() (lp rest
-                     (- overpayment (gnc-lot-get-balance lot))
-                     invoices
-                     (let lp ((lot-splits (gnc-lot-get-split-list lot))
-                              (acc opposing-splits))
-                       (match lot-splits
-                         (() acc)
-                         (((? equal-to-split?) . rest) (lp rest acc))
-                         ((lot-split . rest) (lp rest (cons lot-split acc)))))))
+             (() (let lp1 ((lot-splits (gnc-lot-get-split-list lot))
+                           (opposing-splits opposing-splits))
+                   (match lot-splits
+                     (() (lp rest
+                             (- overpayment (gnc-lot-get-balance lot))
+                             invoices
+                             opposing-splits))
+                     (((? equal-to-split?) . tail) (lp1 tail opposing-splits))
+                     ((head . tail) (lp1 tail (cons head opposing-splits))))))
              (inv
               (lp rest
                   overpayment

commit 09d3e953792d5272790710acf31f553800a6ad52
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Feb 9 09:54:25 2020 +0800

    [new-owner-report] if Payment amount is negative, label "Refund"
    
    and add logic to properly handle AP/AR negation rules

diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm
index a3b0924d1..87e013ec1 100644
--- a/gnucash/report/business-reports/new-owner-report.scm
+++ b/gnucash/report/business-reports/new-owner-report.scm
@@ -274,12 +274,14 @@
       (let ((inv (gncInvoiceGetInvoiceFromLot (xaccSplitGetLot split))))
         (gnc:make-html-text (invoice->anchor inv)))))))
 
-(define (split->type-str split)
+(define (split->type-str split payable?)
   (let* ((txn (xaccSplitGetParent split))
+         (amt (xaccSplitGetAmount split))
+         (refund? (if payable? (< amt 0) (> amt 0)))
          (invoice (gncInvoiceGetInvoiceFromTxn txn)))
     (cond
      ((txn-is-invoice? txn) (gncInvoiceGetTypeString invoice))
-     ((txn-is-payment? txn) (_ "Payment"))
+     ((txn-is-payment? txn) (if refund? (_ "Refund") (_ "Payment")))
      ((txn-is-link? txn) (_ "Link"))
      (else (_ "Unknown")))))
 
@@ -573,7 +575,7 @@
                         (cons (make-link-data
                                (qof-print-date (xaccTransGetDate lot-txn))
                                (split->reference lot-split)
-                               (split->type-str lot-split)
+                               (split->type-str lot-split payable?)
                                (splits->desc non-document)
                                (gnc:make-html-text (split->anchor lot-split #t))
                                (list->cell
@@ -600,7 +602,7 @@
                          (cons (make-link-data
                                 (qof-print-date (xaccTransGetDate posting-txn))
                                 (split->reference posting-split)
-                                (split->type-str posting-split)
+                                (split->type-str posting-split payable?)
                                 (splits->desc (list posting-split))
                                 (gnc:make-html-text (split->anchor lot-split neg))
                                 (gnc:make-html-text (split->anchor posting-split neg))
@@ -689,7 +691,7 @@
          (make-link-data
           (qof-print-date (xaccTransGetDate (xaccSplitGetParent s)))
           (split->reference s)
-          (split->type-str s)
+          (split->type-str s payable?)
           (splits->desc (list s))
           (gnc:make-html-text (split->anchor s #f))
           (gnc:make-html-text (split->anchor s #f))
@@ -771,7 +773,7 @@
         (add-row
          table odd-row? used-columns date (gncInvoiceGetDateDue invoice)
          (split->reference split)
-         (split->type-str split)
+         (split->type-str split payable?)
          (splits->desc (list split))
          currency (+ total value)
          (and (>= orig-value 0) (amount->anchor split orig-value))
@@ -800,7 +802,7 @@
         (add-row
          table odd-row? used-columns date #f
          (split->reference split)
-         (split->type-str split)
+         (split->type-str split payable?)
          (splits->desc (xaccTransGetAPARAcctSplitList txn #t))
          currency (+ total value)
          (and (>= orig-value 0) (amount->anchor split orig-value))
diff --git a/gnucash/report/business-reports/test/test-new-owner-report.scm b/gnucash/report/business-reports/test/test-new-owner-report.scm
index 30beb02ab..f28676b65 100644
--- a/gnucash/report/business-reports/test/test-new-owner-report.scm
+++ b/gnucash/report/business-reports/test/test-new-owner-report.scm
@@ -274,25 +274,25 @@
         ((sxpath `(// (table 3) // (tr 11) // *text*)) sxml))
 
       ;; tests for refund $120 to partially repay
-      (test-equal "line 12"
-        '("1980-06-28" "Payment" "-$148.25" "1980-06-30" "Payment"
+      (test-equal "line 12 refund $120 to partially repay"
+        '("1980-06-28" "Payment" "-$148.25" "1980-06-30" "Refund"
           "$160.00" "$50.00" "$50.00")
         ((sxpath `(// (table 3) // (tr 12) // *text*)) sxml))
-      (test-equal "line 13"
-        '("1980-06-29" "Payment" "$120.00" "$120.00")
+      (test-equal "line 13 refund $120 to partially repay"
+        '("1980-06-29" "Refund" "$120.00" "$120.00")
         ((sxpath `(// (table 3) // (tr 13) // *text*)) sxml))
-      (test-equal "line 14"
+      (test-equal "line 14 refund $120 to partially repay"
         '("Pre-Payment" "-$10.00")
         ((sxpath `(// (table 3) // (tr 14) // *text*)) sxml))
-      (test-equal "line 15"
-        '("1980-06-29" "Payment" "-$28.25" "1980-06-28" "Payment"
+      (test-equal "line 15 refund $120 to partially repay"
+        '("1980-06-29" "Refund" "-$28.25" "1980-06-28" "Payment"
           "$120.00" "-$120.00" "-$120.00")
         ((sxpath `(// (table 3) // (tr 15) // *text*)) sxml))
-      (test-equal "line 16"
-        '("1980-06-30" "Payment" "$21.75" "1980-06-28" "Payment"
+      (test-equal "line 16 refund $120 to partially repay"
+        '("1980-06-30" "Refund" "$21.75" "1980-06-28" "Payment"
           "$50.00" "-$40.00" "-$40.00")
         ((sxpath `(// (table 3) // (tr 16) // *text*)) sxml))
-      (test-equal "line 17"
+      (test-equal "line 17 refund $120 to partially repay"
         '("Pre-Payment" "-$10.00")
         ((sxpath `(// (table 3) // (tr 17) // *text*)) sxml))
 

commit 6e64a37839ae951d187f349ecf775e4aa32282fa
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Feb 9 09:56:58 2020 +0800

    [new-owner-report] fix comment for non-document accumulator

diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm
index 81720a62a..a3b0924d1 100644
--- a/gnucash/report/business-reports/new-owner-report.scm
+++ b/gnucash/report/business-reports/new-owner-report.scm
@@ -607,9 +607,8 @@
                                 (gncInvoiceReturnGUID document))
                                result)))))
 
-               ;; this payment's peer APAR split can't find
-               ;; document. this likely is an old style link txn. RHS
-               ;; show transaction only.
+               ;; this payment's peer split can't find document. this
+               ;; is a regular payment or an old link txn. accumulate.
                (else
                 (lp1 (cdr lot-txn-splits)
                      (cons (car lot-txn-splits) non-document)



Summary of changes:
 .../report/business-reports/new-owner-report.scm   | 39 +++++++++++-----------
 .../test/test-new-owner-report.scm                 | 36 +++++++++-----------
 2 files changed, 35 insertions(+), 40 deletions(-)



More information about the gnucash-changes mailing list