1 | |
2 | type Xero = { |
3 | token: string |
4 | } |
5 | |
6 | * Updates salary and wages record for a specific employee |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Xero, |
11 | EmployeeID: string, |
12 | SalaryAndWagesID: string, |
13 | Xero_Tenant_Id: string, |
14 | Idempotency_Key: string, |
15 | body: { |
16 | salaryAndWagesID?: string |
17 | earningsRateID: string |
18 | numberOfUnitsPerWeek: number |
19 | ratePerUnit?: number |
20 | numberOfUnitsPerDay?: number |
21 | effectiveFrom: string |
22 | annualSalary: number |
23 | status: 'Active' | 'Pending' | 'History' |
24 | paymentType: 'Salary' | 'Hourly' |
25 | } |
26 | ) { |
27 | const url = new URL( |
28 | `https://api.xero.com/payroll.xro/2.0/Employees/${EmployeeID}/SalaryAndWages/${SalaryAndWagesID}` |
29 | ) |
30 |
|
31 | const response = await fetch(url, { |
32 | method: 'PUT', |
33 | headers: { |
34 | Accept: 'application/json', |
35 | 'Xero-Tenant-Id': Xero_Tenant_Id, |
36 | 'Idempotency-Key': Idempotency_Key, |
37 | 'Content-Type': 'application/json', |
38 | Authorization: 'Bearer ' + auth.token |
39 | }, |
40 | body: JSON.stringify(body) |
41 | }) |
42 | if (!response.ok) { |
43 | const text = await response.text() |
44 | throw new Error(`${response.status} ${text}`) |
45 | } |
46 | return await response.json() |
47 | } |
48 |
|