pha-hermes 1.14.0 → 1.16.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/expenses/expenseClient.d.ts +15 -0
- package/dist/api/liphe_legacy/assignment/assignmentClient.d.ts +28 -0
- package/dist/api/{liphe1.0 → liphe_legacy}/auth/authClient.d.ts +1 -1
- package/dist/api/liphe_legacy/contract_request/contractRequestClient.d.ts +80 -0
- package/dist/api/liphe_legacy/contract_request_period/contractRequestPeriodClient.d.ts +47 -0
- package/dist/api/{lipheApiClient.d.ts → liphe_legacy/lipheApiClient.d.ts} +4 -2
- package/dist/api/liphe_legacy/practitioner/practitionerClient.d.ts +7 -0
- package/dist/api/{apiClient.d.ts → salesforce/apiClient.d.ts} +3 -1
- package/dist/api/{payperiod → salesforce/payperiod}/payperiodClient.d.ts +1 -7
- package/dist/api/{practitioner → salesforce/practitioner}/practitionerClient.d.ts +1 -1
- package/dist/api/{timesheet → salesforce/timesheet}/timesheetClient.d.ts +1 -1
- package/dist/api/{workorder → salesforce/workorder}/workorderClient.d.ts +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/models/expense.d.ts +6 -0
- package/dist/models/index.d.ts +13 -17
- package/dist/models/{practitioner.d.ts → user.d.ts} +4 -0
- package/dist/models/workorder.d.ts +20 -0
- package/dist/pha-hermes.cjs.development.js +356 -3
- 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 +357 -4
- package/dist/pha-hermes.esm.js.map +1 -1
- package/package.json +2 -1
- package/src/api/expenses/expenseClient.ts +70 -0
- package/src/api/liphe_legacy/assignment/assignmentClient.ts +67 -0
- package/src/api/{liphe1.0 → liphe_legacy}/auth/authClient.ts +11 -2
- package/src/api/liphe_legacy/contract_request/contractRequestClient.ts +128 -0
- package/src/api/liphe_legacy/contract_request_period/contractRequestPeriodClient.ts +233 -0
- package/src/api/{lipheApiClient.ts → liphe_legacy/lipheApiClient.ts} +23 -3
- package/src/api/{liphe1.0 → liphe_legacy}/practitioner/practitionerClient.ts +12 -4
- package/src/api/{apiClient.ts → salesforce/apiClient.ts} +4 -1
- package/src/api/{payperiod → salesforce/payperiod}/payperiodClient.ts +1 -8
- package/src/api/{practitioner → salesforce/practitioner}/practitionerClient.ts +1 -1
- package/src/api/{timesheet → salesforce/timesheet}/timesheetClient.ts +1 -1
- package/src/api/{workorder → salesforce/workorder}/workorderClient.ts +1 -1
- package/src/index.ts +14 -8
- package/src/models/expense.ts +6 -0
- package/src/models/index.ts +13 -18
- package/src/models/{practitioner.ts → user.ts} +5 -0
- package/src/models/workorder.ts +21 -0
- package/dist/api/liphe1.0/practitioner/practitionerClient.d.ts +0 -13
- package/src/api/.env +0 -5
- /package/dist/api/{auth → salesforce/auth}/auth.d.ts +0 -0
- /package/src/api/{auth → salesforce/auth}/auth.ts +0 -0
package/dist/pha-hermes.esm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import FormData from 'form-data';
|
|
3
|
+
import axiosRetry from 'axios-retry';
|
|
3
4
|
|
|
4
5
|
function _arrayLikeToArray(r, a) {
|
|
5
6
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -1078,6 +1079,125 @@ var listOfIdsForQuery = function listOfIdsForQuery(payPeriodIDs) {
|
|
|
1078
1079
|
return "('" + payPeriodIDs.join('\', \'') + "')";
|
|
1079
1080
|
};
|
|
1080
1081
|
|
|
1082
|
+
var EXPENSE_FIELD_MAP = {
|
|
1083
|
+
Lodging: 'StipendTotalOverride__c',
|
|
1084
|
+
'Per diem': 'Per_Diem_Total__c',
|
|
1085
|
+
Other: 'Reimburseable_Expenses__c',
|
|
1086
|
+
Transportation: 'TaxiAmount__c'
|
|
1087
|
+
};
|
|
1088
|
+
var SFExpenseClient = /*#__PURE__*/function () {
|
|
1089
|
+
function SFExpenseClient(axiosInstance) {
|
|
1090
|
+
this.axiosInstance = axiosInstance;
|
|
1091
|
+
}
|
|
1092
|
+
var _proto = SFExpenseClient.prototype;
|
|
1093
|
+
_proto.fetchExpenseTotals = /*#__PURE__*/function () {
|
|
1094
|
+
var _fetchExpenseTotals = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(timesheetId) {
|
|
1095
|
+
var url, _yield$this$axiosInst, data;
|
|
1096
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1097
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1098
|
+
case 0:
|
|
1099
|
+
_context.prev = 0;
|
|
1100
|
+
url = "/services/data/" + SF_API_VERSION + "/sobjects/Timesheet__c/" + timesheetId;
|
|
1101
|
+
_context.next = 4;
|
|
1102
|
+
return this.axiosInstance.get(url, {
|
|
1103
|
+
params: {
|
|
1104
|
+
fields: 'Reimburseable_Expenses__c,Per_Diem_Total__c,StipendTotalOverride__c,TaxiAmount__c'
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
case 4:
|
|
1108
|
+
_yield$this$axiosInst = _context.sent;
|
|
1109
|
+
data = _yield$this$axiosInst.data;
|
|
1110
|
+
if (data) {
|
|
1111
|
+
_context.next = 8;
|
|
1112
|
+
break;
|
|
1113
|
+
}
|
|
1114
|
+
return _context.abrupt("return", null);
|
|
1115
|
+
case 8:
|
|
1116
|
+
return _context.abrupt("return", toExpense(data));
|
|
1117
|
+
case 11:
|
|
1118
|
+
_context.prev = 11;
|
|
1119
|
+
_context.t0 = _context["catch"](0);
|
|
1120
|
+
console.error('Failed to fetch expense totals', _context.t0);
|
|
1121
|
+
throw _context.t0;
|
|
1122
|
+
case 15:
|
|
1123
|
+
case "end":
|
|
1124
|
+
return _context.stop();
|
|
1125
|
+
}
|
|
1126
|
+
}, _callee, this, [[0, 11]]);
|
|
1127
|
+
}));
|
|
1128
|
+
function fetchExpenseTotals(_x) {
|
|
1129
|
+
return _fetchExpenseTotals.apply(this, arguments);
|
|
1130
|
+
}
|
|
1131
|
+
return fetchExpenseTotals;
|
|
1132
|
+
}();
|
|
1133
|
+
_proto.patchTimesheet = /*#__PURE__*/function () {
|
|
1134
|
+
var _patchTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(timesheetId, body) {
|
|
1135
|
+
var url, res;
|
|
1136
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1137
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1138
|
+
case 0:
|
|
1139
|
+
url = "/services/data/" + SF_API_VERSION + "/sobjects/Timesheet__c/" + timesheetId;
|
|
1140
|
+
_context2.next = 3;
|
|
1141
|
+
return this.axiosInstance.patch(url, body);
|
|
1142
|
+
case 3:
|
|
1143
|
+
res = _context2.sent;
|
|
1144
|
+
if ([200, 204, 304].includes(res.status)) {
|
|
1145
|
+
_context2.next = 6;
|
|
1146
|
+
break;
|
|
1147
|
+
}
|
|
1148
|
+
throw new Error("Unexpected status " + res.status);
|
|
1149
|
+
case 6:
|
|
1150
|
+
case "end":
|
|
1151
|
+
return _context2.stop();
|
|
1152
|
+
}
|
|
1153
|
+
}, _callee2, this);
|
|
1154
|
+
}));
|
|
1155
|
+
function patchTimesheet(_x2, _x3) {
|
|
1156
|
+
return _patchTimesheet.apply(this, arguments);
|
|
1157
|
+
}
|
|
1158
|
+
return patchTimesheet;
|
|
1159
|
+
}();
|
|
1160
|
+
_proto.updateExpense = /*#__PURE__*/function () {
|
|
1161
|
+
var _updateExpense = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(expense) {
|
|
1162
|
+
var _this$patchTimesheet;
|
|
1163
|
+
var timesheetId, amount, field;
|
|
1164
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1165
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1166
|
+
case 0:
|
|
1167
|
+
timesheetId = expense.workorderPeriodId;
|
|
1168
|
+
amount = Number(expense.amount);
|
|
1169
|
+
field = EXPENSE_FIELD_MAP[expense.type];
|
|
1170
|
+
if (field) {
|
|
1171
|
+
_context3.next = 5;
|
|
1172
|
+
break;
|
|
1173
|
+
}
|
|
1174
|
+
throw new Error("Unsupported expense type: " + expense.type);
|
|
1175
|
+
case 5:
|
|
1176
|
+
_context3.next = 7;
|
|
1177
|
+
return this.patchTimesheet(timesheetId, (_this$patchTimesheet = {}, _this$patchTimesheet[field] = amount, _this$patchTimesheet));
|
|
1178
|
+
case 7:
|
|
1179
|
+
case "end":
|
|
1180
|
+
return _context3.stop();
|
|
1181
|
+
}
|
|
1182
|
+
}, _callee3, this);
|
|
1183
|
+
}));
|
|
1184
|
+
function updateExpense(_x4) {
|
|
1185
|
+
return _updateExpense.apply(this, arguments);
|
|
1186
|
+
}
|
|
1187
|
+
return updateExpense;
|
|
1188
|
+
}();
|
|
1189
|
+
return SFExpenseClient;
|
|
1190
|
+
}();
|
|
1191
|
+
function toExpense(raw) {
|
|
1192
|
+
var _raw$Reimburseable_Ex, _raw$Per_Diem_Total__, _raw$StipendTotalOver, _raw$TaxiAmount__c;
|
|
1193
|
+
return {
|
|
1194
|
+
reimbursable: Number((_raw$Reimburseable_Ex = raw.Reimburseable_Expenses__c) != null ? _raw$Reimburseable_Ex : 0),
|
|
1195
|
+
perDiem: Number((_raw$Per_Diem_Total__ = raw.Per_Diem_Total__c) != null ? _raw$Per_Diem_Total__ : 0),
|
|
1196
|
+
lodging: Number((_raw$StipendTotalOver = raw.StipendTotalOverride__c) != null ? _raw$StipendTotalOver : 0),
|
|
1197
|
+
transportation: Number((_raw$TaxiAmount__c = raw.TaxiAmount__c) != null ? _raw$TaxiAmount__c : 0)
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1081
1201
|
var SF_API_VERSION = 'v57.0';
|
|
1082
1202
|
var SFApiClient = /*#__PURE__*/function () {
|
|
1083
1203
|
function SFApiClient(baseUrl) {
|
|
@@ -1090,6 +1210,7 @@ var SFApiClient = /*#__PURE__*/function () {
|
|
|
1090
1210
|
this.workorderClient = new SFWorkorderClient(this.axiosInstance);
|
|
1091
1211
|
this.practitionerClient = new SFPractitionerClient(this.axiosInstance);
|
|
1092
1212
|
this.payPeriodClient = new SFPayPeriodClient(this.axiosInstance);
|
|
1213
|
+
this.expenseClient = new SFExpenseClient(this.axiosInstance);
|
|
1093
1214
|
}
|
|
1094
1215
|
var _proto = SFApiClient.prototype;
|
|
1095
1216
|
_proto.init = /*#__PURE__*/function () {
|
|
@@ -1166,6 +1287,12 @@ var LipheAuthenticator = /*#__PURE__*/function () {
|
|
|
1166
1287
|
this.token = undefined;
|
|
1167
1288
|
this.tokenRefreshPromise = null;
|
|
1168
1289
|
this.authenticatedAxiosInstance = authenticatedAxiosInstance;
|
|
1290
|
+
axiosRetry(this.axiosTokenInstance, {
|
|
1291
|
+
retries: 10,
|
|
1292
|
+
retryDelay: function retryDelay(retryCount) {
|
|
1293
|
+
return Math.min(1000 * Math.pow(2, retryCount - 1), 30000);
|
|
1294
|
+
}
|
|
1295
|
+
});
|
|
1169
1296
|
this.email = email;
|
|
1170
1297
|
this.password = password;
|
|
1171
1298
|
this.type = type;
|
|
@@ -1254,7 +1381,7 @@ var LipheAuthenticator = /*#__PURE__*/function () {
|
|
|
1254
1381
|
form.append('password', this.password);
|
|
1255
1382
|
form.append('type', this.type);
|
|
1256
1383
|
_context3.next = 6;
|
|
1257
|
-
return this.axiosTokenInstance.post('
|
|
1384
|
+
return this.axiosTokenInstance.post('v2/signin', form, {
|
|
1258
1385
|
headers: form.getHeaders()
|
|
1259
1386
|
});
|
|
1260
1387
|
case 6:
|
|
@@ -1305,7 +1432,7 @@ var LiphePractitionerClient = /*#__PURE__*/function () {
|
|
|
1305
1432
|
break;
|
|
1306
1433
|
}
|
|
1307
1434
|
_context.next = 7;
|
|
1308
|
-
return this.axios.get('
|
|
1435
|
+
return this.axios.get('v2/employees', {
|
|
1309
1436
|
params: {
|
|
1310
1437
|
agency_id: agencyId,
|
|
1311
1438
|
page: page
|
|
@@ -1335,7 +1462,15 @@ var LiphePractitionerClient = /*#__PURE__*/function () {
|
|
|
1335
1462
|
_context.next = 4;
|
|
1336
1463
|
break;
|
|
1337
1464
|
case 17:
|
|
1338
|
-
return _context.abrupt("return", practitioners)
|
|
1465
|
+
return _context.abrupt("return", practitioners.map(function (p) {
|
|
1466
|
+
return {
|
|
1467
|
+
id: String(p.id),
|
|
1468
|
+
firstName: p.firstname,
|
|
1469
|
+
lastName: p.lastname,
|
|
1470
|
+
email: p.email,
|
|
1471
|
+
staffId: String(p.id)
|
|
1472
|
+
};
|
|
1473
|
+
}));
|
|
1339
1474
|
case 18:
|
|
1340
1475
|
case "end":
|
|
1341
1476
|
return _context.stop();
|
|
@@ -1350,6 +1485,200 @@ var LiphePractitionerClient = /*#__PURE__*/function () {
|
|
|
1350
1485
|
return LiphePractitionerClient;
|
|
1351
1486
|
}();
|
|
1352
1487
|
|
|
1488
|
+
var ContractRequestPeriodClient = /*#__PURE__*/function () {
|
|
1489
|
+
function ContractRequestPeriodClient(axiosInstance) {
|
|
1490
|
+
this.axiosInstance = axiosInstance;
|
|
1491
|
+
}
|
|
1492
|
+
var _proto = ContractRequestPeriodClient.prototype;
|
|
1493
|
+
_proto.fetchAllContractRequestPeriods = /*#__PURE__*/function () {
|
|
1494
|
+
var _fetchAllContractRequestPeriods = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(agencyId, from, to, page, activeAssignationsOnly, assignedPractitionerId) {
|
|
1495
|
+
var url, params, periods, nextPage, response, _iterator, _step, period;
|
|
1496
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1497
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1498
|
+
case 0:
|
|
1499
|
+
if (page === void 0) {
|
|
1500
|
+
page = 1;
|
|
1501
|
+
}
|
|
1502
|
+
if (activeAssignationsOnly === void 0) {
|
|
1503
|
+
activeAssignationsOnly = true;
|
|
1504
|
+
}
|
|
1505
|
+
url = "v2/contract-request-periods/agency/" + agencyId;
|
|
1506
|
+
params = new URLSearchParams();
|
|
1507
|
+
periods = [];
|
|
1508
|
+
nextPage = true;
|
|
1509
|
+
if (from) {
|
|
1510
|
+
params.append('from', from.toISOString().split('T')[0] + ' 00:00:00');
|
|
1511
|
+
}
|
|
1512
|
+
if (to) {
|
|
1513
|
+
params.append('to', to.toISOString().split('T')[0] + ' 23:59:59');
|
|
1514
|
+
}
|
|
1515
|
+
if (page) {
|
|
1516
|
+
params.append('page', page.toString());
|
|
1517
|
+
}
|
|
1518
|
+
if (activeAssignationsOnly) {
|
|
1519
|
+
params.append('active_assignations_only', activeAssignationsOnly ? '1' : '0');
|
|
1520
|
+
}
|
|
1521
|
+
if (assignedPractitionerId) {
|
|
1522
|
+
params.append('assigned_employee_id', assignedPractitionerId);
|
|
1523
|
+
}
|
|
1524
|
+
case 11:
|
|
1525
|
+
if (!nextPage) {
|
|
1526
|
+
_context.next = 21;
|
|
1527
|
+
break;
|
|
1528
|
+
}
|
|
1529
|
+
params.set('page', page.toString());
|
|
1530
|
+
_context.next = 15;
|
|
1531
|
+
return this.axiosInstance.get(url, {
|
|
1532
|
+
params: params
|
|
1533
|
+
});
|
|
1534
|
+
case 15:
|
|
1535
|
+
response = _context.sent;
|
|
1536
|
+
for (_iterator = _createForOfIteratorHelperLoose(response.data.data); !(_step = _iterator()).done;) {
|
|
1537
|
+
period = _step.value;
|
|
1538
|
+
periods.push({
|
|
1539
|
+
id: period.id.toString(),
|
|
1540
|
+
name: period.id.toString(),
|
|
1541
|
+
establishmentId: period.contract_request.community.id.toString(),
|
|
1542
|
+
region: period.contract_request.community.contact.address_state,
|
|
1543
|
+
establishmentName: period.contract_request.community.name,
|
|
1544
|
+
role: this.getRole(period),
|
|
1545
|
+
practitionerId: period.assignment.selected_client.id,
|
|
1546
|
+
startDate: new Date(period.start_date),
|
|
1547
|
+
endDate: new Date(period.end_date),
|
|
1548
|
+
createdAt: new Date(period.created_at),
|
|
1549
|
+
updatedAt: new Date(period.updated_at)
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
nextPage = page < response.data.meta.last_page;
|
|
1553
|
+
page++;
|
|
1554
|
+
_context.next = 11;
|
|
1555
|
+
break;
|
|
1556
|
+
case 21:
|
|
1557
|
+
return _context.abrupt("return", periods);
|
|
1558
|
+
case 22:
|
|
1559
|
+
case "end":
|
|
1560
|
+
return _context.stop();
|
|
1561
|
+
}
|
|
1562
|
+
}, _callee, this);
|
|
1563
|
+
}));
|
|
1564
|
+
function fetchAllContractRequestPeriods(_x, _x2, _x3, _x4, _x5, _x6) {
|
|
1565
|
+
return _fetchAllContractRequestPeriods.apply(this, arguments);
|
|
1566
|
+
}
|
|
1567
|
+
return fetchAllContractRequestPeriods;
|
|
1568
|
+
}();
|
|
1569
|
+
_proto.fetchContractRequestPeriod = /*#__PURE__*/function () {
|
|
1570
|
+
var _fetchContractRequestPeriod = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(workorderId) {
|
|
1571
|
+
var url, params, response;
|
|
1572
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1573
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1574
|
+
case 0:
|
|
1575
|
+
url = "v2/contract-request-periods/" + workorderId;
|
|
1576
|
+
params = new URLSearchParams();
|
|
1577
|
+
_context2.next = 4;
|
|
1578
|
+
return this.axiosInstance.get(url, {
|
|
1579
|
+
params: params
|
|
1580
|
+
});
|
|
1581
|
+
case 4:
|
|
1582
|
+
response = _context2.sent;
|
|
1583
|
+
return _context2.abrupt("return", response.data.data);
|
|
1584
|
+
case 6:
|
|
1585
|
+
case "end":
|
|
1586
|
+
return _context2.stop();
|
|
1587
|
+
}
|
|
1588
|
+
}, _callee2, this);
|
|
1589
|
+
}));
|
|
1590
|
+
function fetchContractRequestPeriod(_x7) {
|
|
1591
|
+
return _fetchContractRequestPeriod.apply(this, arguments);
|
|
1592
|
+
}
|
|
1593
|
+
return fetchContractRequestPeriod;
|
|
1594
|
+
}();
|
|
1595
|
+
_proto.getPayPeriodDatesForPayPeriodId = /*#__PURE__*/function () {
|
|
1596
|
+
var _getPayPeriodDatesForPayPeriodId = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payPeriodId) {
|
|
1597
|
+
var period, payPeriods, firstPayPeriodDate, lastPayPeriodDate, weeksBetween, i, tempDate, startDate, endDate;
|
|
1598
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1599
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1600
|
+
case 0:
|
|
1601
|
+
_context3.next = 2;
|
|
1602
|
+
return this.fetchContractRequestPeriod(payPeriodId);
|
|
1603
|
+
case 2:
|
|
1604
|
+
period = _context3.sent;
|
|
1605
|
+
payPeriods = [];
|
|
1606
|
+
firstPayPeriodDate = this.getPayPeriodDayBeforeStartDate(new Date(period.assignment.selected_client.agency.date_first_periode_paie), new Date(period.start_date));
|
|
1607
|
+
lastPayPeriodDate = this.getLastDayOfPayPeriod(new Date(firstPayPeriodDate), new Date(period.end_date)); // Calculate the number of weeks between lastPayPeriodDate and firstPayPeriodDate
|
|
1608
|
+
weeksBetween = this.calculateWeeksBetween(firstPayPeriodDate, lastPayPeriodDate);
|
|
1609
|
+
for (i = 0; i < weeksBetween; i++) {
|
|
1610
|
+
tempDate = new Date(firstPayPeriodDate);
|
|
1611
|
+
startDate = new Date(tempDate.setDate(tempDate.getDate() + 7 * i));
|
|
1612
|
+
endDate = new Date(tempDate.setDate(tempDate.getDate() + 6));
|
|
1613
|
+
payPeriods.push({
|
|
1614
|
+
payPeriodId: '',
|
|
1615
|
+
startDate: startDate.toISOString().split('T')[0],
|
|
1616
|
+
endDate: endDate.toISOString().split('T')[0],
|
|
1617
|
+
workorderId: payPeriodId
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
return _context3.abrupt("return", payPeriods);
|
|
1621
|
+
case 9:
|
|
1622
|
+
case "end":
|
|
1623
|
+
return _context3.stop();
|
|
1624
|
+
}
|
|
1625
|
+
}, _callee3, this);
|
|
1626
|
+
}));
|
|
1627
|
+
function getPayPeriodDatesForPayPeriodId(_x8) {
|
|
1628
|
+
return _getPayPeriodDatesForPayPeriodId.apply(this, arguments);
|
|
1629
|
+
}
|
|
1630
|
+
return getPayPeriodDatesForPayPeriodId;
|
|
1631
|
+
}();
|
|
1632
|
+
_proto.getRole = function getRole(period) {
|
|
1633
|
+
if (period.contract_request.job.translations.length === 0) {
|
|
1634
|
+
return '';
|
|
1635
|
+
}
|
|
1636
|
+
if (period.contract_request.job.translations.length > 1) {
|
|
1637
|
+
var roleTranslation = period.contract_request.job.translations.find(function (translation) {
|
|
1638
|
+
return translation.locale === 'en';
|
|
1639
|
+
});
|
|
1640
|
+
return roleTranslation == null ? void 0 : roleTranslation.content;
|
|
1641
|
+
} else {
|
|
1642
|
+
return period.contract_request.job.translations[0].content;
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
/**
|
|
1646
|
+
* Calculates the pay period day of week that comes before the start date
|
|
1647
|
+
* @param firstPayPeriodDate The first pay period date from the agency
|
|
1648
|
+
* @param startDate The start date to find the pay period before
|
|
1649
|
+
* @returns The day of week (0-6, where 0 is Sunday) of the pay period before start_date
|
|
1650
|
+
*/;
|
|
1651
|
+
_proto.getPayPeriodDayBeforeStartDate = function getPayPeriodDayBeforeStartDate(firstPayPeriodDate, startDate) {
|
|
1652
|
+
var payPeriodDayOfWeek = firstPayPeriodDate.getDay();
|
|
1653
|
+
// Calculate the most recent pay period date that falls before start_date
|
|
1654
|
+
var tempDate = new Date(startDate);
|
|
1655
|
+
// Go back one week at a time until we find a date that matches the pay period day of week
|
|
1656
|
+
while (tempDate.getDay() !== payPeriodDayOfWeek) {
|
|
1657
|
+
tempDate.setDate(tempDate.getDate() - 1);
|
|
1658
|
+
}
|
|
1659
|
+
// If the calculated date is not before start_date, go back another week
|
|
1660
|
+
if (tempDate >= startDate) {
|
|
1661
|
+
tempDate.setDate(tempDate.getDate() - 7);
|
|
1662
|
+
}
|
|
1663
|
+
return tempDate;
|
|
1664
|
+
};
|
|
1665
|
+
_proto.getLastDayOfPayPeriod = function getLastDayOfPayPeriod(firstPayPeriodDate, endDate) {
|
|
1666
|
+
var tempDate = new Date(firstPayPeriodDate);
|
|
1667
|
+
// Go back one week at a time until we find a date that matches the pay period day of week
|
|
1668
|
+
while (endDate > tempDate) {
|
|
1669
|
+
tempDate.setDate(tempDate.getDate() + 7);
|
|
1670
|
+
}
|
|
1671
|
+
return tempDate;
|
|
1672
|
+
};
|
|
1673
|
+
_proto.calculateWeeksBetween = function calculateWeeksBetween(startDate, endDate) {
|
|
1674
|
+
var diffTime = Math.abs(endDate.getTime() - startDate.getTime());
|
|
1675
|
+
var diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
|
1676
|
+
var weeks = Math.floor(diffDays / 7);
|
|
1677
|
+
return weeks;
|
|
1678
|
+
};
|
|
1679
|
+
return ContractRequestPeriodClient;
|
|
1680
|
+
}();
|
|
1681
|
+
|
|
1353
1682
|
var LipheApiClient = /*#__PURE__*/function () {
|
|
1354
1683
|
function LipheApiClient(baseUrl, email, password, type) {
|
|
1355
1684
|
if (type === void 0) {
|
|
@@ -1359,7 +1688,17 @@ var LipheApiClient = /*#__PURE__*/function () {
|
|
|
1359
1688
|
this.axiosInstance = axios.create();
|
|
1360
1689
|
this.axiosInstance.defaults.baseURL = baseUrl;
|
|
1361
1690
|
this.authenticator = new LipheAuthenticator(this.axiosInstance, baseUrl, email, password, type);
|
|
1691
|
+
axiosRetry(this.axiosInstance, {
|
|
1692
|
+
retries: 10,
|
|
1693
|
+
retryDelay: function retryDelay(retryCount) {
|
|
1694
|
+
return Math.min(1000 * Math.pow(2, retryCount - 1), 30000);
|
|
1695
|
+
},
|
|
1696
|
+
onRetry: function onRetry(retryCount, error) {
|
|
1697
|
+
console.log("Retry attempt " + retryCount + " failed: " + error.message);
|
|
1698
|
+
}
|
|
1699
|
+
});
|
|
1362
1700
|
this.practitionerClient = new LiphePractitionerClient(this.axiosInstance);
|
|
1701
|
+
this.contractRequestPeriodClient = new ContractRequestPeriodClient(this.axiosInstance);
|
|
1363
1702
|
}
|
|
1364
1703
|
var _proto = LipheApiClient.prototype;
|
|
1365
1704
|
_proto.init = /*#__PURE__*/function () {
|
|
@@ -1392,5 +1731,19 @@ var LipheApiClient = /*#__PURE__*/function () {
|
|
|
1392
1731
|
return LipheApiClient;
|
|
1393
1732
|
}();
|
|
1394
1733
|
|
|
1395
|
-
|
|
1734
|
+
var Agency;
|
|
1735
|
+
(function (Agency) {
|
|
1736
|
+
Agency["CHCA"] = "7";
|
|
1737
|
+
Agency["CodeBleu"] = "5";
|
|
1738
|
+
Agency["NordikOntario"] = "6";
|
|
1739
|
+
Agency["PHA"] = "8";
|
|
1740
|
+
Agency["PremierSoin"] = "1";
|
|
1741
|
+
Agency["PremierSoinNordik"] = "3";
|
|
1742
|
+
Agency["SolutionNursing"] = "4";
|
|
1743
|
+
Agency["SolutionsStaffing"] = "9";
|
|
1744
|
+
Agency["Transport"] = "2";
|
|
1745
|
+
Agency["SSI"] = "99";
|
|
1746
|
+
})(Agency || (Agency = {}));
|
|
1747
|
+
|
|
1748
|
+
export { Agency, LipheApiClient, LipheAuthenticator, LiphePractitionerClient, SFApiClient, SFAuthenticator, SFExpenseClient, SFPractitionerClient, SFTimesheetClient };
|
|
1396
1749
|
//# sourceMappingURL=pha-hermes.esm.js.map
|