Skip to content

Commit

Permalink
FIX Calculate eur_subtotal for coinbase transactions when it's miss…
Browse files Browse the repository at this point in the history
…ing in file
  • Loading branch information
provinzio committed May 14, 2022
1 parent bfa68b4 commit 9e2d2fa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/book.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ def _read_coinbase(self, file_path: Path) -> None:
change = misc.force_decimal(_change)
# `eur_subtotal` and `eur_fee` are None for withdrawals.
eur_subtotal = misc.xdecimal(_eur_subtotal)
if eur_subtotal is None:
# Cost without fees from CSV is missing. This can happen for
# old transactions (<2018), event though something was bought.
# Calculate the `eur_subtotal` from `eur_spot`.
if eur_spot := misc.xdecimal(_eur_spot):
eur_subtotal = eur_spot * change
eur_fee = misc.xdecimal(_eur_fee)

# Validate data.
Expand Down

0 comments on commit 9e2d2fa

Please sign in to comment.