Skip to content

Commit

Permalink
Merge pull request #824 from hdoupe/bool-split-bug
Browse files Browse the repository at this point in the history
Merged #824
  • Loading branch information
hdoupe authored Feb 27, 2018
2 parents ef97603 + 045d032 commit 505bda3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
5 changes: 4 additions & 1 deletion webapp/apps/taxbrain/behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ def set_fields(self, upstream_obj, nonparam_fields=None):
for field in self._meta.fields:
if (getattr(self, field.attname, None) and
field.name not in nonparam_fields):
self.raw_input_fields[field.name] = getattr(self, field.attname)
raw_val = getattr(self, field.attname)
if field.name.endswith("cpi") and isinstance(raw_val, bool):
raw_val = str(raw_val)
self.raw_input_fields[field.name] = raw_val

param_formatters.amt_fixup(self.raw_input_fields)
input_fields, failed_lookups = param_formatters.parse_fields(
Expand Down
5 changes: 4 additions & 1 deletion webapp/apps/taxbrain/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import six
import json

from ..constants import START_YEAR

from .models import TaxSaveInputs
from .helpers import (TaxCalcField, TaxCalcParam, default_policy, is_number,
int_to_nth, is_string, string_to_float_array, check_wildcards,
Expand Down Expand Up @@ -164,7 +166,8 @@ def __init__(self, first_year, *args, **kwargs):
k
)
self._meta.widgets[k].attrs["placeholder"] = django_val

if first_year is None:
first_year = START_YEAR
self._first_year = int(first_year)
self._default_params = default_policy(self._first_year)

Expand Down
2 changes: 2 additions & 0 deletions webapp/apps/taxbrain/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ def test_old_runs(self):
ID_AmountCap_Switch_0='True',
FICA_ss_trt='0.10',
STD_cpi='True',
SS_Earnings_c_cpi=True,
first_year=start_year
)
tsi.save()
tsi.set_fields()
assert tsi.input_fields['_FICA_ss_trt'] == [0.10]
assert tsi.input_fields['_STD_cpi'] == True
assert tsi.input_fields['_SS_Earnings_c_cpi'] == True
assert tsi.input_fields['_ID_AmountCap_Switch_medical'] == [True]

def test_deprecated_fields(self):
Expand Down
4 changes: 2 additions & 2 deletions webapp/apps/taxbrain/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,11 @@ def edit_personal_results(request, pk):

init_context = {
'form': form_personal_exemp,
'params': nested_form_parameters(int(start_year)),
'params': nested_form_parameters(int(form_personal_exemp._first_year)),
'taxcalc_version': taxcalc_vers_disp,
'webapp_version': webapp_vers_disp,
'start_years': START_YEARS,
'start_year': str(start_year),
'start_year': str(form_personal_exemp._first_year),
'is_edit_page': True,
'has_errors': False
}
Expand Down

0 comments on commit 505bda3

Please sign in to comment.