1 | |
2 | type Xero = { |
3 | token: string |
4 | } |
5 | |
6 | * Updates an employee's detail |
7 | * Update properties on a single employee |
8 | */ |
9 | export async function main( |
10 | auth: Xero, |
11 | EmployeeID: string, |
12 | Xero_Tenant_Id: string, |
13 | Idempotency_Key: string, |
14 | body: { |
15 | FirstName: string |
16 | LastName: string |
17 | DateOfBirth: string |
18 | HomeAddress?: { |
19 | AddressLine1: string |
20 | AddressLine2?: string |
21 | City?: string |
22 | Region?: 'ACT' | 'NSW' | 'NT' | 'QLD' | 'SA' | 'TAS' | 'VIC' | 'WA' |
23 | PostalCode?: string |
24 | Country?: string |
25 | } |
26 | StartDate?: string |
27 | Title?: string |
28 | MiddleNames?: string |
29 | Email?: string |
30 | Gender?: 'N' | 'M' | 'F' | 'I' |
31 | Phone?: string |
32 | Mobile?: string |
33 | TwitterUserName?: string |
34 | IsAuthorisedToApproveLeave?: false | true |
35 | IsAuthorisedToApproveTimesheets?: false | true |
36 | JobTitle?: string |
37 | Classification?: string |
38 | OrdinaryEarningsRateID?: string |
39 | PayrollCalendarID?: string |
40 | EmployeeGroupName?: string |
41 | EmployeeID?: string |
42 | TerminationDate?: string |
43 | TerminationReason?: 'F' | 'I' | 'V' | 'D' | 'R' | 'C' | 'T' |
44 | BankAccounts?: { |
45 | StatementText?: string |
46 | AccountName?: string |
47 | BSB?: string |
48 | AccountNumber?: string |
49 | Remainder?: false | true |
50 | Amount?: number |
51 | }[] |
52 | PayTemplate?: { |
53 | EarningsLines?: { |
54 | EarningsRateID: string |
55 | CalculationType?: 'USEEARNINGSRATE' | 'ENTEREARNINGSRATE' | 'ANNUALSALARY' |
56 | AnnualSalary?: number |
57 | NumberOfUnitsPerWeek?: number |
58 | RatePerUnit?: number |
59 | NormalNumberOfUnits?: number |
60 | Amount?: number |
61 | NumberOfUnits?: number |
62 | FixedAmount?: number |
63 | }[] |
64 | DeductionLines?: { |
65 | DeductionTypeID: string |
66 | CalculationType?: 'FIXEDAMOUNT' | 'PRETAX' | 'POSTTAX' |
67 | Amount?: number |
68 | Percentage?: number |
69 | NumberOfUnits?: number |
70 | }[] |
71 | SuperLines?: { |
72 | SuperMembershipID?: string |
73 | ContributionType?: 'SGC' | 'SALARYSACRIFICE' | 'EMPLOYERADDITIONAL' | 'EMPLOYEE' |
74 | CalculationType?: 'FIXEDAMOUNT' | 'PERCENTAGEOFEARNINGS' | 'STATUTORY' |
75 | MinimumMonthlyEarnings?: number |
76 | ExpenseAccountCode?: string |
77 | LiabilityAccountCode?: string |
78 | Percentage?: number |
79 | Amount?: number |
80 | }[] |
81 | ReimbursementLines?: { |
82 | ReimbursementTypeID?: string |
83 | Amount?: number |
84 | Description?: string |
85 | ExpenseAccount?: string |
86 | }[] |
87 | LeaveLines?: { |
88 | LeaveTypeID?: string |
89 | CalculationType?: |
90 | | 'NOCALCULATIONREQUIRED' |
91 | | 'FIXEDAMOUNTEACHPERIOD' |
92 | | 'ENTERRATEINPAYTEMPLATE' |
93 | | 'BASEDONORDINARYEARNINGS' |
94 | EntitlementFinalPayPayoutType?: 'NOTPAIDOUT' | 'PAIDOUT' |
95 | EmploymentTerminationPaymentType?: 'R' | 'O' |
96 | IncludeSuperannuationGuaranteeContribution?: false | true |
97 | NumberOfUnits?: number |
98 | AnnualNumberOfUnits?: number |
99 | FullTimeNumberOfUnitsPerPeriod?: number |
100 | }[] |
101 | } |
102 | OpeningBalances?: { |
103 | OpeningBalanceDate?: string |
104 | Tax?: string |
105 | EarningsLines?: { |
106 | EarningsRateID: string |
107 | CalculationType?: 'USEEARNINGSRATE' | 'ENTEREARNINGSRATE' | 'ANNUALSALARY' |
108 | AnnualSalary?: number |
109 | NumberOfUnitsPerWeek?: number |
110 | RatePerUnit?: number |
111 | NormalNumberOfUnits?: number |
112 | Amount?: number |
113 | NumberOfUnits?: number |
114 | FixedAmount?: number |
115 | }[] |
116 | DeductionLines?: { |
117 | DeductionTypeID: string |
118 | CalculationType?: 'FIXEDAMOUNT' | 'PRETAX' | 'POSTTAX' |
119 | Amount?: number |
120 | Percentage?: number |
121 | NumberOfUnits?: number |
122 | }[] |
123 | SuperLines?: { |
124 | SuperMembershipID?: string |
125 | ContributionType?: 'SGC' | 'SALARYSACRIFICE' | 'EMPLOYERADDITIONAL' | 'EMPLOYEE' |
126 | CalculationType?: 'FIXEDAMOUNT' | 'PERCENTAGEOFEARNINGS' | 'STATUTORY' |
127 | MinimumMonthlyEarnings?: number |
128 | ExpenseAccountCode?: string |
129 | LiabilityAccountCode?: string |
130 | Percentage?: number |
131 | Amount?: number |
132 | }[] |
133 | ReimbursementLines?: { |
134 | ReimbursementTypeID?: string |
135 | Amount?: number |
136 | Description?: string |
137 | ExpenseAccount?: string |
138 | }[] |
139 | LeaveLines?: { |
140 | LeaveTypeID?: string |
141 | CalculationType?: |
142 | | 'NOCALCULATIONREQUIRED' |
143 | | 'FIXEDAMOUNTEACHPERIOD' |
144 | | 'ENTERRATEINPAYTEMPLATE' |
145 | | 'BASEDONORDINARYEARNINGS' |
146 | EntitlementFinalPayPayoutType?: 'NOTPAIDOUT' | 'PAIDOUT' |
147 | EmploymentTerminationPaymentType?: 'R' | 'O' |
148 | IncludeSuperannuationGuaranteeContribution?: false | true |
149 | NumberOfUnits?: number |
150 | AnnualNumberOfUnits?: number |
151 | FullTimeNumberOfUnitsPerPeriod?: number |
152 | }[] |
153 | PaidLeaveEarningsLines?: { |
154 | LeaveTypeID: string |
155 | Amount: number |
156 | SGCAppliedLeaveLoadingAmount?: number |
157 | SGCExemptedLeaveLoadingAmount?: number |
158 | ResetSTPCategorisation?: false | true |
159 | }[] |
160 | } |
161 | TaxDeclaration?: { |
162 | EmployeeID?: string |
163 | EmploymentBasis?: |
164 | | 'FULLTIME' |
165 | | 'PARTTIME' |
166 | | 'CASUAL' |
167 | | 'LABOURHIRE' |
168 | | 'SUPERINCOMESTREAM' |
169 | | 'NONEMPLOYEE' |
170 | TFNExemptionType?: 'NOTQUOTED' | 'PENDING' | 'PENSIONER' | 'UNDER18' |
171 | TaxFileNumber?: string |
172 | ABN?: string |
173 | AustralianResidentForTaxPurposes?: false | true |
174 | ResidencyStatus?: 'AUSTRALIANRESIDENT' | 'FOREIGNRESIDENT' | 'WORKINGHOLIDAYMAKER' |
175 | TaxScaleType?: |
176 | | 'WORKINGHOLIDAYMAKER' |
177 | | 'REGULAR' |
178 | | 'ACTORSARTISTSENTERTAINERS' |
179 | | 'HORTICULTURISTORSHEARER' |
180 | | 'SENIORORPENSIONER' |
181 | | 'FOREIGN' |
182 | WorkCondition?: 'PROMOTIONAL' | 'THREELESSPERFORMANCESPERWEEK' | 'NONE' |
183 | SeniorMaritalStatus?: 'MEMBEROFCOUPLE' | 'MEMBEROFILLNESSSEPARATEDCOUPLE' | 'SINGLE' |
184 | TaxFreeThresholdClaimed?: false | true |
185 | TaxOffsetEstimatedAmount?: number |
186 | HasHELPDebt?: false | true |
187 | HasSFSSDebt?: false | true |
188 | HasTradeSupportLoanDebt?: false | true |
189 | UpwardVariationTaxWithholdingAmount?: number |
190 | EligibleToReceiveLeaveLoading?: false | true |
191 | ApprovedWithholdingVariationPercentage?: number |
192 | HasStudentStartupLoan?: false | true |
193 | HasLoanOrStudentDebt?: false | true |
194 | UpdatedDateUTC?: string |
195 | } |
196 | IncomeType?: |
197 | | 'LABOURHIRE' |
198 | | 'NONEMPLOYEE' |
199 | | 'WORKINGHOLIDAYMAKER' |
200 | | 'SALARYANDWAGES' |
201 | | 'CLOSELYHELDPAYEES' |
202 | EmploymentType?: 'EMPLOYEE' | 'CONTRACTOR' |
203 | CountryOfResidence?: |
204 | | 'SA' |
205 | | 'AF' |
206 | | 'AX' |
207 | | 'AL' |
208 | | 'DZ' |
209 | | 'AS' |
210 | | 'AD' |
211 | | 'AO' |
212 | | 'AI' |
213 | | 'AQ' |
214 | | 'AG' |
215 | | 'AR' |
216 | | 'AM' |
217 | | 'AW' |
218 | | 'AU' |
219 | | 'AT' |
220 | | 'AZ' |
221 | | 'BS' |
222 | | 'BH' |
223 | | 'BD' |
224 | | 'BB' |
225 | | 'BY' |
226 | | 'BE' |
227 | | 'BZ' |
228 | | 'BJ' |
229 | | 'BM' |
230 | | 'BT' |
231 | | 'BO' |
232 | | 'BA' |
233 | | 'BW' |
234 | | 'BV' |
235 | | 'BR' |
236 | | 'IO' |
237 | | 'BN' |
238 | | 'BG' |
239 | | 'BF' |
240 | | 'BI' |
241 | | 'KH' |
242 | | 'CM' |
243 | | 'CA' |
244 | | 'CV' |
245 | | 'KY' |
246 | | 'CF' |
247 | | 'TD' |
248 | | 'CL' |
249 | | 'CN' |
250 | | 'CX' |
251 | | 'CC' |
252 | | 'CO' |
253 | | 'KM' |
254 | | 'CG' |
255 | | 'CD' |
256 | | 'CK' |
257 | | 'CR' |
258 | | 'CI' |
259 | | 'HR' |
260 | | 'CU' |
261 | | 'CY' |
262 | | 'CZ' |
263 | | 'DK' |
264 | | 'DJ' |
265 | | 'DM' |
266 | | 'DO' |
267 | | 'EC' |
268 | | 'EG' |
269 | | 'SV' |
270 | | 'GQ' |
271 | | 'ER' |
272 | | 'EE' |
273 | | 'ET' |
274 | | 'FK' |
275 | | 'FO' |
276 | | 'FJ' |
277 | | 'FI' |
278 | | 'FR' |
279 | | 'GF' |
280 | | 'PF' |
281 | | 'TF' |
282 | | 'GA' |
283 | | 'GM' |
284 | | 'GE' |
285 | | 'DE' |
286 | | 'GH' |
287 | | 'GI' |
288 | | 'GR' |
289 | | 'GL' |
290 | | 'GD' |
291 | | 'GP' |
292 | | 'GU' |
293 | | 'GT' |
294 | | 'GG' |
295 | | 'GN' |
296 | | 'GW' |
297 | | 'GY' |
298 | | 'HT' |
299 | | 'HM' |
300 | | 'VA' |
301 | | 'HN' |
302 | | 'HK' |
303 | | 'HU' |
304 | | 'IS' |
305 | | 'IN' |
306 | | 'ID' |
307 | | 'IR' |
308 | | 'IQ' |
309 | | 'IE' |
310 | | 'IM' |
311 | | 'IL' |
312 | | 'IT' |
313 | | 'JM' |
314 | | 'JP' |
315 | | 'JE' |
316 | | 'JO' |
317 | | 'KZ' |
318 | | 'KE' |
319 | | 'KI' |
320 | | 'KP' |
321 | | 'KR' |
322 | | 'KW' |
323 | | 'KG' |
324 | | 'LA' |
325 | | 'LV' |
326 | | 'LB' |
327 | | 'LS' |
328 | | 'LR' |
329 | | 'LY' |
330 | | 'LI' |
331 | | 'LT' |
332 | | 'LU' |
333 | | 'MO' |
334 | | 'MK' |
335 | | 'MG' |
336 | | 'MW' |
337 | | 'MY' |
338 | | 'MV' |
339 | | 'ML' |
340 | | 'MT' |
341 | | 'MH' |
342 | | 'MQ' |
343 | | 'MR' |
344 | | 'MU' |
345 | | 'YT' |
346 | | 'MX' |
347 | | 'FM' |
348 | | 'MD' |
349 | | 'MC' |
350 | | 'MN' |
351 | | 'ME' |
352 | | 'MS' |
353 | | 'MA' |
354 | | 'MZ' |
355 | | 'MM' |
356 | | 'NA' |
357 | | 'NR' |
358 | | 'NP' |
359 | | 'NL' |
360 | | 'AN' |
361 | | 'NC' |
362 | | 'NZ' |
363 | | 'NI' |
364 | | 'NE' |
365 | | 'NG' |
366 | | 'NU' |
367 | | 'NF' |
368 | | 'MP' |
369 | | 'NO' |
370 | | 'OM' |
371 | | 'PK' |
372 | | 'PW' |
373 | | 'PS' |
374 | | 'PA' |
375 | | 'PG' |
376 | | 'PY' |
377 | | 'PE' |
378 | | 'PH' |
379 | | 'PN' |
380 | | 'PL' |
381 | | 'PT' |
382 | | 'PR' |
383 | | 'QA' |
384 | | 'RE' |
385 | | 'RO' |
386 | | 'RU' |
387 | | 'RW' |
388 | | 'BL' |
389 | | 'SH' |
390 | | 'KN' |
391 | | 'LC' |
392 | | 'MF' |
393 | | 'PM' |
394 | | 'VC' |
395 | | 'WS' |
396 | | 'SM' |
397 | | 'ST' |
398 | | 'SN' |
399 | | 'RS' |
400 | | 'SC' |
401 | | 'SL' |
402 | | 'SG' |
403 | | 'SK' |
404 | | 'SI' |
405 | | 'SB' |
406 | | 'SO' |
407 | | 'ZA' |
408 | | 'GS' |
409 | | 'ES' |
410 | | 'LK' |
411 | | 'SD' |
412 | | 'SR' |
413 | | 'SJ' |
414 | | 'SZ' |
415 | | 'SE' |
416 | | 'CH' |
417 | | 'SY' |
418 | | 'TW' |
419 | | 'TJ' |
420 | | 'TZ' |
421 | | 'TH' |
422 | | 'TL' |
423 | | 'TG' |
424 | | 'TK' |
425 | | 'TO' |
426 | | 'TT' |
427 | | 'TN' |
428 | | 'TR' |
429 | | 'TM' |
430 | | 'TC' |
431 | | 'TV' |
432 | | 'UG' |
433 | | 'UA' |
434 | | 'AE' |
435 | | 'GB' |
436 | | 'US' |
437 | | 'UM' |
438 | | 'UY' |
439 | | 'UZ' |
440 | | 'VU' |
441 | | 'VE' |
442 | | 'VN' |
443 | | 'VG' |
444 | | 'VI' |
445 | | 'WF' |
446 | | 'EH' |
447 | | 'YE' |
448 | | 'ZM' |
449 | | 'ZW' |
450 | | 'BQ' |
451 | | 'CW' |
452 | | 'SX' |
453 | | 'SS' |
454 | IsSTP2Qualified?: false | true |
455 | LeaveBalances?: { |
456 | LeaveName?: string |
457 | LeaveTypeID?: string |
458 | NumberOfUnits?: number |
459 | TypeOfUnits?: string |
460 | }[] |
461 | LeaveLines?: { |
462 | LeaveTypeID?: string |
463 | CalculationType?: |
464 | | 'NOCALCULATIONREQUIRED' |
465 | | 'FIXEDAMOUNTEACHPERIOD' |
466 | | 'ENTERRATEINPAYTEMPLATE' |
467 | | 'BASEDONORDINARYEARNINGS' |
468 | EntitlementFinalPayPayoutType?: 'NOTPAIDOUT' | 'PAIDOUT' |
469 | EmploymentTerminationPaymentType?: 'R' | 'O' |
470 | IncludeSuperannuationGuaranteeContribution?: false | true |
471 | NumberOfUnits?: number |
472 | AnnualNumberOfUnits?: number |
473 | FullTimeNumberOfUnitsPerPeriod?: number |
474 | }[] |
475 | SuperMemberships?: { |
476 | SuperMembershipID?: string |
477 | SuperFundID: string |
478 | EmployeeNumber: string |
479 | }[] |
480 | Status?: 'ACTIVE' | 'TERMINATED' |
481 | UpdatedDateUTC?: string |
482 | ValidationErrors?: { Message?: string }[] |
483 | }[] |
484 | ) { |
485 | const url = new URL(`https://api.xero.com/payroll.xro/1.0/Employees/${EmployeeID}`) |
486 |
|
487 | const response = await fetch(url, { |
488 | method: 'POST', |
489 | headers: { |
490 | Accept: 'application/json', |
491 | 'Xero-Tenant-Id': Xero_Tenant_Id, |
492 | 'Idempotency-Key': Idempotency_Key, |
493 | 'Content-Type': 'application/json', |
494 | Authorization: 'Bearer ' + auth.token |
495 | }, |
496 | body: JSON.stringify(body) |
497 | }) |
498 | if (!response.ok) { |
499 | const text = await response.text() |
500 | throw new Error(`${response.status} ${text}`) |
501 | } |
502 | return await response.json() |
503 | } |
504 |
|