Browse Source

DIV-743: removing unnecessary scaling of initial values

pull/160/head
Benard Ebinu 7 years ago
parent
commit
69bf010a5c
3 changed files with 15 additions and 12 deletions
  1. +7
    -1
      edivorce/apps/core/static/js/main.js
  2. +7
    -7
      edivorce/apps/core/templates/question/06_children_income_expenses.html
  3. +1
    -4
      edivorce/apps/core/templatetags/input_field.py

+ 7
- 1
edivorce/apps/core/static/js/main.js View File

@ -805,7 +805,13 @@ var replaceSuffix = function(str, suffix) {
// data-mirror_broadcast_change=[true|false] - after change the target element will trigger a change event so // data-mirror_broadcast_change=[true|false] - after change the target element will trigger a change event so
// so any listener attached to target element are notified that // so any listener attached to target element are notified that
// contents have changed. // contents have changed.
var mirrorOnChange = function() {
var mirrorOnChange = function(e) {
// Don't mirror the change if the keypressed was tab. This is to prevent unnecessary calculations that may result
// in some fields changing because scaling up to annual produces a slightly different result, due to rounding, than
// scaling down.
if (e.which === 9) {
return;
}
var target_select = $(this).attr("data-mirror_target"); var target_select = $(this).attr("data-mirror_target");
var scale_factor_identifier = $(this).attr("data-mirror_scale"); var scale_factor_identifier = $(this).attr("data-mirror_scale");
var broadcast_change = $(this).attr("data-mirror_broadcast_change"); var broadcast_change = $(this).attr("data-mirror_broadcast_change");


+ 7
- 7
edivorce/apps/core/templates/question/06_children_income_expenses.html View File

@ -424,7 +424,7 @@
</td> </td>
<td class="fact-sheet-answer table-bordered"> <td class="fact-sheet-answer table-bordered">
<div class="dollar-prefix"> <div class="dollar-prefix">
{% money_input_field name="child_care_expenses" id="child_care_expenses_month" class="fact-sheet-input money extraordinary-expense-monthly" data_mirror_on_pressed="true" data_mirror_target="#child_care_expenses_year" data_mirror_scale="year_up" data_mirror_broadcast_change="true" scale_to_monthly="true" %}
{% money_input_field name="child_care_expenses" id="child_care_expenses_month" class="fact-sheet-input money extraordinary-expense-monthly" data_mirror_on_pressed="true" data_mirror_target="#child_care_expenses_year" data_mirror_scale="year_up" data_mirror_broadcast_change="true" %}
</div> </div>
</td> </td>
<td class="fact-sheet-answer"> <td class="fact-sheet-answer">
@ -439,7 +439,7 @@
</td> </td>
<td class="fact-sheet-answer"> <td class="fact-sheet-answer">
<div class="dollar-prefix"> <div class="dollar-prefix">
{% money_input_field name="children_healthcare_premiums" id="children_healthcare_premiums_month" class="fact-sheet-input money extraordinary-expense-monthly" data_mirror_on_pressed="true" data_mirror_target="#children_healthcare_premiums_year" data_mirror_scale="year_up" scale_to_monthly="true" data_mirror_broadcast_change="true" %}
{% money_input_field name="children_healthcare_premiums" id="children_healthcare_premiums_month" class="fact-sheet-input money extraordinary-expense-monthly" data_mirror_on_pressed="true" data_mirror_target="#children_healthcare_premiums_year" data_mirror_scale="year_up" data_mirror_broadcast_change="true" %}
</div> </div>
</td> </td>
<td class="fact-sheet-answer"> <td class="fact-sheet-answer">
@ -464,7 +464,7 @@
</td> </td>
<td class="fact-sheet-answer"> <td class="fact-sheet-answer">
<div class="dollar-prefix"> <div class="dollar-prefix">
{% money_input_field name="health_related_expenses" id="health_related_expenses_month" class="fact-sheet-input money extraordinary-expense-monthly" data_mirror_on_pressed="true" data_mirror_target="#health_related_expenses_year" data_mirror_scale="year_up" scale_to_monthly="true" data_mirror_broadcast_change="true" %}
{% money_input_field name="health_related_expenses" id="health_related_expenses_month" class="fact-sheet-input money extraordinary-expense-monthly" data_mirror_on_pressed="true" data_mirror_target="#health_related_expenses_year" data_mirror_scale="year_up" data_mirror_broadcast_change="true" %}
</div> </div>
</td> </td>
<td class="fact-sheet-answer"> <td class="fact-sheet-answer">
@ -489,7 +489,7 @@
</td> </td>
<td class="fact-sheet-answer"> <td class="fact-sheet-answer">
<div class="dollar-prefix"> <div class="dollar-prefix">
{% money_input_field name="extraordinary_educational_expenses" id="extraordinary_educational_expenses_month" class="fact-sheet-input money extraordinary-expense-monthly" data_mirror_on_pressed="true" data_mirror_target="#extraordinary_educational_expenses_year" data_mirror_scale="year_up" scale_to_monthly="true" data_mirror_broadcast_change="true" %}
{% money_input_field name="extraordinary_educational_expenses" id="extraordinary_educational_expenses_month" class="fact-sheet-input money extraordinary-expense-monthly" data_mirror_on_pressed="true" data_mirror_target="#extraordinary_educational_expenses_year" data_mirror_scale="year_up" data_mirror_broadcast_change="true" %}
</div> </div>
</td> </td>
<td class="fact-sheet-answer"> <td class="fact-sheet-answer">
@ -503,7 +503,7 @@
<td class="fact-sheet-question">Post-secondary school expenses</td> <td class="fact-sheet-question">Post-secondary school expenses</td>
<td class="fact-sheet-answer"> <td class="fact-sheet-answer">
<div class="dollar-prefix"> <div class="dollar-prefix">
{% money_input_field name="post_secondary_expenses" id="post_secondary_expenses_month" class="fact-sheet-input extraordinary-expense-monthly" data_mirror_on_pressed="true" data_mirror_target="#post_secondary_expenses_year" data_mirror_scale="year_up" scale_to_monthly="true" data_mirror_broadcast_change="true" %}
{% money_input_field name="post_secondary_expenses" id="post_secondary_expenses_month" class="fact-sheet-input extraordinary-expense-monthly" data_mirror_on_pressed="true" data_mirror_target="#post_secondary_expenses_year" data_mirror_scale="year_up" data_mirror_broadcast_change="true" %}
</div> </div>
</td> </td>
<td class="fact-sheet-answer"> <td class="fact-sheet-answer">
@ -530,7 +530,7 @@
</td> </td>
<td class="fact-sheet-answer"> <td class="fact-sheet-answer">
<div class="dollar-prefix"> <div class="dollar-prefix">
{% money_input_field name="extraordinary_extracurricular_expenses" id="extraordinary_extracurricular_expenses_month" class="fact-sheet-input money extraordinary-expense-monthly" data_mirror_on_pressed="true" data_mirror_target="#extraordinary_extracurricular_expenses_year" data_mirror_scale="year_up" scale_to_monthly="true" data_mirror_broadcast_change="true" %}
{% money_input_field name="extraordinary_extracurricular_expenses" id="extraordinary_extracurricular_expenses_month" class="fact-sheet-input money extraordinary-expense-monthly" data_mirror_on_pressed="true" data_mirror_target="#extraordinary_extracurricular_expenses_year" data_mirror_scale="year_up" data_mirror_broadcast_change="true" %}
</div> </div>
</td> </td>
<td class="fact-sheet-answer"> <td class="fact-sheet-answer">
@ -544,7 +544,7 @@
<td class="fact-sheet-question"><strong>Total section 7 expenses</strong></td> <td class="fact-sheet-question"><strong>Total section 7 expenses</strong></td>
<td class="fact-sheet-answer" readonly> <td class="fact-sheet-answer" readonly>
<div class="dollar-prefix"> <div class="dollar-prefix">
{% money_input_field name="total_section_seven_expenses" id="total_extraordinary_expense_monthly" class="fact-sheet-input money " readonly="" scale_to_monthly="true" %}
{% money_input_field name="total_section_seven_expenses" id="total_extraordinary_expense_monthly" class="fact-sheet-input money " readonly="" %}
</div> </div>
</td> </td>


+ 1
- 4
edivorce/apps/core/templatetags/input_field.py View File

@ -1,5 +1,4 @@
from datetime import datetime from datetime import datetime
from decimal import Decimal, ROUND_HALF_UP
import json import json
from django import template from django import template
@ -10,7 +9,7 @@ register = template.Library()
@register.simple_tag(takes_context=True) @register.simple_tag(takes_context=True)
def money_input_field(context, input_type='number', name='', value_src=None, value='', scale_factor=None, scale_to_monthly=None, **kwargs):
def money_input_field(context, input_type='number', name='', value_src=None, value='', scale_factor=None, **kwargs):
""" """
:param context: :param context:
@ -32,8 +31,6 @@ def money_input_field(context, input_type='number', name='', value_src=None, val
if scale_factor: if scale_factor:
value = float(value) * float(scale_factor) value = float(value) * float(scale_factor)
if scale_to_monthly:
value = Decimal(float(value) / 12).quantize(Decimal('.01'), rounding=ROUND_HALF_UP)
step = '0.01' step = '0.01'
if kwargs.get('step', None): if kwargs.get('step', None):


Loading…
Cancel
Save