From dd8b48c31d4501d95b3afb00ac9b387397fca957 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 1 Aug 2020 15:16:36 +0200 Subject: [PATCH] Update the balance of the Kfet club --- management/commands/import_transaction.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/management/commands/import_transaction.py b/management/commands/import_transaction.py index c7be7cb..4f75acd 100644 --- a/management/commands/import_transaction.py +++ b/management/commands/import_transaction.py @@ -185,6 +185,7 @@ class Command(ImportCommand): n = cur.rowcount pk_membership = 1 pk_transaction = 1 + kfet_balance = 0 for idx, row in enumerate(cur): if save or idx % chunk_size == 0: self.update_line(idx, n, row["description"]) @@ -261,6 +262,7 @@ class Command(ImportCommand): } obj_dict0["amount"] = bde_dict["fee"] obj_dict["amount"] = kfet_dict["fee"] + kfet_balance += kfet_dict["fee"] # BDE membership Transaction is inserted before the Kfet membershipTransaction pk_membership += 1 pk_transaction += 1 @@ -291,6 +293,14 @@ class Command(ImportCommand): pk_transaction += 1 bulk_mgr.done() + # Update the balance of the BDE and the Kfet club + note_bde = NoteClub.objects.get(pk=5) + note_kfet = NoteClub.objects.get(pk=6) + note_bde.balance -= kfet_balance + note_kfet.balance += kfet_balance + note_bde.save() + note_kfet.save() + @timed def set_roles(self): bulk_mgr = BulkCreateManager(chunk_size=10000)