Fix performance issue for users with many orders
This commit is contained in:
@@ -81,8 +81,13 @@ def import_csv(filepath: str):
|
||||
lambda: defaultdict(lambda: Order(user_id=1))
|
||||
)
|
||||
|
||||
for row in rows:
|
||||
for i, row in enumerate(rows, start=2):
|
||||
transaction_type = row["typ"].lower()
|
||||
if transaction_type == "einkauf foodcoop":
|
||||
print(
|
||||
"Skipping 'Einkauf Foodcoop' transaction as it's not relevant for the payment system."
|
||||
)
|
||||
continue
|
||||
if transaction_type not in [
|
||||
"essen",
|
||||
"essen kind",
|
||||
@@ -90,8 +95,9 @@ def import_csv(filepath: str):
|
||||
"einkauf",
|
||||
"auszahlung",
|
||||
]:
|
||||
# TODO: Handle other types
|
||||
continue
|
||||
raise ValueError(
|
||||
f"Skipping row {i} with unknown transaction type: '{transaction_type}'"
|
||||
)
|
||||
|
||||
# find or create account for "Partei/Konto"
|
||||
account_name = row["partei_konto"]
|
||||
@@ -123,7 +129,7 @@ def import_csv(filepath: str):
|
||||
if transaction_type == "essen"
|
||||
else kids_meal_product
|
||||
),
|
||||
total_amount=row["betrag"],
|
||||
total_amount=row["betrag"] * -1,
|
||||
quantity=quantity,
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user