From 9e2d2fa522f8a371f23f79a7d336b0ffa960f755 Mon Sep 17 00:00:00 2001 From: Jeppy Date: Sat, 14 May 2022 21:28:20 +0200 Subject: [PATCH] FIX Calculate `eur_subtotal` for coinbase transactions when it's missing in file --- src/book.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/book.py b/src/book.py index 9186740..7966310 100644 --- a/src/book.py +++ b/src/book.py @@ -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.