From a1f1655f063f8f6e20ec940b9dd20d1945e5a770 Mon Sep 17 00:00:00 2001 From: fredericsureau Date: Mon, 12 Sep 2016 14:21:57 +0200 Subject: [PATCH 1/2] Allow negative bill amounts --- budget/forms.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/budget/forms.py b/budget/forms.py index 7d6eb51..4b59a36 100644 --- a/budget/forms.py +++ b/budget/forms.py @@ -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")) From c9b2d17f603bd34dc15b66c123d7b17228362b33 Mon Sep 17 00:00:00 2001 From: fredericsureau Date: Mon, 12 Sep 2016 16:30:01 +0200 Subject: [PATCH 2/2] Update negative amounts test --- budget/tests.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/budget/tests.py b/budget/tests.py index 82465f9..eea7537 100644 --- a/budget/tests.py +++ b/budget/tests.py @@ -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={