r21573 - gnucash/trunk/src/business/business-ledger - Fix subtotal sign in credit note ledger

Geert Janssens gjanssens at code.gnucash.org
Thu Nov 17 17:24:13 EST 2011


Author: gjanssens
Date: 2011-11-17 17:24:13 -0500 (Thu, 17 Nov 2011)
New Revision: 21573
Trac: http://svn.gnucash.org/trac/changeset/21573

Modified:
   gnucash/trunk/src/business/business-ledger/gncEntryLedgerModel.c
Log:
Fix subtotal sign in credit note ledger

Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedgerModel.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedgerModel.c	2011-11-17 22:24:03 UTC (rev 21572)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedgerModel.c	2011-11-17 22:24:13 UTC (rev 21573)
@@ -454,11 +454,22 @@
     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,15 +479,15 @@
             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.
+         */
+
+        if (ledger->is_credit_note)
+            value = gnc_numeric_neg (value);
     }
 
-    /* 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);
-
     return xaccPrintAmount (value, gnc_default_print_info (FALSE));
 }
 



More information about the gnucash-changes mailing list