Browse Source

DIV-743: Ensure section 7 amounts match in wizard and pdf forms

pull/160/head
Benard Ebinu 7 years ago
parent
commit
66d1228b76
2 changed files with 13 additions and 11 deletions
  1. +4
    -3
      edivorce/apps/core/static/js/main.js
  2. +9
    -8
      edivorce/apps/core/utils/derived.py

+ 4
- 3
edivorce/apps/core/static/js/main.js View File

@ -98,13 +98,16 @@ $(function () {
// Calculates the proportionate percentage of claimantOne to the sum of claimantOne // Calculates the proportionate percentage of claimantOne to the sum of claimantOne
// and claimantTwo. The result is a value between [0,100] inclusive. // and claimantTwo. The result is a value between [0,100] inclusive.
var calcPercentage = function(targetElement, claimantOne, claimantTwo) { var calcPercentage = function(targetElement, claimantOne, claimantTwo) {
targetElement.val(Math.round(fraction(claimantOne, claimantTwo) * 100));
targetElement.val(Math.round(fraction(claimantOne, claimantTwo) * 1000) / 10);
targetElement.change();
}; };
var self = $(this); var self = $(this);
var claimantOneElement = $($(this).attr('data-claimant_one_selector')); var claimantOneElement = $($(this).attr('data-claimant_one_selector'));
var claimantTwoElement = $($(this).attr('data-claimant_two_selector')); var claimantTwoElement = $($(this).attr('data-claimant_two_selector'));
self.on('change', ajaxOnChange);
// Calculate and populate the field on initialization of page. // Calculate and populate the field on initialization of page.
calcPercentage(self, claimantOneElement.val(), claimantTwoElement.val()); calcPercentage(self, claimantOneElement.val(), claimantTwoElement.val());
@ -112,11 +115,9 @@ $(function () {
// selectors. // selectors.
claimantOneElement.on('change', function() { claimantOneElement.on('change', function() {
calcPercentage(self, claimantOneElement.val(), claimantTwoElement.val()); calcPercentage(self, claimantOneElement.val(), claimantTwoElement.val());
self.trigger('change');
}); });
claimantTwoElement.on('change', function() { claimantTwoElement.on('change', function() {
calcPercentage(self, claimantOneElement.val(), claimantTwoElement.val()); calcPercentage(self, claimantOneElement.val(), claimantTwoElement.val());
self.trigger('change');
}); });
}); });


+ 9
- 8
edivorce/apps/core/utils/derived.py View File

@ -336,13 +336,11 @@ def claimant_1_share_proportion(responses, derived):
""" """
try: try:
income = float(responses.get('annual_gross_income', 0))
share = float(responses.get('your_proportionate_share_percent', 0))
except ValueError: except ValueError:
income = 0
share = 0
if derived['total_gross_income'] == 0:
return 0
return income / derived['total_gross_income'] * 1000 // 1 / 10
return share
def claimant_1_share(responses, derived): def claimant_1_share(responses, derived):
@ -361,9 +359,12 @@ def claimant_2_share_proportion(responses, derived):
annual income. annual income.
""" """
if derived['total_gross_income'] == 0:
return 0
return 100 - derived['claimant_1_share_proportion'] * 10 // 1 / 10
try:
share = float(responses.get('spouse_proportionate_share_percent', 0))
except ValueError:
share = 0
return share
def claimant_2_share(responses, derived): def claimant_2_share(responses, derived):


Loading…
Cancel
Save