hledger
hledger copied to clipboard
Import will miss transactions that show up on a date earlier than the date stored in .latest file
Hi,
First of all, thanks a lot for hledger and all of its documentation, it's great!
I started using hledger and noticed a possible bug where some transactions will not be imported if they get added on a date that is same as the date stored in the .latest file of the corresponding import file.
Many credit card companies keep a transaction in a pending state for anywhere between 2-5 days, but when such a transaction completes it still shows up on it's original date (i.e the date on which it was posted for the very first time) in the statement. This can cause hledger to think that the transaction has already been imported and it will incorrectly skip importing that transaction.
Here is a concrete example: I buy something using my credit card on 1st Jan 2022. This transaction shows up as a pending transaction on my credit card on the same day. On 1st Jan 2022 I download a CSV of my credit card transactions and import it in hledger. Note that the pending transactions aren't a part of the CSV so this transaction doesn't show up in CSV. hledger imports all the transactions and stores 1st Jan 2022 in the .latest file for future reference. Now this transaction moves to the completed/confirmed state on 5th Jan, but in the credit card statement it still shows up with 1st Jan 2022 as the transaction date. At this point if I download the CSV from my Credit card vendor and import it in hledger, hledger has a .latest file that says all transactions upto 1st Jan 2022 are imported and so this newly added transaction will never be imported in hledger. Same thing happens even if I download and import the CSV on any day between 1st Jan and 5th Jan.
I agree that this is a problem with the credit card vendor generated data and not an hledger issue but I think we might be able to make a change to effectively handle this.
Would it be possible to assign an unique transaction ID for each transactions that is imported? This ID will be a hash of the transaction date, description and amount and so it should never collide with another transaction. That way we can get rid of the .latest file and can be always sure that no transactions are missed during the import.
Having said that, I understand that maybe such a change is currently not possible. Maybe there is a simpler solution already available. In that case please redirect me to that.