Hi, folks. I'm delving into preparing EU VAT returns using hledger and I've run into a defect. Please suggest how to handle this situation.
Summary: When I use the "print" command to extract EU VAT-related transactions from the journal _and_ convert values to EUR _then_ it's possible for the resulting transaction to be unbalanced due to a rounding error.
For now, I'm hand-editing the extracted journal in order to remove the offending amount and let the transaction balance itself; however, I'd like to avoid human intervention _and_ I'd prefer to solve this problem with hledger and not rely on brute-force regex matching, since the latter will tend to be more brittle.
For my purposes, it really only matters to be able to calculate the total Sales in EUR of all the transactions that have a non-zero EU VAT amount. I know that I can do that in a variety of ways, but perhaps the wisdom of the crowd can work in my favor here. :)
Any suggestion is welcome. Thank you.
@jbrains
---- begin sample ledger -----
D 1,000,000,000.00 CAD
commodity 1,000,000,000.00 CAD
commodity 1,000,000,000.00 EUR
P 2023-07-01 EUR 1.4227 CAD
2023-09-08 This transaction leads to a rounding error when converted to EUR at the effective rate.
Revenue:Sales -199.0 CAD
Liabilities:EU VAT -41.79 CAD
Assets:Bank
---- end sample ledger ----
This command produces a defective journal:
$ hledger --file forex-defect.journal --value=then,EUR print
---- begin defective output ----
2023-09-08 This transaction leads to a rounding error when converted to EUR at the effective rate.
Revenue:Sales -139.87 EUR
Liabilities:EU VAT -29.37 EUR
Assets:Bank 169.25 EUR
---- end defective output ----