From 596807811defcfdba1d26a4572a4fc08b9a2bcb4 Mon Sep 17 00:00:00 2001 From: uvok Date: Fri, 18 Apr 2025 11:54:36 +0200 Subject: Support withdrawals --- ledger_process.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'ledger_process.py') diff --git a/ledger_process.py b/ledger_process.py index 7703e58..d5592a2 100644 --- a/ledger_process.py +++ b/ledger_process.py @@ -58,14 +58,14 @@ class LedgerProcess: elif action.type == "withdrawal" and action.asset != "EUR": assert len(actions) == 1 - logger.error("Don't know how do handle withdrawals yet.") - # currency = action.asset - # fifo_queues.setdefault(currency, FIFOQueue()) - # amount = Decimal(action.amount) - # price = 0 # Deposits typically have no associated cost basis - # current = fifo_queues[currency] - - # current.add(amount, price, action.date) + + currency = action.asset + self.external_wallet.setdefault(currency, FIFOQueue()) + self.fifo_queues.setdefault(currency, FIFOQueue()) + + t = self.fifo_queues[currency].remove(lambda t: t.amount == -action.amount + action.fee) + t.remove_coins(action.fee) + self.external_wallet[currency].add_trade(t) def _process_trade(self, refid: str, trades: List[LedgerAction]): if len(trades) == 2: # Ensure we have two related rows (EUR + crypto) -- cgit v1.2.3