diff --git a/ChangeLog b/ChangeLog index 30d886571d..55a5871a45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2001-05-10 Christian Stimming + * src/scm/report/account-summary.scm, balance-sheet.scm, pnl.scm: + moved foreign currency display option to display tab. + + * src/scm/html-utilities.scm + (gnc:html-acct-table-comm-row-helper!): fixed display bug. + * src/engine/gnc-pricedb.c (gnc_pricedb_lookup_nearest_in_time): Fixed this function so that it works properly now. diff --git a/src/scm/html-utilities.scm b/src/scm/html-utilities.scm index 3047501ece..da5c875f10 100644 --- a/src/scm/html-utilities.scm +++ b/src/scm/html-utilities.scm @@ -192,83 +192,87 @@ current-depth my-name my-commodity balance reverse-balance? is-stock-account? main-row-style other-rows-style boldface? group-header-line?) - ;; Adds one row to the table. my-name is the html-object - ;; displayed in the name column; foreign-balance is the - ;; for the foreign column or #f if to be left - ;; empty; domestic-balance is the for the - ;; domestic column. - (define (commodity-row-helper! - my-name foreign-balance domestic-balance row-style) - (gnc:html-table-append-row/markup! - table - row-style - (append - ;; left third of the table - (gnc:html-make-empty-cells (- current-depth 1)) - (list (gnc:html-acct-table-cell (+ 1 (- tree-depth current-depth)) - my-name boldface?)) - ;; right two-thirds of the table - (gnc:html-make-empty-cells - (* 2 (- tree-depth (+ current-depth (if group-header-line? 1 0))))) - (if boldface? - (list - (and foreign-balance - (gnc:make-html-text (gnc:html-markup-b foreign-balance))) - (and domestic-balance - (gnc:make-html-text (gnc:html-markup-b domestic-balance)))) - (list foreign-balance domestic-balance)) - (gnc:html-make-empty-cells (* 2 (- current-depth - (if group-header-line? 0 1))))))) - - ;;;;;;;;;; - ;; the first row for each account: shows the name and the - ;; balance in the report-commodity - (if (and (not is-stock-account?) - ;; FIXME: need to check whether we really have only one - ;; foreign currency if is-stock-account==#t. - (gnc:commodity-equiv? my-commodity report-commodity)) - ;; usual case: the account balance in terms of report - ;; commodity - (commodity-row-helper! - my-name #f - (if balance - (balance 'getmonetary report-commodity reverse-balance?) - #f) - main-row-style) - ;; Special case for stock-accounts: then the foreign commodity - ;; gets displayed in this line rather then the following lines - ;; (loop below). Is also used if is-stock-account? is true. - (let ((my-balance - (if balance (balance 'getmonetary - my-commodity reverse-balance?) #f))) + (let ((already-printed #f)) + ;; Adds one row to the table. my-name is the html-object + ;; displayed in the name column; foreign-balance is the + ;; for the foreign column or #f if to be left + ;; empty; domestic-balance is the for the + ;; domestic column. + (define (commodity-row-helper! + my-name foreign-balance domestic-balance row-style) + (gnc:html-table-append-row/markup! + table + row-style + (append + ;; left third of the table + (gnc:html-make-empty-cells (- current-depth 1)) + (list (gnc:html-acct-table-cell (+ 1 (- tree-depth current-depth)) + my-name boldface?)) + ;; right two-thirds of the table + (gnc:html-make-empty-cells + (* 2 (- tree-depth (+ current-depth (if group-header-line? 1 0))))) + (if boldface? + (list + (and foreign-balance + (gnc:make-html-text (gnc:html-markup-b foreign-balance))) + (and domestic-balance + (gnc:make-html-text (gnc:html-markup-b domestic-balance)))) + (list foreign-balance domestic-balance)) + (gnc:html-make-empty-cells (* 2 (- current-depth + (if group-header-line? 0 1))))))) + + ;;;;;;;;;; + ;; the first row for each account: shows the name and the + ;; balance in the report-commodity + (if (and (not is-stock-account?) + ;; FIXME: need to check whether we really have only one + ;; foreign currency if is-stock-account==#t. + (gnc:commodity-equiv? my-commodity report-commodity)) + ;; usual case: the account balance in terms of report + ;; commodity (commodity-row-helper! - my-name - my-balance - (exchange-fn my-balance report-commodity) - main-row-style))) - - ;; The additional rows: show no name, but the foreign currency - ;; balance and its corresponding value in the - ;; report-currency. One row for each non-report-currency. - (if (and balance (not is-stock-account?)) - (balance - 'format - (lambda (curr val) - (if (gnc:commodity-equiv? curr report-commodity) - '() - (let ((bal - (if reverse-balance? - (gnc:monetary-neg (gnc:make-gnc-monetary curr val)) - (gnc:make-gnc-monetary curr val)))) - (commodity-row-helper! - ;; print no account name - (car (gnc:html-make-empty-cells 1)) - ;; print the account balance in the respective - ;; commodity - bal - (exchange-fn bal report-commodity) - other-rows-style)))) - #f))) + my-name #f + (if balance + (balance 'getmonetary report-commodity reverse-balance?) + #f) + main-row-style) + ;; Special case for stock-accounts: then the foreign commodity + ;; gets displayed in this line rather then the following lines + ;; (loop below). Is also used if is-stock-account? is true. + (let ((my-balance + (if balance (balance 'getmonetary + my-commodity reverse-balance?) #f))) + (set! already-printed my-commodity) + (commodity-row-helper! + my-name + my-balance + (exchange-fn my-balance report-commodity) + main-row-style))) + + ;; The additional rows: show no name, but the foreign currency + ;; balance and its corresponding value in the + ;; report-currency. One row for each non-report-currency. + (if (and balance (not is-stock-account?)) + (balance + 'format + (lambda (curr val) + (if (or (gnc:commodity-equiv? curr report-commodity) + (and already-printed + (gnc:commodity-equiv? curr already-printed))) + '() + (let ((bal + (if reverse-balance? + (gnc:monetary-neg (gnc:make-gnc-monetary curr val)) + (gnc:make-gnc-monetary curr val)))) + (commodity-row-helper! + ;; print no account name + (car (gnc:html-make-empty-cells 1)) + ;; print the account balance in the respective + ;; commodity + bal + (exchange-fn bal report-commodity) + other-rows-style)))) + #f)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -419,7 +423,8 @@ (gnc:html-acct-table-comm-row-helper! table tree-depth report-commodity exchange-fn current-depth my-name my-commodity balance - reverse-balance? is-stock-account? main-row-style other-rows-style boldface? group-header-line?)) + reverse-balance? is-stock-account? + main-row-style other-rows-style boldface? group-header-line?)) ;; Adds all appropriate rows to the table which belong to one ;; account. Uses the above helper function, i.e. here the @@ -447,7 +452,8 @@ ;; Generalization of add-account-rows! for a subtotal or for the ;; total balance. (define (add-subtotal-row! - current-depth subtotal-name balance row-style boldface? group-header-line?) + current-depth subtotal-name balance + row-style boldface? group-header-line?) (if show-other-curr? (add-commodity-rows! current-depth subtotal-name report-commodity diff --git a/src/scm/report/account-summary.scm b/src/scm/report/account-summary.scm index 3c7a014483..2c17eb34de 100644 --- a/src/scm/report/account-summary.scm +++ b/src/scm/report/account-summary.scm @@ -65,10 +65,9 @@ options pagename-general optname-date "a") ;; all about currencies - (gnc:options-add-currency-selection! + (gnc:options-add-currency! options pagename-general - optname-show-foreign optname-report-currency - "b") + optname-report-currency "b") ;; accounts to work on (gnc:options-add-account-selection! @@ -99,6 +98,12 @@ pagename-display optname-show-parent-total "d" (N_ "Show subtotals for parent accounts") #t)) + (gnc:register-option + options + (gnc:make-simple-boolean-option + gnc:pagename-display optname-show-foreign + "e" (N_ "Display the account's foreign currency amount?") #f)) + ;; Set the general page as default option tab (gnc:options-set-default-section options pagename-general) @@ -126,7 +131,7 @@ optname-show-parent-balance)) (show-parent-total? (get-option pagename-display optname-show-parent-total)) - (show-fcur? (get-option pagename-general optname-show-foreign)) + (show-fcur? (get-option pagename-display optname-show-foreign)) (report-currency (get-option pagename-general optname-report-currency)) (date-tp (gnc:timepair-end-day-time diff --git a/src/scm/report/balance-sheet.scm b/src/scm/report/balance-sheet.scm index 4a6064055c..9263bc60c1 100644 --- a/src/scm/report/balance-sheet.scm +++ b/src/scm/report/balance-sheet.scm @@ -77,10 +77,10 @@ optname-to-date "a") ;; all about currencies - (gnc:options-add-currency-selection! + (gnc:options-add-currency! options gnc:pagename-general - optname-show-foreign optname-report-currency - "b") + optname-report-currency "b") + (gnc:options-add-price-source! options gnc:pagename-general optname-price-source "c" 'weighted-average) @@ -110,11 +110,17 @@ gnc:pagename-display optname-show-parent-total "d" (N_ "Show subtotals for parent accounts") #f)) + (gnc:register-option + options + (gnc:make-simple-boolean-option + gnc:pagename-display optname-show-foreign + "e" (N_ "Display the account's foreign currency amount?") #f)) + (gnc:register-option options (gnc:make-simple-boolean-option gnc:pagename-display optname-show-rates - "e" (N_ "Show the exchange rates used") #f)) + "f" (N_ "Show the exchange rates used") #f)) ;; Set the general page as default option tab (gnc:options-set-default-section options gnc:pagename-general) @@ -143,7 +149,7 @@ optname-show-parent-balance)) (show-parent-total? (get-option gnc:pagename-display optname-show-parent-total)) - (show-fcur? (get-option gnc:pagename-general + (show-fcur? (get-option gnc:pagename-display optname-show-foreign)) (report-currency (get-option gnc:pagename-general optname-report-currency)) diff --git a/src/scm/report/pnl.scm b/src/scm/report/pnl.scm index 097dfca246..72732aacf2 100644 --- a/src/scm/report/pnl.scm +++ b/src/scm/report/pnl.scm @@ -57,10 +57,9 @@ optname-from-date optname-to-date "a") ;; all about currencies - (gnc:options-add-currency-selection! + (gnc:options-add-currency! options gnc:pagename-general - optname-show-foreign optname-report-currency - "b") + optname-report-currency "b") ;; accounts to work on (gnc:options-add-account-selection! @@ -90,11 +89,17 @@ gnc:pagename-display optname-show-parent-total "d" (N_ "Show subtotals for parent accounts") #t)) + (gnc:register-option + options + (gnc:make-simple-boolean-option + gnc:pagename-display optname-show-foreign + "e" (N_ "Display the account's foreign currency amount?") #f)) + (gnc:register-option options (gnc:make-simple-boolean-option gnc:pagename-display optname-show-rates - "e" (N_ "Show the exchange rates used") #t)) + "f" (N_ "Show the exchange rates used") #t)) ;; Set the general page as default option tab (gnc:options-set-default-section options gnc:pagename-general) @@ -126,7 +131,7 @@ optname-show-parent-balance)) (show-parent-total? (get-option gnc:pagename-display optname-show-parent-total)) - (show-fcur? (get-option gnc:pagename-general + (show-fcur? (get-option gnc:pagename-display optname-show-foreign)) (report-currency (get-option gnc:pagename-general optname-report-currency))