Doable...

On Fri, 3 Jan 2020 at 11:56, Christopher Lam <christopher....@gmail.com>
wrote:

> This is a nice hack.
>
> It would be even a nicer hack that the transaction report automatically
> inserts the balance brought forward on the same row as the account name. I
> suspect this is doable.
>
> On Fri, 3 Jan 2020, 3:10 pm david whiting, <d...@davidwhiting.me.uk> wrote:
>
>> What I do is add a transaction on the first date of the new period with
>> the
>> transaction reference "Balance carried forward" with nothing in the
>> credit/debit columns. Then a transaction report with running balance has
>> "Balance carried forward" as the first transaction and the running balance
>> shows the amount carried forward. See attached example (our club financial
>> year runs from 1st August to 31st July).
>>
>> David
>>
>> On Thu, 2 Jan 2020, 23:17 Michael or Penny Novack, <
>> stepbystepf...@comcast.net> wrote:
>>
>> > On 1/2/2020 5:33 PM, Christopher Lam wrote:
>> > > If it's a single-creditor liability account, you could try adding the
>> > > Display/Running Balance. However it doesn't quite give you the
>> 'balance
>> > > brought forward' prior to the first printed transaction.
>> > >
>> > I will tell you how I would do this. It would be easy for me, because I
>> > don't insist that that the final printed version be printed from within
>> > gnucash.
>> >
>> > I would use the suggestion above, but set the date range to include the
>> > last transaction before. I would export the resulting report.. I would
>> > then edit the date of that last transaction to be the start date, change
>> > its description to "opening balance" and it's amount to zero/blank << it
>> > is the running balance after this transaction that is the starting
>> > balance >>
>> >
>> > I would then print THAT (or send THAT by electronic means
>> >
>> > Michael D Novack
>> >
>> >
>> > _______________________________________________
>> > gnucash-user mailing list
>> > gnucash-user@gnucash.org
>> > To update your subscription preferences or to unsubscribe:
>> > https://lists.gnucash.org/mailman/listinfo/gnucash-user
>> > If you are using Nabble or Gmane, please see
>> > https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
>> > -----
>> > Please remember to CC this list on all your replies.
>> > You can do this by using Reply-To-List or Reply-All.
>> >
>> _______________________________________________
>> gnucash-user mailing list
>> gnucash-user@gnucash.org
>> To update your subscription preferences or to unsubscribe:
>> https://lists.gnucash.org/mailman/listinfo/gnucash-user
>> If you are using Nabble or Gmane, please see
>> https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
>> -----
>> Please remember to CC this list on all your replies.
>> You can do this by using Reply-To-List or Reply-All.
>>
>
  Transaction Report

  From 14/12/19 to 31/12/20

   Date Num Description Memo/Notes Account Amount Running Balance
   Bank-GBP £1,275.00
   14/12/19 Customer-GBP Bank-GBP [1]-£66.00 [2]£1,209.00
   14/12/19 num Customer-GBP memo1 Bank-GBP [3]£10.00 [4]£1,219.00
   14/12/19 Customer-GBP Bank-GBP [5]£10.00 [6]£1,229.00
   21/12/19 Customer-GBP Bank-GBP [7]£95.00 [8]£1,324.00
   31/12/19 inv-pmt-num Cust-Easy inv-pmt-memo - $100 in GBP Bank-GBP
   [9]£71.43 [10]£1,395.43
   Total For Bank-GBP £120.43
   Bank-USD $961.80
   14/12/19 Vend-USD Bank-USD [11]$100.00 [12]$1,061.80
   23/12/19 num-is-identical Cust-Easy split-memo-from-bank Bank-USD
   [13]$100.00 [14]$1,161.80
   24/12/19 P-101 Cust-Links Bank-USD [15]-$80.00 [16]$1,081.80
   24/12/19 P-100 Cust-Links Bank-USD [17]$80.00 [18]$1,161.80
   25/12/19 Cust-Links memo Bank-USD [19]$36.00 [20]$1,197.80
   31/12/19 inv-pmt-num Cust-Easy inv-pmt-memo - $15 Bank-USD [21]$15.00
   [22]$1,212.80
   02/01/20 pmt-num Cust-Easy bank-memo Bank-USD [23]$304.25 [24]$1,517.05
   Total For Bank-USD $555.25
     __________________________________________________________________

   Grand Total $555.25
   £120.43

References

   1. gnc-register:split-guid=b268ff596c8e47f59d20d21f39eb4203
   2. gnc-register:split-guid=b268ff596c8e47f59d20d21f39eb4203
   3. gnc-register:split-guid=fe2e392ffdc84c8f874f1bc0d79c3e75
   4. gnc-register:split-guid=fe2e392ffdc84c8f874f1bc0d79c3e75
   5. gnc-register:split-guid=105167d4cc31453d9770d84cd7c9cf7e
   6. gnc-register:split-guid=105167d4cc31453d9770d84cd7c9cf7e
   7. gnc-register:split-guid=e8f7d0f441d2408ebef8fff5d2120f48
   8. gnc-register:split-guid=e8f7d0f441d2408ebef8fff5d2120f48
   9. gnc-register:split-guid=baf7b2f7eab04a2e8cf4771280d938fc
  10. gnc-register:split-guid=baf7b2f7eab04a2e8cf4771280d938fc
  11. gnc-register:split-guid=aba54ee0c28b4157bb76d330c90906e8
  12. gnc-register:split-guid=aba54ee0c28b4157bb76d330c90906e8
  13. gnc-register:split-guid=bfd9796a84264ca98a53a76bd004c464
  14. gnc-register:split-guid=bfd9796a84264ca98a53a76bd004c464
  15. gnc-register:split-guid=179dca0494064776a63b992e16c4f719
  16. gnc-register:split-guid=179dca0494064776a63b992e16c4f719
  17. gnc-register:split-guid=5c2adb36f01e42e39aced737383a6fa8
  18. gnc-register:split-guid=5c2adb36f01e42e39aced737383a6fa8
  19. gnc-register:split-guid=70fb905d20fa4f20a467174a711aaeb0
  20. gnc-register:split-guid=70fb905d20fa4f20a467174a711aaeb0
  21. gnc-register:split-guid=c6e62fce27b34c4fb183ad59839b15f3
  22. gnc-register:split-guid=c6e62fce27b34c4fb183ad59839b15f3
  23. gnc-register:split-guid=477a1cf349554393a9a3f32e16304ba2
  24. gnc-register:split-guid=477a1cf349554393a9a3f32e16304ba2
diff --git a/gnucash/report/report-system/trep-engine.scm b/gnucash/report/report-system/trep-engine.scm
index 5e83d506d..922897430 100644
--- a/gnucash/report/report-system/trep-engine.scm
+++ b/gnucash/report/report-system/trep-engine.scm
@@ -1033,7 +1033,8 @@ be excluded from periodic reporting.")
 ;; ;;;;;;;;;;;;;;;;;;;;
 ;; Here comes the big function that builds the whole table.
 
-(define (make-split-table splits options custom-calculated-cells)
+(define (make-split-table splits options custom-calculated-cells
+                          begindate)
 
   (define (opt-val section name)
     (let ((option (gnc:lookup-option options section name)))
@@ -1120,6 +1121,11 @@ be excluded from periodic reporting.")
                              'multi-line))
          (export? (opt-val gnc:pagename-general optname-table-export)))
 
+    (define (acc-reverse? acc)
+      (if account-types-to-reverse
+          (memv (xaccAccountGetType acc) account-types-to-reverse)
+          (gnc-reverse-balance acc)))
+
     (define (column-uses? param)
       (cdr (assq param used-columns)))
 
@@ -1351,7 +1357,7 @@ be excluded from periodic reporting.")
          (if (column-uses? 'running-balance)
              (list (vector (_ "Running Balance")
                            running-balance #t #f #f
-                           (lambda (a) "")))
+                           #f xaccAccountGetBalanceAsOfDate))
              '()))))
 
     (define calculated-cells
@@ -1406,29 +1412,36 @@ be excluded from periodic reporting.")
            table subheading-style
            (append
             (gnc:html-make-empty-cells left-indent)
-            (if (and (opt-val pagename-sorting optname-show-informal-headers)
-                     (column-uses? 'amount-double)
-                     (memq sortkey SORTKEY-INFORMAL-HEADERS))
-                (append
-                 (if export?
-                     (cons
-                      (gnc:make-html-table-cell data)
-                      (gnc:html-make-empty-cells
-                       (+ right-indent width-left-columns -1)))
-                     (list
-                      (gnc:make-html-table-cell/size
-                       1 (+ right-indent width-left-columns) data)))
-                 (map (lambda (cell)
-                        (let ((friendly-fn (vector-ref cell 5)))
-                          (and friendly-fn
-                               (gnc:make-html-text
-                                (gnc:html-markup-b
-                                 (friendly-fn (renderer-fn split)))))))
-                      calculated-cells))
+            (if export?
+                (cons
+                 (gnc:make-html-table-cell data)
+                 (gnc:html-make-empty-cells
+                  (+ right-indent width-left-columns -1)))
                 (list
                  (gnc:make-html-table-cell/size
-                  1 (+ right-indent width-left-columns width-right-columns)
-                  data))))))))
+                  1 (+ right-indent width-left-columns) data)))
+            (map
+             (lambda (cell)
+               (cond
+                ((vector-ref cell 5) =>
+                 (lambda (friendly-fn)
+                   (and (opt-val pagename-sorting optname-show-informal-headers)
+                        (column-uses? 'amount-double)
+                        (memq sortkey SORTKEY-INFORMAL-HEADERS)
+                        (gnc:make-html-text
+                         (gnc:html-markup-b
+                          (friendly-fn (xaccSplitGetAccount split)))))))
+                ((vector-ref cell 6) =>
+                 (lambda (running-bal-fn)
+                   (let* ((acc (xaccSplitGetAccount split))
+                          (bal (running-bal-fn acc begindate))
+                          (rev? (acc-reverse? acc)))
+                     (gnc:make-html-table-cell/markup
+                      "number-cell"
+                      (gnc:make-gnc-monetary
+                       (xaccAccountGetCommodity acc)
+                       (if rev? (- bal) bal))))))))
+             calculated-cells))))))
 
     (define (add-subtotal-row subtotal-string subtotal-collectors
                               subtotal-style level row col)
@@ -1605,10 +1618,7 @@ be excluded from periodic reporting.")
 
     (define (add-split-row split cell-calculators row-style transaction-row?)
       (let* ((account (xaccSplitGetAccount split))
-             (reversible-account? (if account-types-to-reverse
-                                      (memv (xaccAccountGetType account)
-                                            account-types-to-reverse)
-                                      (gnc-reverse-balance account)))
+             (reversible-account? (acc-reverse? account))
              (cells (map (lambda (cell)
                            (let ((split->monetary (vector-ref cell 1)))
                              (vector (split->monetary split)
@@ -2173,7 +2183,8 @@ be excluded from periodic reporting.")
 
        (else
         (let-values (((table grid csvlist)
-                      (make-split-table splits options custom-calculated-cells)))
+                      (make-split-table splits options custom-calculated-cells
+                                        begindate)))
 
           (gnc:html-document-set-title! document report-title)
 
_______________________________________________
gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
If you are using Nabble or Gmane, please see 
https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
-----
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.

Reply via email to