Each quarter, I need to work out how much VAT to pay. It's a very complex calculation. I need to work out how much I've received from each EU country, and apply their particular VAT rate, and when all that's worked out, I need to visit the Irish tax website to report the numbers and pay the VAT owed.
Now that we've left the EU, do I still need to pay the EU this tax? I dn't know - I don't really understand how this ought to work.
For the UK, I need to total UK sales each day, list the VAT-registered purchases, report both numbers and pay VAT at 20% on the difference.
Obviously, I've automated this as much as I can. Each day when I do the billings, I append to a file totallog.txt what the sales are. This is done by the same routine that displays the summary totals.
Yesterday, I wasn't sure if I'd done that last part, so I had a look at totallog.txt to see if it was recorded there. What I saw was scary. What I saw was that every day, since May 3rd, the totals had been recorded twice.
I checked my program. It only recorded this once. How did it appear twice? I used Google to see if there were any clues there - no luck. I added some code to alert me if the output print was called more than once - it wasn't.
Eventually, I found the problem. I opened the totallog.txt twice, once for appending the banked amounts, once for recording the eu and non-eu numbers. But I hadn't closed the file in between doing these, so with the file twice-opened, it was being appended to twice.
This mistake would have doubled my VAT bill. I'm glad I found it before it fed into my next quarter VAT returns.