gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Thu Dec 26 11:18:09 EST 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/b6586301 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fc692696 (commit)
	from  https://github.com/Gnucash/gnucash/commit/12705e4f (commit)



commit b65863019aa662f9c920833656b54f919876c8f8
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Dec 26 15:45:38 2019 +0700

    [new-owner-report] insert narrow-cell to split LHS and RHS cleanly
    
    add narrow-cell to cleanly delineate LHS owner-report and RHS links.
    
    also fix some detail visibility whereby some columns are switched off
    in options.

diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm
index 6e3a58104..df0b9645e 100644
--- a/gnucash/report/business-reports/new-owner-report.scm
+++ b/gnucash/report/business-reports/new-owner-report.scm
@@ -132,11 +132,15 @@
 (define (bal-col columns-used)
   (vector-ref columns-used 9))
 (define (num-link-cols columns-used)
-  (+ (if (date-col columns-used) 1 0)
+  (+ (if (or (date-col columns-used) (type-col columns-used)
+             (ref-col columns-used) (credit-col columns-used)
+             (desc-col columns-used) (debit-col columns-used))
+         1 0)
+     (if (date-col columns-used) 1 0)
      (if (ref-col columns-used) 1 0)
      (if (type-col columns-used) 1 0)
      (if (desc-col columns-used) 1 0)
-     (if (bal-col columns-used) 1 0)))
+     (if (or (credit-col columns-used) (debit-col columns-used)) 1 0)))
 (define columns-used-size 10)
 
 (define (build-column-used options)
@@ -192,6 +196,10 @@
       ((simple)
        (addto! heading-list (_ linked-txns-header)))
       ((detailed)
+       (if (or (date-col column-vector) (type-col column-vector)
+               (ref-col column-vector) (credit-col column-vector)
+               (desc-col column-vector) (debit-col column-vector))
+           (addto! heading-list #f))
        (if (date-col column-vector) (addto! heading-list (_ "Date")))
        (if (ref-col column-vector) (addto! heading-list (_ "Reference")))
        (if (type-col column-vector) (addto! heading-list (_ "Type")))
@@ -291,7 +299,8 @@
 ;; Make a row list based on the visible columns
 ;;
 (define (add-row table odd-row? column-vector date due-date ref type-str
-                 desc currency amt credit debit sale tax anchor-split link-rows)
+                 desc currency amt credit debit sale tax anchor-split
+                 link-option link-rows)
   (define empty-cols
     (count identity
            (map (lambda (f) (f column-vector))
@@ -312,16 +321,15 @@
                "number-cell" (link-data-amount link-data)))))
 
      ((link-desc-amount? link-data)
-      (append
-       (list
-        (gnc:make-html-table-cell/size
-         1 (count identity
-                  (map (lambda (f) (f column-vector))
-                       (list date-col ref-col type-col desc-col)))
-         (link-desc-amount-desc link-data)))
-       (addif (or (debit-col column-vector) (credit-col column-vector))
-              (gnc:make-html-table-cell/markup
-               "number-cell" (link-desc-amount-amount link-data)))))
+      (let ((cols (count identity
+                         (map (lambda (f) (f column-vector))
+                              (list date-col ref-col type-col desc-col)))))
+        (append
+         (addif (< 0 cols) (gnc:make-html-table-cell/size
+                            1 cols (link-desc-amount-desc link-data)))
+         (addif (or (debit-col column-vector) (credit-col column-vector))
+                (gnc:make-html-table-cell/markup
+                 "number-cell" (link-desc-amount-amount link-data))))))
 
      ((link-blank? link-data)
       (make-list (count identity
@@ -338,6 +346,11 @@
           (gnc:html-markup-anchor
            (gnc:split-anchor-text anchor-split)
            (gnc:make-gnc-monetary currency amt)))))
+  (define cell-nohoriz
+    (let ((cell (gnc:make-html-table-cell/size nrows 1 #f)))
+      (gnc:html-table-cell-set-style!
+       cell "td" 'attribute '("style" "border-bottom: none; border-top: none;"))
+      cell))
   (let lp ((link-rows link-rows)
            (first-row? #t))
     (unless (null? link-rows)
@@ -364,6 +377,7 @@
               (addif (credit-col column-vector)  (cell-anchor credit))
               (addif (debit-col column-vector)   (cell-anchor (and debit (- debit))))
               (addif (bal-col column-vector)     (cell amt))))
+            (addif (eq? link-option 'detailed) cell-nohoriz)
             (link-data->cols (car link-rows))))
           (gnc:html-table-append-row/markup!
            table (if odd-row? "normal-row" "alternate-row")
@@ -432,7 +446,7 @@
   (define (add-balance-row odd-row? total)
     (add-row table odd-row? used-columns start-date #f "" (_ "Balance") ""
              currency total #f #f #f #f (list (make-list link-cols #f))
-             (list (make-link-blank))))
+             link-option (list (make-link-blank))))
 
   (define (make-invoice->payments-table invoice)
     (define (tfr-split->row tfr-split)
@@ -686,6 +700,7 @@
            (and (>= value 0) value) (and (< value 0) value)
            (invoice->sale invoice) (invoice->tax invoice)
            (txn->transfer-split txn)
+           link-option
            (cond
             ((and (txn-is-invoice? txn) (eq? link-option 'simple))
              (if (gncInvoiceIsPaid invoice)

commit fc69269664985b5393fd5bc81074d9b81c3128fd
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Dec 26 15:31:46 2019 +0700

    [new-owner-report] improve maintainability - rename vars
    
    1. rename vars to better reflect meaning (num to ref, memo to desc,
    value-col to bal-col)
    2. reindent
    3. final gnc-get-num-action swap to gncInvoiceGetID

diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm
index e6797c3fa..6e3a58104 100644
--- a/gnucash/report/business-reports/new-owner-report.scm
+++ b/gnucash/report/business-reports/new-owner-report.scm
@@ -115,11 +115,11 @@
   (vector-ref columns-used 0))
 (define (date-due-col columns-used)
   (vector-ref columns-used 1))
-(define (num-col columns-used)
+(define (ref-col columns-used)
   (vector-ref columns-used 2))
 (define (type-col columns-used)
   (vector-ref columns-used 3))
-(define (memo-col columns-used)
+(define (desc-col columns-used)
   (vector-ref columns-used 4))
 (define (sale-col columns-used)
   (vector-ref columns-used 5))
@@ -129,14 +129,14 @@
   (vector-ref columns-used 7))
 (define (debit-col columns-used)
   (vector-ref columns-used 8))
-(define (value-col columns-used)
+(define (bal-col columns-used)
   (vector-ref columns-used 9))
 (define (num-link-cols columns-used)
   (+ (if (date-col columns-used) 1 0)
-     (if (num-col columns-used) 1 0)
+     (if (ref-col columns-used) 1 0)
      (if (type-col columns-used) 1 0)
-     (if (memo-col columns-used) 1 0)
-     (if (value-col columns-used) 1 0)))
+     (if (desc-col columns-used) 1 0)
+     (if (bal-col columns-used) 1 0)))
 (define columns-used-size 10)
 
 (define (build-column-used options)
@@ -172,11 +172,11 @@
         (addto! heading-list (_ date-header)))
     (if (date-due-col column-vector)
         (addto! heading-list (_ due-date-header)))
-    (if (num-col column-vector)
+    (if (ref-col column-vector)
         (addto! heading-list (_ reference-header)))
     (if (type-col column-vector)
         (addto! heading-list (_ type-header)))
-    (if (memo-col column-vector)
+    (if (desc-col column-vector)
         (addto! heading-list (_ desc-header)))
     (if (sale-col column-vector)
         (addto! heading-list (_ sale-header)))
@@ -186,16 +186,16 @@
         (addto! heading-list (_ credit-header)))
     (if (debit-col column-vector)
         (addto! heading-list (_ debit-header)))
-    (if (value-col column-vector)
+    (if (bal-col column-vector)
         (addto! heading-list (_ amount-header)))
     (case link-option
       ((simple)
        (addto! heading-list (_ linked-txns-header)))
       ((detailed)
        (if (date-col column-vector) (addto! heading-list (_ "Date")))
-       (if (num-col column-vector) (addto! heading-list (_ "Reference")))
+       (if (ref-col column-vector) (addto! heading-list (_ "Reference")))
        (if (type-col column-vector) (addto! heading-list (_ "Type")))
-       (if (memo-col column-vector) (addto! heading-list (_ "Description")))
+       (if (desc-col column-vector) (addto! heading-list (_ "Description")))
        (if (or (debit-col column-vector) (credit-col column-vector))
            (addto! heading-list (_ "Amount")))))
     (reverse heading-list)))
@@ -290,23 +290,23 @@
 ;;
 ;; Make a row list based on the visible columns
 ;;
-(define (add-row table odd-row? column-vector date due-date num type-str
-                 memo currency amt credit debit sale tax anchor-split link-rows)
+(define (add-row table odd-row? column-vector date due-date ref type-str
+                 desc currency amt credit debit sale tax anchor-split link-rows)
   (define empty-cols
     (count identity
            (map (lambda (f) (f column-vector))
-                (list date-col date-due-col num-col type-col
-                      memo-col sale-col tax-col credit-col
-                      debit-col value-col))))
+                (list date-col date-due-col ref-col type-col
+                      desc-col sale-col tax-col credit-col
+                      debit-col bal-col))))
   (define nrows (if link-rows (length link-rows) 1))
   (define (link-data->cols link-data)
     (cond
      ((link-data? link-data)
       (append
        (addif (date-col column-vector) (link-data-date link-data))
-       (addif (num-col column-vector) (link-data-ref link-data))
+       (addif (ref-col column-vector) (link-data-ref link-data))
        (addif (type-col column-vector) (link-data-type link-data))
-       (addif (memo-col column-vector) (link-data-desc link-data))
+       (addif (desc-col column-vector) (link-data-desc link-data))
        (addif (or (debit-col column-vector) (credit-col column-vector))
               (gnc:make-html-table-cell/markup
                "number-cell" (link-data-amount link-data)))))
@@ -317,7 +317,7 @@
         (gnc:make-html-table-cell/size
          1 (count identity
                   (map (lambda (f) (f column-vector))
-                       (list date-col num-col type-col memo-col)))
+                       (list date-col ref-col type-col desc-col)))
          (link-desc-amount-desc link-data)))
        (addif (or (debit-col column-vector) (credit-col column-vector))
               (gnc:make-html-table-cell/markup
@@ -326,7 +326,7 @@
      ((link-blank? link-data)
       (make-list (count identity
                         (map (lambda (f) (f column-vector))
-                             (list date-col num-col type-col memo-col value-col)))
+                             (list date-col ref-col type-col desc-col bal-col)))
                  #f))
 
      (else link-data)))
@@ -352,19 +352,19 @@
               (addif (date-col column-vector) (qof-print-date date))
               (addif (date-due-col column-vector)
                      (and due-date (qof-print-date due-date)))
-              (addif (num-col column-vector)    num)
+              (addif (ref-col column-vector)    ref)
               (addif (type-col column-vector)   type-str)
-              (addif (memo-col column-vector)   memo)
+              (addif (desc-col column-vector)   desc)
               (addif (sale-col column-vector)   (cell sale))
               (addif (tax-col column-vector)    (cell tax))))
             (map
              (lambda (cell)
                (gnc:make-html-table-cell/size/markup nrows 1 "number-cell" cell))
              (append
-              (addif (credit-col column-vector) (cell-anchor credit))
-              (addif (debit-col column-vector)  (cell-anchor (and debit (- debit))))
-              (addif (value-col column-vector)  (cell amt))))
-             (link-data->cols (car link-rows))))
+              (addif (credit-col column-vector)  (cell-anchor credit))
+              (addif (debit-col column-vector)   (cell-anchor (and debit (- debit))))
+              (addif (bal-col column-vector)     (cell amt))))
+            (link-data->cols (car link-rows))))
           (gnc:html-table-append-row/markup!
            table (if odd-row? "normal-row" "alternate-row")
            (link-data->cols (car link-rows))))
@@ -386,7 +386,7 @@
       (total-cell (gnc:make-gnc-monetary currency amt)))
     (define span
       (count identity (map (lambda (f) (f used-columns))
-                           (list memo-col type-col num-col date-due-col date-col))))
+                           (list desc-col type-col ref-col date-due-col date-col))))
     ;; print period totals
     (if (or (sale-col used-columns) (tax-col used-columns)
             (credit-col used-columns) (debit-col used-columns))
@@ -400,11 +400,11 @@
           (addif (tax-col used-columns)    (make-cell tax))
           (addif (credit-col used-columns) (make-cell credit))
           (addif (debit-col used-columns)  (make-cell (- debit)))
-          (addif (value-col used-columns) (make-cell (+ credit debit)))
+          (addif (bal-col used-columns)    (make-cell (+ credit debit)))
           (addif (> link-cols 0) (gnc:make-html-table-cell/size 1 link-cols #f)))))
 
     ;; print grand total
-    (if (value-col used-columns)
+    (if (bal-col used-columns)
         (gnc:html-table-append-row/markup!
          table "grand-total"
          (append
@@ -414,7 +414,7 @@
                      (_ "Total Credit")
                      (_ "Total Due")))
                 (gnc:make-html-table-cell/size/markup
-                 1 (value-col used-columns)
+                 1 (bal-col used-columns)
                  "total-number-cell"
                  (gnc:make-gnc-monetary currency total)))
           (addif (> link-cols 0)
@@ -446,9 +446,9 @@
          (split->type-str tfr-split)
          (split->desc tfr-split)
          (gnc:make-html-text
-           (gnc:html-markup-anchor
-            (gnc:split-anchor-text (txn->transfer-split pmt-txn))
-            (gnc:make-gnc-monetary tfr-curr tfr-amt))))))
+          (gnc:html-markup-anchor
+           (gnc:split-anchor-text (txn->transfer-split pmt-txn))
+           (gnc:make-gnc-monetary tfr-curr tfr-amt))))))
     (define (posting-split->row posting-split)
       (let* ((posting-txn (xaccSplitGetParent posting-split))
              (inv (gncInvoiceGetInvoiceFromLot (xaccSplitGetLot posting-split))))
@@ -477,7 +477,7 @@
                (cons (make-link-desc-amount
                       (_ "UNPAID")
                       (gnc:make-gnc-monetary
-                        currency (AP-negate (gnc-lot-get-balance lot))))
+                       currency (AP-negate (gnc-lot-get-balance lot))))
                      result))))
 
          ;; This is the regular payment split. Find Transfer acct
@@ -563,9 +563,7 @@
         (lambda (inv)
           (gnc:html-markup-anchor
            (gnc:invoice-anchor-text inv)
-           (gnc-get-num-action
-            (gncInvoiceGetPostedTxn inv)
-            #f)))
+           (gncInvoiceGetID inv)))
         (cdr (payment-txn->overpayment-and-invoices txn)))))))
 
   (define (make-payment->invoices-table txn)
@@ -632,7 +630,7 @@
      ((null? splits)
       ;;Balance row may not have been added if all transactions were before
       ;;start-date (and no other rows would be added either) so add it now
-      (when (and (not printed?) (value-col used-columns) (not (zero? total)))
+      (when (and (not printed?) (bal-col used-columns) (not (zero? total)))
         (add-balance-row odd-row? total))
       (print-totals total debit credit tax sale)
       (gnc:html-table-set-style!
@@ -675,7 +673,7 @@
          ;; if balance row hasn't been rendered, consider
          ;; adding here.  skip if value=0.
          ((not printed?)
-          (let ((print? (and (value-col used-columns) (not (zero? total)))))
+          (let ((print? (and (bal-col used-columns) (not (zero? total)))))
             (if print? (add-balance-row odd-row? total))
             (lp #t (not print?) splits total debit credit tax sale)))
 



Summary of changes:
 .../report/business-reports/new-owner-report.scm   | 113 ++++++++++++---------
 1 file changed, 63 insertions(+), 50 deletions(-)



More information about the gnucash-changes mailing list