jbms / beancount-import

Web UI for semi-automatically importing external data into beancount
GNU General Public License v2.0
392 stars 101 forks source link

Add multiple postings to imported transaction #199

Open addisonklinke opened 1 year ago

addisonklinke commented 1 year ago

I'm using several generic_importer_source data sources which parse CSV data using a basic beancount importer. As expected, each transaction shows up with two postings - one for the source account and another FIXME. The UI lets me enter the appropriate FIXME account which is great. However, there doesn't seem to be support for adding multiple postings. For instance, if my importer provides

2023-05-26 * "Xcel Energy" "Monthly utilities"
  Assets:Checking:Chase                                      -150 USD
  Expenses:FIXME                                              150 USD

I want the UI to let me write the following to my output beancount file

2023-05-26 * "Xcel Energy" "Monthly utilities"
  Assets:Checking:Chase                                      -150 USD
  Expenses:Utilities:NaturalGas                                60 USD
  Expenses:Utilities:Electric                                  90 USD

This would be very useful for dividing an expense across multiple accounts

Zburatorul commented 1 year ago

Have your importer generate multiple postings, for FIXME:A, FIXME:B etc.

addisonklinke commented 1 year ago

That's a decent workaround, but it's not always possible to know the number of postings ahead of time.

For example, if my company sends travel reimbursements to my checking account in a lump sum but it should get booked to multiple expense accounts (restaurants, lodging, transportation, etc). I can't know in advance which accounts will be involved. Also, the signature of the transaction (in a downloaded CSV) might look identical to my regular paycheck (which doesn't contain any reimbursements), so the importer wouldn't have any distinguishing factors (other than amount which isn't reliable month-to-month) to determine if the placeholder reimbursement postings should be added.

Things would be a lot easier if the UI had a "add/remove posting" button or similar to dynamically alter the transaction. Is there a reason this feature couldn't be on the roadmap?

jbms commented 1 year ago

Another way this can be accomplished currently is to use "Shift+Enter" to accept a candidate but immediately focus it in the editor view for editing. Then you can edit the postings as you like. It seems that if we supported editing postings in the candidate view it would ultimately require full text editing which would be difficult to integrate, and it isn't clear that it would be better than the existing solution.

Another thing to consider: you could in separate transactions add each reimbursable expense to an Assets:Receivable:Company-Name account. Then for your paycheck transaction you would just need one other account.

addisonklinke commented 1 year ago

I'll try switching to the editor window, that seems like a reasonable workflow especially with the keyboard shortcut. Thanks!

addisonklinke commented 1 year ago

@jbms The shift + enter option has been working for me, except after I save the journal I can't get back to the list of pending candidates I had previously without restarting the server. Is this expected?