2021-06-14 19:45:36 +00:00
|
|
|
# Copyright (C) 2018-2021 by BDE ENS Paris-Saclay
|
2020-03-23 20:30:57 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2020-03-24 16:14:29 +00:00
|
|
|
from treasury.models import SpecialTransactionProxy, RemittanceType
|
2020-03-23 20:30:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def save_special_transaction(instance, created, **kwargs):
|
|
|
|
"""
|
|
|
|
When a special transaction is created, we create its linked proxy
|
|
|
|
"""
|
2020-04-18 13:59:59 +00:00
|
|
|
|
2020-09-07 12:52:37 +00:00
|
|
|
if not hasattr(instance, "_no_signal"):
|
2020-10-23 14:55:33 +00:00
|
|
|
if created and RemittanceType.objects.filter(
|
|
|
|
note=instance.source if instance.is_credit() else instance.destination).exists():
|
|
|
|
proxy = SpecialTransactionProxy(transaction=instance, remittance=None)
|
|
|
|
proxy._force_save = True
|
|
|
|
proxy.save()
|