[GNC] Transaction Report Sign Reverses

Christopher Lam christopher.lck at gmail.com
Tue Aug 13 01:12:46 EDT 2019


Maybe I'm being thick here, but it's still not easy. We need to start with
the knowledge that *internally* income amounts are negative -- after all
they usually balance with positive asset amounts. Also, liability amounts
are also internally negative, but no one seems to have a problem with that.

Second, the Transaction Report historically needs to handle multiple types
of grouping and sorting -- not only account-name, but also
other-account-name. Running a TR with sort=other-account-name may not be
that common, but is still supported.

Third, we can select both income and expense accounts for reporting. If
during a period I earn $100 and spend $80, I expect the grand total to be
$20 (or -$20) rather than $180. Conversely if we select both asset and
liability accounts, we'd expect the grand-total to be a net-worth-type
amount.

The TR internally will:
1) get all splits from all specified accounts
2) sort them accordingly - typically stable-sort by account-name (or
other-account-name) and date.
3) keep a tally of subtotals, adding split-amounts which are currently
negative for income amounts.
4) add split details onto table. When the sort-criteria (e.g. account-name)
changes between rows, render the subtotals.

How to design a subtotal strategy that handles all possibilities as above?
Do we want the *split* amounts to be negative for expenses and liability? I
don't know. A better strategy can be used as along as it can handle all gnc
peculiarities as above. I would hope that the TR can produce a useful
output, with subtotals & grand-totals which are consistent irrespective of
the global sign-reversing strategy.

Anyone wishing to try the old strategy, can patch trep-engine.scm as
follows:
        (map (lambda (cell)
               (let ((cell-monetary (vector-ref cell 0))
+                    (reverse? (and (vector-ref cell 1)
reversible-account?))
                     (subtotal? (vector-ref cell 2)))
-                (and subtotal? cell-monetary)))
+                (and subtotal?
+                     (if reverse?
+                         (gnc:monetary-neg cell-monetary)
+                         cell-monetary))))
             cells)))


On Tue., 13 Aug. 2019, 04:01 Adrien Monteleone, <
adrien.monteleone at lusfiber.net> wrote:

> I agree, the FAQ example is incorrect. It doesn’t reverse the sign of
> Business:Expenses when it should.
>
> Even if that were a contra-income account, it would still normally have a
> debit balance (+) and get reversed.
>
> The same goes for using the ‘Credit Accounts’ setting.
>
> 1) Assets = Liabilities + Equity + Retained Earnings/Loss
> textbook
>
> 2) Assets = Liabilities + Equity + (Income - Expenses)
> expand Retained Earnings/Loss
>
> 3) Assets - Liabilities - Equity - (Income - Expenses) = 0
> Move everything to the left side
>
> 4) Assets - Liabilities - Equity - Income + Expenses = 0
> distribute the operation on Income and Expenses
>
> 5) Assets + (-Liabilities) + (-Equity) + (-Income) + Expenses = 0
> changing all operations to (+)
>
> Sign reversal should be for *display* not for calculations. It should
> happen *after* the calculation is done.
>
> Sign reversal is only necessary because the formula used puts everything
> on one side equal to zero and then sets all operations to addition. If the
> formula was changed to the textbook version, all accounts (except expenses
> and contra-accounts) are positive. (or technically, *all* accounts are
> positive, but some operations are subtraction)
>
> Note that in the last equation above (5), Liabilities, Equity and Income
> are NOT negative numbers, that is, you are not reading a double negative.
> Distributing the negative sign when moving all terms to the left IS the
> reversal for the zero balanced version of the equation. Reversing the signs
> again is effectively moving them back to the right, you don’t reverse the
> signs again and then still use the zero balanced equation leaving the
> reversed terms on the left.
>
> Applying the FAQ example:
>
> Assets = $90
> Liabilities = 0
> Equity = 0
> Income = $110
> Expenses = $20
>
> 2) $90 = 0 + 0 + ($110 - $20)
>
> 3) $90 - 0 - 0 - ($110 - $20) = 0
>
> 4) $90 - 0 - 0 - $110 + $20 = 0
>
> 5) $90 + (0) + (0) + (-$110) + $20 = 0
>
> What you can’t do is this:
>
> 6) $90 + (0) + (0) + $110 - $20 ≠ 0 (it equals $180)
> reversing Income/Expense or all Credit accounts
>
> By reversing the signs *again* (on just Credit accounts or just
> Income/Expense) after moving everything to the left and *then* doing the
> calculation is what results in the inequality.
>
> The current report has a bug.
>
> (and from the question posed by the FAQ, what is the sense in running a
> transaction report on your entire book anyway? What might you expect to
> glean from that?)
>
> Regards,
> Adrien
>
>
> > On Aug 12, 2019, at 3:45 AM, David T. via gnucash-user <
> gnucash-user at gnucash.org> wrote:
> >
> > Well, it seems odd to me that "Double" display (as Adrien noted)(thank
> you, Adrien!) is able to display the figures as the user prefers. It is
> also odd to me that the report knows to switch the values of the individual
> transactions, but is unable to remember that fact when it comes to the
> totals. That right there is the problem.
> >
> > As for the FAQ, it seems to me that there is a mistake in the example
> there: the GnuCash option is to change signs for Income *and* Expenses. But
> the example provided reverses Income but not Expenses. Were it to reverse
> both sets of accounts as the preference indicates, then the math should
> work out correctly ($100+10-20=$90). Or am I missing something here?
> >
> > Why is it not possible to perform the calculation for totals and then
> apply a display modifier so that the user sees numbers as they prefer?
> >
> > The current solution is a poor one.
>
>
> _______________________________________________
> gnucash-user mailing list
> gnucash-user at gnucash.org
> To update your subscription preferences or to unsubscribe:
> https://lists.gnucash.org/mailman/listinfo/gnucash-user
> If you are using Nabble or Gmane, please see
> https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
> -----
> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.
>


More information about the gnucash-user mailing list