stand_socotra_policy_transformer 2.0.0 → 2.0.2

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.
@@ -1,319 +1,136 @@
1
1
  const {SocotraEntry} = require("./socotra_structure_helper");
2
+ class SocotraPayloadConverter {
3
+ constructor(entries) {
4
+ this.entries = entries
5
+ }
6
+ policy_holder_payload(retool_payload) {
7
+ let missing = []
8
+ let required_fields = ['owner_first_name', 'owner_last_name', 'owner_email']
9
+ for (const field of required_fields) {
10
+ if (!retool_payload[field]) {
11
+ missing.push(field)
12
+ }
2
13
 
3
- function policy_holder_payload(retool_payload) {
4
- let missing = []
5
- let required_fields = ['owner_first_name', 'owner_last_name', 'owner_email']
6
- for (const field of required_fields) {
7
- if (!retool_payload[field]) {
8
- missing.push(field)
9
14
  }
10
-
11
- }
12
- if (missing.length == 0) {
13
- let values = {
14
- first_name: retool_payload.owner_first_name,
15
- last_name: retool_payload.owner_last_name,
16
- email: retool_payload.owner_email,
17
- phone_number: retool_payload.owner_phone_number,
18
- mailing_street_address: retool_payload.mailing_street_address,
19
- mailing_street_address_2: retool_payload.mailing_street_address2,
20
- mailing_city: retool_payload.mailing_city,
21
- mailing_state: retool_payload.mailing_state,
22
- mailing_zip: retool_payload.mailing_zip,
23
- ofac_date: retool_payload.ofac_date_pulled,
24
- ofac_reason: retool_payload.ofac_reason,
25
- ofac_outcome: retool_payload.ofac_outcome
15
+ if (missing.length == 0) {
16
+ let values = {
17
+ first_name: retool_payload.owner_first_name,
18
+ last_name: retool_payload.owner_last_name,
19
+ email: retool_payload.owner_email,
20
+ phone_number: retool_payload.owner_phone_number,
21
+ mailing_street_address: retool_payload.mailing_street_address,
22
+ mailing_street_address_2: retool_payload.mailing_street_address2,
23
+ mailing_city: retool_payload.mailing_city,
24
+ mailing_state: retool_payload.mailing_state,
25
+ mailing_zip: retool_payload.mailing_zip,
26
+ ofac_date: retool_payload.ofac_date_pulled,
27
+ ofac_reason: retool_payload.ofac_reason,
28
+ ofac_outcome: retool_payload.ofac_outcome
29
+ }
30
+ return {
31
+ status: 'success',
32
+ error_message: '',
33
+ payload:
34
+ {
35
+ completed: true,
36
+ values: this.stripNoneValues(values, true, true, false)
26
37
  }
27
- return {
28
- status: 'success',
29
- error_message: '',
30
- payload:
31
- {
32
- completed: true,
33
- values: stripNoneValues(values, true, true, false)
34
- }
38
+ }
39
+ } else {
40
+ return {payload: {}, status: 'error', error_message: `must include the following fields [${missing}]`}
35
41
  }
36
- } else {
37
- return {payload: {}, status: 'error', error_message: `must include the following fields [${missing}]`}
38
42
  }
39
- }
40
43
 
41
- function new_policy_payload(retool_payload, policy_holder_locator) {
42
- let payload = SocotraEntry.socotra_create_policy_template(policy_holder_locator)
43
- entries.forEach(entry => {
44
- entry.socotra_create_response(retool_payload, payload)
45
- })
44
+ new_policy_payload(retool_payload, policy_holder_locator) {
45
+ let payload = SocotraEntry.socotra_create_policy_template(policy_holder_locator)
46
+ this.entries.forEach(entry => {
47
+ entry.socotra_create_response(retool_payload, payload)
48
+ })
46
49
 
47
- let cleaned_payload = stripNoneValues(payload, true, true, true)
48
- return {payload: cleaned_payload, error_message: "", status: "success"}
49
- }
50
+ let cleaned_payload = this.stripNoneValues(payload, true, true, true)
51
+ return {payload: cleaned_payload, error_message: "", status: "success"}
52
+ }
50
53
 
51
- function quote_to_retool_payload(socotra_quote) {
52
- let payload = {}
53
- entries.forEach(entry => {
54
- entry.retool_response(socotra_quote, payload)
55
- })
56
- return {payload: stripNoneValues(payload, false, true, false), error_message: "", status: "success"}
57
- }
54
+ quote_to_retool_payload(socotra_quote) {
55
+ let payload = {}
56
+ this.entries.forEach(entry => {
57
+ entry.retool_response(socotra_quote, payload)
58
+ })
59
+ return {payload: this.stripNoneValues(payload, false, true, false), error_message: "", status: "success"}
60
+ }
58
61
 
59
- function retool_to_quote_updated(retool_payload, old_quote) {
60
- let old_payload = quote_to_retool_payload(old_quote)["payload"]
62
+ retool_to_quote_updated(retool_payload, old_quote) {
63
+ let old_payload = this.quote_to_retool_payload(old_quote)["payload"]
61
64
 
62
- let new_keys = Object.keys(retool_payload)
63
- new_keys.forEach(key => {
64
- if(Array.isArray(retool_payload[key])){
65
- let new_array = retool_payload[key]
66
- let old_array = old_payload[key]
65
+ let new_keys = Object.keys(retool_payload)
66
+ new_keys.forEach(key => {
67
+ if (Array.isArray(retool_payload[key])) {
68
+ let new_array = retool_payload[key]
69
+ let old_array = old_payload[key]
67
70
 
68
- if(JSON.stringify(new_array) === JSON.stringify(old_array)){
71
+ if (JSON.stringify(new_array) === JSON.stringify(old_array)) {
72
+ delete retool_payload[key]
73
+ }
74
+ } else if (old_payload[key] === retool_payload[key]) {
69
75
  delete retool_payload[key]
70
76
  }
77
+ })
78
+ let dwelling_exposure_locator = old_quote.exposures.find(obj => obj.name === 'dwelling')["locator"]
79
+ let payload = SocotraEntry.socotra_create_update_template(dwelling_exposure_locator)
80
+ this.entries.forEach(entry => {
81
+ if (Object.keys(retool_payload).includes(entry.retool_id)) {
82
+ entry.socotra_update(retool_payload, payload)
83
+ }
84
+ })
85
+
86
+ payload = this.stripNoneValues(payload, true, true, false)
87
+ if (Object.keys(payload.updateExposures[0].fieldValues).length === 0) {
88
+ delete payload["updateExposures"]
71
89
  }
72
- else if (old_payload[key] === retool_payload[key]){
73
- delete retool_payload[key]
74
- }
75
- })
76
- let dwelling_exposure_locator = old_quote.exposures.find(obj => obj.name === 'dwelling')["locator"]
77
- let payload = SocotraEntry.socotra_create_update_template(dwelling_exposure_locator)
78
- entries.forEach(entry => {
79
- if (Object.keys(retool_payload).includes(entry.retool_id)){
80
- entry.socotra_update(retool_payload, payload)
81
- }
82
- })
83
90
 
84
- payload = stripNoneValues(payload, true, true, false)
85
- if(Object.keys(payload.updateExposures[0].fieldValues).length === 0){
86
- delete payload["updateExposures"]
87
- }
91
+ if (Object.keys(payload.fieldValues).length === 0) {
92
+ delete payload["fieldValues"]
93
+ }
88
94
 
89
- if(Object.keys(payload.fieldValues).length === 0){
90
- delete payload["fieldValues"]
95
+ return {payload: payload, error_message: "", status: "success"}
91
96
  }
92
97
 
93
- return {payload: payload, error_message: "", status: "success"}
94
- }
95
-
96
- function stripNoneValues(payload, nulls, undefineds, nans){
97
- if(nulls){
98
- payload = stripNulls(payload, x => x == null)
99
- }
98
+ stripNoneValues(payload, nulls, undefineds, nans) {
99
+ if (nulls) {
100
+ payload = this.stripNulls(payload, x => x == null)
101
+ }
100
102
 
101
- if(undefineds){
102
- payload = stripNulls(payload, x => x === undefined)
103
- }
103
+ if (undefineds) {
104
+ payload = this.stripNulls(payload, x => x === undefined)
105
+ }
104
106
 
105
- if(nans){
106
- payload = stripNulls(payload, x => Number.isNaN(x))
107
+ if (nans) {
108
+ payload = this.stripNulls(payload, x => Number.isNaN(x))
109
+ }
110
+ return payload
107
111
  }
108
- return payload
109
- }
110
112
 
111
113
  //Socotra Doesn't like nulls, so we have to strip them
112
- function stripNulls(payload, filter_func) {
113
- let strip_with_args = x => stripNulls(x, filter_func)
114
-
115
- if (Array.isArray(payload)) {
116
- // If it's an array, recursively process each item and filter out nulls
117
- return payload
118
- .map(strip_with_args)
119
- .filter(item => !filter_func(item));
120
- } else if (typeof payload === 'object' && payload !== null) {
121
- // If it's an object, recursively process each key-value pair
122
- return Object.fromEntries(
123
- Object.entries(payload)
124
- .map(([key, value]) => [key, strip_with_args(value)]) // Recursively call for each value
125
- .filter(([_, value]) => !filter_func(value)) // Filter out null values
126
- );
127
- }
128
- // Return the value itself if it's not an object or array
129
- return payload;
130
- }
131
114
 
132
- function convertDecimalToString(num) {
133
- let str = num.toString();
134
- if (num < 1) {
135
- str = str.slice(1);
136
- } else if (num === parseInt(num)) {
137
- str = parseInt(num).toString();
115
+ stripNulls(payload, filter_func) {
116
+ let strip_with_args = x => this.stripNulls(x, filter_func)
117
+
118
+ if (Array.isArray(payload)) {
119
+ // If it's an array, recursively process each item and filter out nulls
120
+ return payload
121
+ .map(strip_with_args)
122
+ .filter(item => !filter_func(item));
123
+ } else if (typeof payload === 'object' && payload !== null) {
124
+ // If it's an object, recursively process each key-value pair
125
+ return Object.fromEntries(
126
+ Object.entries(payload)
127
+ .map(([key, value]) => [key, strip_with_args(value)]) // Recursively call for each value
128
+ .filter(([_, value]) => !filter_func(value)) // Filter out null values
129
+ );
130
+ }
131
+ // Return the value itself if it's not an object or array
132
+ return payload;
138
133
  }
139
- return str;
140
134
  }
141
135
 
142
- function solar_panel_functions(){
143
- let to_socotra_map = {0: "No", "1+": "Yes"}
144
- let to_retool_map = {"No": 0, "Yes": "1+"}
145
- return [(x) => to_retool_map[x], (x) => to_socotra_map[x]]
146
- }
147
-
148
- const entries = [
149
- new SocotraEntry("quote_name", "quote_name", "quote.name"),
150
- new SocotraEntry("socotra_config_version", "config_version", "quote.version"),
151
- new SocotraEntry("fire_deductible", "wf_deductible", "exposure.dwelling.fields", parseFloat),
152
- new SocotraEntry("other_deductible", "aop_deductible", "exposure.dwelling.fields", parseInt),
153
- new SocotraEntry("water_deductible", "water_deductible", "exposure.dwelling.fields", parseInt),
154
- // new SocotraEntry("3", "number_of_stories", "exposure.dwelling.fields"),
155
- // new SocotraEntry("3", "number_of_bathrooms", "exposure.dwelling.fields"),
156
- new SocotraEntry("square_feet", "square_feet", "exposure.dwelling.fields", undefined, parseInt),
157
- new SocotraEntry("stand_protect_discount", "stand_protect_discount", "exposure.dwelling.fields"),
158
- new SocotraEntry("multi_policy_discount", "multi_policy_discount", "exposure.dwelling.fields"),
159
- new SocotraEntry(undefined, "has_any_claim_history", "exposure.dwelling.fields", (x) => undefined,x => "No"),
160
- new SocotraEntry("roof_rating", "roof_rating", "exposure.dwelling.fields"),
161
- new SocotraEntry("slab_plumbing", "slab_plumbing", "exposure.dwelling.fields"),
162
- new SocotraEntry("foundation_type", "foundation_type", "exposure.dwelling.fields"),
163
- new SocotraEntry("siding_material", "siding_material", "exposure.dwelling.fields"),
164
- new SocotraEntry("distance_to_fire_department", "dist_to_fire_department", "exposure.dwelling.fields"),
165
- new SocotraEntry("protection_class", "protection_class", "exposure.dwelling.fields"),
166
- new SocotraEntry("purchase_year", "property_purchase_year", "exposure.dwelling.fields", undefined, parseInt),
167
- new SocotraEntry("roof_material", "roof_material", "exposure.dwelling.fields"),
168
- // new SocotraEntry("No", "has_solar_panels", "exposure.dwelling.fields"),
169
- new SocotraEntry("presence_of_fence", "fence", "exposure.dwelling.fields"),
170
- new SocotraEntry("year_built", "year_built", "exposure.dwelling.fields"),
171
- // new SocotraEntry("Class A", "roof_rating", "exposure.dwelling.fields"),
172
- new SocotraEntry("construction_type", "construction_type", "exposure.dwelling.fields"),
173
- // new SocotraEntry("No", "has_any_claim_history", "exposure.dwelling.fields"),
174
- new SocotraEntry("water_damage_limit", "water_damage_limit", "exposure.dwelling.fields"),
175
- new SocotraEntry("extended_dwelling_coverage", "extended_dwelling_coverage", "exposure.dwelling.fields"),
176
- new SocotraEntry("sprinkler", "sprinkler", "exposure.dwelling.fields"),
177
- new SocotraEntry("smoke", "smoke", "exposure.dwelling.fields"),
178
- new SocotraEntry("fire_alarm", "fire_alarm_type", "exposure.dwelling.fields"),
179
- new SocotraEntry("fire_ext", "fire_ext", "exposure.dwelling.fields"),
180
- new SocotraEntry("deadbolt", "dead_bolt", "exposure.dwelling.fields"),
181
- new SocotraEntry(undefined, "24_hour_security_guard", "exposure.dwelling.fields", (x) => undefined, (x) => "No"),
182
- new SocotraEntry("theft_alarm", "theft_alarm_type", "exposure.dwelling.fields"),
183
- new SocotraEntry("distance_to_neighboring_home", "distance_to_nearest_home_ft", "exposure.dwelling.fields"),
184
- new SocotraEntry("chimney_spark_arrestors", "chimney_mesh_cover", "exposure.dwelling.fields"),
185
- new SocotraEntry("ember_resistant_vents", "ember_vents", "exposure.dwelling.fields"),
186
- new SocotraEntry("enclosed_eaves", "enclosed_eaves", "exposure.dwelling.fields"),
187
- new SocotraEntry("fuel_tank_distance", "propane_tank_proximity", "exposure.dwelling.fields"),
188
- new SocotraEntry("ground_clearance", "exterior_clearance", "exposure.dwelling.fields"),
189
- new SocotraEntry("windows_frame_type", "window_frame_type", "exposure.dwelling.fields"),
190
- new SocotraEntry("windows_type", "window_glass_type", "exposure.dwelling.fields"),
191
-
192
- new SocotraEntry("replacement_cost", "full_replacement_value", "policy.fields", parseInt),
193
- new SocotraEntry("street_address", "address", "policy.fields"),
194
- new SocotraEntry("state", "state", "policy.fields"),
195
- // new SocotraEntry("No", "has_dogs", "policy.fields"),
196
- // new SocotraEntry("None", "farming_type", "policy.fields"),
197
- // new SocotraEntry("No", "has_exotic_pet", "policy.fields"),
198
- new SocotraEntry("is_rental", "is_rental", "policy.fields"),
199
- // new SocotraEntry("No", "beenRefusedInsurance", "policy.fields"),
200
- new SocotraEntry("pool_type", "swimming_pool_type", "policy.fields"),
201
- new SocotraEntry("has_home_business", "home_business", "policy.fields"),
202
- new SocotraEntry("occupation", "occupation", "policy.fields"),
203
- new SocotraEntry("water_shutoff", "water_shutoff_system", "policy.fields"),
204
- new SocotraEntry("waterflow_alarm", "waterflow_alarm", "policy.fields"),
205
- new SocotraEntry("city", "city", "policy.fields"),
206
- new SocotraEntry("electrical_updated_year", "electrical_last_updated", "policy.fields"),
207
- new SocotraEntry("coverage_b", "coverage_b", "policy.fields", parseInt),
208
- new SocotraEntry("coverage_c", "coverage_c", "policy.fields", parseInt),
209
- // new SocotraEntry("No", "is_vacant", "policy.fields"),
210
- // new SocotraEntry("Contra Costa", "county", "policy.fields"),
211
- new SocotraEntry("coverage_a", "coverage_a", "policy.fields", parseInt),
212
- new SocotraEntry("retrofitted", "retrofit_1997", "policy.fields"),
213
- new SocotraEntry("roof_replacement_year", "roof_replaced_year", "policy.fields"),
214
- new SocotraEntry("seismic_shutoff", "seismic_shutoff", "policy.fields"),
215
- new SocotraEntry("coverage_f", "coverage_f", "policy.fields"),
216
- new SocotraEntry("first_street_score", "first_street_wf_score", "policy.fields", parseInt),
217
- new SocotraEntry("degree_of_slope", "degrees_of_slope", "policy.fields"),
218
- new SocotraEntry("number_of_bankrupcies", "bankruptcies_judgements_liens", "policy.fields"),
219
- new SocotraEntry("coverage_d", "coverage_d", "policy.fields", parseInt),
220
- new SocotraEntry("coverage_e", "coverage_e", "policy.fields"),
221
- new SocotraEntry("gre_wf_score", "gre_wf_score", "policy.fields", parseFloat),
222
- // new SocotraEntry("2024-07-04", "prevPolicyExpiration", "policy.fields"),
223
- new SocotraEntry("state", "state", "policy.fields"),
224
- new SocotraEntry("has_steel_braided_hoses", "steel_braided_hoses", "policy.fields"),
225
- // new SocotraEntry("No", "hasFraudConviction", "policy.fields"),
226
- new SocotraEntry("core_logic_wf_score", "core_logic_score", "policy.fields", parseInt),
227
- new SocotraEntry(undefined, "channel", "policy.fields", (x) => undefined, (x) => "Broker"),
228
- new SocotraEntry(undefined, "coverageForm", "policy.fields", (x) => undefined, (x) => "HO-5 Comprehensive"),
229
- new SocotraEntry("zip", "zip", "policy.fields"),
230
- new SocotraEntry("has_underground_fuel_tank", "underground_fuel_tank", "policy.fields"),
231
- new SocotraEntry("residence_type", "dwelling_use_type", "policy.fields"),
232
- new SocotraEntry("attractive_nuisance", "has_attractive_nuisance", "policy.fields"),
233
- // new SocotraEntry("No", "circuit_breaker", "policy.fields"),
234
- new SocotraEntry("zesty_l2", "zesty_l2", "policy.fields", parseInt),
235
- new SocotraEntry("zesty_l1", "zesty_l1", "policy.fields", parseInt),
236
- // new SocotraEntry("Yes", "hasContinuousCoverage", "policy.fields"),
237
- // new SocotraEntry("Safeco", "pastCarrier", "policy.fields"),
238
- new SocotraEntry("water_heater_update_year", "water_heaters_last_updated", "policy.fields"),
239
- new SocotraEntry("plumbing_updated_year", "plumbing_last_updated", "policy.fields"),
240
- new SocotraEntry("home_heating_update_year", "home_heater_last_updated", "policy.fields", undefined, (x) => x === "" ? null: x ),
241
- new SocotraEntry("insured_dob", "date_of_birth", "policy.fields"),
242
- new SocotraEntry("gre_arf", "arf", "policy.fields", parseFloat),
243
- new SocotraEntry("insured_dob", "date_of_birth", "policy.fields"),
244
- new SocotraEntry("flood_score", "first_street_flood_score", "policy.fields"),
245
- // new SocotraEntry("Yes", "beenPreviouslyInsured", "policy.fields"),
246
- new SocotraEntry("home_heating_source", "heating_source", "policy.fields"),
247
- new SocotraEntry("horses", "has_horses", "policy.fields"),
248
- new SocotraEntry("metal_fittings_toilet_supply_line", "metal_fittings", "policy.fields"),
249
- new SocotraEntry("is_under_renovation", "renovation", "policy.fields"),
250
- new SocotraEntry("pool_type", "swimming_pool_type", "policy.fields"),
251
- new SocotraEntry("residence_type", "dwelling_use_type", "policy.fields"),
252
- new SocotraEntry("previous_insurance_company", "pastCarrier", "policy.fields"),
253
- new SocotraEntry("previous_policy_expiration_date", "prevPolicyExpiration", "policy.fields"),
254
- new SocotraEntry("previous_premium", "prevPolicyPremium", "policy.fields", undefined, parseInt),
255
- new SocotraEntry("fireshed_ID", "fireshed_id", "policy.fields"),
256
- new SocotraEntry("fireshed_code", "fireshed_code", "policy.fields"),
257
- new SocotraEntry("fireshed_capacity", "fireshed_capacity", "policy.fields", parseFloat),
258
- new SocotraEntry("county", "county", "policy.fields"),
259
- new SocotraEntry("ensemble_mean", "wf_score_mean", "policy.fields", parseFloat),
260
- new SocotraEntry("ensemble_variance", "wf_score_variance", "policy.fields", parseFloat),
261
- new SocotraEntry("wildfire_category", "wf_score_category", "policy.fields"),
262
- new SocotraEntry("has_additional_insured", "has_co_applicant", "policy.fields"),
263
- new SocotraEntry("months_unoccupied", "months_unoccupied", "policy.fields", (x) => x == null ? "0": x),
264
- new SocotraEntry("multifamily_unit_count", "multi_family_unit_count", "policy.fields", undefined, parseInt),
265
- new SocotraEntry("spouse_first_name", "has_co_applicant", "policy.fields", (x) => null, (x) => x? "Yes" : "No"),
266
- new SocotraEntry("spouse_first_name", "co_applicant_first_name", "policy.fields"),
267
- new SocotraEntry("spouse_last_name", "co_applicant_last_name", "policy.fields"),
268
- new SocotraEntry("spouse_email", "co_applicant_email", "policy.fields"),
269
- new SocotraEntry("spouse_phone_number", "co_applicant_phone_number", "policy.fields"),
270
- new SocotraEntry("number_of_mortgages", "num_mortgages", "policy.fields"),
271
- new SocotraEntry("past_liens", "bankruptcies_judgements_liens", "policy.fields"),
272
- new SocotraEntry("property_id", "retool_property_id", "policy.fields"),
273
- new SocotraEntry("primary_dwelling_insured", "primary_insured_by_stand", "policy.fields", (x) => x? x : "Yes"),
274
- new SocotraEntry("lat","latitude", "policy.fields", parseFloat),
275
- new SocotraEntry("lng", "longitude", "policy.fields", parseFloat),
276
- new SocotraEntry("count_of_solar_panels", "has_solar_panels", "exposure.dwelling.fields", ...solar_panel_functions()),
277
-
278
- new SocotraEntry("producer_license_number", "producer_license_number", "policy.fields"),
279
- new SocotraEntry("producer_id", "producerId", "policy.fields"),
280
- new SocotraEntry("producer_email", "producerEmail", "policy.fields"),
281
- new SocotraEntry("producer_name", "producerName", "policy.fields"),
282
- new SocotraEntry("producer_ascend_id", "producer_ascend_id", "policy.fields"),
283
- new SocotraEntry("producer_license_number", "producer_license_number", "policy.fields"),
284
- new SocotraEntry("producer_phone_number", "producer_phone_number", "policy.fields"),
285
- new SocotraEntry("producer_state", "producer_state", "policy.fields"),
286
- new SocotraEntry("producer_commission", "commissionRate", "policy.fields"),
287
- new SocotraEntry("producer_zip", "producer_zip", "policy.fields"),
288
- new SocotraEntry("producer_city", "producer_city", "policy.fields"),
289
- new SocotraEntry("producer_street_address", "producer_street_address", "policy.fields"),
290
- new SocotraEntry("producer_street_address2", "producer_street_address_2", "policy.fields"),
291
-
292
- new SocotraEntry("broker_license_number", "distributor_license_number", "policy.fields"),
293
- new SocotraEntry("broker_name", "distributor_name", "policy.fields"),
294
-
295
-
296
- new SocotraEntry("premium_calculated", "indicated_policy_cost", "policy.fields"),
297
- new SocotraEntry("withdrawal_reasons", "withdrawal_reason", "policy.fields.array"),
298
- new SocotraEntry("rejection_reasons", "declination_reason", "policy.fields.array"),
299
- new SocotraEntry("competing_carrier", "competing_carrier", "policy.fields"),
300
- new SocotraEntry("competing_pricing", "competing_pricing", "policy.fields"),
301
-
302
- new SocotraEntry("stand_second_approval", "stand_second_approval", "policy.fields"),
303
- new SocotraEntry("fronting_carrier_approval", "fronting_carrier_approval", "policy.fields"),
304
- new SocotraEntry("reinsurance_carrier_approved", "reinsurance_carrier_approved", "policy.fields"),
305
- new SocotraEntry("reinsurance_rate", "reinsurance_rate", "policy.fields"),
306
-
307
- new SocotraEntry("is_agreed_value", "is_agreed_value", "policy.fields"),
308
- new SocotraEntry("is_difference_in_condition", "is_difference_in_condition", "policy.fields"),
309
- new SocotraEntry("lead_source", "lead_source", "policy.fields", (x) => null),
310
-
311
- new SocotraEntry("start_date", "startTimestamp", "effective_date"),
312
- new SocotraEntry("payment_schedule", "paymentScheduleName", "payment_schedule"),
313
-
314
- ]
315
-
316
-
317
-
318
-
319
- module.exports = {policy_holder_payload, new_policy_payload, quote_to_retool_payload, retool_to_quote_updated}
136
+ module.exports = {SocotraPayloadConverter}
@@ -0,0 +1,167 @@
1
+ const {SocotraEntry} = require("../socotra_structure_helper");
2
+ function solar_panel_functions() {
3
+ let to_socotra_map = {0: "No", "1+": "Yes"}
4
+ let to_retool_map = {"No": 0, "Yes": "1+"}
5
+ return [(x) => to_retool_map[x], (x) => to_socotra_map[x]]
6
+ }
7
+
8
+ entries_v1 = [
9
+ new SocotraEntry("quote_name", "quote_name", "quote.name"),
10
+ new SocotraEntry("socotra_config_version", "config_version", "quote.version"),
11
+ new SocotraEntry("fire_deductible", "wf_deductible", "exposure.dwelling.fields", parseFloat),
12
+ new SocotraEntry("other_deductible", "aop_deductible", "exposure.dwelling.fields", parseInt),
13
+ new SocotraEntry("water_deductible", "water_deductible", "exposure.dwelling.fields", parseInt),
14
+ // new SocotraEntry("3", "number_of_stories", "exposure.dwelling.fields"),
15
+ // new SocotraEntry("3", "number_of_bathrooms", "exposure.dwelling.fields"),
16
+ new SocotraEntry("square_feet", "square_feet", "exposure.dwelling.fields", undefined, parseInt),
17
+ new SocotraEntry("stand_protect_discount", "stand_protect_discount", "exposure.dwelling.fields"),
18
+ new SocotraEntry("multi_policy_discount", "multi_policy_discount", "exposure.dwelling.fields"),
19
+ new SocotraEntry(undefined, "has_any_claim_history", "exposure.dwelling.fields", (x) => undefined, x => "No"),
20
+ new SocotraEntry("roof_rating", "roof_rating", "exposure.dwelling.fields"),
21
+ new SocotraEntry("slab_plumbing", "slab_plumbing", "exposure.dwelling.fields"),
22
+ new SocotraEntry("foundation_type", "foundation_type", "exposure.dwelling.fields"),
23
+ new SocotraEntry("siding_material", "siding_material", "exposure.dwelling.fields"),
24
+ new SocotraEntry("distance_to_fire_department", "dist_to_fire_department", "exposure.dwelling.fields"),
25
+ new SocotraEntry("protection_class", "protection_class", "exposure.dwelling.fields"),
26
+ new SocotraEntry("purchase_year", "property_purchase_year", "exposure.dwelling.fields", undefined, parseInt),
27
+ new SocotraEntry("roof_material", "roof_material", "exposure.dwelling.fields"),
28
+ new SocotraEntry("presence_of_fence", "fence", "exposure.dwelling.fields"),
29
+ new SocotraEntry("year_built", "year_built", "exposure.dwelling.fields"),
30
+ new SocotraEntry("construction_type", "construction_type", "exposure.dwelling.fields"),
31
+ // new SocotraEntry("No", "has_any_claim_history", "exposure.dwelling.fields"),
32
+ new SocotraEntry("water_damage_limit", "water_damage_limit", "exposure.dwelling.fields"),
33
+ new SocotraEntry("extended_dwelling_coverage", "extended_dwelling_coverage", "exposure.dwelling.fields"),
34
+ new SocotraEntry("sprinkler", "sprinkler", "exposure.dwelling.fields"),
35
+ new SocotraEntry("smoke", "smoke", "exposure.dwelling.fields"),
36
+ new SocotraEntry("fire_alarm", "fire_alarm_type", "exposure.dwelling.fields"),
37
+ new SocotraEntry("fire_ext", "fire_ext", "exposure.dwelling.fields"),
38
+ new SocotraEntry("deadbolt", "dead_bolt", "exposure.dwelling.fields"),
39
+ new SocotraEntry(undefined, "24_hour_security_guard", "exposure.dwelling.fields", (x) => undefined, (x) => "No"),
40
+ new SocotraEntry("theft_alarm", "theft_alarm_type", "exposure.dwelling.fields"),
41
+ new SocotraEntry("distance_to_neighboring_home", "distance_to_nearest_home_ft", "exposure.dwelling.fields"),
42
+ new SocotraEntry("chimney_spark_arrestors", "chimney_mesh_cover", "exposure.dwelling.fields"),
43
+ new SocotraEntry("ember_resistant_vents", "ember_vents", "exposure.dwelling.fields"),
44
+ new SocotraEntry("enclosed_eaves", "enclosed_eaves", "exposure.dwelling.fields"),
45
+ new SocotraEntry("fuel_tank_distance", "propane_tank_proximity", "exposure.dwelling.fields"),
46
+ new SocotraEntry("ground_clearance", "exterior_clearance", "exposure.dwelling.fields"),
47
+ new SocotraEntry("windows_frame_type", "window_frame_type", "exposure.dwelling.fields"),
48
+ new SocotraEntry("windows_type", "window_glass_type", "exposure.dwelling.fields"),
49
+
50
+ new SocotraEntry("replacement_cost", "full_replacement_value", "policy.fields", parseInt),
51
+ new SocotraEntry("street_address", "address", "policy.fields"),
52
+ new SocotraEntry("state", "state", "policy.fields"),
53
+ new SocotraEntry("is_rental", "is_rental", "policy.fields"),
54
+ new SocotraEntry("pool_type", "swimming_pool_type", "policy.fields"),
55
+ new SocotraEntry("has_home_business", "home_business", "policy.fields"),
56
+ new SocotraEntry("occupation", "occupation", "policy.fields"),
57
+ new SocotraEntry("water_shutoff", "water_shutoff_system", "policy.fields"),
58
+ new SocotraEntry("waterflow_alarm", "waterflow_alarm", "policy.fields"),
59
+ new SocotraEntry("city", "city", "policy.fields"),
60
+ new SocotraEntry("electrical_updated_year", "electrical_last_updated", "policy.fields"),
61
+ new SocotraEntry("coverage_b", "coverage_b", "policy.fields", parseInt),
62
+ new SocotraEntry("coverage_c", "coverage_c", "policy.fields", parseInt),
63
+ new SocotraEntry("coverage_a", "coverage_a", "policy.fields", parseInt),
64
+ new SocotraEntry("retrofitted", "retrofit_1997", "policy.fields"),
65
+ new SocotraEntry("roof_replacement_year", "roof_replaced_year", "policy.fields"),
66
+ new SocotraEntry("seismic_shutoff", "seismic_shutoff", "policy.fields"),
67
+ new SocotraEntry("coverage_f", "coverage_f", "policy.fields"),
68
+ new SocotraEntry("first_street_score", "first_street_wf_score", "policy.fields", parseInt),
69
+ new SocotraEntry("degree_of_slope", "degrees_of_slope", "policy.fields"),
70
+ new SocotraEntry("number_of_bankrupcies", "bankruptcies_judgements_liens", "policy.fields"),
71
+ new SocotraEntry("coverage_d", "coverage_d", "policy.fields", parseInt),
72
+ new SocotraEntry("coverage_e", "coverage_e", "policy.fields"),
73
+ new SocotraEntry("gre_wf_score", "gre_wf_score", "policy.fields", parseFloat),
74
+ // new SocotraEntry("2024-07-04", "prevPolicyExpiration", "policy.fields"),
75
+ new SocotraEntry("state", "state", "policy.fields"),
76
+ new SocotraEntry("has_steel_braided_hoses", "steel_braided_hoses", "policy.fields"),
77
+ // new SocotraEntry("No", "hasFraudConviction", "policy.fields"),
78
+ new SocotraEntry("core_logic_wf_score", "core_logic_score", "policy.fields", parseInt),
79
+ new SocotraEntry(undefined, "channel", "policy.fields", (x) => undefined, (x) => "Broker"),
80
+ new SocotraEntry(undefined, "coverageForm", "policy.fields", (x) => undefined, (x) => "HO-5 Comprehensive"),
81
+ new SocotraEntry("zip", "zip", "policy.fields"),
82
+ new SocotraEntry("has_underground_fuel_tank", "underground_fuel_tank", "policy.fields"),
83
+ new SocotraEntry("residence_type", "dwelling_use_type", "policy.fields"),
84
+ new SocotraEntry("attractive_nuisance", "has_attractive_nuisance", "policy.fields"),
85
+ // new SocotraEntry("No", "circuit_breaker", "policy.fields"),
86
+ new SocotraEntry("zesty_l2", "zesty_l2", "policy.fields", parseInt),
87
+ new SocotraEntry("zesty_l1", "zesty_l1", "policy.fields", parseInt),
88
+ // new SocotraEntry("Yes", "hasContinuousCoverage", "policy.fields"),
89
+ // new SocotraEntry("Safeco", "pastCarrier", "policy.fields"),
90
+ new SocotraEntry("water_heater_update_year", "water_heaters_last_updated", "policy.fields"),
91
+ new SocotraEntry("plumbing_updated_year", "plumbing_last_updated", "policy.fields"),
92
+ new SocotraEntry("home_heating_update_year", "home_heater_last_updated", "policy.fields", undefined, (x) => x === "" ? null : x),
93
+ new SocotraEntry("insured_dob", "date_of_birth", "policy.fields"),
94
+ new SocotraEntry("gre_arf", "arf", "policy.fields", parseFloat),
95
+ new SocotraEntry("insured_dob", "date_of_birth", "policy.fields"),
96
+ new SocotraEntry("flood_score", "first_street_flood_score", "policy.fields"),
97
+ // new SocotraEntry("Yes", "beenPreviouslyInsured", "policy.fields"),
98
+ new SocotraEntry("home_heating_source", "heating_source", "policy.fields"),
99
+ new SocotraEntry("horses", "has_horses", "policy.fields"),
100
+ new SocotraEntry("metal_fittings_toilet_supply_line", "metal_fittings", "policy.fields"),
101
+ new SocotraEntry("is_under_renovation", "renovation", "policy.fields"),
102
+ new SocotraEntry("pool_type", "swimming_pool_type", "policy.fields"),
103
+ new SocotraEntry("residence_type", "dwelling_use_type", "policy.fields"),
104
+ new SocotraEntry("previous_insurance_company", "pastCarrier", "policy.fields"),
105
+ new SocotraEntry("previous_policy_expiration_date", "prevPolicyExpiration", "policy.fields"),
106
+ new SocotraEntry("previous_premium", "prevPolicyPremium", "policy.fields", undefined, parseInt),
107
+ new SocotraEntry("fireshed_ID", "fireshed_id", "policy.fields"),
108
+ new SocotraEntry("fireshed_code", "fireshed_code", "policy.fields"),
109
+ new SocotraEntry("fireshed_capacity", "fireshed_capacity", "policy.fields", parseFloat),
110
+ new SocotraEntry("county", "county", "policy.fields"),
111
+ new SocotraEntry("ensemble_mean", "wf_score_mean", "policy.fields", parseFloat),
112
+ new SocotraEntry("ensemble_variance", "wf_score_variance", "policy.fields", parseFloat),
113
+ new SocotraEntry("wildfire_category", "wf_score_category", "policy.fields"),
114
+ new SocotraEntry("has_additional_insured", "has_co_applicant", "policy.fields"),
115
+ new SocotraEntry("months_unoccupied", "months_unoccupied", "policy.fields", (x) => x == null ? "0" : x),
116
+ new SocotraEntry("multifamily_unit_count", "multi_family_unit_count", "policy.fields", undefined, parseInt),
117
+ new SocotraEntry("spouse_first_name", "has_co_applicant", "policy.fields", (x) => null, (x) => x ? "Yes" : "No"),
118
+ new SocotraEntry("spouse_first_name", "co_applicant_first_name", "policy.fields"),
119
+ new SocotraEntry("spouse_last_name", "co_applicant_last_name", "policy.fields"),
120
+ new SocotraEntry("spouse_email", "co_applicant_email", "policy.fields"),
121
+ new SocotraEntry("spouse_phone_number", "co_applicant_phone_number", "policy.fields"),
122
+ new SocotraEntry("number_of_mortgages", "num_mortgages", "policy.fields"),
123
+ new SocotraEntry("past_liens", "bankruptcies_judgements_liens", "policy.fields"),
124
+ new SocotraEntry("property_id", "retool_property_id", "policy.fields"),
125
+ new SocotraEntry("primary_dwelling_insured", "primary_insured_by_stand", "policy.fields", (x) => x ? x : "Yes"),
126
+ new SocotraEntry("lat", "latitude", "policy.fields", parseFloat),
127
+ new SocotraEntry("lng", "longitude", "policy.fields", parseFloat),
128
+ new SocotraEntry("count_of_solar_panels", "has_solar_panels", "exposure.dwelling.fields", ...solar_panel_functions()),
129
+
130
+ new SocotraEntry("producer_license_number", "producer_license_number", "policy.fields"),
131
+ new SocotraEntry("producer_id", "producerId", "policy.fields"),
132
+ new SocotraEntry("producer_email", "producerEmail", "policy.fields"),
133
+ new SocotraEntry("producer_name", "producerName", "policy.fields"),
134
+ new SocotraEntry("producer_ascend_id", "producer_ascend_id", "policy.fields"),
135
+ new SocotraEntry("producer_license_number", "producer_license_number", "policy.fields"),
136
+ new SocotraEntry("producer_phone_number", "producer_phone_number", "policy.fields"),
137
+ new SocotraEntry("producer_state", "producer_state", "policy.fields"),
138
+ new SocotraEntry("producer_commission", "commissionRate", "policy.fields"),
139
+ new SocotraEntry("producer_zip", "producer_zip", "policy.fields"),
140
+ new SocotraEntry("producer_city", "producer_city", "policy.fields"),
141
+ new SocotraEntry("producer_street_address", "producer_street_address", "policy.fields"),
142
+ new SocotraEntry("producer_street_address2", "producer_street_address_2", "policy.fields"),
143
+
144
+ new SocotraEntry("broker_license_number", "distributor_license_number", "policy.fields"),
145
+ new SocotraEntry("broker_name", "distributor_name", "policy.fields"),
146
+
147
+
148
+ new SocotraEntry("premium_calculated", "indicated_policy_cost", "policy.fields"),
149
+ new SocotraEntry("withdrawal_reasons", "withdrawal_reason", "policy.fields.array"),
150
+ new SocotraEntry("rejection_reasons", "declination_reason", "policy.fields.array"),
151
+ new SocotraEntry("competing_carrier", "competing_carrier", "policy.fields"),
152
+ new SocotraEntry("competing_pricing", "competing_pricing", "policy.fields"),
153
+
154
+ new SocotraEntry("stand_second_approval", "stand_second_approval", "policy.fields"),
155
+ new SocotraEntry("fronting_carrier_approval", "fronting_carrier_approval", "policy.fields"),
156
+ new SocotraEntry("reinsurance_carrier_approved", "reinsurance_carrier_approved", "policy.fields"),
157
+ new SocotraEntry("reinsurance_rate", "reinsurance_rate", "policy.fields"),
158
+
159
+ new SocotraEntry("start_date", "startTimestamp", "effective_date"),
160
+ new SocotraEntry("payment_schedule", "paymentScheduleName", "payment_schedule"),
161
+ ]
162
+
163
+
164
+
165
+
166
+
167
+ module.exports = {entries_v1}