Re: [GNC-dev] How do I get the "sign" (or side) of the transaction from the account or transaction element in xml?

2021-07-11 Thread John Ralls



> On Jul 11, 2021, at 4:50 AM, Geert Janssens  
> wrote:
> 
> Op zondag 11 juli 2021 13:38:43 CEST schreef Arman Schwarz:
>> Thanks Geert,
>> 
>> I'm aware of the need to think in terms of debit/credit signs, but my
>> question was how I could know whether a positive value in the split element
>> in the XML will increase or decrease the "balance" that the user sees in
>> gnucash.
>> 
>> This depends on the side of the accounting equation the account is on, e.g.
>> positive split values increase the balance of an asset account, but
>> decrease the balance of an income account. Rather than manually maintaining
>> a mapping of account types and whether the sign is positive or negative, I
>> was hoping there'd be something in the XML or perhaps in those bindings you
>> mentioned that would do this for me.
>> 
> 
> I don't think this is stored in the xml file as the net representation in the 
> gui is a combination of account type and the user preference. The former is 
> hard-coded, the latter can be changed by the user. I don't know if we can 
> access either information via the python bindings. I don't use them myself.

Using only the XML file you can connect the split with its account via the 
account's guid. The account record of course carries the account type.

As  Geert explained GnuCash uses negative numbers to represent credits. This is 
computationally very convenient because it means that internally GnuCash 
doesn't need to distinguish debit-balance and credit-balance accounts: As long 
as the sum of all non-trading account balances is 0 the book is in balance.

For the UI it's user-choice based on the Preferences>Accounts>Reversed Balance 
with choices income/expense, credit, and none. There's a function, 
gnc_reverse_balance(Account*), that looks up the preference and the account 
type. It's not exposed to the python bindings, but the logic is simple and you 
could replicate it pretty easily. The relevant code starts at 
https://github.com/Gnucash/gnucash/blob/e1c153a516f0689b04efff7191639ad604a6b6b6/libgnucash/app-utils/gnc-ui-util.c#L129.

That said only the credit preference produces a UI and reports that would make 
sense to an accountant so were I in your place I'd ignore the preference and 
write a simple function to test the account type against a list of the 5 
credit-balance types (EQUIT, INCOME, LIABILITY, CREDIT, and PAYABLE).

Regards,
John Ralls

___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: [GNC-dev] How do I get the "sign" (or side) of the transaction from the account or transaction element in xml?

2021-07-11 Thread D. via gnucash-devel
I'm not sure I follow your issue, but I'll note that the list of types of 
accounts in GnuCash is outlined in the Help docs in Chapter 5 at 
https://code.gnucash.org/docs/C/gnucash-help/acct-types.html

There are 13 types listed there. 


 Original Message 
From: Arman Schwarz 
Sent: Sun Jul 11 08:03:51 EDT 2021
To: Geert Janssens 
Cc: gnucash-devel@gnucash.org
Subject: Re: [GNC-dev] How do I get the "sign" (or side) of the transaction 
from the account or transaction element in xml?

Ok I'll take a look myself, thanks for pointing me in the right direction.

On Sun, 11 Jul 2021, 9:50 pm Geert Janssens, 
wrote:

> Op zondag 11 juli 2021 13:38:43 CEST schreef Arman Schwarz:
> > Thanks Geert,
> >
> > I'm aware of the need to think in terms of debit/credit signs, but my
> > question was how I could know whether a positive value in the split
> element
> > in the XML will increase or decrease the "balance" that the user sees in
> > gnucash.
> >
> > This depends on the side of the accounting equation the account is on,
> e.g.
> > positive split values increase the balance of an asset account, but
> > decrease the balance of an income account. Rather than manually
> maintaining
> > a mapping of account types and whether the sign is positive or negative,
> I
> > was hoping there'd be something in the XML or perhaps in those bindings
> you
> > mentioned that would do this for me.
> >
>
> I don't think this is stored in the xml file as the net representation in
> the
> gui is a combination of account type and the user preference. The former
> is
> hard-coded, the latter can be changed by the user. I don't know if we can
> access either information via the python bindings. I don't use them myself.
>
> Regards,
>
> Geert
>
>
>
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: [GNC-dev] How do I get the "sign" (or side) of the transaction from the account or transaction element in xml?

2021-07-11 Thread Arman Schwarz
Ok I'll take a look myself, thanks for pointing me in the right direction.

On Sun, 11 Jul 2021, 9:50 pm Geert Janssens, 
wrote:

> Op zondag 11 juli 2021 13:38:43 CEST schreef Arman Schwarz:
> > Thanks Geert,
> >
> > I'm aware of the need to think in terms of debit/credit signs, but my
> > question was how I could know whether a positive value in the split
> element
> > in the XML will increase or decrease the "balance" that the user sees in
> > gnucash.
> >
> > This depends on the side of the accounting equation the account is on,
> e.g.
> > positive split values increase the balance of an asset account, but
> > decrease the balance of an income account. Rather than manually
> maintaining
> > a mapping of account types and whether the sign is positive or negative,
> I
> > was hoping there'd be something in the XML or perhaps in those bindings
> you
> > mentioned that would do this for me.
> >
>
> I don't think this is stored in the xml file as the net representation in
> the
> gui is a combination of account type and the user preference. The former
> is
> hard-coded, the latter can be changed by the user. I don't know if we can
> access either information via the python bindings. I don't use them myself.
>
> Regards,
>
> Geert
>
>
>
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: [GNC-dev] How do I get the "sign" (or side) of the transaction from the account or transaction element in xml?

2021-07-11 Thread Geert Janssens
Op zondag 11 juli 2021 13:38:43 CEST schreef Arman Schwarz:
> Thanks Geert,
> 
> I'm aware of the need to think in terms of debit/credit signs, but my
> question was how I could know whether a positive value in the split element
> in the XML will increase or decrease the "balance" that the user sees in
> gnucash.
> 
> This depends on the side of the accounting equation the account is on, e.g.
> positive split values increase the balance of an asset account, but
> decrease the balance of an income account. Rather than manually maintaining
> a mapping of account types and whether the sign is positive or negative, I
> was hoping there'd be something in the XML or perhaps in those bindings you
> mentioned that would do this for me.
> 

I don't think this is stored in the xml file as the net representation in the 
gui is a combination of account type and the user preference. The former is 
hard-coded, the latter can be changed by the user. I don't know if we can 
access either information via the python bindings. I don't use them myself.

Regards,

Geert


___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: [GNC-dev] How do I get the "sign" (or side) of the transaction from the account or transaction element in xml?

2021-07-11 Thread Arman Schwarz
Thanks Geert,

I'm aware of the need to think in terms of debit/credit signs, but my
question was how I could know whether a positive value in the split element
in the XML will increase or decrease the "balance" that the user sees in
gnucash.

This depends on the side of the accounting equation the account is on, e.g.
positive split values increase the balance of an asset account, but
decrease the balance of an income account. Rather than manually maintaining
a mapping of account types and whether the sign is positive or negative, I
was hoping there'd be something in the XML or perhaps in those bindings you
mentioned that would do this for me.

By the way those python bindings are a good suggestion anyway, I'll check
them out.

On Sun, 11 Jul 2021, 9:32 pm Geert Janssens, 
wrote:

> Op zondag 11 juli 2021 10:36:40 CEST schreef Arman Schwarz:
> > Hi Frank, I'm not sure how this helps. Are you suggesting that I should
> > change the way the GUI renders the balances? I had hoped to instead just
> > find a way to programmatically know the sign of the balance from looking
> at
> > the XML. If that makes sense.
> >
> Alas, that doesn't make sense in a few ways.
>
> Firstly transactions don't have balances in gnucash, but I guess you mean
> splits. Those have positive or negative quantities and values. Positive
> values
> represent debits, negative ones are credits.
>
> Secondly, if you want to manipulate data directly (which voids your
> waranty by
> the way ;-), you have to think in terms of those credit and debit signs,
> because that's how the data internally is signed. The way it's represented
> in
> the GUI is a matter of taste and influenced by the preferences Frank
> already
> pointed you at.
>
> Our tutorial and concepts guide should give you some information on how
> the
> accounting equation works, which is the basis for the double accounting
> gnucash is implementing. Perhaps that gives you some more insight.
>
> Regards,
>
> Geert
>
> PS
> I quickly looked at your code and notice you have chosen to parse the xml
> data
> file directly outside of gnucash. While you are certainly free to do so,
> do
> know that gnucash development will ignore that completely and you may end
> up
> with unexpected data format changes at random releases (hence the "voided
> warranty" claim earlier on).
> We also provide python bindings. Perhaps those can do what you need as
> well ?
>
>
>
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: [GNC-dev] How do I get the "sign" (or side) of the transaction from the account or transaction element in xml?

2021-07-11 Thread Geert Janssens
Op zondag 11 juli 2021 10:36:40 CEST schreef Arman Schwarz:
> Hi Frank, I'm not sure how this helps. Are you suggesting that I should
> change the way the GUI renders the balances? I had hoped to instead just
> find a way to programmatically know the sign of the balance from looking at
> the XML. If that makes sense.
> 
Alas, that doesn't make sense in a few ways.

Firstly transactions don't have balances in gnucash, but I guess you mean 
splits. Those have positive or negative quantities and values. Positive values 
represent debits, negative ones are credits.

Secondly, if you want to manipulate data directly (which voids your waranty by 
the way ;-), you have to think in terms of those credit and debit signs,  
because that's how the data internally is signed. The way it's represented in 
the GUI is a matter of taste and influenced by the preferences Frank already 
pointed you at.

Our tutorial and concepts guide should give you some information on how the 
accounting equation works, which is the basis for the double accounting 
gnucash is implementing. Perhaps that gives you some more insight.

Regards,

Geert

PS
I quickly looked at your code and notice you have chosen to parse the xml data 
file directly outside of gnucash. While you are certainly free to do so, do 
know that gnucash development will ignore that completely and you may end  up 
with unexpected data format changes at random releases (hence the "voided 
warranty" claim earlier on).
We also provide python bindings. Perhaps those can do what you need as well ?


___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: [GNC-dev] How do I get the "sign" (or side) of the transaction from the account or transaction element in xml?

2021-07-11 Thread Arman Schwarz
Hi Frank, I'm not sure how this helps. Are you suggesting that I should
change the way the GUI renders the balances? I had hoped to instead just
find a way to programmatically know the sign of the balance from looking at
the XML. If that makes sense.

On Sun, 11 Jul 2021 at 14:33, Frank H. Ellenberger <
frank.h.ellenber...@gmail.com> wrote:

> Hi,
>
> see
> https://code.gnucash.org/docs/C/gnucash-help/set-prefs.html#prefs-accounts
> and
> https://wiki.gnucash.org/wiki/Configuration_Locations#GSettings
>
> HTH
> FrRank
>
> Am 11.07.21 um 03:00 schrieb Arman Schwarz:
> > Hi,
> >
> > I probably didn't use the right terminology in the title. I've
> implemented
> > balance assertions for gnucash myself since I couldn't find that feature
> in
> > gnucash (https://github.com/armanschwarz/gnc_tools). This allows me to
> put
> > expected balances into the ledger and ensure that they remain that way
> even
> > if I make changes later on.
> >
> > This works fine except for the fact that I have to put my assertions in
> as
> > negative numbers, e.g. if they're in a liability account. This makes
> sense
> > from an accounting equation perspective but it's counterintuitive to see
> a
> > negative balance assertion in the ledger against a positive "balance"
> > (since gnucash GUI shows a liability as a "balance" while the sum of the
> > transaction values in the XML file will be negative).
> >
> > It would be helpful if I could somehow look in the transaction element in
> > XML and figure out whether the "balance" value should be multitplied by 1
> > or -1 before comparing it with the sum of the individual transactions.
> >
> > Looking at the XML file though, I didn't see any values that would tell
> me
> > this. I could construct a dictionary of "act:type" to "sign", but then
> I'd
> > have to manually maintain a possibly large dictionary. That's not the end
> > of the world, but if that's the solution, is there an exhaustive list of
> > account types and their sign that I could get access to?
> > ___
> > gnucash-devel mailing list
> > gnucash-devel@gnucash.org
> > https://lists.gnucash.org/mailman/listinfo/gnucash-devel
> >
>
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel