1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

Merge pull request #150 from fredericsureau/negative-amounts

Allow negative bill amounts
This commit is contained in:
Alexis Metaireau 2016-09-12 17:54:58 +02:00 committed by GitHub
commit 7ba9048b06
2 changed files with 2 additions and 6 deletions

View file

@ -143,9 +143,7 @@ class BillForm(Form):
self.payed_for.data = self.payed_for.default
def validate_amount(self, field):
if field.data < 0:
field.data = abs(field.data)
elif field.data == 0:
if field.data == 0:
raise ValidationError(_("Bills can't be null"))

View file

@ -398,12 +398,10 @@ class BudgetTestCase(TestCase):
'what': u'fromage à raclette',
'payer': members_ids[0],
'payed_for': members_ids,
# bill with a negative value should be converted to a positive
# value
'amount': '-25'
})
bill = models.Bill.query.filter(models.Bill.date == '2011-08-12')[0]
self.assertEqual(bill.amount, 25)
self.assertEqual(bill.amount, -25)
#add a bill with a comma
self.app.post("/raclette/add", data={