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.
@@ -1,6 +1,6 @@
1
1
  import { AxiosInstance } from 'axios'
2
2
  import { Price } from '../../../models/price'
3
- import { SF_API_VERSION } from '../apiClient'
3
+ import { SF_API_VERSION } from '../../../index'
4
4
 
5
5
  export class SFPriceClient {
6
6
  private axiosInstance: AxiosInstance
@@ -1,6 +1,6 @@
1
1
  import { AxiosInstance } from 'axios'
2
2
  import { TimesheetDayEntry } from '../../../models'
3
- import { SF_API_VERSION } from '../apiClient'
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(workorderId: string, periodStartDate?: Date, periodEndDate?: Date): Promise<string[]> {
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(workorderId: string, fields?: SFTimesheetHourFieldKeys[], periodStartDate?: Date, periodEndDate?: Date): Promise<TimesheetDayEntry[]> {
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 '../apiClient'
2
+ import { SF_API_VERSION } from '../../../index'
3
3
  import { Workorder } from '../../../models'
4
4
 
5
5
  export class SFWorkorderClient {
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export const SF_API_VERSION: string = 'v57.0'
2
+
1
3
  // Salesforce API
2
4
  export { SFApiClient } from './api/salesforce/apiClient'
3
5
  export { SFPractitionerClient } from './api/salesforce/practitioner/practitionerClient'