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

Bills can't be negative. Fix #45

This commit is contained in:
Alexis Metaireau 2011-10-18 18:13:54 +02:00
parent 6e3834048b
commit b88b317faa
5 changed files with 19 additions and 0 deletions

View file

@ -120,6 +120,10 @@ class BillForm(Form):
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 negative"))
class MemberForm(Form):

View file

@ -445,3 +445,6 @@ msgstr ""
msgid "each"
msgstr ""
msgid "Bills can't be negative"
msgstr ""

View file

@ -283,6 +283,15 @@ class BudgetTestCase(TestCase):
bill = models.Bill.query.one()
self.assertEqual(bill.amount, 25)
self.app.post("/raclette/add", data={
'date': '2011-08-10',
'what': u'fromage à raclette',
'payer': members_ids[0],
'payed_for': members_ids,
'amount': '-25', # bill with a negative value is not possible
})
self.assertEqual(1, models.Bill.query.count())
# edit the bill
resp = self.app.post("/raclette/edit/%s" % bill.id, data={
'date': '2011-08-10',

View file

@ -451,3 +451,6 @@ msgstr "et les notifier vous même"
msgid "each"
msgstr "chacun"
msgid "Bills can't be negative"
msgstr "Le montant d'une facture ne peut pas être négatif"