Edits history of script submission #10487 for ' Updates an employee's salary and wages record (xero)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Xero = {
    	token: string
    }
    /**
     * Updates an employee's salary and wages record
     *
     */
    export async function main(
    	auth: Xero,
    	EmployeeID: string,
    	SalaryAndWagesID: string,
    	Xero_Tenant_Id: string,
    	Idempotency_Key: string,
    	body: {
    		salaryAndWagesID?: string
    		earningsRateID: string
    		numberOfUnitsPerWeek: number
    		ratePerUnit?: number
    		numberOfUnitsPerDay: number
    		daysPerWeek?: number
    		effectiveFrom: string
    		annualSalary: number
    		status: 'Active' | 'Pending' | 'History'
    		paymentType: 'Salary' | 'Hourly'
    		workPatternType?: 'DaysAndHours' | 'RegularWeek'
    	}
    ) {
    	const url = new URL(
    		`https://api.xero.com/payroll.xro/2.0/Employees/${EmployeeID}/SalaryAndWages/${SalaryAndWagesID}`
    	)
    
    	const response = await fetch(url, {
    		method: 'PUT',
    		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