//native
type Xero = {
token: string
}
/**
* Updates the tax records for a specific employee
*
*/
export async function main(
auth: Xero,
EmployeeID: string,
Xero_Tenant_Id: string,
Idempotency_Key: string,
body: {
irdNumber?: string
taxCode?:
| 'ND'
| 'M'
| 'ME'
| 'MSL'
| 'MESL'
| 'SB'
| 'S'
| 'SH'
| 'ST'
| 'SBSL'
| 'SSL'
| 'SHSL'
| 'STSL'
| 'WT'
| 'CAE'
| 'EDW'
| 'NSW'
| 'STC'
| 'STCSL'
specialTaxRatePercentage?: number
hasSpecialStudentLoanRate?: false | true
specialStudentLoanRatePercentage?: number
isEligibleForKiwiSaver?: false | true
esctRatePercentage?: number
kiwiSaverContributions?:
| 'MakeContributions'
| 'OptOut'
| 'OnAContributionsHoliday'
| 'OnASavingsSuspension'
| 'NotCurrentlyAKiwiSaverMember'
kiwiSaverEmployeeContributionRatePercentage?: number
kiwiSaverEmployerContributionRatePercentage?: number
kiwiSaverEmployerSalarySacrificeContributionRatePercentage?: number
kiwiSaverOptOutDate?: string
kiwiSaverContributionHolidayEndDate?: string
hasStudentLoanBalance?: false | true
studentLoanBalance?: number
studentLoanAsAt?: string
}
) {
const url = new URL(`https://api.xero.com/payroll.xro/2.0/Employees/${EmployeeID}/Tax`)
const response = await fetch(url, {
method: 'POST',
headers: {
Accept: 'application/json',
'Xero-Tenant-Id': Xero_Tenant_Id,
'Idempotency-Key': Idempotency_Key,
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.token
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 515 days ago