From 66d1228b768b7a47a37da682bd004942014101c5 Mon Sep 17 00:00:00 2001 From: Benard Ebinu Date: Tue, 13 Feb 2018 14:17:46 -0800 Subject: [PATCH] DIV-743: Ensure section 7 amounts match in wizard and pdf forms --- edivorce/apps/core/static/js/main.js | 7 ++++--- edivorce/apps/core/utils/derived.py | 17 +++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js index 242a3966..f5d795b2 100755 --- a/edivorce/apps/core/static/js/main.js +++ b/edivorce/apps/core/static/js/main.js @@ -98,13 +98,16 @@ $(function () { // 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)); + targetElement.val(Math.round(fraction(claimantOne, claimantTwo) * 1000) / 10); + targetElement.change(); }; var self = $(this); var claimantOneElement = $($(this).attr('data-claimant_one_selector')); var claimantTwoElement = $($(this).attr('data-claimant_two_selector')); + self.on('change', ajaxOnChange); + // Calculate and populate the field on initialization of page. calcPercentage(self, claimantOneElement.val(), claimantTwoElement.val()); @@ -112,11 +115,9 @@ $(function () { // selectors. claimantOneElement.on('change', function() { calcPercentage(self, claimantOneElement.val(), claimantTwoElement.val()); - self.trigger('change'); }); claimantTwoElement.on('change', function() { calcPercentage(self, claimantOneElement.val(), claimantTwoElement.val()); - self.trigger('change'); }); }); diff --git a/edivorce/apps/core/utils/derived.py b/edivorce/apps/core/utils/derived.py index 4405ad68..0c337b4e 100644 --- a/edivorce/apps/core/utils/derived.py +++ b/edivorce/apps/core/utils/derived.py @@ -336,13 +336,11 @@ def claimant_1_share_proportion(responses, derived): """ try: - income = float(responses.get('annual_gross_income', 0)) + share = float(responses.get('your_proportionate_share_percent', 0)) 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): @@ -361,9 +359,12 @@ def claimant_2_share_proportion(responses, derived): 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):