stand_socotra_policy_transformer 3.0.11 → 3.0.13

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 (71) hide show
  1. package/dist/stand_underwriter.js +1 -1
  2. package/package.json +8 -2
  3. package/__tests__/__utils__/load_payload.js +0 -16
  4. package/__tests__/__utils__/payloads/ai_additional_insured_new.json +0 -90
  5. package/__tests__/__utils__/payloads/ai_no_change_new_payload.json +0 -103
  6. package/__tests__/__utils__/payloads/ai_no_change_old_payload.json +0 -764
  7. package/__tests__/__utils__/payloads/ai_old_payload.json +0 -707
  8. package/__tests__/__utils__/payloads/claims_new_policy.json +0 -117
  9. package/__tests__/__utils__/payloads/claims_remove_new_payload.json +0 -68
  10. package/__tests__/__utils__/payloads/claims_remove_socotra_policy.json +0 -785
  11. package/__tests__/__utils__/payloads/claims_socotra_payload.json +0 -764
  12. package/__tests__/__utils__/payloads/minimal_change_base.json +0 -574
  13. package/__tests__/__utils__/payloads/minimal_change_base2.json +0 -574
  14. package/__tests__/__utils__/payloads/minimal_change_resulting_socotra.json +0 -17
  15. package/__tests__/__utils__/payloads/minimal_change_resulting_socotra2.json +0 -27
  16. package/__tests__/__utils__/payloads/minimal_change_retool.json +0 -37
  17. package/__tests__/__utils__/payloads/minimal_change_retool2.json +0 -27
  18. package/__tests__/__utils__/payloads/sample_minimal_retool.json +0 -33
  19. package/__tests__/__utils__/payloads/sample_minimal_socotra_payload.json +0 -116
  20. package/__tests__/__utils__/payloads/sample_new_policy_holder.json +0 -17
  21. package/__tests__/__utils__/payloads/sample_new_quote.json +0 -216
  22. package/__tests__/__utils__/payloads/sample_new_quote_retool.json +0 -93
  23. package/__tests__/__utils__/payloads/sample_retool.json +0 -157
  24. package/__tests__/__utils__/payloads/sample_retool_converted_quote.json +0 -54
  25. package/__tests__/__utils__/payloads/sample_retool_socotra_subset.json +0 -163
  26. package/__tests__/__utils__/payloads/sample_socotra_quote.json +0 -782
  27. package/__tests__/__utils__/payloads/sample_socotra_with_additional_insured.json +0 -764
  28. package/__tests__/__utils__/payloads/sample_update_quote.json +0 -18
  29. package/__tests__/__utils__/payloads/versions/v1/sample_new_quote.json +0 -211
  30. package/__tests__/__utils__/payloads/versions/v1/sample_retool.json +0 -160
  31. package/__tests__/__utils__/payloads/versions/v1/sample_retool_socotra_subset.json +0 -128
  32. package/__tests__/__utils__/payloads/versions/v1/sample_socotra_quote.json +0 -776
  33. package/__tests__/__utils__/payloads/versions/v1/sample_update_quote.json +0 -18
  34. package/__tests__/__utils__/payloads/versions/v2/sample_new_quote.json +0 -215
  35. package/__tests__/__utils__/payloads/versions/v2/sample_retool.json +0 -165
  36. package/__tests__/__utils__/payloads/versions/v2/sample_retool_socotra_subset.json +0 -159
  37. package/__tests__/__utils__/payloads/versions/v2/sample_socotra_quote.json +0 -779
  38. package/__tests__/__utils__/payloads/versions/v2/sample_update_quote.json +0 -18
  39. package/__tests__/basic_knockout.test.js +0 -113
  40. package/__tests__/claims_history_knockout.test.js +0 -56
  41. package/__tests__/exterior_knockout.test.js +0 -192
  42. package/__tests__/helpers/index.js +0 -10
  43. package/__tests__/home_owner_knockouts.js +0 -260
  44. package/__tests__/interior_knockout.test.js +0 -321
  45. package/__tests__/package_version.test.js +0 -7
  46. package/__tests__/rate_call_knockouts.test.js +0 -347
  47. package/__tests__/retool_utils/socotra_group_update.test.js +0 -563
  48. package/__tests__/retool_utils/socotra_payload.test.js +0 -270
  49. package/__tests__/retool_utils/socotra_structure_helper.test.js +0 -242
  50. package/__tests__/retool_utils/versions/entries_v1.test.js +0 -51
  51. package/__tests__/retool_utils/versions/entries_v2.test.js +0 -51
  52. package/__tests__/underwriter.test.js +0 -169
  53. package/__tests__/wf_knockout.test.js +0 -124
  54. package/src/index.js +0 -14
  55. package/src/knockouts/basic_knockouts.js +0 -66
  56. package/src/knockouts/claims_history_knockout.js +0 -24
  57. package/src/knockouts/exterior_knockouts.js +0 -97
  58. package/src/knockouts/home_owner_knockouts.js +0 -118
  59. package/src/knockouts/index.js +0 -83
  60. package/src/knockouts/interior_knockouts.js +0 -149
  61. package/src/knockouts/rate_call_knockouts.js +0 -155
  62. package/src/knockouts/wf_knockouts.js +0 -66
  63. package/src/retool_to_socotra.js +0 -18
  64. package/src/retool_utils/socotra_entries_helper_fuctions.js +0 -0
  65. package/src/retool_utils/socotra_payloads.js +0 -161
  66. package/src/retool_utils/socotra_structure_helper.js +0 -687
  67. package/src/retool_utils/versions/stand_v1_entries.js +0 -167
  68. package/src/retool_utils/versions/stand_v2_entries.js +0 -211
  69. package/src/retool_utils/versions/stand_v3_entries.js +0 -274
  70. package/src/underwriter.js +0 -86
  71. package/webpack.config.js +0 -14
@@ -1,169 +0,0 @@
1
- const {underwrite} = require('../src')
2
- const {claims_history_helper} = require("./helpers")
3
-
4
- beforeAll(() => {
5
- jest
6
- .useFakeTimers()
7
- .setSystemTime(new Date('2024-07-04').getTime());
8
- });
9
-
10
- afterAll(() => {
11
- jest.useRealTimers();
12
- });
13
-
14
- describe('Underwriter', () => {
15
- describe('with_full_check', () =>{
16
- test('Accepts with passing payload', () => {
17
- let decision = underwrite(payload_helper())
18
- expect(decision.decision).toBe('accept')
19
- expect(decision.notes).toEqual([])
20
- expect(decision.refers).toEqual([])
21
-
22
- expect(Object.keys(decision.all_decisions).length).toEqual(43)
23
- expect(decision.all_decisions['full_replacement_value']).toBe('accept')
24
-
25
- expect(Object.keys(decision.notes_dict).length).toEqual(43)
26
- expect(decision.notes_dict['full_replacement_value']).toBe(null)
27
- });
28
-
29
- test('Rejects if something in payload rejects', () => {
30
- let decision = underwrite(payload_helper({flood_score: 10, is_vacant: "Yes"}))
31
- expect(decision.decision).toBe('reject')
32
- expect(decision.notes.length).toEqual(2)
33
- expect(decision.refers).toEqual([])
34
-
35
- expect(Object.keys(decision.all_decisions).length).toEqual(43)
36
- expect(decision.all_decisions['flood_score']).toBe('reject')
37
- expect(decision.all_decisions['is_vacant']).toBe('reject')
38
-
39
- expect(Object.keys(decision.notes_dict).length).toEqual(43)
40
- expect(decision.notes_dict['flood_score']).not.toBe(null)
41
- expect(decision.all_decisions['is_vacant']).not.toBe(null)
42
-
43
- });
44
-
45
- test('Refer if something in payload refers', () => {
46
- let decision = underwrite(payload_helper({"full_replacement_value": 6_500_000}))
47
- expect(decision.decision).toBe('refer')
48
- expect(decision.notes.length).toEqual(0)
49
- expect(decision.refers).toEqual(["full_replacement_value"])
50
-
51
- expect(Object.keys(decision.all_decisions).length).toEqual(43)
52
- expect(decision.all_decisions['full_replacement_value']).toBe('refer')
53
-
54
- expect(Object.keys(decision.notes_dict).length).toEqual(43)
55
- });
56
-
57
- test('Reject if something in payload refers and something else rejects', () => {
58
- let decision = underwrite(payload_helper({full_replacement_value: 6_500_000, flood_score: 10}))
59
- expect(decision.decision).toBe('reject')
60
- expect(decision.notes.length).toEqual(1)
61
- expect(decision.refers).toEqual(["full_replacement_value"])
62
-
63
- expect(Object.keys(decision.all_decisions).length).toEqual(43)
64
- expect(decision.all_decisions['full_replacement_value']).toBe('refer')
65
- expect(decision.all_decisions['flood_score']).toBe('reject')
66
-
67
- expect(Object.keys(decision.notes_dict).length).toEqual(43)
68
- expect(decision.notes_dict['full_replacement_value']).toBeNull()
69
- expect(decision.notes_dict['flood_score']).not.toBeNull()
70
-
71
- });
72
-
73
- test('Reject if something in payload is missing', () => {
74
- payload = payload_helper()
75
- delete payload.full_replacement_value
76
- delete payload.arf
77
- let decision = underwrite(payload)
78
- expect(decision.decision).toBe('reject')
79
- expect(decision.notes.length).toEqual(2)
80
- expect(decision.refers).toEqual([])
81
-
82
- expect(Object.keys(decision.all_decisions).length).toEqual(43)
83
- expect(decision.all_decisions['full_replacement_value']).toBe('reject')
84
- expect(decision.all_decisions['wf_score_mean']).toBe('reject')
85
- });
86
- });
87
- describe("partial_check", () => {
88
- test("doesn't reject for missing fields", ()=> {
89
- let decision = underwrite({
90
- multi_family_unit_count: 1, primary_dwelling_insured: 'Yes',
91
- full_replacement_value: 6_000_000, prior_carrier: "Yes"}, false)
92
- expect(decision.decision).toBe('accept')
93
- expect(decision.notes).toEqual([])
94
- expect(decision.refers).toEqual([])
95
-
96
- expect(Object.keys(decision.all_decisions).length).toEqual(4)
97
- expect(decision.all_decisions['full_replacement_value']).toBe('accept')
98
- })
99
-
100
- test("rejects if it should", ()=> {
101
- let decision = underwrite({
102
- multi_family_unit_count: 1, primary_dwelling_insured: 'Yes',
103
- full_replacement_value: 6_000_000, prior_carrier: "Yes",
104
- number_of_bankruptcies_judgements_or_liens: 2}, false)
105
- expect(decision.decision).toBe('reject')
106
- expect(decision.notes).toEqual(["Has bankruptcies, judgements, or liens"])
107
- expect(decision.refers).toEqual([])
108
-
109
- expect(Object.keys(decision.all_decisions).length).toEqual(5)
110
- expect(decision.all_decisions['full_replacement_value']).toBe('accept')
111
- });
112
- });
113
- });
114
-
115
- function payload_helper(override){
116
- let sample_payload = {
117
- address: '1234 main street',
118
- year_built: '2005',
119
- co_applicant_address: '1234 main street',
120
- multi_family_unit_count: 1,
121
- primary_dwelling_insured: 'Yes',
122
- full_replacement_value: 6_000_000,
123
- prior_carrier: "Yes",
124
- wf_variance: .001,
125
- wf_score_mean: .3,
126
- arf: 1.9,
127
- flood_score: 5,
128
- distance_to_coast: 1.4,
129
- pool_features: ['Inground', "Fenced with self-locking gate"],
130
- number_of_dogs: 1,
131
- dog_history: 'No',
132
- dog_breeds: ['non-guard dog of other breeds'],
133
- exotic_pets: "No",
134
- farming_type: "None",
135
- number_of_mortgages: 0,
136
- number_of_bankruptcies_judgements_or_liens: 0,
137
- is_vacant: "No",
138
- under_renovation: "No",
139
- plumbing_last_update_year: 2022,
140
- water_heater_last_update_year: 2022,
141
- electrical_last_update_year: 2022,
142
- home_heating_last_update_year: 2022,
143
- heating_source: 'central gas heat',
144
- has_underground_fuel_tank: "No",
145
- has_steel_braided_hose: "Yes",
146
- has_water_shutoff: "Yes",
147
- circuit_breaker: "No",
148
- home_business_type: "no",
149
- has_attractive_nuisance: "No",
150
- home_rental_type: "no",
151
- degree_of_slope: 15,
152
- construction_type: "Concrete",
153
- siding_material: "Adobe",
154
- protection_class: "4",
155
- roof_material: "Corrugated Steel - Metal",
156
- class_a_roof: "Yes",
157
- foundation_type: "Crawlspace",
158
- has_slab_foundation_plumbing: "No",
159
- fire_protective_devices: ["Central"],
160
- theft_protective_devices: ["Dead Bolt", "Direct"],
161
- occupation: "writer",
162
- claims: [
163
- claims_history_helper('06/23/2022', 'Hurricane', 100),
164
- claims_history_helper('11/1/2020', 'SlipFall', 100)
165
- ]
166
- }
167
-
168
- return {...sample_payload, ...override}
169
- }
@@ -1,124 +0,0 @@
1
- const { knockout } = require('../src/knockouts/index.js');
2
- const { stand_wf_knockout } = require('../src/knockouts/wf_knockouts')
3
- describe("WF Knockouts", () =>
4
- {
5
- describe("wf_score_mean", () => {
6
-
7
- test('rejects if mean > 0.7', () => {
8
- let result = stand_wf_knockout(.7, .2);
9
- let decision = result.underwriter_result;
10
-
11
- expect(result.category).toBe("D");
12
- expect(decision.decision).toBe("reject");
13
- expect(decision.note).toBe("Stand WF mean must be less than or equal to 0.7");
14
- });
15
-
16
- test('set as c and refer if arf >= 8', () => {
17
- let result = stand_wf_knockout(.1, 8.0);
18
- let decision = result.underwriter_result;
19
-
20
- expect(result.category).toBe("C");
21
- expect(decision.decision).toBe("refer");
22
- expect(decision.note).toBe(null);
23
- });
24
-
25
- test('set as c and acept if 5 < arf < 8', () => {
26
- let result = stand_wf_knockout(.1, 5.0);
27
- let decision = result.underwriter_result;
28
-
29
- expect(result.category).toBe("C");
30
- expect(decision.decision).toBe("accept");
31
- expect(decision.note).toBe(null);
32
- });
33
-
34
- test('set as c and accept if arf <8 and .2 < mean < .7', () => {
35
- let result = stand_wf_knockout(.34, 4.2);
36
- let decision = result.underwriter_result;
37
-
38
- expect(result.category).toBe("C");
39
- expect(decision.decision).toBe("accept");
40
- expect(decision.note).toBe(null);
41
- });
42
-
43
- test('set as B and accept if arf <5 and .1 < mean < .2', () => {
44
- let result = stand_wf_knockout(.14, 4.3);
45
- let decision = result.underwriter_result;
46
-
47
- expect(result.category).toBe("B");
48
- expect(decision.decision).toBe("accept");
49
- expect(decision.note).toBe(null);
50
- });
51
-
52
- test('set as A and accept if arf <5 and 0 < mean < .1', () => {
53
- let result = stand_wf_knockout(.04, 4.3);
54
- let decision = result.underwriter_result;
55
-
56
- expect(result.category).toBe("A");
57
- expect(decision.decision).toBe("accept");
58
- expect(decision.note).toBe(null);
59
- });
60
-
61
- test('negative mean used reject', () => {
62
- let result = stand_wf_knockout(-.04, 4.3);
63
- let decision = result.underwriter_result;
64
-
65
- expect(result.category).toBe("");
66
- expect(decision.decision).toBe("reject");
67
- expect(decision.note).toBe("Mean and ARF must be positive numbers");
68
- });
69
-
70
- test('negative arf used reject', () => {
71
- let result = stand_wf_knockout(.04, -4.3);
72
- let decision = result.underwriter_result;
73
-
74
- expect(result.category).toBe("");
75
- expect(decision.decision).toBe("reject");
76
- expect(decision.note).toBe("Mean and ARF must be positive numbers");
77
- });
78
-
79
- test('non number arf used reject', () => {
80
- let result = stand_wf_knockout(.04, "hi");
81
- let decision = result.underwriter_result;
82
-
83
- expect(result.category).toBe("");
84
- expect(decision.decision).toBe("reject");
85
- expect(decision.note).toBe("ARF must be a number");
86
- });
87
- test('non number arf used reject', () => {
88
- let result = stand_wf_knockout("hi", 4);
89
- let decision = result.underwriter_result;
90
-
91
- expect(result.category).toBe("");
92
- expect(decision.decision).toBe("reject");
93
- expect(decision.note).toBe("ARF must be a number");
94
- });
95
-
96
- });
97
-
98
- describe("WF Variance Knockout", () => {
99
-
100
- test('accept if variance <= 0.09', () => {
101
- let decision = knockout('wf_variance', 0.08);
102
- expect(decision.decision).toBe("accept");
103
- expect(decision.note).toBe(null)
104
- });
105
-
106
- test('refer if variance > .09', () => {
107
- let decision = knockout('wf_variance', 0.1);
108
- expect(decision.decision).toBe("refer");
109
- expect(decision.note).toBe(null)
110
- });
111
-
112
- test('rejects if value is not an number', () => {
113
- let decision = knockout('wf_variance', "hi");
114
- expect(decision.decision).toBe("reject");
115
- expect(decision.note).toBe("Variance must be a number.")
116
- });
117
-
118
- test('rejects if value is negative', () => {
119
- let decision = knockout('wf_variance', -3);
120
- expect(decision.decision).toBe("reject");
121
- expect(decision.note).toBe("Variance must be a positive number.")
122
- });
123
- });
124
- })
package/src/index.js DELETED
@@ -1,14 +0,0 @@
1
- const {underwrite, knockout_names} = require('./underwriter')
2
- const {SocotraPayloadConverter} = require('./retool_utils/socotra_payloads')
3
- const {entries_v1} = require('./retool_utils/versions/stand_v1_entries')
4
- const {entries_v2} = require('./retool_utils/versions/stand_v2_entries')
5
- const {entries_v3} = require('./retool_utils/versions/stand_v3_entries')
6
- const { version } = require('../package.json');
7
-
8
- const transformer_hash = {
9
- '1': new SocotraPayloadConverter(entries_v1),
10
- '2': new SocotraPayloadConverter(entries_v2),
11
- '3': new SocotraPayloadConverter(entries_v3)
12
- }
13
-
14
- module.exports = {underwrite, knockout_names, transformer_hash, package_version: version}
@@ -1,66 +0,0 @@
1
- function multi_family_unit_count(num_units){
2
-
3
- if(!Number.isInteger(num_units)){
4
- return {decision: "reject", note: "Number of units must be an integer"}
5
- }
6
- else if(num_units > 2){
7
- return {decision: "reject", note: "We only allow homes with two units or less."}
8
- } else if (num_units <= 0){
9
- return {decision: "reject", note: "Number of units must be greater than 0"}
10
- }
11
- else{
12
- return {decision: "accept", note: null}
13
- }
14
- }
15
-
16
- function primary_dwelling_is_insured(is_insured_string){
17
-
18
- if(is_insured_string == 'No'){
19
- return {decision: "refer", note: null}
20
- } else if(is_insured_string == 'Yes'){
21
- return {decision: "accept", note: null}
22
- } else {
23
- return {decision: "reject", note: "Primary dwelling insured value must be in ['yes', 'no']"}
24
- }
25
- }
26
-
27
- function full_replacement_value(replacement_value){
28
- if(!Number.isInteger(replacement_value)){
29
- return {decision: "reject", note: "Full replacement value must be an integer"}
30
- }
31
- else if(replacement_value > 6_000_000){
32
- return {decision: "refer", note: null}
33
- } else if (replacement_value < 2_000_000){
34
- return {decision: "reject", note: "We only insure homes greater than $1M"}
35
- }
36
- else{
37
- return {decision: "accept", note: null}
38
- }
39
- }
40
-
41
- function prior_carrier(carrier_string){
42
-
43
- if(carrier_string === ""){
44
- return {decision: "refer", note: null}
45
- } else if(typeof carrier_string == 'string'){
46
- return {decision: "accept", note: null}
47
- } else {
48
- return {decision: "reject", note: "Prior Carrier Must be a string"}
49
- }
50
- }
51
-
52
- function occupation(occ){
53
- if(typeof occ != 'string'){
54
- return {decision: "reject", note: "Occupation must be a string"}
55
- } else if (['Professional Athlete', 'Entertainer', 'Journalist',' Politician'].includes(occ)){
56
- return {decision: "refer", note: null}
57
- } else {
58
- return {decision: "accept", note: null}
59
- }
60
- }
61
-
62
-
63
- module.exports = {
64
- multi_family_unit_count, primary_dwelling_is_insured, full_replacement_value, prior_carrier,
65
- occupation
66
- }
@@ -1,24 +0,0 @@
1
- function check_claims_history(history){
2
- if (!history){
3
- return {decision: 'reject', note: "For Claims use empty instead of null"}
4
- }
5
-
6
- let current_date = new Date();
7
- let date_five_years_ago = new Date();
8
- let date_three_years_ago = new Date();
9
- date_five_years_ago.setFullYear(current_date.getFullYear() - 5);
10
- date_three_years_ago.setFullYear(current_date.getFullYear() - 3);
11
-
12
- let claims_in_last_five_years = history.filter(claim => claim['date'] > date_five_years_ago)
13
- let claims_in_last_three_years = history.filter(claim => claim['date'] > date_three_years_ago)
14
-
15
- if(claims_in_last_five_years.length > 2){
16
- return {decision: 'reject', note: "To many claims in the past 5 years"}
17
- } else if (claims_in_last_three_years.length > 1){
18
- return {decision: 'reject', note: "To many claims in the past 3 years"}
19
- } else {
20
- return {decision: "accept", note: null}
21
- }
22
- }
23
-
24
- module.exports = {check_claims_history}
@@ -1,97 +0,0 @@
1
- function flood_score(score){
2
- if(!Number.isFinite(score) ) {
3
- return {decision: "reject", note: "Flood score must be a number."}
4
- } else if(score < 0){
5
- return {decision: "reject", note: "Flood score must be a positive number."}
6
- }
7
-
8
- if(score < 9){
9
- return {decision: "accept", note: null}
10
- } else {
11
- return {decision: "reject", note: "Flood risk is too high"}
12
- }
13
- }
14
-
15
- function distance_to_coast(distance){
16
- if(!Number.isFinite(distance) ) {
17
- return {decision: "reject", note: "Distance to coast must be a number."}
18
- } else if(distance < 0){
19
- return {decision: "reject", note: "Distance to coast must be a positive number."}
20
- }
21
-
22
- if(distance > 0.19){
23
- return {decision: "accept", note: null}
24
- } else {
25
- return {decision: "refer", note: null}
26
- }
27
- }
28
-
29
- function pool_features(feature_list){
30
- if(!Array.isArray(feature_list)){
31
- return {decision: "reject", note: "Pool features must be a list."}
32
- }
33
-
34
- let has_drowning_mitigation = feature_list.includes("Inground") && (
35
- feature_list.includes("Electric retractable safety cover")
36
- || feature_list.includes("Fenced with self-locking gate")
37
- )
38
-
39
- has_drowning_mitigation = has_drowning_mitigation || (
40
- feature_list.includes("Above Ground") && feature_list.includes("Retractable/removable ladder"))
41
-
42
-
43
- if(feature_list.includes('Diving Board') || feature_list.includes('Slide')){
44
- return {decision: "refer", note: null}
45
- } else if(has_drowning_mitigation) {
46
- return {decision: "accept", note: null}
47
- } else {
48
- return {decision: "refer", note: null}
49
- }
50
- }
51
-
52
- function farming_type(type){
53
- let type_enum = ["Farming activities produce income",
54
- "Incidental or hobby farming", "Vineyard", "None"]
55
- if(typeof type != 'string') {
56
- return {decision: "reject", note: "Farming type must be a string"}
57
- } else if(!type_enum.includes(type)){
58
- return {decision: "reject", note: `Farming type must be in [${type_enum}]`}
59
- }
60
-
61
- if(type == 'Vineyard'){
62
- return {decision: "refer", note: null}
63
- } else if (type == 'Farming activities produce income'){
64
- return {decision: "reject", note: "Cannot insure commercial farms"}
65
- } else {
66
- return {decision: "accept", note: null}
67
- }
68
- }
69
-
70
- function has_attractive_nuisance(has_nuisance){
71
- if(has_nuisance == "Yes"){
72
- return {decision: "refer", note: null}
73
- } else if(has_nuisance == "No"){
74
- return {decision: "accept", note: null}
75
- }
76
- return {decision: "reject", note: "Has attractive nuisance must be Yes or No."}
77
- }
78
-
79
- function degree_of_slope(slope_angle){
80
- if(!Number.isFinite(slope_angle) ) {
81
- return {decision: "reject", note: "Degree of slope must be a number."}
82
- } else if(slope_angle < 0){
83
- return {decision: "reject", note: "Degree of slope must be a positive number."}
84
- }
85
-
86
- if(slope_angle > 30){
87
- return {decision: "reject", note: "Slope greater than 30 degrees"}
88
- } else {
89
- return {decision: "accept", note: null}
90
- }
91
- }
92
-
93
-
94
-
95
- module.exports = {
96
- distance_to_coast, pool_features, farming_type, has_attractive_nuisance, degree_of_slope, flood_score
97
- }
@@ -1,118 +0,0 @@
1
- function number_of_dogs(num_dog){
2
- if(!Number.isFinite(num_dog) ) {
3
- return {decision: "reject", note: "Number of dogs must be a number."}
4
- } else if(num_dog < 0){
5
- return {decision: "reject", note: "Number of dogs must be a positive number."}
6
- }
7
-
8
- if(num_dog < 4){
9
- return {decision: "accept", note: null}
10
- } else {
11
- return {decision: "reject", note: "Owner has 4 or more dogs"}
12
- }
13
- }
14
-
15
- function dog_history(has_history){
16
- if(has_history == "Yes"){
17
- return {decision: "reject", note: "Has a dog with a history of aggressive behavior"}
18
- } else if(has_history == "No"){
19
- return {decision: "accept", note: null}
20
- }
21
- return {decision: "reject", note: "Dog has history must be Yes or No."}
22
- }
23
-
24
- function dog_breeds(dogs){
25
- if(!Array.isArray(dogs)){
26
- return {decision: "reject", note: "Dog breed must be a list"}
27
- }
28
-
29
- if(dogs.every(value => value === "non-guard dog of other breeds")){
30
- return {decision: "accept", note: null}
31
- } else {
32
- return {decision: "reject", note: "Dog of given breed not allowed"}
33
- }
34
- }
35
-
36
- function exotic_pets(has_exotic_pets){
37
- if(has_exotic_pets == "Yes"){
38
- return {decision: "reject", note: "Has an exotic pet"}
39
- } else if(has_exotic_pets == "No"){
40
- return {decision: "accept", note: null}
41
- }
42
- return {decision: "reject", note: "Has exotic pet must be Yes or No."}
43
- }
44
-
45
- function number_of_mortgages(num_mortgages){
46
- if(!Number.isFinite(num_mortgages) ) {
47
- return {decision: "reject", note: "Number of mortgages must be a number."}
48
- } else if(num_mortgages < 0){
49
- return {decision: "reject", note: "Number of mortgages must be a positive number."}
50
- }
51
-
52
- if(num_mortgages < 2){
53
- return {decision: "accept", note: null}
54
- } else {
55
- return {decision: "refer", note: null}
56
- }
57
- }
58
-
59
- function number_of_bankruptcies_judgements_or_liens(num_bankruptcies){
60
- if(!Number.isFinite(num_bankruptcies) ) {
61
- return {decision: "reject", note: "Number of bankruptcies, judgements, or liens must be a number"}
62
- } else if(num_bankruptcies < 0){
63
- return {decision: "reject", note: "Number of bankruptcies, judgements, or liens must be a positive number"}
64
- }
65
-
66
- if(num_bankruptcies === 0){
67
- return {decision: "accept", note: null}
68
- } else {
69
- return {decision: "reject", note: "Has bankruptcies, judgements, or liens"}
70
- }
71
- }
72
-
73
- function home_business_type(type) {
74
- let type_enum = ["yes - day care", "yes - other", "no"]
75
- if (typeof type != 'string') {
76
- return {decision: "reject", note: "Home business type must be a string"}
77
- } else if (!type_enum.includes(type)) {
78
- return {decision: "reject", note: "Home business type must be in [yes - day care, yes - other, no]"}
79
- }
80
-
81
- if (type == "no") {
82
- return {decision: "accept", note: null}
83
- } else if (type == 'yes - day care') {
84
- return {decision: "reject", note: "Cannot insure daycare"}
85
- } else {
86
- return {decision: "refer", note: null}
87
- }
88
- }
89
-
90
- function home_rental_type(type){
91
- let type_enum = ["short-term rentals less than 6 months of the year", "short term rentals more than 6 months of the year", "timeshare", "no"]
92
- if (typeof type != 'string') {
93
- return {decision: "reject", note: "Home rental type must be a string"}
94
- } else if (!type_enum.includes(type)) {
95
- return {decision: "reject", note: "Home rental type must be in [short-term rentals less than 6 months of the year, short term rentals more than 6 months of the year, timeshare, no]"}
96
- }
97
-
98
- if (type == "no") {
99
- return {decision: "accept", note: null}
100
- } else if (["short-term rentals less than 6 months of the year", "timeshare"].includes(type)) {
101
- return {decision: "refer", note: null}
102
- } else {
103
- return {decision: "reject", note: "Cannot insure rentals longer than 6 months"}
104
- }
105
- }
106
-
107
- function same_address(applicant_address, co_applicant_address){
108
- if (applicant_address === co_applicant_address){
109
- return {decision: "accept", note: null}
110
- } else {
111
- return {decision: "reject", note: "Co-Applicant must have same address as Applicant."}
112
- }
113
- }
114
-
115
- module.exports = {
116
- number_of_dogs, dog_history, dog_breeds, exotic_pets, number_of_mortgages,
117
- number_of_bankruptcies_judgements_or_liens, home_business_type, home_rental_type, same_address
118
- }