mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-06 05:01:48 +02:00
enforce multiple currency check in model
On the same way that form validator does
This commit is contained in:
parent
867e84ae91
commit
535f9fce90
1 changed files with 6 additions and 1 deletions
|
@ -274,7 +274,12 @@ class Project(db.Model):
|
|||
def switch_currency(self, new_currency):
|
||||
# Update converted currency
|
||||
if new_currency != self.default_currency:
|
||||
for bill in self.get_bills():
|
||||
if (
|
||||
new_currency == CurrencyConverter.no_currency
|
||||
and self.has_multiple_currencies()
|
||||
):
|
||||
raise ValueError(f"Can't unset currency of project {self.id}")
|
||||
for bill in self.get_bills_unordered():
|
||||
|
||||
if new_currency == CurrencyConverter.no_currency:
|
||||
# Use old currency to flatten all amount before stripping
|
||||
|
|
Loading…
Reference in a new issue