r19451 - gnucash/trunk/src/app-utils - Automatically map pre-2.3.15 report option names to their new 2.3.15 equivalents.

Geert Janssens gjanssens at code.gnucash.org
Sat Aug 21 11:16:42 EDT 2010


Author: gjanssens
Date: 2010-08-21 11:16:42 -0400 (Sat, 21 Aug 2010)
New Revision: 19451
Trac: http://svn.gnucash.org/trac/changeset/19451

Modified:
   gnucash/trunk/src/app-utils/options.scm
Log:
Automatically map pre-2.3.15 report option names to their new 2.3.15 equivalents.

This will ensure that users won't lose the settings they stored in saved reports
and open report windows when switching from 2.2.x to 2.4.

Note that this only works in one direction, from 2.2.x to 2.4. If a user switches
back to 2.2.x, the open report windows will lose many settings, almost resetting
them to their default state. Saved reports won't have this problem as they are
copied to a new file during the migration.

In detail:
For open reports:
pre-2.3.15 -> 2.3.15+ : options for open reports will be migrated
2.3.15+ -> pre-2.3.15 : options for open reports will be migrated

For saved reports:
2.2.x -> 2.3.15+      : all options will be migrated, if saved-reports-2.4
                        does not yet exist
pre-2.3.15 -> 2.3.15+ : options for saved reports won't be migrated but reports
                        continue to work. It would be best to save the reports again,
                        but my scheme-fu is not good enough to let the code do that
                        automatically. Alternatively users should remove the file
                        saved-reports-2.4 to recreate it on the next run, based on
                        saved-reports-2.0.
2.3.15+ -> 2.2.x      : options are unaffected, sine 2.2.x and 2.15 use different
                        saved reports files
2.3.15+ -> pre-2.3.15 : reports saved in 2.3.15 will lose their options, older reports
                        are unaffected. But returning to 2.3.15+, the options will
                        continue to work.

Modified: gnucash/trunk/src/app-utils/options.scm
===================================================================
--- gnucash/trunk/src/app-utils/options.scm	2010-08-21 08:18:33 UTC (rev 19450)
+++ gnucash/trunk/src/app-utils/options.scm	2010-08-21 15:16:42 UTC (rev 19451)
@@ -1313,7 +1313,35 @@
   (define (lookup-option section name)
     (let ((section-hash (hash-ref option-hash section)))
       (if section-hash
-          (hash-ref section-hash name)
+          (let ((option-hash (hash-ref section-hash name)))
+            (if option-hash
+                option-hash
+                ; Option name was not found. Perhaps it was renamed ?
+                ; Let's try to map it to a known new name
+                (let* ((new-names-list (list
+                        "Accounts to include" "Accounts"
+                        "Exclude transactions between selected accounts?" "Exclude transactions between selected accounts"
+                        "Filter Accounts" "Filter By..."
+                        "Flatten list to depth limit?" "Flatten list to depth limit"
+                        "From" "Start Date"
+                        "Report Accounts" "Accounts"
+                        "Report Currency" "Report's currency"
+                        "Show Account Code?" "Show Account Code"
+                        "Show Full Account Name?" "Show Full Account Name"
+                        "Show Multi-currency Totals?" "Show Multi-currency Totals"
+                        "Show zero balance items?" "Show zero balance items"
+                        "Sign Reverses?" "Sign Reverses"
+                        "To" "End Date"
+                        "Use Full Account Name?" "Use Full Account Name"
+                        "Use Full Other Account Name?" "Use Full Other Account Name"
+                        "Void Transactions?" "Void Transactions"
+                        ))
+                       (name-match (member name new-names-list)))
+
+                      (if name-match 
+                        (let ((new-name (cadr name-match)))
+                             (lookup-option section new-name))
+                        #f))))
           #f)))
 
   (define (option-changed section name)



More information about the gnucash-changes mailing list