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

ofx: support non-sale transfers out #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions beancount_import/source/ofx.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,14 +916,14 @@ def get_subaccount_cash(inv401ksource: Optional[str] = None) -> str:
units = normalize_fraction(raw.units)
if quantity_round_digits is not None:
units = round(units, quantity_round_digits)
unitprice = normalize_fraction(raw.unitprice)
if raw.unitprice is not None:
unitprice = normalize_fraction(raw.unitprice)

cost_spec = None
price = None
is_sale = False
if raw.trantype in SELL_TYPES or (raw.trantype == 'TRANSFER' and
units < ZERO):
is_sale = True
units = -abs(units)
# For sell transactions, rely on beancount to determine the matching lot.
cost_spec = CostSpec(
Expand All @@ -933,7 +933,9 @@ def get_subaccount_cash(inv401ksource: Optional[str] = None) -> str:
date=None,
label=None,
merge=False)
price = Amount(number=unitprice, currency=self.currency)
if unitprice != ZERO:
is_sale = True
price = Amount(number=unitprice, currency=self.currency)
elif raw.trantype == 'TRANSFER' and units > ZERO:
# Transfer in.
# OFX does not specify the lot information, so it will have to be manually fixed.
Expand Down