1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 18:08:21 +02:00

Fix money creation, closes #25

This commit is contained in:
Yohann D'ANELLO
2020-02-27 17:22:59 +01:00
parent 94c0971abf
commit 3764bc44ff
3 changed files with 26 additions and 10 deletions

View File

@ -84,8 +84,6 @@ class Transaction(PolymorphicModel):
amount is store in centimes of currency, making it a positive integer
value. (from someone to someone else)
TODO: Ensure source != destination.
"""
source = models.ForeignKey(
@ -126,6 +124,11 @@ class Transaction(PolymorphicModel):
"""
When saving, also transfer money between two notes
"""
if self.source.pk == self.destination.pk:
# When source == destination, no money is transfered
return
created = self.pk is None
to_transfer = self.amount * self.quantity
if not created: