1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-23 07:52:23 +00:00

Update Sogé credit amount when a transaction is added if the credit was already validated

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2021-09-07 13:04:09 +02:00
parent 4b03a78ad6
commit da1e15c5e6
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

View File

@ -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()