-
-
Save guipdutra/f682e0c9572e85662e07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| commit 3501c0d5b6937ade2adc43e2c3997ccc9c280743 | |
| Author: Guilherme Dutra <[email protected]> | |
| Date: Wed Jul 2 09:51:19 2014 -0300 | |
| 22568 - Add iss_value to underwriting alerts | |
| diff --git a/lib/to_mongo/updaters/underwriting_divergence_updater.rb b/lib/to_mongo/updaters/underwriting_divergence_updater.rb | |
| index 9acb948..1ee77fb 100755 | |
| --- a/lib/to_mongo/updaters/underwriting_divergence_updater.rb | |
| +++ b/lib/to_mongo/updaters/underwriting_divergence_updater.rb | |
| @@ -35,10 +35,10 @@ class UnderwritingDivergenceUpdater < Updater | |
| no_movement_flag: has_flag(c['value']['no_movement']), | |
| no_retention_flag: has_flag(c['value']['no_retention']), | |
| non_rps_conversion_flag: has_flag(c['value']['non_rps_conversion']), | |
| - non_consistent_uw: { flag: c['value']['non_consistent_alert']['flag'], value: c['value']['non_consistent_alert']['value'], count: c['value']['non_consistent_alert']['count'] }, | |
| - non_taxed_uw: { flag: c['value']['non_taxed_uw_alert']['flag'], value: c['value']['non_taxed_uw_alert']['value'], count: c['value']['non_taxed_uw_alert']['count'] }, | |
| - non_retained_uw: { flag: c['value']['non_retained_uw_alert']['flag'], value: c['value']['non_retained_uw_alert']['value'], count: c['value']['non_retained_uw_alert']['count'] }, | |
| - national_simple_uw: { flag: c['value']['national_simple_uw_alert']['flag'], value: c['value']['national_simple_uw_alert']['value'], count: c['value']['national_simple_uw_alert']['count'] } | |
| + non_consistent_uw: { flag: c['value']['non_consistent_alert']['flag'], iss_value: c['value']['non_consistent_alert']['iss_value'], value: c['value']['non_consistent_alert']['value'], count: c['value']['non_consistent_alert']['count'] }, | |
| + non_taxed_uw: { flag: c['value']['non_taxed_uw_alert']['flag'], iss_value: c['value']['non_taxed_uw_alert']['iss_value'], value: c['value']['non_taxed_uw_alert']['value'], count: c['value']['non_taxed_uw_alert']['count'] }, | |
| + non_retained_uw: { flag: c['value']['non_retained_uw_alert']['flag'], iss_value: c['value']['non_retained_uw_alert']['iss_value'], value: c['value']['non_retained_uw_alert']['value'], count: c['value']['non_retained_uw_alert']['count'] }, | |
| + national_simple_uw: { flag: c['value']['national_simple_uw_alert']['flag'], iss_value: c['value']['national_simple_uw_alert']['iss_value'], value: c['value']['national_simple_uw_alert']['value'], count: c['value']['national_simple_uw_alert']['count'] } | |
| }} | |
| ) | |
| end | |
| @@ -69,10 +69,10 @@ class UnderwritingDivergenceUpdater < Updater | |
| no_movement_flag: false, | |
| no_retention_flag: false, | |
| non_rps_conversion_flag: false, | |
| - non_consistent_uw: { flag: false, value: 0, count: 0 }, | |
| - non_taxed_uw: { flag: false, value: 0, count: 0 }, | |
| - non_retained_uw: { flag: false, value: 0, count: 0 }, | |
| - national_simple_uw: { flag: false, value: 0, count: 0 } | |
| + non_consistent_uw: { flag: false, iss_value: 0, value: 0, count: 0 }, | |
| + non_taxed_uw: { flag: false, iss_value: 0, value: 0, count: 0 }, | |
| + non_retained_uw: { flag: false, iss_value: 0, value: 0, count: 0 }, | |
| + national_simple_uw: { flag: false, iss_value: 0, value: 0, count: 0 } | |
| }}, | |
| { multi: true } | |
| ) | |
| @@ -96,10 +96,10 @@ class UnderwritingDivergenceUpdater < Updater | |
| issued_rps_values = timetable(); | |
| delayed_rps_values = timetable(); | |
| delayed_rps_values = timetable(); | |
| - non_consistent_alert = { flag: false, value: 0, count: 0 }; | |
| - non_taxed_uw_alert = { flag: false, value: 0, count: 0 }; | |
| - non_retained_uw_alert = { flag: false, value: 0, count: 0 }; | |
| - national_simple_uw_alert = { flag: false, value: 0, count: 0 }; | |
| + non_consistent_alert = { flag: false, iss_value: 0, value: 0, count: 0 }; | |
| + non_taxed_uw_alert = { flag: false, iss_value: 0, value: 0, count: 0 }; | |
| + non_retained_uw_alert = { flag: false, iss_value: 0, value: 0, count: 0 }; | |
| + national_simple_uw_alert = { flag: false, iss_value: 0, value: 0, count: 0 }; | |
| month = this.incidence.getUTCMonth(); | |
| year = this.incidence.getUTCFullYear(); | |
| @@ -122,6 +122,7 @@ class UnderwritingDivergenceUpdater < Updater | |
| if(i == 'last_five_years'){ | |
| non_consistent_alert['flag'] = true; | |
| non_consistent_alert['value'] = this.value; | |
| + non_consistent_alert['iss_value'] = this.iss_value; | |
| non_consistent_alert['count'] = 1; | |
| } | |
| } | |
| @@ -142,6 +143,7 @@ class UnderwritingDivergenceUpdater < Updater | |
| if (i == 'last_five_years' && this.national_simple_uw_flag ) { | |
| national_simple_uw_alert['flag'] = true; | |
| national_simple_uw_alert['value'] = this.value; | |
| + national_simple_uw_alert['iss_value'] = this.iss_value; | |
| national_simple_uw_alert['count'] = 1; | |
| } | |
| if (this.non_taxed_flag && this.overdue_flag){ | |
| @@ -150,6 +152,7 @@ class UnderwritingDivergenceUpdater < Updater | |
| if(i == 'last_five_years'){ | |
| non_taxed_uw_alert['flag'] = true; | |
| non_taxed_uw_alert['value'] = this.value; | |
| + non_taxed_uw_alert['iss_value'] = this.iss_value; | |
| non_taxed_uw_alert['count'] = 1; | |
| } | |
| } | |
| @@ -159,6 +162,7 @@ class UnderwritingDivergenceUpdater < Updater | |
| if(i == 'last_five_years'){ | |
| non_retained_uw_alert['flag'] = true; | |
| non_retained_uw_alert['value'] = this.value; | |
| + non_retained_uw_alert['iss_value'] = this.iss_value; | |
| non_retained_uw_alert['count'] = 1; | |
| } | |
| } | |
| @@ -210,10 +214,10 @@ class UnderwritingDivergenceUpdater < Updater | |
| retained_values = timetable(); | |
| issued_rps_values = timetable(); | |
| delayed_rps_values = timetable(); | |
| - non_consistent_alert = { flag: false, value: 0, count: 0 }; | |
| - non_taxed_uw_alert = { flag: false, value: 0, count: 0 }; | |
| - non_retained_uw_alert = { flag: false, value: 0, count: 0 }; | |
| - national_simple_uw_alert = { flag: false, value: 0, count: 0 }; | |
| + non_consistent_alert = { flag: false, iss_value: 0, value: 0, count: 0 }; | |
| + non_taxed_uw_alert = { flag: false, iss_value: 0, value: 0, count: 0 }; | |
| + non_retained_uw_alert = { flag: false, iss_value: 0, value: 0, count: 0 }; | |
| + national_simple_uw_alert = { flag: false, iss_value: 0, value: 0, count: 0 }; | |
| values.forEach(function(doc) { | |
| for (var i in divergence) { | |
| @@ -234,24 +238,28 @@ class UnderwritingDivergenceUpdater < Updater | |
| non_consistent_alert['flag'] = (non_consistent_alert['flag'] || doc.non_consistent_alert['flag']); | |
| if(doc.non_consistent_alert['flag']) { | |
| non_consistent_alert['value'] += doc.non_consistent_alert['value']; | |
| + non_consistent_alert['iss_value'] += doc.non_consistent_alert['iss_value']; | |
| non_consistent_alert['count'] += doc.non_consistent_alert['count']; | |
| } | |
| non_taxed_uw_alert['flag'] = (non_taxed_uw_alert['flag'] || doc.non_taxed_uw_alert['flag']); | |
| if(doc.non_taxed_uw_alert['flag']) { | |
| non_taxed_uw_alert['value'] += doc.non_taxed_uw_alert['value']; | |
| + non_taxed_uw_alert['iss_value'] += doc.non_taxed_uw_alert['iss_value']; | |
| non_taxed_uw_alert['count'] += doc.non_taxed_uw_alert['count']; | |
| } | |
| non_retained_uw_alert['flag'] = (non_retained_uw_alert['flag'] || doc.non_retained_uw_alert['flag']); | |
| if(doc.non_retained_uw_alert['flag']) { | |
| non_retained_uw_alert['value'] += doc.non_retained_uw_alert['value']; | |
| + non_retained_uw_alert['iss_value'] += doc.non_retained_uw_alert['iss_value']; | |
| non_retained_uw_alert['count'] += doc.non_retained_uw_alert['count']; | |
| } | |
| national_simple_uw_alert['flag'] = (national_simple_uw_alert['flag'] || doc.national_simple_uw_alert['flag']); | |
| if(doc.national_simple_uw_alert['flag']) { | |
| national_simple_uw_alert['value'] += doc.national_simple_uw_alert['value']; | |
| + national_simple_uw_alert['iss_value'] += doc.national_simple_uw_alert['iss_value']; | |
| national_simple_uw_alert['count'] += doc.national_simple_uw_alert['count']; | |
| } | |
| } | |
| diff --git a/lib/to_mongo/updaters/underwriting_pending_updater.rb b/lib/to_mongo/updaters/underwriting_pending_updater.rb | |
| index 65996d3..97868be 100644 | |
| --- a/lib/to_mongo/updaters/underwriting_pending_updater.rb | |
| +++ b/lib/to_mongo/updaters/underwriting_pending_updater.rb | |
| @@ -24,8 +24,8 @@ class UnderwritingPendingUpdater < Updater | |
| { '$set' => { | |
| pending_underwriting: c['value']['pending_underwriting'], | |
| pending_underwriting_flag: has_flag(c['value']['pending_underwriting']), | |
| - non_accepted_underwriting: { flag: c['value']['non_accepted_alert']['flag'], value: c['value']['non_accepted_alert']['value'].to_f, count: c['value']['non_accepted_alert']['count'] }, | |
| - non_accepted_rps_underwriting: { flag: c['value']['non_accepted_rps_alert']['flag'], value: c['value']['non_accepted_rps_alert']['value'].to_f, count: c['value']['non_accepted_rps_alert']['count'] } | |
| + non_accepted_underwriting: { flag: c['value']['non_accepted_alert']['flag'], iss_value: c['value']['non_accepted_alert']['iss_value'].to_f, value: c['value']['non_accepted_alert']['value'].to_f, count: c['value']['non_accepted_alert']['count'] }, | |
| + non_accepted_rps_underwriting: { flag: c['value']['non_accepted_rps_alert']['flag'], iss_value: c['value']['non_accepted_rps_alert']['iss_value'].to_f, value: c['value']['non_accepted_rps_alert']['value'].to_f, count: c['value']['non_accepted_rps_alert']['count'] } | |
| }} | |
| ) | |
| end | |
| @@ -41,8 +41,8 @@ class UnderwritingPendingUpdater < Updater | |
| { '$set' => { | |
| pending_underwriting: { last_five_years: 0, last_year: 0, this_year: 0, last_twelve_months: 0, prev_month: 0, this_month: 0 }, | |
| pending_underwriting_flag: false, | |
| - non_accepted_underwriting: { flag: false, value: 0, count: 0 }, | |
| - non_accepted_rps_underwriting: { flag: false, value: 0, count: 0 } | |
| + non_accepted_underwriting: { flag: false, iss_value: 0, value: 0, count: 0 }, | |
| + non_accepted_rps_underwriting: { flag: false, iss_value: 0, value: 0, count: 0 } | |
| }}, | |
| { multi: true } | |
| ) | |
| @@ -52,8 +52,8 @@ class UnderwritingPendingUpdater < Updater | |
| return <<-EOS | |
| function() { | |
| pending_underwriting = timetable() | |
| - non_accepted_alert = { flag: false, value: 0, count: 0 } | |
| - non_accepted_rps_alert = { flag: false, value: 0, count: 0 } | |
| + non_accepted_alert = { flag: false, iss_value: 0, value: 0, count: 0 } | |
| + non_accepted_rps_alert = { flag: false, iss_value: 0, value: 0, count: 0 } | |
| month = this.incidence.getUTCMonth(); | |
| year = this.incidence.getUTCFullYear(); | |
| @@ -67,11 +67,13 @@ class UnderwritingPendingUpdater < Updater | |
| pending_underwriting[i] = this.value | |
| if(i == 'last_five_years'){ | |
| non_accepted_alert['flag'] = true; | |
| + non_accepted_alert['iss_value'] = this.iss_value; | |
| non_accepted_alert['value'] = this.value; | |
| non_accepted_alert['count'] = 1; | |
| if (this.non_accepted_rps_underwriting_flag) { | |
| non_accepted_rps_alert['flag'] = true; | |
| + non_accepted_rps_alert['iss_value'] = this.iss_value; | |
| non_accepted_rps_alert['value'] = this.value; | |
| non_accepted_rps_alert['count'] = 1; | |
| } | |
| @@ -95,18 +97,20 @@ class UnderwritingPendingUpdater < Updater | |
| return <<-EOS | |
| function(key, values) { | |
| pending_underwriting = timetable() | |
| - non_accepted_alert = { flag: false, value: 0, count: 0 } | |
| - non_accepted_rps_alert = { flag: false, value: 0, count: 0 } | |
| + non_accepted_alert = { flag: false, iss_value: 0, value: 0, count: 0 } | |
| + non_accepted_rps_alert = { flag: false, iss_value: 0, value: 0, count: 0 } | |
| values.forEach(function(doc) { | |
| for (var i in pending_underwriting) { | |
| pending_underwriting[i] += doc.pending_underwriting[i]; | |
| if(i == 'last_five_years'){ | |
| non_accepted_alert['flag'] = (non_accepted_alert['flag'] || doc.non_accepted_alert['flag']); | |
| + non_accepted_alert['iss_value'] += doc.non_accepted_alert['iss_value']; | |
| non_accepted_alert['value'] += doc.non_accepted_alert['value']; | |
| non_accepted_alert['count'] += doc.non_accepted_alert['count']; | |
| non_accepted_rps_alert['flag'] = (non_accepted_rps_alert['flag'] || doc.non_accepted_rps_alert['flag']); | |
| + non_accepted_rps_alert['iss_value'] += doc.non_accepted_rps_alert['iss_value']; | |
| non_accepted_rps_alert['value'] += doc.non_accepted_rps_alert['value']; | |
| non_accepted_rps_alert['count'] += doc.non_accepted_rps_alert['count']; | |
| } | |
| diff --git a/test/updaters/underwriting_divergence_updater_test.rb b/test/updaters/underwriting_divergence_updater_test.rb | |
| index 0df5d8f..f7b6765 100644 | |
| --- a/test/updaters/underwriting_divergence_updater_test.rb | |
| +++ b/test/updaters/underwriting_divergence_updater_test.rb | |
| @@ -19,6 +19,7 @@ class UnderwritingDivergenceUpdaterTest < UpdaterTestCase | |
| mongo_doc = DB['taxpayer_ccms'].find_one(taxpayer_id: 1) | |
| assert mongo_doc['non_taxed_uw']['flag'] | |
| assert_equal 70000.0, mongo_doc['non_taxed_uw']['value'] | |
| + assert_equal 50.0, mongo_doc['non_taxed_uw']['iss_value'] | |
| assert_equal 1, mongo_doc['non_taxed_uw']['count'] | |
| end | |
| @@ -35,10 +36,12 @@ class UnderwritingDivergenceUpdaterTest < UpdaterTestCase | |
| assert mongo_doc['non_taxed_uw']['flag'] | |
| assert_equal 80000.0, mongo_doc['non_taxed_uw']['value'] | |
| + assert_equal 100.0, mongo_doc['non_taxed_uw']['iss_value'] | |
| assert_equal 2, mongo_doc['non_taxed_uw']['count'] | |
| assert mongo_doc['non_retained_uw']['flag'] | |
| assert_equal 500.0, mongo_doc['non_retained_uw']['value'] | |
| + assert_equal 50.0, mongo_doc['non_retained_uw']['iss_value'] | |
| assert_equal 1, mongo_doc['non_retained_uw']['count'] | |
| end | |
| @@ -47,10 +50,12 @@ class UnderwritingDivergenceUpdaterTest < UpdaterTestCase | |
| assert !mongo_doc['non_taxed_uw']['flag'] | |
| assert_equal 0, mongo_doc['non_taxed_uw']['value'] | |
| + assert_equal 0, mongo_doc['non_taxed_uw']['iss_value'] | |
| assert_equal 0, mongo_doc['non_taxed_uw']['count'] | |
| assert !mongo_doc['non_retained_uw']['flag'] | |
| assert_equal 0, mongo_doc['non_retained_uw']['value'] | |
| + assert_equal 0, mongo_doc['non_retained_uw']['iss_value'] | |
| assert_equal 0, mongo_doc['non_retained_uw']['count'] | |
| end | |
| @@ -100,11 +105,13 @@ class UnderwritingDivergenceUpdaterTest < UpdaterTestCase | |
| mongo_doc = DB["taxpayer_ccms"].find_one(taxpayer_id: 1) | |
| assert mongo_doc["national_simple_uw"]["flag"] | |
| assert_equal 10000, mongo_doc["national_simple_uw"]["value"] | |
| + assert_equal 50.0, mongo_doc["national_simple_uw"]["iss_value"] | |
| assert_equal 1, mongo_doc["national_simple_uw"]["count"] | |
| mongo_doc = DB["taxpayer_ccms"].find_one(taxpayer_id: 6) | |
| assert !mongo_doc["national_simple_uw"]["flag"] | |
| assert_equal 0, mongo_doc["national_simple_uw"]["value"] | |
| + assert_equal 0, mongo_doc["national_simple_uw"]["iss_value"] | |
| assert_equal 0, mongo_doc["national_simple_uw"]["count"] | |
| end | |
| end | |
| diff --git a/test/updaters/underwriting_pending_updater_test.rb b/test/updaters/underwriting_pending_updater_test.rb | |
| index 6f8539f..69c750f 100644 | |
| --- a/test/updaters/underwriting_pending_updater_test.rb | |
| +++ b/test/updaters/underwriting_pending_updater_test.rb | |
| @@ -12,6 +12,7 @@ class UnderwritingPendingUpdaterTest < UpdaterTestCase | |
| assert mongo_doc['non_accepted_underwriting']['flag'] | |
| assert_equal 1, mongo_doc['non_accepted_underwriting']['count'] | |
| + assert_equal 5.55, mongo_doc['non_accepted_underwriting']['iss_value'] | |
| assert_equal 1.11, mongo_doc['non_accepted_underwriting']['value'] | |
| end | |
| @@ -21,4 +22,4 @@ class UnderwritingPendingUpdaterTest < UpdaterTestCase | |
| assert !mongo_doc.has_key?('non_accepted_underwriting') | |
| end | |
| -end | |
| \ No newline at end of file | |
| +end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment