summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruvok2025-04-18 11:54:36 +0200
committeruvok2025-04-18 11:54:36 +0200
commit596807811defcfdba1d26a4572a4fc08b9a2bcb4 (patch)
treec6c0e90731a5a3d0749ef5925b75d66deaf330a3
parentae8212598e4fc21caf587e5d58b7be2c1e98bb5d (diff)
Support withdrawals
-rw-r--r--ledger_process.py16
1 files changed, 8 insertions, 8 deletions
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)