diff --git a/ihatemoney/forms.py b/ihatemoney/forms.py index e9973fdd3..a8ebd0758 100644 --- a/ihatemoney/forms.py +++ b/ihatemoney/forms.py @@ -387,9 +387,7 @@ def set_default(self): self.payed_for.data = self.payed_for.default def validate_amount(self, field): - if field.data == "0": - raise ValidationError(_("Bills can't be null")) - elif decimal.Decimal(field.data) > decimal.MAX_EMAX: + if decimal.Decimal(field.data) > decimal.MAX_EMAX: # See https://github.com/python-babel/babel/issues/821 raise ValidationError(f"Result is too high: {field.data}") diff --git a/ihatemoney/tests/api_test.py b/ihatemoney/tests/api_test.py index 585c795da..21c61e17d 100644 --- a/ihatemoney/tests/api_test.py +++ b/ihatemoney/tests/api_test.py @@ -926,7 +926,7 @@ def test_amount_is_null(self): }, headers=self.get_auth("raclette"), ) - self.assertStatus(400, req) + self.assertStatus(201, req) def test_project_creation_with_mixed_case(self): self.api_create("Raclette") diff --git a/ihatemoney/tests/budget_test.py b/ihatemoney/tests/budget_test.py index 06681f06c..696a4cd15 100644 --- a/ihatemoney/tests/budget_test.py +++ b/ihatemoney/tests/budget_test.py @@ -1589,7 +1589,7 @@ def test_amount_is_null(self): self.client.post("/raclette/members/add", data={"name": "zorglub"}) # null amount - resp = self.client.post( + self.client.post( "/raclette/add", data={ "date": "2016-12-31", @@ -1600,11 +1600,12 @@ def test_amount_is_null(self): "original_currency": "EUR", }, ) - self.assertIn('
', resp.data.decode("utf-8")) - resp = self.client.get("/raclette/") - # No bills, the previous one was not added - self.assertIn("No bills", resp.data.decode("utf-8")) + # Bill should have been accepted + project = self.get_project("raclette") + self.assertEqual(project.get_bills().count(), 1) + last_bill = project.get_bills().first() + self.assertEqual(last_bill.amount, 0) def test_decimals_on_weighted_members_list(self): self.post_project("raclette")