stand_socotra_policy_transformer 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/__tests__/__utils__/load_payload.js +16 -0
  2. package/__tests__/__utils__/payloads/minimal_change_base.json +574 -0
  3. package/__tests__/__utils__/payloads/minimal_change_base2.json +574 -0
  4. package/__tests__/__utils__/payloads/minimal_change_resulting_socotra.json +17 -0
  5. package/__tests__/__utils__/payloads/minimal_change_resulting_socotra2.json +27 -0
  6. package/__tests__/__utils__/payloads/minimal_change_retool.json +37 -0
  7. package/__tests__/__utils__/payloads/minimal_change_retool2.json +27 -0
  8. package/__tests__/__utils__/payloads/sample_minimal_retool.json +33 -0
  9. package/__tests__/__utils__/payloads/sample_minimal_socotra_payload.json +116 -0
  10. package/__tests__/__utils__/payloads/sample_new_policy_holder.json +17 -0
  11. package/__tests__/__utils__/payloads/sample_new_quote.json +210 -0
  12. package/__tests__/__utils__/payloads/sample_new_quote_retool.json +93 -0
  13. package/__tests__/__utils__/payloads/sample_retool.json +160 -0
  14. package/__tests__/__utils__/payloads/sample_retool_converted_quote.json +54 -0
  15. package/__tests__/__utils__/payloads/sample_retool_socotra_subset.json +127 -0
  16. package/__tests__/__utils__/payloads/sample_socotra_quote.json +773 -0
  17. package/__tests__/__utils__/payloads/sample_update_quote.json +18 -0
  18. package/__tests__/basic_knockout.test.js +113 -0
  19. package/__tests__/claims_history_knockout.test.js +56 -0
  20. package/__tests__/exterior_knockout.test.js +192 -0
  21. package/__tests__/helpers/index.js +10 -0
  22. package/__tests__/home_owner_knockouts.js +260 -0
  23. package/__tests__/interior_knockout.test.js +321 -0
  24. package/__tests__/rate_call_knockouts.test.js +347 -0
  25. package/__tests__/retool_utils/socotra_payload.test.js +168 -0
  26. package/__tests__/retool_utils/socotra_structure_helper.test.js +129 -0
  27. package/__tests__/underwriter.test.js +169 -0
  28. package/__tests__/wf_knockout.test.js +124 -0
  29. package/package.json +17 -0
  30. package/src/index.js +3 -0
  31. package/src/knockouts/basic_knockouts.js +66 -0
  32. package/src/knockouts/claims_history_knockout.js +24 -0
  33. package/src/knockouts/exterior_knockouts.js +97 -0
  34. package/src/knockouts/home_owner_knockouts.js +118 -0
  35. package/src/knockouts/index.js +83 -0
  36. package/src/knockouts/interior_knockouts.js +149 -0
  37. package/src/knockouts/rate_call_knockouts.js +155 -0
  38. package/src/knockouts/wf_knockouts.js +66 -0
  39. package/src/retool_to_socotra.js +18 -0
  40. package/src/retool_utils/socotra_payloads.js +316 -0
  41. package/src/retool_utils/socotra_structure_helper.js +223 -0
  42. package/src/underwriter.js +86 -0
  43. package/webpack.config.js +25 -0
@@ -0,0 +1,86 @@
1
+ const {
2
+ knockout, knockout_names, same_address, stand_wf_knockout, has_circuit_breaker, has_class_a_roof,
3
+ check_claims_history
4
+ } = require('./knockouts')
5
+ function underwrite(payload, full_check = true){
6
+ // claims
7
+
8
+ let decisions = {}
9
+ let notes = []
10
+ let notes_dict = {}
11
+
12
+ for (let underwriting_function of knockout_names()){
13
+ if (full_check || Object.keys(payload).includes(underwriting_function)) {
14
+ let decision = knockout(underwriting_function, payload[underwriting_function])
15
+ add_decision(decision, underwriting_function, notes, decisions, notes_dict)
16
+ }
17
+ }
18
+
19
+ if (full_check || (('address' in payload)) && ('co_applicant_address' in payload)) {
20
+ let address_result = same_address(payload['address'], payload['co_applicant_address'])
21
+ add_decision(address_result, "co_applicant_address", notes, decisions, notes_dict)
22
+ }
23
+
24
+ let wf_result
25
+ if (full_check || (('wf_score_mean' in payload)) && ('arf' in payload)) {
26
+ wf_result = stand_wf_knockout(payload['wf_score_mean'], payload['arf'])
27
+ add_decision(wf_result.underwriter_result, "wf_score_mean", notes, decisions, notes_dict)
28
+ }
29
+
30
+ if (full_check || (('circuit_breaker' in payload)) && ('year_built' in payload)) {
31
+ let circuit_breaker_result =
32
+ has_circuit_breaker(payload['circuit_breaker'], payload['year_built'])
33
+ add_decision(circuit_breaker_result, 'circuit_breaker', notes, decisions, notes_dict)
34
+ }
35
+
36
+ if (full_check || ('class_a_roof' in payload)) {
37
+ let roof_result =
38
+ has_class_a_roof(payload['class_a_roof'], wf_result.category)
39
+ add_decision(roof_result, 'roof_rating', notes, decisions, notes_dict)
40
+ }
41
+
42
+ if (full_check || ('claims' in payload)) {
43
+ let claims_result = check_claims_history(payload['claims'])
44
+ add_decision(claims_result, 'claims', notes, decisions, notes_dict)
45
+ }
46
+
47
+ return {
48
+ decision: determine_final_result(decisions), notes: notes, refers: collect_refers(decisions),
49
+ all_decisions: decisions, notes_dict: notes_dict
50
+ }
51
+ }
52
+
53
+ function collect_refers(all_decisions){
54
+ let refer_checks = []
55
+ for(let key in all_decisions ){
56
+ if(all_decisions[key] === "refer"){
57
+ refer_checks.push(key)
58
+ }
59
+ }
60
+ return refer_checks
61
+ }
62
+ function determine_final_result(all_decisions){
63
+ for(let key in all_decisions ){
64
+ if(all_decisions[key] === "reject"){
65
+ return "reject"
66
+ }
67
+ }
68
+
69
+ for(let key in all_decisions ){
70
+ if(all_decisions[key] === "refer"){
71
+ return "refer"
72
+ }
73
+ }
74
+
75
+ return "accept"
76
+ }
77
+
78
+ function add_decision(decision, key, notes, all_decisions, notes_dict = {}){
79
+ all_decisions[key] = decision.decision
80
+ notes_dict[key] = decision.note
81
+ if (decision.note){
82
+ notes.push(decision.note)
83
+ }
84
+ }
85
+
86
+ module.exports = {underwrite, knockout_names}
@@ -0,0 +1,25 @@
1
+ const path = require('path');
2
+
3
+ module.exports = [{
4
+ mode: 'production',
5
+ entry: './src/index.js',
6
+ output: {
7
+ path: path.resolve(__dirname, 'dist'),
8
+ filename: 'stand_underwriter.js',
9
+ library: 'stand_underwriter',
10
+ libraryTarget: 'umd',
11
+ globalObject: 'this',
12
+ },
13
+ },
14
+ {
15
+ mode: 'production',
16
+ entry: './src/index.js',
17
+ output: {
18
+ path: path.resolve(__dirname, '../stand/scripts/lib/underwriter'),
19
+ filename: 'stand_underwriter.js',
20
+ library: 'stand_underwriter',
21
+ libraryTarget: 'umd',
22
+ globalObject: 'this',
23
+ },
24
+ }
25
+ ];