From 81a20860d576347e064e07c7f74667a15545d95d Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Tue, 11 May 2021 20:37:44 +0200 Subject: [PATCH] fix importing from Bitcoin.de via API, storing the fees and amounts in the new way --- apps/transactions/importbtcde.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/transactions/importbtcde.py b/apps/transactions/importbtcde.py index 39ac107..61ee798 100644 --- a/apps/transactions/importbtcde.py +++ b/apps/transactions/importbtcde.py @@ -18,7 +18,7 @@ class ImportBtcDe: break for trade in trades: - # TODO: check if this trade_id does not exist in the database for this user + # check if this trade_id does not exist in the database for this user with connection.cursor() as cursor: sql = """SELECT trade_id FROM `transaction` WHERE trade_id=%s and owner_id=%s""" cursor.execute(sql, [trade['trade_id'], Owner.id]) @@ -37,14 +37,14 @@ class ImportBtcDe: if trade['trading_pair'].upper().endswith(f): t.fiat_currency = f t.owner = Owner - t.amount_before_fee = Decimal(trade['amount']) - t.amount_after_fee = Decimal(trade['amount']) - Decimal(trade['fee_currency']) - t.amount = Decimal(trade['volume']) + t.crypto_amount = Decimal(trade['amount']) + t.crypto_fee = Decimal(trade['fee_currency']) + t.fiat_amount = Decimal(trade['volume']) + t.fiat_fee = Decimal(trade['fee_eur']) if trade['type'] == 'sell': - t.amount -= Decimal(trade['fee_eur']) - t.amount_before_fee *= -1 - t.amount_after_fee *= -1 - t.amount *= -1 + t.transaction_type = 'S' + else: + t.transaction_type = 'B' t.exchange_rate = trade['price'] t.date_valid = trade['created_at'] t.save()