//native
/**
* Create an invoice adjustment
* Create an invoice adjustment using this endpoint. For example, you can add a bonus, commission, VAT %, deduction etc. to an invoice.
**Token scopes**: `invoice-adjustments:write`, `worker:write`
*/
export async function main(auth: RT.Deel, body: Body, recurring?: string | undefined) {
const url = new URL(`https://api.letsdeel.com/rest/v2/invoice-adjustments`)
for (const [k, v] of [['recurring', recurring]]) {
if (v !== undefined && v !== '') {
url.searchParams.append(k, v)
}
}
const formData = new FormData()
for (const [k, v] of Object.entries(body)) {
if (v !== undefined && v !== '') {
formData.append(k, String(v))
}
}
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
export interface Body {
/**
* Details of invoice adjustment to create.
*/
data: {
/**
* Type of invoice adjustment.
*/
type:
| 'bonus'
| 'commission'
| 'deduction'
| 'expense'
| 'other'
| 'overtime'
| 'time_off'
| 'vat'
/**
* Amount to be paid. Must be a positive number.
*/
amount: number
/**
* Id of a Deel contract.
*/
contract_id: string
/**
* Description of the adjustment.
*/
description: string
/**
* Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
*/
date_submitted: string
/**
* ID of an existing active payment cycle - required if type is "vat"
*/
paymentCycleId?: number
/**
* If true, the invoice adjustment will be automatically approved as part of the request.
*/
is_auto_approved?: boolean
/**
* Id of an existing preset.
*/
hourly_report_preset_id?: string
[k: string]: unknown
}
[k: string]: unknown
}
Submitted by hugo697 235 days ago