pha-hermes 1.21.0 → 1.23.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.
@@ -0,0 +1,70 @@
1
+ import { AxiosInstance } from 'axios'
2
+ import { Price } from '../../../models/price'
3
+ import { SF_API_VERSION } from '../apiClient'
4
+
5
+ export class SFPriceClient {
6
+ private axiosInstance: AxiosInstance
7
+
8
+ constructor(axiosInstance: AxiosInstance) {
9
+ this.axiosInstance = axiosInstance
10
+ }
11
+
12
+ async getPriceListByWorkorderId(workorderId?: string): Promise<Price> {
13
+ try {
14
+ const url = `/services/data/${SF_API_VERSION}/query`
15
+ const query = `SELECT UnitPrice__r.Price__r.Id,
16
+ UnitPrice__r.Price__r.Name,
17
+ UnitPrice__r.Price__r.MileageBillingRate__c,
18
+ UnitPrice__r.Price__r.MileageWageRate__c,
19
+ UnitPrice__r.Price__r.BillingRate__c,
20
+ UnitPrice__r.Price__r.WageRate__c,
21
+ UnitPrice__r.Price__r.Overtime1BillingRate__c,
22
+ UnitPrice__r.Price__r.Overtime1WageRate__c,
23
+ UnitPrice__r.Price__r.Overtime2BillingRate__c,
24
+ UnitPrice__r.Price__r.Overtime2WageRate__c,
25
+ UnitPrice__r.Price__r.CallBackBillingRate__c,
26
+ UnitPrice__r.Price__r.CallBackWageRate__c,
27
+ UnitPrice__r.Price__r.OnCallBillingRate__c,
28
+ UnitPrice__r.Price__r.OnCallWageRate__c,
29
+ UnitPrice__r.Price__r.Additional_Billing_Information__c,
30
+ UnitPrice__r.Price__r.Additional_Wage_Information__c
31
+ FROM WorkOrder__c WHERE Id = '${workorderId}' `
32
+
33
+ return await this.axiosInstance
34
+ .get(url, {
35
+ params: { q: query }
36
+ })
37
+ .then(({ data: { records } }) => {
38
+ return records.map(
39
+ (record): Price => ({
40
+ id: record?.UnitPrice__r?.Price__r.Id,
41
+ name: record?.UnitPrice__r?.Price__r.Name,
42
+ mileageBillingRate:
43
+ record?.UnitPrice__r?.Price__r.MileageBillingRate__c,
44
+ mileageWageRate: record?.UnitPrice__r?.Price__r.MileageWageRate__c,
45
+ regularBillingRate: record?.UnitPrice__r?.Price__r.BillingRate__c,
46
+ regularWageRate: record?.UnitPrice__r?.Price__r.WageRate__c,
47
+ overtime1BillingRate:
48
+ record?.UnitPrice__r?.Price__r.Overtime1BillingRate__c,
49
+ overtime1WageRate: record?.UnitPrice__r?.Price__r.Overtime1WageRate__c,
50
+ overtime2BillingRate:
51
+ record?.UnitPrice__r?.Price__r.Overtime2BillingRate__c,
52
+ overtime2WageRate: record?.UnitPrice__r?.Price__r.Overtime2WageRate__c,
53
+ callbackBillingRate:
54
+ record?.UnitPrice__r?.Price__r.CallBackBillingRate__c,
55
+ callbackWageRate: record?.UnitPrice__r?.Price__r.CallBackWageRate__c,
56
+ onCallBillingRate: record?.UnitPrice__r?.Price__r.OnCallBillingRate__c,
57
+ onCallWageRate: record?.UnitPrice__r?.Price__r.OnCallWageRate__c,
58
+ additionalBillingInfo:
59
+ record?.UnitPrice__r?.Price__r.Additional_Billing_Information__c,
60
+ additionalWageInfo:
61
+ record?.UnitPrice__r?.Price__r.Additional_Wage_Information__c
62
+ })
63
+ )
64
+ })
65
+ } catch (error) {
66
+ console.error('Error fetching Price list: ', error.message)
67
+ throw error
68
+ }
69
+ }
70
+ }
@@ -45,14 +45,17 @@ export class SFWorkorderClient {
45
45
  CreatedDate,
46
46
  LastModifiedDate,
47
47
  Unit__c,
48
- HealthAuthority__c
48
+ HealthAuthority__c,
49
+ UnitPrice__r.Price__c,
50
+ TravelDate__c,
51
+ ReturnDate__c
49
52
  FROM WorkOrder__c ${whereClause}`
50
53
  return await this.axiosInstance
51
54
  .get(url, {
52
55
  params: { q: query }
53
56
  })
54
- .then(({ data: { records } }) =>
55
- records.map(
57
+ .then(({ data: { records } }) => {
58
+ return records.map(
56
59
  (record): Workorder => ({
57
60
  id: record.Id,
58
61
  name: record.Name,
@@ -68,10 +71,13 @@ export class SFWorkorderClient {
68
71
  unit: formatString(record.Unit__c),
69
72
  externalUnitId: formatId(record.Unit__c),
70
73
  healthAuthority: formatString(record.HealthAuthority__c),
71
- externalHealthAuthorityId: formatId(record.HealthAuthority__c)
74
+ externalHealthAuthorityId: formatId(record.HealthAuthority__c),
75
+ price: record.UnitPrice__r.Price__c,
76
+ travelInTime: new Date(record.TravelDate__c),
77
+ travelOutTime: new Date(record.ReturnDate__c)
72
78
  })
73
79
  )
74
- )
80
+ })
75
81
  } catch (error) {
76
82
  console.error('Error fetching work orders: ', error.message)
77
83
  throw error
@@ -79,11 +85,12 @@ export class SFWorkorderClient {
79
85
  }
80
86
  }
81
87
 
82
- const formatString = (unformattedUnit: string) => !unformattedUnit ? '' : unformattedUnit.replace(/<[^>]*>/g, '').trim()
88
+ const formatString = (unformattedUnit: string) =>
89
+ !unformattedUnit ? '' : unformattedUnit.replace(/<[^>]*>/g, '').trim()
83
90
 
84
91
  const formatId = (htmlString: string): string => {
85
92
  if (!htmlString) return ''
86
-
93
+
87
94
  const hrefMatch = htmlString.match(/href="\/([^"]+)"/i)
88
95
  return hrefMatch ? hrefMatch[1] : ''
89
96
  }
package/src/index.ts CHANGED
@@ -3,12 +3,13 @@ export { SFApiClient } from './api/salesforce/apiClient'
3
3
  export { SFPractitionerClient } from './api/salesforce/practitioner/practitionerClient'
4
4
  export { SFTimesheetClient } from './api/salesforce/timesheet/timesheetClient'
5
5
  export { SFAuthenticator } from './api/salesforce/auth/auth'
6
+ export { SFPriceClient } from './api/salesforce/prices/priceClient'
7
+ export { SFExpenseClient } from './api/salesforce/expenses/expenseClient'
6
8
 
7
9
  // Liphe API
8
10
  export { LipheApiClient } from './api/liphe_legacy/lipheApiClient'
9
11
  export { LipheAuthenticator } from './api/liphe_legacy/auth/authClient'
10
12
  export { LiphePractitionerClient } from './api/liphe_legacy/practitioner/practitionerClient'
11
- export { SFExpenseClient } from './api/expenses/expenseClient'
12
13
 
13
14
  // Common Models
14
15
  export { Practitioner, Role, TimesheetDayEntry, Workorder, Agency, Period } from './models'
@@ -0,0 +1,18 @@
1
+ export interface Price {
2
+ id: string
3
+ name?: string
4
+ mileageBillingRate?: number
5
+ mileageWageRate?: number
6
+ regularBillingRate?: number
7
+ regularWageRate?: number
8
+ overtime1BillingRate?: number
9
+ overtime2BillingRate?: number
10
+ overtime1WageRate?: number
11
+ overtime2WageRate?: number
12
+ callbackBillingRate?: number
13
+ callbackWageRate?: number
14
+ onCallBillingRate?: number
15
+ onCallWageRate?: number
16
+ additionalBillingInfo?: string
17
+ additionalWageInfo?: string
18
+ }
@@ -22,4 +22,7 @@ export interface Workorder {
22
22
  externalUnitId?: string
23
23
  healthAuthority?: string
24
24
  externalHealthAuthorityId?: string
25
+ price?: string
26
+ travelInTime?: Date
27
+ travelOutTime?: Date
25
28
  }