@homeworksenergy/utility-service 1.0.22 → 1.1.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 (2) hide show
  1. package/index.js +76 -77
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -27,71 +27,74 @@ const BUSINESSES = {
27
27
 
28
28
  const EVENT_TYPES = {
29
29
  '00': {
30
- '00': 'HEA Visit',
31
- '01': 'Multi Family HEA Visit',
32
- '02': 'VEA Visit',
33
- '03': 'VEA QC Visit',
34
- '04': 'Return (Duration 1 Hour)',
35
- '05': 'Return (Duration 2 Hour)',
36
- '06': 'CAP Visit',
30
+ '00': {
31
+ '00': 'HEA Visit',
32
+ '01': 'Multi Family HEA Visit',
33
+ '02': 'VEA Visit',
34
+ '03': 'VEA QC Visit',
35
+ '04': 'Return (Duration 1 Hour)',
36
+ '05': 'Return (Duration 2 Hour)',
37
+ '06': 'CAP Visit',
38
+ },
39
+ '01': { '00': 'Sales Visit', '01': 'DHW Call', '02': 'Return Visit' },
40
+ '02': {
41
+ '00': 'Service Visit',
42
+ '01': 'Preventative Maintenance',
43
+ '02': 'Customer Service',
44
+ '03': 'Failed Combustion Safety Test',
45
+ },
46
+ '03': {
47
+ '00': 'Walkthrough',
48
+ '01': 'Final Walkthrough',
49
+ },
50
+ '04': {
51
+ '00': 'Install Visit',
52
+ '01': 'Gas Furnace',
53
+ '02': 'Gas Furnace/AC',
54
+ '03': 'Gas/DHW',
55
+ '04': 'Gas FHW Boiler',
56
+ '05': 'Gas/Combination Boiler',
57
+ '06': 'Air Handler/Heat Pump',
58
+ '07': 'Ductless Mini Split',
59
+ '08': 'Oil Furnace',
60
+ '09': 'Oil Furnace A/C',
61
+ 10: 'Oil FHW Boiler',
62
+ 11: 'Oil DHW',
63
+ 12: 'Electric DHW',
64
+ 13: 'A/C Only',
65
+ 14: 'Gas Steam Boiler',
66
+ 15: 'Oil Steam Boiler',
67
+ 16: 'Gas Space Heater',
68
+ 17: 'Gas Furnace & HP',
69
+ 18: 'Direct Vent Space Heater',
70
+ 19: 'Heated Bath Fan',
71
+ 20: 'Electric Baseboard',
72
+ },
73
+ '05': {
74
+ '00': 'Insulation Install',
75
+ '01': 'Insulation Callback',
76
+ '02': 'Insulation Internal Callback',
77
+ '03': 'Insulation Truck Service',
78
+ '04': 'Insulation Finish',
79
+ '05': 'Insulation Manager Visit',
80
+ '06': 'Insulation Manager QC Visit',
81
+ // 90 is Rhode Island
82
+ '90': 'Insulation Install'
83
+ },
84
+ 88: {
85
+ '00': 'Knob and Tube',
86
+ '01':'Mold',
87
+ '02':'Vermiculite'
88
+ },
89
+ 89: {
90
+ '00': 'N/A'
91
+ },
37
92
  },
38
- '01': { '00': 'Sales Visit', '01': 'DHW Call', '02': 'Return Visit' },
39
- '02': {
40
- '00': 'Service Visit',
41
- '01': 'Preventative Maintenance',
42
- '02': 'Customer Service',
43
- '03': 'Failed Combustion Safety Test',
44
- },
45
- '03': {
46
- '00': 'Walkthrough',
47
- '01': 'Final Walkthrough',
48
- },
49
- '04': {
50
- '00': 'Install Visit',
51
- '01': 'Gas Furnace',
52
- '02': 'Gas Furnace/AC',
53
- '03': 'Gas/DHW',
54
- '04': 'Gas FHW Boiler',
55
- '05': 'Gas/Combination Boiler',
56
- '06': 'Air Handler/Heat Pump',
57
- '07': 'Ductless Mini Split',
58
- '08': 'Oil Furnace',
59
- '09': 'Oil Furnace A/C',
60
- 10: 'Oil FHW Boiler',
61
- 11: 'Oil DHW',
62
- 12: 'Electric DHW',
63
- 13: 'A/C Only',
64
- 14: 'Gas Steam Boiler',
65
- 15: 'Oil Steam Boiler',
66
- 16: 'Gas Space Heater',
67
- 17: 'Gas Furnace & HP',
68
- 18: 'Direct Vent Space Heater',
69
- 19: 'Heated Bath Fan',
70
- 20: 'Electric Baseboard',
71
- },
72
- '05': {
73
- '00': 'Insulation Install',
74
- '01': 'Insulation Callback',
75
- '02': 'Insulation Internal Callback',
76
- '03': 'Insulation Truck Service',
77
- '04': 'Insulation Finish',
78
- '05': 'Insulation Manager Visit',
79
- '06': 'Insulation Manager QC Visit',
80
- // 90 is Rhode Island
81
- '90': 'Insulation Install'
82
- },
83
- 88: {
84
- '00': 'Knob and Tube',
85
- '01':'Mold',
86
- '02':'Vermiculite'
87
- },
88
- 89: {
89
- '00': 'N/A'
90
- },
91
- 99: { 99: 'Custom Block' },
93
+ '01': { '00': 'HEA Visit', '01': 'Insulation Quote' },
94
+ 99: { 99: { 99: 'Custom Block' } },
92
95
  };
93
96
 
94
- const getHweCode = ({ state, department, eventType})=>{
97
+ const getHweCode = ({ state, department, eventType}) => {
95
98
  const resultObj = {
96
99
  stateCode: 99,
97
100
  departmentCode: 99,
@@ -100,10 +103,10 @@ const getHweCode = ({ state, department, eventType})=>{
100
103
  if(state){
101
104
  resultObj.stateCode = Object.keys(STATES).find(key => STATES[key] === state) || 99;
102
105
  }
103
- if(department){
106
+ if (department) {
104
107
  resultObj.departmentCode = Object.keys(BUSINESSES).find(key => BUSINESSES[key] === department) || 99;
105
- if( eventType){
106
- resultObj.eventTypeCode = Object.keys(EVENT_TYPES[resultObj.departmentCode]).find(key => EVENT_TYPES[resultObj.departmentCode[key]] === eventType) || 99;
108
+ if (eventType) {
109
+ resultObj.eventTypeCode = Object.keys(EVENT_TYPES[resultObj.stateCode][resultObj.departmentCode]).find(key => EVENT_TYPES[resultObj.departmentCode[key]] === eventType) || 99;
107
110
  }
108
111
  }
109
112
  return resultObj;
@@ -116,21 +119,11 @@ const decodeEventType = (eventType) => {
116
119
  return {
117
120
  state: STATES[state],
118
121
  business: BUSINESSES[business],
119
- businessEvent: EVENT_TYPES[business][businessEvent],
122
+ businessEvent: EVENT_TYPES[state][business][businessEvent],
120
123
  };
121
124
  };
122
125
 
123
- const getDetailTableNameForEventType = (type) => {
124
- const { business, businessEvent } = decodeEventType(type);
125
- const DETAIL_TABLES = {
126
- 'HVAC Install': 'hvac_install_event',
127
- 'Custom Block': 'custom_block_event',
128
- };
129
- if (DETAIL_TABLES[business]) return DETAIL_TABLES[business];
130
- if (DETAIL_TABLES[businessEvent]) return DETAIL_TABLES[businessEvent];
131
- return null;
132
- };
133
-
126
+ // TODO: I don't think this is used anywhere
134
127
  const getEventTypeForDepartment = (department, state = 'MA') => {
135
128
  const stateId = Object.keys(STATES).find((id) => STATES[id] === state);
136
129
  const departmentId = Object.keys(BUSINESSES).find(
@@ -140,6 +133,11 @@ const getEventTypeForDepartment = (department, state = 'MA') => {
140
133
  return `${stateId}${departmentId}%`;
141
134
  };
142
135
 
136
+ const isHWEUser = (user)=>{
137
+ const { company } = user;
138
+ return company?.toLowerCase()?.includes('hwe') || false;
139
+ }
140
+
143
141
  module.exports = {
144
142
  decodeEventType,
145
143
  getHweCode,
@@ -152,4 +150,5 @@ module.exports = {
152
150
  addStartEndTimesToEvents,
153
151
  getStartEndTimesForEvent,
154
152
  getDatabaseInsertSlots,
153
+ isHWEUser
155
154
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homeworksenergy/utility-service",
3
- "version": "1.0.22",
3
+ "version": "1.1.0",
4
4
  "description": "Event type Transaction",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,4 +22,4 @@
22
22
  "dependencies": {
23
23
  "moment": "^2.29.1"
24
24
  }
25
- }
25
+ }