//native
type Xero = {
token: string
}
/**
* Creates a new earnings rate
*
*/
export async function main(
auth: Xero,
Xero_Tenant_Id: string,
Idempotency_Key: string,
body: {
earningsRateID?: string
name: string
earningsType:
| 'Allowance'
| 'BackPay'
| 'Bonus'
| 'Commission'
| 'LumpSum'
| 'OtherEarnings'
| 'OvertimeEarnings'
| 'RegularEarnings'
| 'StatutoryAdoptionPay'
| 'StatutoryAdoptionPayNonPensionable'
| 'StatutoryBereavementPay'
| 'StatutoryMaternityPay'
| 'StatutoryMaternityPayNonPensionable'
| 'StatutoryPaternityPay'
| 'StatutoryPaternityPayNonPensionable'
| 'StatutoryParentalBereavementPayNonPensionable'
| 'StatutorySharedParentalPay'
| 'StatutorySharedParentalPayNonPensionable'
| 'StatutorySickPay'
| 'StatutorySickPayNonPensionable'
| 'TipsNonDirect'
| 'TipsDirect'
| 'TerminationPay'
rateType: 'RatePerUnit' | 'MultipleOfOrdinaryEarningsRate' | 'FixedAmount'
typeOfUnits: string
currentRecord?: false | true
expenseAccountID: string
ratePerUnit?: number
multipleOfOrdinaryEarningsRate?: number
fixedAmount?: number
}
) {
const url = new URL(`https://api.xero.com/payroll.xro/2.0/EarningsRates`)
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