Skip to content

Commit

Permalink
fix discount and tax fields
Browse files Browse the repository at this point in the history
before, the field would always display the default value, regardless of the value set in the database
  • Loading branch information
paulapreuss committed Jun 20, 2024
1 parent 61bb836 commit c50f314
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 0 additions & 2 deletions app/cp_nigeria/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ def __init__(self, *args, **kwargs):

super().__init__(*args, **kwargs)
self.fields["discount"].validators.append(validate_not_zero)
self.initial["discount"] = 12.0
self.initial["tax"] = 7.5

# def save(self, *args, **kwargs):
# ed = super().save(*args, **kwargs)
Expand Down
7 changes: 6 additions & 1 deletion app/cp_nigeria/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,12 @@ def cpn_scenario_create(request, proj_id=None, step_id=STEP_MAPPING["choose_loca
qs_report = ImplementationPlanContent.objects.filter(simulation=project.scenario.simulation)
if qs_report.exists() and economic_data.has_changed():
qs_report.delete()
economic_data = economic_data.save()
economic_data = economic_data.save(commit=False)
# set the initial values for discount and tax
economic_data.discount = 0.12
economic_data.tax = 0.075
economic_data.save()

project = form.save(user=request.user, commit=False)
project.economic_data = economic_data
project.save()
Expand Down

0 comments on commit c50f314

Please sign in to comment.