Add Additional Column to Register Report (PATCH INCLUDED)

Robert Stocks robert.stocks at gmail.com
Mon Jun 2 17:45:12 EDT 2008


Hi, First post so be nice if I get something wrong.

I had a requirement for a specific report - Basically I needed to be
able to report on all the splits that affect a specific account.
Example Transaction Phone bill (2 phones on account one is mine other
is a friends)
Split for transaction in Checking is 4 way (My Calls/My Line Rental) -
Expense Accounts  (Their calls/There Line Rental)  Assets:Loans:Friend

I needed to run the report on their loan account showing the breakdown
(in the split memo box) for each line but not showing MY items from
the Split.
Additionally I only need to report on the "new" (Unreconciled) transactions.

(long pause while I try every report there is)

The closest I could get to what I needed was by setting the account
view to Basic / single line / filter by (unreconciled)
But that did not include the memo field from the Split ( but it did
have both lines)

So I added the Split Description Column to the register report,  this
was my first Scheme programming, so it took a while but was fun.

This patch is the result of my work, please comment or ignore or tell
me I could have solved my problem another way, either way here is a
diff against TRUNK (revision 17187).


Index: src/report/standard-reports/register.scm
===================================================================
--- src/report/standard-reports/register.scm	(revision 17187)
+++ src/report/standard-reports/register.scm	(working copy)
@@ -26,22 +26,24 @@
   (vector-ref columns-used 1))
 (define (description-col columns-used)
   (vector-ref columns-used 2))
+(define (split-description-col columns-used)
+  (vector-ref columns-used 3))
 (define (account-col columns-used)
-  (vector-ref columns-used 3))
+  (vector-ref columns-used 4))
 (define (shares-col columns-used)
-  (vector-ref columns-used 4))
+  (vector-ref columns-used 5))
 (define (price-col columns-used)
-  (vector-ref columns-used 5))
+  (vector-ref columns-used 6))
 (define (amount-single-col columns-used)
-  (vector-ref columns-used 6))
+  (vector-ref columns-used 7))
 (define (debit-col columns-used)
-  (vector-ref columns-used 7))
+  (vector-ref columns-used 8))
 (define (credit-col columns-used)
-  (vector-ref columns-used 8))
+  (vector-ref columns-used 9))
 (define (balance-col columns-used)
-  (vector-ref columns-used 9))
+  (vector-ref columns-used 10))

-(define columns-used-size 10)
+(define columns-used-size 11)

 (define (num-columns-required columns-used)
   (do ((i 0 (+ i 1))
@@ -68,17 +70,23 @@
     (set-col (opt-val "Display" "Date") 0)
     (set-col (opt-val "Display" "Num") 1)
     (set-col (opt-val "Display" "Description") 2)
-    (set-col (opt-val "Display" "Account") 3)
-    (set-col (opt-val "Display" "Shares") 4)
-    (set-col (opt-val "Display" "Price") 5)
+    (set-col
+        (if (opt-val "__reg" "journal")
+        #f
+        (opt-val "Display" "Split Description")
+        )
+        3)
+    (set-col (opt-val "Display" "Account") 4)
+    (set-col (opt-val "Display" "Shares") 5)
+    (set-col (opt-val "Display" "Price") 6)
     (let ((invoice? #f)
           (amount-setting (opt-val "Display" "Amount")))
       (if (or invoice? (eq? amount-setting 'single))
-          (set-col #t 6)
+          (set-col #t 7)
           (begin
-            (set-col #t 7)
-            (set-col #t 8))))
-    (set-col (opt-val "Display" "Running Balance") 9)
+            (set-col #t 8)
+            (set-col #t 9))))
+    (set-col (opt-val "Display" "Running Balance") 10)

     col-vector))

@@ -93,6 +101,8 @@
         (addto! heading-list (_ "Num")))
     (if (description-col column-vector)
         (addto! heading-list (_ "Description")))
+    (if (split-description-col column-vector)
+        (addto! heading-list (_ "Split Description")))
     (if (account-col column-vector)
         (addto! heading-list (if multi-rows?
                                  (_ "Account")
@@ -149,6 +159,11 @@
                     (if split-info?
                         (xaccSplitGetMemo split)
                         " "))))
+    (if (split-description-col column-vector)
+        (addto! row-contents
+                (if transaction-info?
+                    (xaccSplitGetMemo split)
+                    " ")))
     (if (account-col column-vector)
         (addto! row-contents
                 (if split-info?
@@ -277,6 +292,11 @@

   (gnc:register-reg-option
    (gnc:make-simple-boolean-option
+    (N_ "Display") (N_ "Split Description")
+    "e" (N_ "Display the Split description?") #t))
+
+  (gnc:register-reg-option
+   (gnc:make-simple-boolean-option
     (N_ "Display") (N_ "Account")
     "g" (N_ "Display the account?") #t))




-- 
Robert (StocksR in the IRC channel)


More information about the gnucash-devel mailing list