banks2ledger icon indicating copy to clipboard operation
banks2ledger copied to clipboard

feature request: allow specifying alternates for amount

Open justin-roche opened this issue 4 years ago • 3 comments

My banks csv looks like this:

Date,CheckNum,Description,Withdrawal Amount,Deposit Amount,Additional Info

Sometimes deposit is empty, sometimes withdrawl is empty. Is there a way to handle this?

If I were to add the functionality, what would you want the api to be like?

justin-roche avatar Mar 06 '20 21:03 justin-roche

Very relevant request, thank you!

I think the best way to fit this into banks2ledger is to enhance the interpretation of the -m option to be similar to -t in that in would accept a special kind of column index spec. This could be a single number referring to a given column (as of today) or be something more complicated, e.g., in your case "-%3!%4" to convey that the negated value of column 3 (zero-based index) should be used (withdrawal amount), or if that is empty, the value of column 4 (deposit amount). The signs would possibly need to be adjusted, since I am not sure about the values in your CSV and assumed both withdrawals and deposits are represented as positive numbers. I picked ! as the separator of alternatives, for consistency with -t, in retrospect it would probably have been better to choose : there, but I'm not sure I want to change that now.

You get the idea - let me know if this would work for you or you have any other suggestion on how this would ideally work.

If you are in a hurry to use this and/or want to do the coding anyway, feel free to go ahead and submit a patch. Otherwise I can do it when I find the time hopefully within a couple weeks.

tomscii avatar Mar 07 '20 08:03 tomscii

Yes, that's pretty much exactly what I had in mind.

I'm not in a big hurry. But I'll give it a try!

justin-roche avatar Mar 08 '20 05:03 justin-roche

Well, I tried, but although I can get it partially working, getting it fully working would require more time than I want to invest.

So, I guess whenever you get the time to do it that would be awesome. Thanks!

justin-roche avatar Mar 19 '20 18:03 justin-roche