diff --git a/ihatemoney/forms.py b/ihatemoney/forms.py index 3d80d319..a9780faa 100644 --- a/ihatemoney/forms.py +++ b/ihatemoney/forms.py @@ -38,7 +38,7 @@ def get_billform_for(project, set_default=True, **kwargs): display the default form, it will call set_default on it. """ - form = BillForm(project=project, **kwargs) + form = BillForm(**kwargs) form.original_currency.label = Label("original_currency", "Currency (Default: %s)" % (project.default_currency)) active_members = [(m.id, m.name) for m in project.active_members] @@ -193,7 +193,7 @@ class BillForm(FlaskForm): bill.date = self.date.data bill.owers = [Person.query.get(ower, project) for ower in self.payed_for.data] bill.original_currency = self.original_currency.data - bill.original_amount = currency_helper.exchange_currency(bill.amount, bill.original_currency, project.default_currency) + bill.original_amount = self.currency_helper.exchange_currency(bill.amount, bill.original_currency, project.default_currency) return bill diff --git a/ihatemoney/templates/forms.html b/ihatemoney/templates/forms.html index 739c2c37..fa1a24ac 100644 --- a/ihatemoney/templates/forms.html +++ b/ihatemoney/templates/forms.html @@ -97,8 +97,8 @@ {{ input(form.what, inline=True) }} {{ input(form.payer, inline=True, class="form-control custom-select") }} {{ input(form.amount, inline=True) }} - {{ input(form.external_link, inline=True) }} {{ input(form.original_currency, inline=True) }} + {{ input(form.external_link, inline=True) }}
diff --git a/ihatemoney/tests/tests.py b/ihatemoney/tests/tests.py index fb96d358..5eeb07e6 100644 --- a/ihatemoney/tests/tests.py +++ b/ihatemoney/tests/tests.py @@ -1099,6 +1099,8 @@ class BudgetTestCase(IhatemoneyTestCase): "payer": 1, "payed_for": [1, 2, 3, 4], "amount": "10.0", + "original_amount": "10.0", + "original_currency": "USD", }, ) @@ -1110,6 +1112,8 @@ class BudgetTestCase(IhatemoneyTestCase): "payer": 2, "payed_for": [1, 3], "amount": "200", + "original_amount": "200", + "original_currency": "USD", }, ) @@ -1121,6 +1125,8 @@ class BudgetTestCase(IhatemoneyTestCase): "payer": 3, "payed_for": [2], "amount": "13.33", + "original_amount": "13.3", + "original_currency": "USD", }, ) @@ -1134,6 +1140,8 @@ class BudgetTestCase(IhatemoneyTestCase): "payer_name": "tata", "payer_weight": 1.0, "owers": ["fred"], + "original_amount": "13.3", + "original_currency": "USD", }, { "date": "2016-12-31", @@ -1142,6 +1150,8 @@ class BudgetTestCase(IhatemoneyTestCase): "payer_name": "fred", "payer_weight": 1.0, "owers": ["alexis", "tata"], + "original_amount": "200.0", + "original_currency": "USD", }, { "date": "2016-12-31", @@ -1150,6 +1160,8 @@ class BudgetTestCase(IhatemoneyTestCase): "payer_name": "alexis", "payer_weight": 2.0, "owers": ["alexis", "fred", "tata", "p\xe9p\xe9"], + "original_amount": "10.0", + "original_currency": "USD", }, ] self.assertEqual(json.loads(resp.data.decode("utf-8")), expected)