Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

several minor OFX improvements #223

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

several minor OFX improvements #223

wants to merge 6 commits into from

Conversation

jktomer
Copy link
Contributor

@jktomer jktomer commented Jan 8, 2024

Bugs fixed:

  • fix an assert failure when an ofx file included a zero-value transfer
  • don't emit balance assertions for cash accounts (like we already don't for securities accounts) on the same day that there was a transaction

New features:

  • support an additional after-tax account to be marked as related to a main account
  • support listing multiple CUSIPs for the same security (for securities that don't have a real CUSIP and different banks assign different fake ones for their OFX feeds)
  • support a configurable format string for producing the payee for a transaction
  • support providing historical account IDs for an account

some banks (notably Vanguard) distinguish between a Roth 401(k) and an
after-tax 401(k).
The OFX parser already skips emitting balance checks for securities on dates
that had activity on that day because Beancount's ordering constraints might
require changing the date of either the transaction or the balance assertion.

This commit does the same thing for balance assertions on cash accounts.
For some securities which don't have real CUSIPs or ticker symbols (e.g.
institutional share classes of mutual funds), it seems that most providers
make up a fake CUSIP to put in their OFX streams. Unfortunately, there is no
consistency between the fake CUSIPs used by different providers; for example,
Vanguard gives "Trust Select" shares of their Target Retirement 2030 fund the
fake CUSIP "92204E605", but Fidelity gives the same share class of the same
fund the fake CUSIP "OP1G."

This change permits mutliple CUSIPs to be listed for a single currency,
separated by commas, and the OFX parser will treat them all as referring to
the same currency.
Code in ofx.py includes an assert to check that the amount on an outbound
transfer posting is negative. However, sometimes OFX files include (apparently
useless) transfers of zero shares of a security. These trigger the assert,
killing beancount_import, even if the zero was properly a negative zero.

This commit changes the assert in question to handle negative zero amounts
correctly.
I have a credit card whose OFX records otherwise come out looking like
"STMTTRN - payee's actual name - garble of digits" which is not actually
useful. This lets me instead give a format string for the payee, allowing the
interpolation of those fields that are relevant for a particular account.

Format strings are given in the account metadata, key 'ofx_payee_format', as a
regular Python str.format() format string, with supported substitutions
trantype, incometype, inv401ksource, name, and memo.
Sometimes an account (e.g. a credit card) changes primary identifiers but
maintains a continuous transaction history and OFX series.  This change makes
it possible to list the old account identifiers for an account in the
`old_account_ids` meta field of an open directive; transactions from OFX files
matching either the old or new account ids will be associated with the account.
@Zburatorul
Copy link
Collaborator

I noticed the ultipro PR also skips balance entries on same day as other transactions. Is there a way to handle this at a higher level for all sources simultaneously, with an optional flag to do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants