gnucash master: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Wed Nov 13 10:47:42 EST 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/e6c6d4e0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0a3653e5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/36367ed1 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/2dcdda0a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c520c5af (commit)
	 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)
	 via  https://github.com/Gnucash/gnucash/commit/346d2e24 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3d5d8191 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/980776f4 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9189bcbe (commit)
	from  https://github.com/Gnucash/gnucash/commit/7e5784ff (commit)



commit e6c6d4e0bba9523f96fefbb8d463b8a289efa8dd
Merge: 0a3653e56 c520c5af1
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Nov 13 23:37:19 2019 +0800

    Merge branch 'maint'


commit 0a3653e56d6c834189c7d13b09e373de85f1989c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Nov 13 22:54:54 2019 +0800

    [category-barchart] simplify all-data generator

diff --git a/gnucash/report/reports/standard/category-barchart.scm b/gnucash/report/reports/standard/category-barchart.scm
index fa28c96a1..4e5765831 100644
--- a/gnucash/report/reports/standard/category-barchart.scm
+++ b/gnucash/report/reports/standard/category-barchart.scm
@@ -470,38 +470,28 @@ developing over time"))
           (set! work-to-do (count-accounts 1 topl-accounts))
 
           ;; Sort the account list according to the account code field.
-          (set! all-data (sort
-                          (filter (lambda (l)
-                                    (not (zero?
-                                          (gnc:gnc-monetary-amount
-                                           (apply gnc:monetary+ (cadr l))))))
-                                  (traverse-accounts 1 topl-accounts))
-                          (cond
-                           ((eq? sort-method 'acct-code)
-                            (lambda (a b)
-                              (string<? (xaccAccountGetCode (car a))
-                                        (xaccAccountGetCode (car b)))))
-                           ((eq? sort-method 'alphabetical)
-                            (lambda (a b)
-                              (string<? ((if show-fullname?
-                                             gnc-account-get-full-name
-                                             xaccAccountGetName) (car a))
-                                        ((if show-fullname?
-                                             gnc-account-get-full-name
-                                             xaccAccountGetName) (car b)))))
-                           (else
-                            (lambda (a b)
-                              (> (gnc:gnc-monetary-amount (apply gnc:monetary+ (cadr a)))
-                                 (gnc:gnc-monetary-amount (apply gnc:monetary+ (cadr b)))))))))
-          ;; Or rather sort by total amount?
-          ;;(< (apply + (cadr a))
-          ;;   (apply + (cadr b))))))
-          ;; Other sort criteria: max. amount, standard deviation of amount,
-          ;; min. amount; ascending, descending. FIXME: Add user options to
-          ;; choose sorting.
-
-
-          ;;(gnc:warn "all-data" all-data)
+          (set! all-data
+            (sort
+             (filter (lambda (l)
+                       (not (zero? (gnc:gnc-monetary-amount
+                                    (apply gnc:monetary+ (cadr l))))))
+                     (traverse-accounts 1 topl-accounts))
+             (case sort-method
+               ((alphabetical)
+                (lambda (a b)
+                  (if show-fullname?
+                      (string<? (gnc-account-get-full-name (car a))
+                                (gnc-account-get-full-name (car b)))
+                      (string<? (xaccAccountGetName (car a))
+                                (xaccAccountGetName (car b))))))
+               ((acct-code)
+                (lambda (a b)
+                  (string<? (xaccAccountGetCode (car a))
+                            (xaccAccountGetCode (car b)))))
+               ((amount)
+                (lambda (a b)
+                  (> (gnc:gnc-monetary-amount (apply gnc:monetary+ (cadr a)))
+                     (gnc:gnc-monetary-amount (apply gnc:monetary+ (cadr b)))))))))
 
           ;; Proceed if the data is non-zeros
           (if

commit 36367ed1904fa546730aac8ed4726d4fd979d02a
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Nov 13 22:41:01 2019 +0800

    [category-barchart] clean up html-table generator
    
    add data row-wise instead of col-wise is much more concise

diff --git a/gnucash/report/reports/standard/category-barchart.scm b/gnucash/report/reports/standard/category-barchart.scm
index 5067e24ab..fa28c96a1 100644
--- a/gnucash/report/reports/standard/category-barchart.scm
+++ b/gnucash/report/reports/standard/category-barchart.scm
@@ -261,7 +261,6 @@ developing over time"))
          (show-table? (get-option gnc:pagename-display (N_ "Show table")))
          (document (gnc:make-html-document))
          (chart (gnc:make-html-chart))
-         (table (gnc:make-html-table))
          (topl-accounts (gnc:filter-accountlist-type
                          account-types
                          (gnc-account-get-children-sorted
@@ -611,62 +610,51 @@ developing over time"))
 
              (gnc:report-percent-done 98)
              (gnc:html-document-add-object! document chart)
-             (if show-table?
-                 (let ((scu (gnc-commodity-get-fraction report-currency)))
-                   (gnc:html-table-append-column! table date-string-list)
 
-                   (for-each
+             (when show-table?
+               (let ((table (gnc:make-html-table))
+                     (scu (gnc-commodity-get-fraction report-currency))
+                     (cols>1? (> (length all-data) 1)))
+
+                 (define (make-cell contents)
+                   (gnc:make-html-table-cell/markup "number-cell" contents))
+
+                 (define (monetary-round mon)
+                   (gnc:make-gnc-monetary
+                    report-currency
+                    (gnc-numeric-convert
+                     (gnc:gnc-monetary-amount mon)
+                     scu GNC-HOW-RND-ROUND)))
+
+                 (for-each
+                  (lambda (date row)
+                    (gnc:html-table-append-row!
+                     table (map make-cell (append (list date)
+                                                  (map monetary-round row)
+                                                  (if cols>1?
+                                                      (list
+                                                       (monetary-round
+                                                        (apply gnc:monetary+ row)))
+                                                      '())))))
+                  date-string-list
+                  (apply zip (map cadr all-data)))
+
+                 (gnc:html-table-set-col-headers!
+                  table
+                  (append
+                   (list (_ "Date"))
+                   (map
                     (lambda (col)
-                      (gnc:html-table-append-column!
-                       table
-                       (map
-                        (lambda (mon)
-                          (gnc:make-gnc-monetary
-                           report-currency
-                           (gnc-numeric-convert
-                            (gnc:gnc-monetary-amount mon)
-                            scu GNC-HOW-RND-ROUND)))
-                        col)))
-                    (map cadr all-data))
-
-                   (gnc:html-table-set-col-headers!
-                    table
-                    (append
-                     (list (_ "Date"))
-                     (map (lambda (pair)
-                            (if (string? (car pair))
-                                (car pair)
-                                ((if show-fullname?
-                                     gnc-account-get-full-name
-                                     xaccAccountGetName) (car pair))))
-                          all-data)
-                     (if (> (gnc:html-table-num-columns table) 2)
-                         (list (_ "Grand Total"))
-                         '())))
-
-                   (if (> (gnc:html-table-num-columns table) 2)
-                       (letrec
-                           ((sumtot
-                             (lambda (row)
-                               (if (null? row)
-                                   '()
-                                   (cons (sumrow (car row)) (sumtot (cdr row))))))
-                            (sumrow
-                             (lambda (row)
-                               (if (not (null? row))
-                                   (gnc:monetary+ (car row) (sumrow (cdr row)))
-                                   (gnc:make-gnc-monetary report-currency 0)))))
-                         (gnc:html-table-append-column!
-                          table
-                          (sumtot (apply zip (map cadr all-data))))))
-                   ;; set numeric columns to align right
-                   (for-each
-                    (lambda (col)
-                      (gnc:html-table-set-col-style!
-                       table col "td"
-                       'attribute (list "class" "number-cell")))
-                    '(1 2 3 4 5 6 7 8 9 10 11 12 13 14))
-                   (gnc:html-document-add-object! document table))))
+                      (cond
+                       ((string? col) col)
+                       (show-fullname? (gnc-account-get-full-name col))
+                       (else (xaccAccountGetName col))))
+                    (map car all-data))
+                   (if cols>1?
+                       (list (_ "Grand Total"))
+                       '())))
+
+                 (gnc:html-document-add-object! document table))))
 
            ;; else if empty data
            (gnc:html-document-add-object!

commit 2dcdda0a33b991303c4fb59b5a9056d450bbe0d8
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Nov 13 22:09:20 2019 +0800

    [category-barchart] srfi-9 records for variants

diff --git a/gnucash/report/reports/standard/category-barchart.scm b/gnucash/report/reports/standard/category-barchart.scm
index 952d2cd86..5067e24ab 100644
--- a/gnucash/report/reports/standard/category-barchart.scm
+++ b/gnucash/report/reports/standard/category-barchart.scm
@@ -25,6 +25,7 @@
 ;; depends must be outside module scope -- and should eventually go away.
 (define-module (gnucash reports standard category-barchart))
 (use-modules (srfi srfi-1))
+(use-modules (srfi srfi-9))
 (use-modules (gnucash utilities))
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))
@@ -353,7 +354,7 @@ developing over time"))
                (let ((ignore-closing? (not (gnc:account-is-inc-exp? acc))))
                  (cons acc
                        (map
-                        (if (reverse-balance? acc) gnc:monetary-neg identity)
+                        (if reverse-balance? gnc:monetary-neg identity)
                         (gnc:account-get-balances-at-dates
                          acc dates-list
                          #:split->amount
@@ -682,39 +683,62 @@ developing over time"))
     (gnc:report-finished)
     document))
 
+(define-record-type :variant
+  (make-variant reportname acct-types intervals? menuname menutip reverse? uuid)
+  variant?
+  (reportname get-reportname)
+  (acct-types get-acct-types)
+  (intervals? get-intervals?)
+  (menuname   get-menuname)
+  (menutip    get-menutip)
+  (reverse?   get-reverse?)
+  (uuid       get-uuid))
+
+(define variants
+  (list
+   (make-variant reportname-income
+                 (list ACCT-TYPE-INCOME)
+                 #t menuname-income menutip-income
+                 #t category-barchart-income-uuid)
+
+   (make-variant reportname-expense
+                 (list ACCT-TYPE-EXPENSE)
+                 #t menuname-expense menutip-expense
+                 #f category-barchart-expense-uuid)
+
+   (make-variant reportname-assets
+                 (list ACCT-TYPE-ASSET ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CHECKING
+                       ACCT-TYPE-SAVINGS ACCT-TYPE-MONEYMRKT
+                       ACCT-TYPE-RECEIVABLE ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL
+                       ACCT-TYPE-CURRENCY)
+                 #f menuname-assets menutip-assets
+                 #f category-barchart-asset-uuid)
+
+   (make-variant reportname-liabilities
+                 (list ACCT-TYPE-LIABILITY ACCT-TYPE-PAYABLE ACCT-TYPE-CREDIT
+                       ACCT-TYPE-CREDITLINE)
+                 #f menuname-liabilities menutip-liabilities
+                 #t category-barchart-liability-uuid)))
+
 (for-each
- (lambda (l)
-   (let ((tip-and-rev (cddddr l)))
-     (gnc:define-report
-      'version 1
-      'name (car l)
-      'report-guid (car (reverse l))
-      'menu-path (if (caddr l)
-                     (list gnc:menuname-income-expense)
-                     (list gnc:menuname-asset-liability))
-      'menu-name (cadddr l)
-      'menu-tip (car tip-and-rev)
-      'options-generator (lambda () (options-generator (cadr l)
-                                                       (cadr tip-and-rev)
-                                                       (caddr l)))
-      'renderer (lambda (report-obj)
-                  (category-barchart-renderer report-obj
-                                              (car l)
-                                              (car (reverse l))
-                                              (cadr l)
-                                              (caddr l))))))
- (list
-  ;; reportname, account-types, do-intervals?,
-  ;; menu-reportname, menu-tip
-  (list reportname-income (list ACCT-TYPE-INCOME) #t menuname-income menutip-income (lambda (x) #t) category-barchart-income-uuid)
-  (list reportname-expense (list ACCT-TYPE-EXPENSE) #t menuname-expense menutip-expense (lambda (x) #f) category-barchart-expense-uuid)
-  (list reportname-assets
-        (list ACCT-TYPE-ASSET ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CHECKING
-              ACCT-TYPE-SAVINGS ACCT-TYPE-MONEYMRKT
-              ACCT-TYPE-RECEIVABLE ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL
-              ACCT-TYPE-CURRENCY)
-        #f menuname-assets menutip-assets (lambda (x) #f) category-barchart-asset-uuid)
-  (list reportname-liabilities
-        (list ACCT-TYPE-LIABILITY ACCT-TYPE-PAYABLE ACCT-TYPE-CREDIT
-              ACCT-TYPE-CREDITLINE)
-        #f menuname-liabilities menutip-liabilities (lambda (x) #t) category-barchart-liability-uuid)))
+ (lambda (variant)
+   (gnc:define-report
+    'version 1
+    'name (get-reportname variant)
+    'report-guid (get-uuid variant)
+    'menu-path (if (get-intervals? variant)
+                   (list gnc:menuname-income-expense)
+                   (list gnc:menuname-asset-liability))
+    'menu-name (get-menuname variant)
+    'menu-tip (get-menutip variant)
+    'options-generator (lambda ()
+                         (options-generator (get-acct-types variant)
+                                            (get-reverse? variant)
+                                            (get-intervals? variant)))
+    'renderer (lambda (report-obj)
+                (category-barchart-renderer report-obj
+                                            (get-reportname variant)
+                                            (get-uuid variant)
+                                            (get-acct-types variant)
+                                            (get-intervals? variant)))))
+ variants)

commit c520c5af197c70fd32bd998706bf3fb0cb7e2a8a
Author: pianoslum <pianoslum at mailbox.org>
Date:   Tue Nov 12 21:46:50 2019 +0100

    Add three missing German translations

diff --git a/po/de.po b/po/de.po
index b652b9b0f..2a1dd5cd7 100644
--- a/po/de.po
+++ b/po/de.po
@@ -25,8 +25,8 @@ msgstr ""
 "Report-Msgid-Bugs-To: https://bugs.gnucash.org/enter_bug.cgi?"
 "product=GnuCash&component=Translations\n"
 "POT-Creation-Date: 2019-09-29 21:34+0200\n"
-"PO-Revision-Date: 2019-09-29 21:44+0200\n"
-"Last-Translator: Christian Stimming <christian at cstimming.de>\n"
+"PO-Revision-Date: 2019-11-12 21:44+0200\n"
+"Last-Translator: pianoslum <pianoslum at mailbox.org>\n"
 "Language-Team: GnuCash-de <gnucash-de at gnucash.org>\n"
 "Language: de\n"
 "MIME-Version: 1.0\n"
@@ -27429,11 +27429,11 @@ msgstr "Eine Spalte mit der Differenz zwischen Budget (Soll) und Ist anzeigen."
 
 #: gnucash/report/standard-reports/budget.scm:58
 msgid "Use accumulated amounts"
-msgstr ""
+msgstr "Aufsummierte Buchungen anzeigen"
 
 #: gnucash/report/standard-reports/budget.scm:59
 msgid "Values are accumulated across periods."
-msgstr ""
+msgstr "Werte werden über Perioden aufsummiert."
 
 #: gnucash/report/standard-reports/budget.scm:60
 msgid "Show Column with Totals"
@@ -27565,7 +27565,7 @@ msgstr "Differenz"
 #. of only using the budget-period amounts.
 #: gnucash/report/standard-reports/budget.scm:702
 msgid "using accumulated amounts"
-msgstr ""
+msgstr "aufsummierte Beträge verwenden"
 
 #: gnucash/report/standard-reports/cashflow-barchart.scm:40
 msgid "Cash Flow Barchart"

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)))

commit 346d2e24da17e30b93b011324e76c196cf2c9974
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Nov 11 21:09:25 2019 +0800

    [new-owner-report] use total-number-cell for monetaries
    
    Previous would tag all cells as total-label-cell. Tag monetaries with
    total-number-cell which leads to right-aligned period totals.

diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm
index 8764cbb0e..2987db118 100644
--- a/gnucash/report/business-reports/new-owner-report.scm
+++ b/gnucash/report/business-reports/new-owner-report.scm
@@ -252,7 +252,7 @@
   (define link-cols (assq-ref '((none . 0) (simple . 1) (detailed . 3)) link-option))
   (define (print-totals total debit credit tax sale)
     (define (total-cell cell)
-      (gnc:make-html-table-cell/markup "total-label-cell" cell))
+      (gnc:make-html-table-cell/markup "total-number-cell" cell))
     (define (make-cell amt)
       (total-cell (gnc:make-gnc-monetary currency amt)))
     (define span
@@ -264,7 +264,8 @@
         (gnc:html-table-append-row/markup!
          table "grand-total"
          (append
-          (list (total-cell (_ "Period Totals")))
+          (list (gnc:make-html-table-cell/markup
+                 "total-label-cell" (_ "Period Totals")))
           (addif (>= span 2) (gnc:make-html-table-cell/size 1 (1- span) ""))
           (addif (sale-col used-columns)   (make-cell sale))
           (addif (tax-col used-columns)    (make-cell tax))
@@ -278,7 +279,8 @@
         (gnc:html-table-append-row/markup!
          table "grand-total"
          (append
-          (list (total-cell
+          (list (gnc:make-html-table-cell/markup
+                 "total-label-cell"
                  (if (negative? total)
                      (_ "Total Credit")
                      (_ "Total Due")))

commit 3d5d8191dd1aca478269fc4046e3ce180c6f223e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Nov 10 23:42:26 2019 +0800

    [report-utilities] fix: overpayments in gnc:owner-splits->aging-list
    
    Previous algorithm had assumed all payments would match attached
    invoices. This updated algorithm does not assume.
    
    Invoice: add into appropriate bucket and save invoice+splits into
    list.
    
    Payment: scan payments from invoice+splits to find appropriate
    invoice, and deduct from the transfer account. The remainder is an
    pre/overpayment and added into prepayment bucket.
    
    It will always assume that the splitlist being processed will *all*
    belong to one owner.

diff --git a/gnucash/report/report-system/report-utilities.scm b/gnucash/report/report-system/report-utilities.scm
index 825928834..1cc84bad0 100644
--- a/gnucash/report/report-system/report-utilities.scm
+++ b/gnucash/report/report-system/report-utilities.scm
@@ -1114,18 +1114,19 @@ flawed. see report-utilities.scm. please update reports.")
         (buckets (make-vector num-buckets 0)))
     (define (addbucket! idx amt)
       (vector-set! buckets idx (+ amt (vector-ref buckets idx))))
-    (let lp ((splits splits))
+    (let lp ((splits splits)
+             (invoices-and-splits '()))
       (cond
        ((null? splits)
         (vector->list buckets))
 
-       ;; next split is an invoice posting split. note we don't need
-       ;; to handle invoice payments because these payments will
-       ;; reduce the lot balance automatically.
+       ;; next split is an invoice posting split. add its balance to
+       ;; bucket, and add splits to invoices-and-splits for payments.
        ((eqv? (xaccTransGetTxnType (xaccSplitGetParent (car splits)))
               TXN-TYPE-INVOICE)
         (let* ((invoice (gncInvoiceGetInvoiceFromTxn
                          (xaccSplitGetParent (car splits))))
+               (inv-splits (gnc-lot-get-split-list (gncInvoiceGetPostedLot invoice)))
                (lot (gncInvoiceGetPostedLot invoice))
                (bal (gnc-lot-get-balance lot))
                (bal (if receivable? bal (- bal)))
@@ -1136,23 +1137,33 @@ flawed. see report-utilities.scm. please update reports.")
           (let loop ((idx 0) (bucket-dates bucket-dates))
             (if (< date (car bucket-dates))
                 (addbucket! idx bal)
-                (loop (1+ idx) (cdr bucket-dates)))))
-        (lp (cdr splits)))
-
-       ;; next split is a prepayment
-       ((and (eqv? (xaccTransGetTxnType (xaccSplitGetParent (car splits)))
-                   TXN-TYPE-PAYMENT)
-             (null? (gncInvoiceGetInvoiceFromLot (xaccSplitGetLot (car splits)))))
-        (let* ((prepay (xaccSplitGetAmount (car splits)))
-               (prepay (if receivable? prepay (- prepay))))
-          (gnc:pk 'next=prepay (car splits) prepay)
-          (addbucket! (1- num-buckets) prepay))
-        (lp (cdr splits)))
+                (loop (1+ idx) (cdr bucket-dates))))
+          (lp (cdr splits)
+              (cons (cons invoice inv-splits) invoices-and-splits))))
+
+       ;; next split is a payment. find the associated invoices,
+       ;; deduct their totals. the remaining is an overpayment.
+       ((eqv? (xaccTransGetTxnType (xaccSplitGetParent (car splits)))
+              TXN-TYPE-PAYMENT)
+        (let* ((txn (xaccSplitGetParent (car splits)))
+               (payment (apply + (map xaccSplitGetAmount
+                                      (xaccTransGetPaymentAcctSplitList txn))))
+               (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)))
+          (gnc:pk 'payment (car splits) payment "->" overpayment)
+          (when (positive? overpayment)
+            (addbucket! (1- num-buckets) (- overpayment)))
+          (lp (cdr splits) invoices-and-splits)))
 
        ;; not invoice/prepayment. regular or payment split.
        (else
         (gnc:pk 'next=skipped (car splits))
-        (lp (cdr splits)))))))
+        (lp (cdr splits) invoices-and-splits))))))
 
 ;; ***************************************************************************
 

commit 980776f46f9fc84f9aedbb566ff4fa33beaa7273
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Nov 10 22:17:29 2019 +0800

    [new-owner-report] fix: overpayments must show prepayment row
    
    If a payment exceeds the amounts from associated invoices, the amount
    remaining must be considered a prepayment.

diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm
index ee8263f70..8764cbb0e 100644
--- a/gnucash/report/business-reports/new-owner-report.scm
+++ b/gnucash/report/business-reports/new-owner-report.scm
@@ -348,29 +348,33 @@
             #f)))
         payment-splits)))))
 
-  (define (make-payment->invoices-table split payment-splits currency)
-    (if (null? payment-splits)
-        (list (list (gnc:make-html-table-cell/size 1 2 (_ "Prepayments"))
-                    (make-cell
-                     (gnc:make-gnc-monetary
-                      currency (- (xaccSplitGetAmount split))))))
-        (map
-         (lambda (inv-splits)
-           (let ((inv (car inv-splits))
-                 (inv-split (cadr inv-splits)))
-             (list
-              (qof-print-date
-               (gncInvoiceGetDatePosted inv))
-              (gnc:make-html-text
-               (gnc:html-markup-anchor
-                (gnc:invoice-anchor-text inv)
-                (gnc-get-num-action
-                 (gncInvoiceGetPostedTxn inv) #f)))
-              (make-cell
-               (gnc:make-gnc-monetary
-                currency
-                (- (xaccSplitGetAmount inv-split)))))))
-         payment-splits)))
+  (define (make-payment->invoices-table amount payment-splits currency)
+    (let lp ((payment-splits payment-splits)
+             (amount (- amount))
+             (result '()))
+      (cond
+       ((null? payment-splits)
+        (reverse
+         (if (positive? amount)
+             (cons (list (gnc:make-html-table-cell/size 1 2 (_ "Prepayments"))
+                         (make-cell (gnc:make-gnc-monetary currency amount)))
+                   result)
+             result)))
+       (else
+        (let* ((payment-split (car payment-splits))
+               (inv (car payment-split))
+               (inv-split (cadr payment-split))
+               (inv-amount (xaccSplitGetAmount inv-split)))
+          (lp (cdr payment-splits)
+              (- amount inv-amount)
+              (cons (list
+                     (qof-print-date (gncInvoiceGetDatePosted inv))
+                     (gnc:make-html-text
+                      (gnc:html-markup-anchor
+                       (gnc:invoice-anchor-text inv)
+                       (gnc-get-num-action (gncInvoiceGetPostedTxn inv) #f)))
+                     (make-cell (gnc:make-gnc-monetary currency inv-amount)))
+                    result)))))))
 
   (define (split->type-str split)
     (let* ((txn (xaccSplitGetParent split))
@@ -494,7 +498,7 @@
             ((and payment-splits (eq? link-option 'simple))
              (make-payment->invoices-list invoice payment-splits))
             ((and payment-splits (eq? link-option 'detailed))
-             (make-payment->invoices-table split payment-splits currency))
+             (make-payment->invoices-table value payment-splits currency))
             ;; some error occurred, show 1 line containing empty-list
             (else '(()))))
 

commit 9189bcbe41dae281e8b7cf4ee34f7e3d89189070
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Nov 10 12:30:15 2019 -0800

    Bug 797078 - "Automatic decimal point" Should Not Cause 2 Different Behaviors
    
    It's documented only for automatically inserting the decimal point
    so remove the code that affects number display.

diff --git a/libgnucash/app-utils/gnc-ui-util.c b/libgnucash/app-utils/gnc-ui-util.c
index eb149eb8d..bae5f388b 100644
--- a/libgnucash/app-utils/gnc-ui-util.c
+++ b/libgnucash/app-utils/gnc-ui-util.c
@@ -1553,18 +1553,9 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info)
         val = gnc_numeric_convert(val, denom, GNC_HOW_RND_ROUND_HALF_UP);
         value_is_decimal = gnc_numeric_to_decimal(&val, NULL);
     }
-    /* Force at least auto_decimal_places zeros */
-    if (auto_decimal_enabled)
-    {
-        min_dp = MAX(auto_decimal_places, info->min_decimal_places);
-        max_dp = MAX(auto_decimal_places, info->max_decimal_places);
-    }
-    else
-    {
-        min_dp = info->min_decimal_places;
-        max_dp = info->max_decimal_places;
-    }
-
+    min_dp = info->min_decimal_places;
+    max_dp = info->max_decimal_places;
+    
     /* Don to limit the number of decimal places _UNLESS_ force_fit is
      * true. */
     if (!info->force_fit)



Summary of changes:
 gnucash/report/report-utilities.scm                |  45 ++--
 .../report/reports/standard/category-barchart.scm  | 248 +++++++++++----------
 .../report/reports/standard/new-owner-report.scm   | 136 ++++++-----
 libgnucash/app-utils/gnc-ui-util.c                 |  15 +-
 po/de.po                                           |  10 +-
 5 files changed, 236 insertions(+), 218 deletions(-)



More information about the gnucash-changes mailing list