Fix money creation, closes #25
This commit is contained in:
parent
94c0971abf
commit
3764bc44ff
3 changed files with 26 additions and 10 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue