pha-hermes 1.22.0 → 1.24.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.
- package/dist/api/salesforce/expenses/expenseClient.d.ts +1 -1
- package/dist/api/salesforce/practitioner/practitionerClient.d.ts +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/models/workorder.d.ts +2 -0
- package/dist/pha-hermes.cjs.development.js +70 -24
- package/dist/pha-hermes.cjs.development.js.map +1 -1
- package/dist/pha-hermes.cjs.production.min.js +1 -1
- package/dist/pha-hermes.cjs.production.min.js.map +1 -1
- package/dist/pha-hermes.esm.js +70 -25
- package/dist/pha-hermes.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/api/salesforce/expenses/expenseClient.ts +4 -4
- package/src/api/salesforce/payperiod/payperiodClient.ts +2 -2
- package/src/api/salesforce/practitioner/practitionerClient.ts +32 -3
- package/src/api/salesforce/prices/priceClient.ts +1 -1
- package/src/api/salesforce/timesheet/timesheetClient.ts +14 -6
- package/src/api/salesforce/workorder/workorderClient.ts +10 -6
- package/src/index.ts +2 -0
- package/src/models/workorder.ts +2 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios'
|
|
2
|
-
import { Practitioner } from '../../../models'
|
|
3
|
-
import { SF_API_VERSION } from '
|
|
2
|
+
import { Practitioner, Role } from '../../../models'
|
|
3
|
+
import { SF_API_VERSION } from '../../../index'
|
|
4
4
|
|
|
5
5
|
export class SFPractitionerClient {
|
|
6
6
|
private axiosInstance: AxiosInstance
|
|
@@ -66,6 +66,35 @@ export class SFPractitionerClient {
|
|
|
66
66
|
throw error
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
async fetchRoles(): Promise<Role[]> {
|
|
71
|
+
try {
|
|
72
|
+
const url = `/services/data/${SF_API_VERSION}/query`
|
|
73
|
+
const query = `SELECT Label, Value FROM PicklistValueInfo \
|
|
74
|
+
WHERE EntityParticle.EntityDefinition.QualifiedApiName = 'WorkOrder__c'\
|
|
75
|
+
AND EntityParticle.QualifiedApiName = 'ProfessionalDesignation__c' \
|
|
76
|
+
AND isActive = true`
|
|
77
|
+
return this.axiosInstance
|
|
78
|
+
.get(url, {
|
|
79
|
+
params: { q: query }
|
|
80
|
+
})
|
|
81
|
+
.then(({ data: { records } }) =>
|
|
82
|
+
records.map(
|
|
83
|
+
(record): Role => ({
|
|
84
|
+
label: record.Label,
|
|
85
|
+
value: record.Value
|
|
86
|
+
})
|
|
87
|
+
)
|
|
88
|
+
)
|
|
89
|
+
.catch(error => {
|
|
90
|
+
console.error('Error fetching roles: ', error.message)
|
|
91
|
+
throw error
|
|
92
|
+
})
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.error('Error fetching roles: ', error.message)
|
|
95
|
+
throw error
|
|
96
|
+
}
|
|
97
|
+
}
|
|
69
98
|
}
|
|
70
99
|
|
|
71
100
|
function toPractitioner(raw: any): Practitioner {
|
|
@@ -75,6 +104,6 @@ function toPractitioner(raw: any): Practitioner {
|
|
|
75
104
|
lastName: raw.LastName__c,
|
|
76
105
|
email: raw.Email__c,
|
|
77
106
|
staffId: raw.StaffID__c,
|
|
78
|
-
createdAt: raw.CreatedDate.replace(/\+0000$/, 'Z')
|
|
107
|
+
createdAt: raw.CreatedDate ? raw.CreatedDate.replace(/\+0000$/, 'Z') : undefined
|
|
79
108
|
}
|
|
80
109
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios'
|
|
2
2
|
import { TimesheetDayEntry } from '../../../models'
|
|
3
|
-
import { SF_API_VERSION } from '
|
|
3
|
+
import { SF_API_VERSION } from '../../../index'
|
|
4
4
|
import FormData from 'form-data'
|
|
5
5
|
|
|
6
6
|
interface SFTimesheetHourField {
|
|
@@ -61,7 +61,11 @@ export class SFTimesheetClient {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
async getTimesheetIds(
|
|
64
|
+
async getTimesheetIds(
|
|
65
|
+
workorderId: string,
|
|
66
|
+
periodStartDate?: Date,
|
|
67
|
+
periodEndDate?: Date
|
|
68
|
+
): Promise<string[]> {
|
|
65
69
|
// Find all timesheet Ids that belong to this WO
|
|
66
70
|
const url = `/services/data/${SF_API_VERSION}/query`
|
|
67
71
|
let query = `SELECT Id
|
|
@@ -74,8 +78,7 @@ export class SFTimesheetClient {
|
|
|
74
78
|
AND PayPeriodEndDate__c >= ${new Date(periodEndDate).toISOString().substring(0, 10)}
|
|
75
79
|
`
|
|
76
80
|
}
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
81
|
+
} catch (error) {
|
|
79
82
|
console.error('Invalid period dates', error)
|
|
80
83
|
}
|
|
81
84
|
const {
|
|
@@ -110,7 +113,12 @@ export class SFTimesheetClient {
|
|
|
110
113
|
return timesheets
|
|
111
114
|
}
|
|
112
115
|
|
|
113
|
-
async getTimesheetHours(
|
|
116
|
+
async getTimesheetHours(
|
|
117
|
+
workorderId: string,
|
|
118
|
+
fields?: SFTimesheetHourFieldKeys[],
|
|
119
|
+
periodStartDate?: Date,
|
|
120
|
+
periodEndDate?: Date
|
|
121
|
+
): Promise<TimesheetDayEntry[]> {
|
|
114
122
|
const timesheetIds = await this.getTimesheetIds(workorderId, periodStartDate, periodEndDate)
|
|
115
123
|
|
|
116
124
|
const allHours: SFTimesheetHourField[] = []
|
|
@@ -121,7 +129,7 @@ export class SFTimesheetClient {
|
|
|
121
129
|
FROM TimesheetHour__c
|
|
122
130
|
WHERE Timesheet__c = '${timesheetId}'`
|
|
123
131
|
try {
|
|
124
|
-
if (fields?.length) {
|
|
132
|
+
if (fields?.length && periodStartDate && periodEndDate) {
|
|
125
133
|
query += `
|
|
126
134
|
AND Date__c >= ${new Date(periodStartDate).toISOString().substring(0, 10)}
|
|
127
135
|
AND Date__c <= ${new Date(periodEndDate).toISOString().substring(0, 10)}`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios'
|
|
2
|
-
import { SF_API_VERSION } from '
|
|
2
|
+
import { SF_API_VERSION } from '../../../index'
|
|
3
3
|
import { Workorder } from '../../../models'
|
|
4
4
|
|
|
5
5
|
export class SFWorkorderClient {
|
|
@@ -46,14 +46,16 @@ export class SFWorkorderClient {
|
|
|
46
46
|
LastModifiedDate,
|
|
47
47
|
Unit__c,
|
|
48
48
|
HealthAuthority__c,
|
|
49
|
-
UnitPrice__r.Price__c
|
|
49
|
+
UnitPrice__r.Price__c,
|
|
50
|
+
TravelDate__c,
|
|
51
|
+
ReturnDate__c
|
|
50
52
|
FROM WorkOrder__c ${whereClause}`
|
|
51
53
|
return await this.axiosInstance
|
|
52
54
|
.get(url, {
|
|
53
55
|
params: { q: query }
|
|
54
56
|
})
|
|
55
|
-
.then(({ data: { records } }) =>
|
|
56
|
-
records.map(
|
|
57
|
+
.then(({ data: { records } }) => {
|
|
58
|
+
return records.map(
|
|
57
59
|
(record): Workorder => ({
|
|
58
60
|
id: record.Id,
|
|
59
61
|
name: record.Name,
|
|
@@ -70,10 +72,12 @@ export class SFWorkorderClient {
|
|
|
70
72
|
externalUnitId: formatId(record.Unit__c),
|
|
71
73
|
healthAuthority: formatString(record.HealthAuthority__c),
|
|
72
74
|
externalHealthAuthorityId: formatId(record.HealthAuthority__c),
|
|
73
|
-
price: record.UnitPrice__r.Price__c
|
|
75
|
+
price: record.UnitPrice__r.Price__c,
|
|
76
|
+
travelInTime: new Date(record.TravelDate__c),
|
|
77
|
+
travelOutTime: new Date(record.ReturnDate__c)
|
|
74
78
|
})
|
|
75
79
|
)
|
|
76
|
-
)
|
|
80
|
+
})
|
|
77
81
|
} catch (error) {
|
|
78
82
|
console.error('Error fetching work orders: ', error.message)
|
|
79
83
|
throw error
|
package/src/index.ts
CHANGED