ananthakumaran / paisa

Paisa – Personal Finance Manager. https://paisa.fyi demo: https://demo.paisa.fyi
https://paisa.fyi
GNU Affero General Public License v3.0
2.5k stars 131 forks source link

The app crashes if ISO dates are used #29

Closed alensiljak closed 1 year ago

alensiljak commented 1 year ago

Describe the bug When synchronizing the ledger, the application will crash if the ISO dates are used (YYYY-MM-DD). I understand this setting comes from the locale but I have a book with ISO dates and the date is also configured in .ledgerrc. There should be a way to tell the application not to try to be too smart and decide which dates I should use. I'm not aware of any locale that has this format as the default, unfortunately. Hence, this brief testing ends here, considering the application is really unusable in it's current state.

FATAL parsing time "2000-11-01" as "2006/01/02": cannot parse "-11-01" as "/"

ananthakumaran commented 1 year ago

Can you share the .ledgerrc config related to date? I use iso format as well in my ledger as well. ledger command usually prints output in a standard format and I am assuming your .ledgerrc is changing the behavior?

alensiljak commented 1 year ago

Hi! Thanks for the prompt response.

The relevant parts of .ledgerrc would be

--date-format %Y-%m-%d
--wide

I was wondering if it is reading only the configured book.ledger, which is just a collection of imports, but the fact that it is reporting the date of the oldest available transaction means that this part is ok.

So it could be wide? However, the error message clearly reports that it found a date value but can't parse it. Interesting.

alensiljak commented 1 year ago

The interesting part is actually the second date in the error message:

FATAL parsing time "2000-11-01" as "2006/01/02": cannot parse "-11-01" as "/"

Where is this coming from? This is also not formatted in the selected locale (en-AU), for example.

ananthakumaran commented 1 year ago

I don't want the user config to interfere with what Paisa is trying to do. There is --args-only which seem to do what I want, I will fix this issue using that flag

ananthakumaran commented 1 year ago

You didn't really clarify where is the 2006/01/02 date coming from

Sorry, I didn't read your full message. To answer our question, golang has a unique way of parsing date. Instead of using YYYY/MM/DD, you have to say 2006/01/02. It will parse the format and will figure out what you actually want to do. So yes, the date is not from your ledger, rather it's just printing the format I have given.

https://github.com/ananthakumaran/paisa/blob/9a9c87312c22325eba5ed9e4301edd376d91bc69/internal/ledger/ledger.go#L203

alensiljak commented 1 year ago

Sorry, I didn't read your full message.

No worries. I figured out something along those lines after I (voiced and) posted the question, hence I deleted the original message.