Automatic VAT postings

31 views
Skip to first unread message

Allan Odgaard

unread,
Jun 11, 2021, 12:52:40 PMJun 11
to hledger
I have a bank account for my business and convert the statement (CSV) to ledger items on a periodic basis.

Some bank entries include VAT, which I can reclaim, so if I have an entry like this:

2021-01-01 T-Mobile: January 2021
    Expenses:Phone
    Assets:Bank -100

I need to add a VAT line like this (25% VAT):

2021-01-01 T-Mobile: January 2021
    Expenses:Phone
    Assets:AR:VAT    20
    Assets:Bank    -100

I don’t mind adding the extra row, but I dislike having to calculate the VAT amount and put in an absolute amount (source of error).

I can tag the VAT entries like this:

2021-01-01 T-Mobile: January 2021
    Expenses:Phone
    Assets:Bank     -100; VAT25:

And ideally I would make a rule like this:

= tag:VAT25
    Assets:AR:VAT  *-0.20

Unfortunately though, the posting has to balance before and after the automatic postings are generated, so the above will give me an error. Instead I have to add an account to my rule, but I don’t know which expense account the rule is applied to, so I end up with:

= tag:VAT25
    Expenses:VAT
    Assets:AR:VAT  *-0.20

But this means that my phone expenses etc. will include VAT, and all VAT expenses are aggregated on the Expenses:VAT account.

I wonder, have anyone found a good solution for this problem?

It seems a solution could either be to allow referencing involved accounts in the rule (which I believe ledger-cli does), or to change the balance requirement, so that this is not enforced until after the generated postings have been added.

Caleb Maclennan

unread,
Jun 16, 2021, 4:56:58 PMJun 16
to hledger
My solution would be to pre-process the CSV file (probably using something from CSVKit) to break out the VAT from the total before converting it to a posting. Then the rules that convert it just have to bring in the static amounts and everything is filed in the right account from the outset without needing any tags or post-processing to shuffle everything around.

Would something like that work in your scenario?

Allan Odgaard

unread,
Jun 21, 2021, 4:43:57 AMJun 21
to hledger
Only a subset of items (from the CSV) contain VAT, and there is a difference between VAT paid (asset) and VAT charged (liability).

Furthermore, transactions that involve VAT should just get an extra posting (split transaction), which is not something I think the existing CSV importers can do.

So converting the CSV to ledger format and then tagging transactions seems to be the simplest approach.

What I could do is run `hledger print --auto` (after tagging postings) and then remove one of the two postings that was generated by my rule, but then it would probably be simpler to use a text editor macro to calculate the VAT and insert the appropriate posting.

What I would like to see is for hledger to not require that the rule’s postings balance on their own, when it is applied to a transaction where one of the postings does not have an explicit amount.

This should make rules more useful without breaking backwards compatibility, and maybe I am missing something, but it should be possible to still ensure that rules do not cause transactions to become unbalanced.

Simon Michael

unread,
Jun 21, 2021, 3:36:21 PMJun 21
to hledger
Brief comment: I do understand your desire to change the sequence of balanced-transaction checking and auto posting generation, and, I think we have done it different ways in the past; some archaeology in the relevant code's history, or the issue tracker, would probably find it and maybe some of the reasons for the current setup.


-- 
You received this message because you are subscribed to the Google Groups "hledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hledger+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hledger/2093b1c2-9bc9-44f8-a4f2-4147051ec261n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages