summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bla.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/bla.py b/bla.py
index c73c234..d6fbecc 100644
--- a/bla.py
+++ b/bla.py
@@ -11,7 +11,10 @@ class FIFOQueue:
def remove(self, amount):
remaining = amount
cost_basis = 0
+
while remaining > 0:
+ if not self.queue:
+ raise ValueError(f"Insufficient assets in queue to process sale of {amount}.")
quantity, price = self.queue[0]
if quantity > remaining:
cost_basis += remaining * price
@@ -21,6 +24,7 @@ class FIFOQueue:
cost_basis += quantity * price
remaining -= quantity
self.queue.popleft()
+
return cost_basis
def process_ledger(file_path):