pha-hermes 1.23.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/practitioner/practitionerClient.d.ts +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/pha-hermes.cjs.development.js +63 -19
- 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 +63 -20
- package/dist/pha-hermes.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/api/.env +5 -0
- package/src/api/salesforce/expenses/expenseClient.ts +1 -1
- 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 +1 -1
- package/src/index.ts +2 -0
|
@@ -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)}`
|