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 @@ +

+

+ Are there any + + special and extraordinary expenses + ? +

+
+
+ +
+
+ +
+
+ +
+

+ 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) +

+
+ + +
{% endblock %} diff --git a/edivorce/apps/core/templatetags/format_utils.py b/edivorce/apps/core/templatetags/format_utils.py index 2fc63a27..296aa12d 100644 --- a/edivorce/apps/core/templatetags/format_utils.py +++ b/edivorce/apps/core/templatetags/format_utils.py @@ -23,6 +23,7 @@ def date_formatter(value): d = datetime.strptime(value, '%d/%m/%Y') return d.strftime('%d %b %Y') + @register.simple_tag() def required(field, size=None, trail=''): """ Return the required field value or the not-entered span """ diff --git a/edivorce/fixtures/Question.json b/edivorce/fixtures/Question.json index 86d8aa38..fdd848be 100644 --- a/edivorce/fixtures/Question.json +++ b/edivorce/fixtures/Question.json @@ -1172,5 +1172,147 @@ }, "model": "core.question", "pk": "income_others" +}, +{ + "fields": { + "name": "Are there any special and extraordinary expenses?", + "description": "For Step 6, Your children - Income & expenses", + "summary_order": 0, + "required": "Required" + }, + "model": "core.question", + "pk": "special_extraordinary_expenses" +}, +{ + "fields": { + "name": "Child care expenses for when the recipient works or goes to school", + "description": "For Step 6, Your children - Income & expenses - Spouse Fact Sheet F", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "special_extraordinary_expenses", + "reveal_response": "Children's Child Care|Medical|Education|Extraordinary extracurricular activity expenses" + }, + "model": "core.question", + "pk": "child_care_expenses" +}, +{ + "fields": { + "name": "Any healthcare premiums you pay to your employer or other provider to provide the coverage to your children rather than yourself", + "description": "For Step 6, Your children - Income & expenses - Spouse Fact Sheet F", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "special_extraordinary_expenses", + "reveal_response": "Children's Child Care|Medical|Education|Extraordinary extracurricular activity expenses" + }, + "model": "core.question", + "pk": "children_healthcare_premiums" +}, +{ + "fields": { + "name": "Health related expenses that exceed insurance reimbursement by at least $100", + "description": "For Step 6, Your children - Income & expenses - Spouse Fact Sheet F", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "special_extraordinary_expenses", + "reveal_response": "Children's Child Care|Medical|Education|Extraordinary extracurricular activity expenses" + }, + "model": "core.question", + "pk": "health_related_expenses" +}, +{ + "fields": { + "name": "Extraordinary primary, secondary or other educational expenses", + "description": "For Step 6, Your children - Income & expenses - Spouse Fact Sheet F", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "special_extraordinary_expenses", + "reveal_response": "Children's Child Care|Medical|Education|Extraordinary extracurricular activity expenses" + }, + "model": "core.question", + "pk": "extraordinary_educational_expenses" +}, +{ + "fields": { + "name": "Post-secondary school expenses", + "description": "For Step 6, Your children - Income & expenses - Spouse Fact Sheet F", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "special_extraordinary_expenses", + "reveal_response": "Children's Child Care|Medical|Education|Extraordinary extracurricular activity expenses" + }, + "model": "core.question", + "pk": "post_secondary_expenses" +}, +{ + "fields": { + "name": "Extraordinary extracurricular activities expenses", + "description": "For Step 6, Your children - Income & expenses - Spouse Fact Sheet F", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "special_extraordinary_expenses", + "reveal_response": "Children's Child Care|Medical|Education|Extraordinary extracurricular activity expenses" + }, + "model": "core.question", + "pk": "extraordinary_extracurricular_expenses" +}, +{ + "fields": { + "name": "Total section 7 expenses", + "description": "For Step 6, Your children - Income & expenses - Spouse Fact Sheet F", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "special_extraordinary_expenses", + "reveal_response": "Children's Child Care|Medical|Education|Extraordinary extracurricular activity expenses" + }, + "model": "core.question", + "pk": "total_section_seven_expenses" +}, +{ + "fields": { + "name": "Your proportionate share", + "description": "For Step 6, Your children - Income & expenses - Spouse Fact Sheet F", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "special_extraordinary_expenses", + "reveal_response": "Children's Child Care|Medical|Education|Extraordinary extracurricular activity expenses" + }, + "model": "core.question", + "pk": "your_proportionate_share_percent" +}, +{ + "fields": { + "name": "Your proportionate share", + "description": "For Step 6, Your children - Income & expenses - Spouse Fact Sheet F", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "special_extraordinary_expenses", + "reveal_response": "Children's Child Care|Medical|Education|Extraordinary extracurricular activity expenses" + }, + "model": "core.question", + "pk": "your_proportionate_share_amount" +}, +{ + "fields": { + "name": "Spouse's proportionate share", + "description": "For Step 6, Your children - Income & expenses - Spouse Fact Sheet F", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "special_extraordinary_expenses", + "reveal_response": "Children's Child Care|Medical|Education|Extraordinary extracurricular activity expenses" + }, + "model": "core.question", + "pk": "spouse_proportionate_share_percent" +}, +{ + "fields": { + "name": "Spouse's proportionate share", + "description": "For Step 6, Your children - Income & expenses - Spouse Fact Sheet F", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "special_extraordinary_expenses", + "reveal_response": "Children's Child Care|Medical|Education|Extraordinary extracurricular activity expenses" + }, + "model": "core.question", + "pk": "spouse_proportionate_share_amount" } ]