From 9189bcbe41dae281e8b7cf4ee34f7e3d89189070 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 10 Nov 2019 12:30:15 -0800 Subject: [PATCH 1/8] 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. --- libgnucash/app-utils/gnc-ui-util.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/libgnucash/app-utils/gnc-ui-util.c b/libgnucash/app-utils/gnc-ui-util.c index eb149eb8d5..bae5f388bc 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) From 980776f46f9fc84f9aedbb566ff4fa33beaa7273 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sun, 10 Nov 2019 22:17:29 +0800 Subject: [PATCH 2/8] [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. --- .../business-reports/new-owner-report.scm | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm index ee8263f701..8764cbb0ec 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 '(())))) From 3d5d8191dd1aca478269fc4046e3ce180c6f223e Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sun, 10 Nov 2019 23:42:26 +0800 Subject: [PATCH 3/8] [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. --- .../report/report-system/report-utilities.scm | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/gnucash/report/report-system/report-utilities.scm b/gnucash/report/report-system/report-utilities.scm index 8259288343..1cc84bad05 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)))))) ;; *************************************************************************** From 346d2e24da17e30b93b011324e76c196cf2c9974 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Mon, 11 Nov 2019 21:09:25 +0800 Subject: [PATCH 4/8] [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. --- gnucash/report/business-reports/new-owner-report.scm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm index 8764cbb0ec..2987db118c 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"))) From a63ba726241d04080d762a93f5dbc40955208b54 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Tue, 12 Nov 2019 14:50:51 +0800 Subject: [PATCH 5/8] [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. --- gnucash/report/report-system/report-utilities.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnucash/report/report-system/report-utilities.scm b/gnucash/report/report-system/report-utilities.scm index 1cc84bad05..36237a4b47 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))) From 0b8bfe668331f4cd9982c4d6171c4a7c7efe7741 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Tue, 12 Nov 2019 15:01:46 +0800 Subject: [PATCH 6/8] [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. --- .../business-reports/new-owner-report.scm | 66 ++++++++++--------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm index 2987db118c..2c0ed474d2 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 From c4a19b9b5a7d6abb65c853051a90befee81fa980 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Tue, 12 Nov 2019 16:27:43 +0800 Subject: [PATCH 7/8] [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. --- gnucash/report/business-reports/new-owner-report.scm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm index 2c0ed474d2..543f9b8232 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) From c520c5af197c70fd32bd998706bf3fb0cb7e2a8a Mon Sep 17 00:00:00 2001 From: pianoslum Date: Tue, 12 Nov 2019 21:46:50 +0100 Subject: [PATCH 8/8] Add three missing German translations --- po/de.po | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/po/de.po b/po/de.po index b652b9b0f8..2a1dd5cd79 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 \n" +"PO-Revision-Date: 2019-11-12 21:44+0200\n" +"Last-Translator: pianoslum \n" "Language-Team: GnuCash-de \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"