diff --git a/edivorce/apps/core/static/js/functions.js b/edivorce/apps/core/static/js/functions.js index 4184936c..ae9ef533 100644 --- a/edivorce/apps/core/static/js/functions.js +++ b/edivorce/apps/core/static/js/functions.js @@ -113,29 +113,28 @@ var showHideRevealClass = function(el, target_css_class) { } }; -// Controls Checkbox behaviour for children_financial_support -// If No is checked, un-check all Yes checkboxes -// If Yes is checked, un-check No checkbox -// Once checkbox is checked, always at least one box will be checked -var childSupportCheckboxControl = function(el) { +// Controls Checkbox behaviour for a checkbox group. +// If a checkbox with the data-checkbox_radio_state_set=false is checked, un-check all checkboxes with +// data-checkbox_radio_state_set=true. +// If a checkbox with the data-checkbox_radio_state_set=true is checked, un-check all checkboxes with +// data-checkbox_radio_state_set=false. +// Once a checkbox is checked, at least one box will always be checked. +// data-checkbox_radio=[true|false] - specifies which check boxes are part of of checkbox radio control +// data-checkbox_radio_state_set=[true|false] - specifies whether part of the negative or positive checkbox +// radio state. When an check box in the negative state is checked +// all checkboxes in the opposite state will be unchecked. Visa versa. +var checkboxRadioControl = function(el) { var boxName = el.prop("name"); - // Make sure at least one box is checked - if ($(".checkbox-group").find("input[type=checkbox]:checked").length === 0){ + if (el.closest('.checkbox-group').find("input[type=checkbox]:checked").length === 0){ el.prop('checked', true); - } - else { - if (el.val() === "NO") { - $("input[name=" + boxName + "]").each(function () { - if ($(this).val() !== "NO") { - $(this).prop('checked', false); - } + } else { + if (el.attr('data-checkbox_radio_state_set') === "false") { + $("input[name=" + boxName + "]").filter('[data-checkbox_radio_state_set="true"]').each(function () { + $(this).prop('checked', false); }); - } - else { - $("input[name=" + boxName + "]").each(function () { - if ($(this).val() === "NO") { - $(this).prop('checked', false); - } + } else { + $("input[name=" + boxName + "]").filter('[data-checkbox_radio_state_set="false"]').each(function () { + $(this).prop('checked', false); }); } } @@ -171,9 +170,8 @@ var getValue = function(el, question){ var value = []; // if checkbox, get list of values. if (el.is("input[type=checkbox]")){ - // special behaviour for question children_financial_support - if (question === "children_financial_support"){ - childSupportCheckboxControl(el); + if (el.attr('data-checkbox_radio') === "true") { + checkboxRadioControl(el); } el.parents(".checkbox-group").find("input[type=checkbox]:checked").each(function(){ value.push($(this).val()); diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js index df6715fd..7dda4bb5 100755 --- a/edivorce/apps/core/static/js/main.js +++ b/edivorce/apps/core/static/js/main.js @@ -59,6 +59,64 @@ $(function () { // be persisted to the server. $('[data-save_row="true"]').on('change', saveListControlRow); + + var fraction = function(part1, part2) { + part1 = parseFloat(part1); + part2 = parseFloat(part2); + if (part1 + part2 === 0) { + return 0; + } else { + return part1 / (part1 + part2); + } + }; + + // Calculates the proportionate percentage of claimantOne to the sum of claimantOne + // and claimantTwo. The result is a value between [0,100] inclusive. + var calcPercentage = function(targetElement, claimantOne, claimantTwo) { + targetElement.val(Math.round(fraction(claimantOne, claimantTwo) * 100)); + }; + + // Calculates the proportionate amount of claimantOne to the sum of claimantOne + // and claimantTwo. The result is a value between [0,claimantOne] inclusive. + var calcPercentageAmount = function (targetElement, claimantOne, claimantTwo) { + var amount = parseFloat(claimantOne) * fraction(claimantOne, claimantTwo); + targetElement.val(amount.toFixed(2)); + }; + + // We want a way to dynamically calculate what proportion a given number is + // relative to the sum of that number with another number. Our specific use + // case is calculating the proportion of a given claimant's child support + // payment relative to their spouse. We calculate these proportions based off + // of each claimant's income. + // data-calc_percentage=[true|false] - whether to compute amount between [0,100] inclusive. + // data-calc_proportions=[true|false] - whether to compute amount between [0, value at data-claimant_one_selector] + // data-claimant_one_selector=[any jQuery input selector] - the input field that will contain claimant one + // income information. When the value in this input field changes the + // proportionate amounts will automatically get recalculated. + // data-claimant_two_selector=[any jQuery input selector] - the input field that will contain claimant two + // income information. + $('[data-calc_percentage="true"], [data-calc_proportions="true"]').each(function() { + var self = $(this); + var claimantOneElement = $($(this).attr('data-claimant_one_selector')); + var claimantTwoElement = $($(this).attr('data-claimant_two_selector')); + var calcFunction = calcPercentage; + if ($(this).attr('data-calc_proportions') !== undefined) { + calcFunction = calcPercentageAmount; + } + + // Calculate and populate the field on initialization of page. + calcFunction(self, claimantOneElement.val(), claimantTwoElement.val()); + + // Calculate and populate the fields whenever there is a change in the input + // selectors. + claimantOneElement.on('change', function() { + calcFunction(self, claimantOneElement.val(), claimantTwoElement.val()); + }); + claimantTwoElement.on('change', function() { + calcFunction(self, claimantOneElement.val(), claimantTwoElement.val()); + }); + }); + // Only close Terms and Conditions when user check the I agree checkbox $('#terms_agree_button').on('click', function() { $('#terms_warning').remove(); diff --git a/edivorce/apps/core/templates/prequalification/step_04.html b/edivorce/apps/core/templates/prequalification/step_04.html index 39cf7054..80e4aa40 100644 --- a/edivorce/apps/core/templates/prequalification/step_04.html +++ b/edivorce/apps/core/templates/prequalification/step_04.html @@ -207,11 +207,11 @@ years or older?
Please check all that apply.
You're asking the court for any order related to the children. This diff --git a/edivorce/apps/core/templates/question/06_children_income_expenses.html b/edivorce/apps/core/templates/question/06_children_income_expenses.html index 817897b7..c734d0b7 100644 --- a/edivorce/apps/core/templates/question/06_children_income_expenses.html +++ b/edivorce/apps/core/templates/question/06_children_income_expenses.html @@ -836,6 +836,275 @@ +
+ Health-related expenses that exceed insurance reimbursement by at least $100 per year, including + orthodontic + treatments, counseling, physiotherapy, occupational therapy, speech therapy, hearing therapy, + prescription + drugs, hearing aids, glasses, and contact lenses +
++ Expenses for post-secondary education, tutoring, private school (if the child was attending private + school + before the separation and the parents can afford the expense +
++ Expenses for activities in which the child excels and is shown to be particularly gifted (for example, + expenses for a child who is a gifted figure skater, but not expenses for general skating lessons) +
+| + | Monthly | +Annually | +
|---|---|---|
| Child care expenses for when the recipient works or goes to school + | +
+
+ {% money_input_field name="child_care_expenses" id="child_care_expenses_month" class="fact-sheet-input money extraordinary-expense-monthly" data_sum="true" data_sum_class="extraordinary-expense-monthly" data_sum_target_id="total_extraordinary_expense_monthly" data_mirror="true" data_mirror_target="#child_care_expenses_year" data_mirror_scale="year_up" %}
+
+ |
+
+
+ {% money_input_field value_src="child_care_expenses" id="child_care_expenses_year" class="fact-sheet-input money extraordinary_expense_annually" scale_factor="12" data_mirror="true" data_mirror_target_id="child_care_expenses_month" data_mirror_scale="month_down" data_mirror_broadcast_change="true" %}
+
+ |
+
| Any healthcare premiums you pay to your employer or other provider + to provide the coverage to your children rather than yourself + | +
+
+ {% money_input_field name="children_healthcare_premiums" id="children_healthcare_premiums_month" class="fact-sheet-input money extraordinary-expense-monthly" data_sum="true" data_sum_class="extraordinary-expense-monthly" data_sum_target_id="total_extraordinary_expense_monthly" data_mirror="true" data_mirror_target="#children_healthcare_premiums_year" data_mirror_scale="year_up" %}
+
+ |
+
+
+ {% money_input_field value_src="children_healthcare_premiums" id="children_healthcare_premiums_year" class="fact-sheet-input money extraordinary_expense_annually" scale_factor="12" data_mirror="true" data_mirror_target="#children_healthcare_premiums_month" data_mirror_scale="month_down" data_mirror_broadcast_change="true" %}
+
+ |
+
| + + Health related expenses + + that exceed insurance reimbursement by at least $100 + | +
+
+ {% money_input_field name="health_related_expenses" id="health_related_expenses_month" class="fact-sheet-input money extraordinary-expense-monthly" data_sum="true" data_sum_class="extraordinary-expense-monthly" data_sum_target_id="total_extraordinary_expense_monthly" data_mirror="true" data_mirror_target="#health_related_expenses_year" data_mirror_scale="year_up" %}
+
+ |
+
+
+ {% money_input_field value_src="health_related_expenses" id="health_related_expenses_year" class="fact-sheet-input money extraordinary_expense_annually" scale_factor="12" data_mirror="true" data_mirror_target="#health_related_expenses_month" data_mirror_scale="month_down" data_mirror_broadcast_change="true" %}
+
+ |
+
| + Extraordinary primary, secondary or other + + educational expenses + + | +
+
+ {% money_input_field name="extraordinary_educational_expenses" id="extraordinary_educational_expenses_month" class="fact-sheet-input money extraordinary-expense-monthly" data_sum="true" data_sum_class="extraordinary-expense-monthly" data_sum_target_id="total_extraordinary_expense_monthly" data_mirror="true" data_mirror_target="#extraordinary_educational_expenses_year" data_mirror_scale="year_up" %}
+
+ |
+
+
+ {% money_input_field value_src="extraordinary_educational_expenses" id="extraordinary_educational_expenses_year" class="fact-sheet-input money extraordinary_expense_annually" scale_factor="12" data_mirror="true" data_mirror_target="#extraordinary_educational_expenses_month" data_mirror_scale="month_down" data_mirror_broadcast_change="true" %}
+
+ |
+
| Post-secondary school expenses | +
+
+ {% money_input_field name="post_secondary_expenses" id="post_secondary_expenses_month" class="fact-sheet-input extraordinary-expense-monthly" data_sum="true" data_sum_class="extraordinary-expense-monthly" data_sum_target_id="total_extraordinary_expense_monthly" data_mirror="true" data_mirror_target="#post_secondary_expenses_year" data_mirror_scale="year_up" %}
+
+ |
+
+
+ {% money_input_field value_src="post_secondary_expenses" id="post_secondary_expenses_year" class="fact-sheet-input money extraordinary_expense_annually" scale_factor="12" data_mirror="true" data_mirror_target="#post_secondary_expenses_month" data_mirror_scale="month_down" data_mirror_broadcast_change="true" %}
+
+ |
+
| Extraordinary + + extracurricular activities + + + expenses + | +
+
+ {% money_input_field name="extraordinary_extracurricular_expenses" id="extraordinary_extracurricular_expenses_month" class="fact-sheet-input money extraordinary-expense-monthly" data_sum="true" data_sum_class="extraordinary-expense-monthly" data_sum_target_id="total_extraordinary_expense_monthly" data_mirror="true" data_mirror_target="#extraordinary_extracurricular_expenses_year" data_mirror_scale="year_up" %}
+
+ |
+
+
+ {% money_input_field value_src="extraordinary_extracurricular_expenses" id="extraordinary_extracurricular_expenses_year" class="fact-sheet-input money extraordinary_expense_annually" scale_factor="12" data_mirror="true" data_mirror_target="#extraordinary_extracurricular_expenses_month" data_mirror_scale="month_down" data_mirror_broadcast_change="true" %}
+
+ |
+
| Total section 7 expenses | +
+
+ {% money_input_field name="total_section_seven_expenses" id="total_extraordinary_expense_monthly" class="fact-sheet-input money " readonly="" data_mirror="true" data_mirror_target="#total_extraordinary_expense_annually" data_mirror_scale="year_up" %}
+
+ |
+
+
+
+ {% money_input_field value_src="total_section_seven_expenses" id="total_extraordinary_expense_annually" class="fact-sheet-input money " scale_factor="12" readonly="" %}
+
+ |
+
Parties respective + + proportionate shares + + + of the total net monthly Section 7 expenses referred to above:
+| + | Percentage | +Amount | +
|---|---|---|
| Your proportionate share | ++ {% input_field type="number" name="your_proportionate_share_percent" value="0" readonly="" id="your_proportionate_share_percent" class="fact-sheet-input" data_calc_percentage="true" data_claimant_one_selector="input[name='annual_gross_income']" data_claimant_two_selector="input[name='spouse_annual_gross_income']" %} + | +
+
+ {% money_input_field name="your_proportionate_share_amount" id="your_proportionate_share_amount" class="fact-sheet-input money" data_calc_proportions="true" data_claimant_one_selector="input[name='annual_gross_income']" data_claimant_two_selector="input[name='spouse_annual_gross_income']" readonly="" %}
+
+ |
+
| Spouse's proportionate share | ++ {% input_field type="number" name="spouse_proportionate_share_percent" value="0" readonly="" id="spouse_proportionate_share_percent" class="fact-sheet-input" data_calc_percentage="true" data_claimant_one_selector="input[name='spouse_annual_gross_income']" data_claimant_two_selector="input[name='annual_gross_income']" %} + | +
+
+ {% money_input_field name="spouse_proportionate_share_amount" id="spouse_proportionate_share_amount" class="fact-sheet-input money" data_calc_proportions="true" data_claimant_one_selector="input[name='spouse_annual_gross_income']" data_claimant_two_selector="input[name='annual_gross_income']" readonly="" %}
+
+ |
+
Total monthly child support payment amount + Including the monthly Guidelines table amount under Schedule 1 of the Guidelines and the section 7 + expenses is: + +
+