From 1357c9e73762484bd8383035a41d505481d22d04 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Thu, 17 Nov 2011 22:24:13 +0000 Subject: [PATCH] Fix subtotal sign in credit note ledger git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21573 57a11ea4-9604-0410-9ed3-97b8803252fd --- .../business-ledger/gncEntryLedgerModel.c | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/business/business-ledger/gncEntryLedgerModel.c b/src/business/business-ledger/gncEntryLedgerModel.c index 5f02676bd7..cca89cb320 100644 --- a/src/business/business-ledger/gncEntryLedgerModel.c +++ b/src/business/business-ledger/gncEntryLedgerModel.c @@ -454,11 +454,22 @@ static const char * get_value_entry (VirtualLocation virt_loc, GncEntryLedger *ledger = user_data; gnc_numeric value; + /* Credit notes need some attention here: the ledger displays values + * as on the document, meaning positive for credit notes. Credit note + * values are negative internally though. So depending on which values + * are used to calculate the subtotal, the resulting subtotal has to be + * sign-reversed before displaying. + */ /* Check if this is the current cursor */ if (virt_cell_loc_equal (ledger->table->current_cursor_loc.vcell_loc, virt_loc.vcell_loc)) { gnc_entry_ledger_compute_value (ledger, &value, NULL); + /* Credit note info: this function works with values as seen + * on-screen in the ledger, so they are always in the proper sign. + * As per the above no sign reversal is needed for + * credit note type ledgers. + */ } else { @@ -468,14 +479,14 @@ static const char * get_value_entry (VirtualLocation virt_loc, return NULL; value = gncEntryReturnValue (entry, ledger->is_cust_doc); - } + /* Credit note info: this function works with internal values, + * so they are negative for credit note type ledgers and have to + * be sign-reversed as per the above. + */ - /* Credit notes have negative values, but the ledger should - * display it as on the document, meaning positive. - * So reverse the value for credit notes. - */ - if (ledger->is_credit_note) - value = gnc_numeric_neg (value); + if (ledger->is_credit_note) + value = gnc_numeric_neg (value); + } return xaccPrintAmount (value, gnc_default_print_info (FALSE)); }