2020-03-23 20:30:57 +00:00
|
|
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2020-04-10 21:41:13 +00:00
|
|
|
from note.models import NoteSpecial
|
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-10 21:41:13 +00:00
|
|
|
if created and isinstance(instance.source, NoteSpecial) \
|
|
|
|
and RemittanceType.objects.filter(note=instance.source).exists():
|
2020-03-23 20:30:57 +00:00
|
|
|
SpecialTransactionProxy.objects.create(transaction=instance, remittance=None).save()
|