[GNC-dev] Auto-incrementing global transaction numbers

John Ralls jralls at ceridwen.us
Sat Aug 28 13:14:38 EDT 2021



> On Aug 28, 2021, at 5:10 AM, Thomas A <thomasa88 at gmail.com> wrote:
> 
> Hi,
> 
> I just started using Gnucash. It works very good!
> 
> I need to write a unique number (or ID) on all my receipts, bank
> statements, etc. that correspond to a transaction in Gnucash. I found that
> I can use the "Num" field in the ledgers for this and also that there is a
> shortcut ("+") for incrementing the number. However, the number has a
> counter for each account, whereas I need a globally unique number for the
> whole book.
> 
> I googled a bit, but did not find any recent discussions on a global
> automatic number increment for transactions, so I took a stab at the code:
> https://github.com/thomasa88/gnucash/commits/transaction-counter
> 
> The change adds a counter to File -> Properties -> Counters, called
> Transaction number. Every time a transaction with an empty number is saved,
> the counter value is filled in into the number field.
> 
> Before I do anything more, Is there interest for adding this feature? Is my
> solution orthogonal to the Gnucash code architecture?
> 
> I think the choice of ID might have to be changed (I used GNC_ID_TRANS for
> the counter) and maybe the code is in the wrong place. It works very well
> when using the ledger though :).
> 
> Things to add: unit test?, doc, enable/disable setting? more?
> Future: Error on non-unique value.

It's not the intended purpose of transaction numbers; that was paper checks, an increasingly rare instrument. A lot of people would find that irritating so it should indeed have an enable button next to the field in settings.

There's another option that I think is mutually exclusive to this proposal: Switch num and action. That uses the current account's split action field for the number so that a transaction can have different numbers in different accounts, perhaps the check number in the bank account and the invoice number in the expense account. You'll need to prevent both options being enabled.

GNC_ID_TRANS is already in use for something very different indeed. You'll need to invent a different identifier.

Unit tests are always good, and yes, it needs to be documented in help, including a new screenshot.

Regards,
John Ralls





More information about the gnucash-devel mailing list