From f53c24098ce2f635fe94172bc122649eedd68562 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Mon, 23 Dec 2024 00:08:24 +0100 Subject: [PATCH] WIP --- crypto_tax/__init__.py | 2 +- crypto_tax/__main__.py | 2 +- crypto_tax/output_excel.py | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crypto_tax/__init__.py b/crypto_tax/__init__.py index 1a9afe8..3902f38 100644 --- a/crypto_tax/__init__.py +++ b/crypto_tax/__init__.py @@ -43,7 +43,7 @@ def compute_tax(transfers: list) -> TaxReport: bought_and_spent_for: list[BoughtAndSold] = [] prices_bought_for: dict[Asset, deque[BoughtAndNotYetSold]] = {} - if False: + if True: prices_bought_for[MPC] = deque() prices_bought_for[MPC].append(BoughtAndNotYetSold(AssetAmount(MPC, Decimal(100)), datetime.datetime(2000, 1,1,1,1,1,1))) prices_bought_for[USDT] = deque() diff --git a/crypto_tax/__main__.py b/crypto_tax/__main__.py index 3e90b62..2166315 100644 --- a/crypto_tax/__main__.py +++ b/crypto_tax/__main__.py @@ -32,7 +32,7 @@ def main(): logger.setLevel('INFO') TRANSFERS = list(KRAKEN_CLIENT._get_double_registers()) - #TRANSFERS += list(KUCOIN_CLIENT._get_double_registers()) + TRANSFERS += list(KUCOIN_CLIENT._get_double_registers()) tax_report = compute_tax(TRANSFERS) logger.info('-'*80) diff --git a/crypto_tax/output_excel.py b/crypto_tax/output_excel.py index 2cbf678..bfd9525 100644 --- a/crypto_tax/output_excel.py +++ b/crypto_tax/output_excel.py @@ -27,6 +27,8 @@ TAX_TYPES: dict[fin_defs.Asset, str] = { NOW = datetime.datetime.now(tz=datetime.UTC) def mult_a(a, b): + if a == 0 or b == 0: + return 0 if a is None or b is None: return 'Unknown' return a * b @@ -38,7 +40,7 @@ def write_current_assets(sheet, tax_report: TaxReport): for asset, positions in tax_report.current_assets.items(): total_amount: Decimal = sum((p.amount.amount for p in positions), start=Decimal(0)) exchange_rate_asset_to_dkk = tax_report.exchange_rate_at_time(asset, fin_defs.DKK, NOW) - assert exchange_rate_asset_to_dkk is not None, asset + #assert exchange_rate_asset_to_dkk is not None, asset row = [ asset.raw_short_name(), total_amount,