2020-03-23 21:30:57 +01:00
|
|
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2020-03-24 17:14:29 +01:00
|
|
|
from treasury.models import SpecialTransactionProxy, RemittanceType
|
2020-03-23 21:30:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
def save_special_transaction(instance, created, **kwargs):
|
|
|
|
"""
|
|
|
|
When a special transaction is created, we create its linked proxy
|
|
|
|
"""
|
2020-04-18 15:59:59 +02:00
|
|
|
|
2020-09-07 14:52:37 +02:00
|
|
|
if not hasattr(instance, "_no_signal"):
|
2020-10-23 16:55:33 +02: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()
|