I keep finding I spend too much time dealing with sales taxes while I'm entering transactions from receipts I've kept into my ledger file/journal. I wonder how this goes for you, and if you would have some tricks to share on this. Here is an example.
Let's say I have this receipt from the hardware store:
Item A - 9.67$ +tx
Item B - 5.77$ +tx
--
Subtotal - 15.44$
Tax1 - 1.53$
Tax2 - 0.76$ ; I live in Canada, we usually have 2 sale taxes charged.
--
Total - 17.73$
Paid with Visa.
I edit my ledger file using Emacs. I can use Ledger's "xact" function to kind-of get a head-start on writing the transaction, but it my experience, I often to have to re-edit a bunch of things. The irritating part is the sales taxes. Basically, the transaction I would enter would look like something like this:
2024/12/01 Hardware Store
liability:visa -17.73
spending:projectA ? ; I want to put Item A on the receipt under "projectA"
spending:other ? ; This is where Item B goes.
In order to find the right amount for each posting, I have to calculate how much taxes to add for Item A, and Item B. In Emacs, I use "Calc" mode, but I still find this quite tedious. And often, because of rounding, I will be 1 or 2 cents off, so the transaction won't balance. I have "Flymake" in Emacs that tells me automatically that the transaction doesn't balance, but it doesn't tell me in what ways. I have to launch a report just to get the full error message, so I will know if I have to add or subtract 1 cent somewhere.
Do you have this kind of situation? Do you have tricks to make this quicker?
I have it eg with long supermarket receipts. My trick is guess/approximate. Eg I might first write down the postings with exact pre-tax amounts, then mentally distribute the tax amount among just the biggest postings, increasing their amounts to make the transaction balance. (I too use flycheck/flymake, and it's handy to see the live updating imbalance amount.)
I wrote some Elisp code to make this easier. It works with Ledger mode. If you set the following function to a key binding, for example C-c C-x in ledger-mode-map, and type this while your cursor is over or next to an amount in your ledger, it will replace the amount with the same amount with sales tax added. You have to put your own tax amount in my/ledger-sales-tax.
(defvar my/ledger-sales-tax 0.12
"The sales tax, as a decimal number. Eg: 12% => 0.12")
(defun my/ledger-add-tax-to-amount-at-point ()
"Add sales tax to the amount at point.
The tax amount has to be defined in `my/ledger-sales-tax'."
(interactive)
(beginning-of-line)
(when (re-search-forward ledger-post-line-regexp (line-end-position) t)
(goto-char (match-end ledger-regex-post-line-group-account))
(if (re-search-forward ledger-amount-regexp (line-end-position) t)
(let* ((old-amount (string-to-number (match-string 0)))
(tax (+ 1 my/ledger-sales-tax))
(amount-with-tax (/ (ftruncate (* old-amount tax 100)) 100))
(old-amount (format "%.2f" old-amount))
(amount-with-tax (format "%.2f" amount-with-tax)))
(goto-char (match-beginning 0))
(delete-region (match-beginning 0) (match-end 0))
(insert amount-with-tax " ; " old-amount "+tx")))))
It works for me, but note that I don't use thousands separators, I don't write any currency sign, and my decimal sign is a ".", not a comma. It might not work well in those other cases... Otherwise, I think it is a great improvement.