Fix subtotal sign in credit note ledger

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21573 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens 2011-11-17 22:24:13 +00:00
parent 0313539a88
commit 1357c9e737

View File

@ -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));
}