gnucash maint: Multiple changes pushed

Mike Alexander mta at code.gnucash.org
Sun Jan 18 23:36:21 EST 2015


Updated	 via  https://github.com/Gnucash/gnucash/commit/79ad3909 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/67edea72 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/13abe849 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/80d65c8e (commit)
	from  https://github.com/Gnucash/gnucash/commit/d9900a7b (commit)



commit 79ad39095c95b3785d703d59542586337ea32eec
Author: Mike Alexander <mta at umich.edu>
Date:   Mon Nov 24 01:50:08 2014 -0500

    book.not_saved should be book.session_not_saved

diff --git a/src/optional/python-bindings/example_scripts/simple_book.py b/src/optional/python-bindings/example_scripts/simple_book.py
index 668a32a..bbc3354 100644
--- a/src/optional/python-bindings/example_scripts/simple_book.py
+++ b/src/optional/python-bindings/example_scripts/simple_book.py
@@ -16,10 +16,10 @@ book = ses.get_book()
 
 #Call some methods that produce output to show that Book works
 book.get_root_account().SetDescription("hello, book")
-print "Book is saved:", not book.not_saved()
+print "Book is saved:", not book.session_not_saved()
 
 print "saving..."
 ses.save()
 
-print "Book is saved:", not book.not_saved()
+print "Book is saved:", not book.session_not_saved()
 ses.end()

commit 67edea72ca69ab5a3e448eb564cdee33928df09e
Author: Mike Alexander <mta at umich.edu>
Date:   Sun Jan 18 18:44:02 2015 -0500

    Bug 739228 -  Advanced Portfolio report: wrong calculation of Value
    Correctly convert the value into the report's currency.

diff --git a/src/report/standard-reports/advanced-portfolio.scm b/src/report/standard-reports/advanced-portfolio.scm
index b1fb320..7f15c03 100644
--- a/src/report/standard-reports/advanced-portfolio.scm
+++ b/src/report/standard-reports/advanced-portfolio.scm
@@ -441,12 +441,22 @@
             (define (my-exchange-fn fromunits tocurrency)
               (if (and (gnc-commodity-equiv currency tocurrency)
                        (gnc-commodity-equiv (gnc:gnc-monetary-commodity fromunits) commodity))
-                    (gnc:make-gnc-monetary tocurrency
-                      (gnc-numeric-mul (gnc:gnc-monetary-amount fromunits)
-                                       (if use-txn
-                                           (gnc:gnc-monetary-amount price)
-                                           (gnc-price-get-value price))
-                                       currency-frac GNC-RND-ROUND))
+                    ;; Have a price for this commodity, but not necessarily in the report's
+                    ;; currency.  Get the value in the commodity's currency and convert it to
+                    ;; report currency.
+                    (exchange-fn
+                      ;; This currency will usually be the same as tocurrency so the
+                      ;; call to exchange-fn below will do nothing
+                      (gnc:make-gnc-monetary 
+                        (if use-txn
+                            (gnc:gnc-monetary-commodity price)
+                            (gnc-price-get-currency price))
+                        (gnc-numeric-mul (gnc:gnc-monetary-amount fromunits)
+                                         (if use-txn
+                                             (gnc:gnc-monetary-amount price)
+                                             (gnc-price-get-value price))
+                                         currency-frac GNC-RND-ROUND))
+                      tocurrency)
                     (exchange-fn fromunits tocurrency)))
             
             (gnc:debug "Starting account " (xaccAccountGetName current) ", initial price: " 

commit 13abe849e5ed1551108d157f09c01bd5d86f6503
Author: Mike Alexander <mta at umich.edu>
Date:   Sun Jan 18 18:17:05 2015 -0500

    Improve income and expense reporting in advanced portfolio report
    
    Look for transactions from the parent account to an income or expense
    account whose name matches the name of the stock account.

diff --git a/src/report/standard-reports/advanced-portfolio.scm b/src/report/standard-reports/advanced-portfolio.scm
index 57db443..b1fb320 100644
--- a/src/report/standard-reports/advanced-portfolio.scm
+++ b/src/report/standard-reports/advanced-portfolio.scm
@@ -780,6 +780,65 @@
 	       )
 	     (xaccAccountGetSplitList current)
 	     )
+	     
+	    ;; Look for income and expense transactions that don't have a split in the
+	    ;; the account we're processing.  We do this as follow
+	    ;; 1. Make sure the parent account is a currency-valued asset or bank account
+	    ;; 2. If so go through all the splits in that account
+	    ;; 3. If a split is part of a two split transaction where the other split is
+	    ;;    to an income or expense account and the leaf name of that account is the 
+	    ;;    same as the leaf name of the account we're processing, add it to the
+	    ;;    income or expense accumulator
+	    ;;
+	    ;; In other words with an account structure like
+	    ;;
+	    ;;   Assets (type ASSET)
+	    ;;     Broker (type ASSET)
+	    ;;       Widget Stock (type STOCK)
+	    ;;   Income (type INCOME)
+	    ;;     Dividends (type INCOME)
+	    ;;       Widget Stock (type INCOME)
+	    ;;
+	    ;; If you are producing a report on "Assets:Broker:Widget Stock" a 
+	    ;; transaction that debits the Assets:Broker account and credits the 
+	    ;; "Income:Dividends:Widget Stock" account will count as income in 
+	    ;; the report even though it doesn't have a split in the account 
+	    ;; being reported on.
+	    
+	    (let ((parent-account (gnc-account-get-parent current))
+	          (account-name (xaccAccountGetName current)))
+	      (if (and (not (null? parent-account))
+	               (member (xaccAccountGetType parent-account) (list ACCT-TYPE-ASSET ACCT-TYPE-BANK)) 
+	               (gnc-commodity-is-currency (xaccAccountGetCommodity parent-account)))
+	        (for-each
+	          (lambda (split)
+	            (let* ((other-split (xaccSplitGetOtherSplit split)) 
+	                   ;; This is safe because xaccSplitGetAccount returns null for a null split
+	                   (other-acct (xaccSplitGetAccount other-split)))
+	              (if (and (not (null? other-acct))
+	                       (string=? (xaccAccountGetName other-acct) account-name)
+	                       (gnc-commodity-is-currency (xaccAccountGetCommodity other-acct)))
+	                ;; This is a two split transaction where the other split is to an 
+	                ;; account with the same name as the current account.  If it's an
+	                ;; income or expense account accumulate the value of the transaction
+	                (let ((val (xaccSplitGetValue split))
+	                      (curr (xaccAccountGetCommodity other-acct)))
+                          (cond ((split-account-type? other-split ACCT-TYPE-INCOME)
+	                         (gnc:debug "More income " (gnc-numeric-to-string val))
+	                         (dividendcoll 'add curr val))
+                                ((split-account-type? other-split ACCT-TYPE-EXPENSE)
+                                 (gnc:debug "More expense " (gnc-numeric-to-string 
+                                                             (gnc-numeric-neg val)))
+                                 (brokeragecoll 'add curr (gnc-numeric-neg val)))
+	                  ) 
+	                ) 
+	              )
+	            )  
+	          )
+	          (xaccAccountGetSplitList parent-account)
+	        )
+	      )
+	    )
 
 	    (gnc:debug "pricing txn is " pricing-txn)
 	    (gnc:debug "use txn is " use-txn)

commit 80d65c8efc385d76eeb7d7f0f999d07740dfcf08
Author: Mike Alexander <mta at umich.edu>
Date:   Sun Nov 23 23:28:26 2014 -0500

    Accept prices of the form n.nnne[+-]nn, i.e. with an exponent.
    An example requiring this is currency conversion from IDR to USD.

diff --git a/src/quotes/gnc-fq-helper.in b/src/quotes/gnc-fq-helper.in
index 13dfb3b..eb7862e 100644
--- a/src/quotes/gnc-fq-helper.in
+++ b/src/quotes/gnc-fq-helper.in
@@ -187,7 +187,7 @@ sub schemify_num {
 
   if(!$numstr) { return "failed-conversion"; }
 
-  if($numstr =~ /^\s*(\d+(\.\d+)?)$/o) {
+  if($numstr =~ /^\s*(\d+(\.\d+)?([eE][+-]?\d+)?)$/o) {
     return $1;
   } else {
     return "failed-conversion";



Summary of changes:
 .../python-bindings/example_scripts/simple_book.py |  4 +-
 src/quotes/gnc-fq-helper.in                        |  2 +-
 src/report/standard-reports/advanced-portfolio.scm | 81 ++++++++++++++++++++--
 3 files changed, 78 insertions(+), 9 deletions(-)



More information about the gnucash-changes mailing list