From da1e15c5e66cb69f6679833330a941acd0dc5b4d Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 7 Sep 2021 13:04:09 +0200 Subject: [PATCH] =?UTF-8?q?Update=20Sog=C3=A9=20credit=20amount=20when=20a?= =?UTF-8?q?=20transaction=20is=20added=20if=20the=20credit=20was=20already?= =?UTF-8?q?=20validated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yohann D'ANELLO --- apps/wei/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/wei/models.py b/apps/wei/models.py index 9e99cd1c..7ab56f57 100644 --- a/apps/wei/models.py +++ b/apps/wei/models.py @@ -372,3 +372,11 @@ class WEIMembership(Membership): soge_credit.update_transactions() soge_credit.save() + + if soge_credit.valid and \ + soge_credit.credit_transaction.total != sum(tr.total for tr in soge_credit.transactions.all()): + # The credit is already validated, but we add a new transaction (eg. for the WEI). + # Then we invalidate the transaction, update the credit transaction amount + # and re-validate the credit. + soge_credit.validate(True) + soge_credit.save()