//native
/**
* Initiate EOR contract termination request
* Enables clients to initiate a request for the termination of an Employee of Record (EOR) contract for members of their team.
**Token scopes**: `contracts:write`
*/
export async function main(auth: RT.Deel, contract_id: string, body: Body) {
const url = new URL(
`https://api.letsdeel.com/rest/v2/eor/contracts/${contract_id}/offboarding/termination`
)
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: {
Authorization: 'Bearer ' + auth.apiKey
},
body: formData
})
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 {
data: {
/**
* Reason why the contract is being terminated
*/
reason:
| 'DEEL_COLLECTIONS'
| 'STATUS_CHANGE'
| 'RELOCATION'
| 'COMPENSATION'
| 'RETIREMENT'
| 'JOB_ABANDONMENT'
| 'WORK_RELATED'
| 'PERSONAL'
| 'OTHER_OPPORTUNITY'
| 'NON_RENEWAL'
| 'PROBATION'
| 'ASSIGNMENT_ENDED'
| 'POSITION_ELIMINATION'
| 'FORCE_REDUCTION'
| 'DEATH'
| 'FOR_CAUSE'
| 'PERFORMANCE'
| 'MEDICAL'
| 'PERFORMANCE_ISSUES'
| 'ATTENDANCE_ISSUES'
| 'REORGANIZATION_DOWNSIZING_BUDGET_OR_REDUCTION_OF_WORKFORCE'
| 'ROLE_BECAME_REDUNDANT_OR_ROLE_CHANGED'
| 'OFFER_WAS_REVOKED'
| 'EXITING_THE_MARKET'
| 'NO_LONGER_WISH_TO_WORK_WITH_DEEL'
| 'COMPANY_ACQUIRED'
| 'STEALING'
| 'MISCONDUCT'
| 'FALSIFYING'
| 'HARASSMENT'
| 'VIOLENCE'
| 'REORGANIZATION_DOWNSIZING_BUDGET_OR_REDUCTION_OF_WORKFORCE_OR_ROLE_BECAME_REDUNDANT_OR_ROLE_CHANGED'
| 'UNAUTHORIZED_ABSENCES_OR_LACK_OF_ATTENDANCE'
| 'STANDARD_RESELLER_PRACTICE'
| 'MOVING_EMPLOYEE_TO_INTERNAL_ENTITY'
| 'MOVING_EMPLOYEE_TO_DEEL_PEO'
| 'OTHER'
/**
* This field allows for uploading multiple files at once. Attach any document that is important for the request to terminate the contract. Includes common image formats (JPG, JPEG, PNG, HEIC) and PDF documents.
*/
attachments?: string
/**
* Defines whether the termination is sensitive. In this case, only the person requesting the termination will be able to view the termination, receive emails or notifications.
*/
is_sensitive?: boolean
/**
* Field to better explain how communication with the employee will be and/or their reaction to the communication, or other necessary information
*/
reason_detail: string
used_time_off: {
/**
* Type of time off tracking - whether it's tracked on Deel platform or off platform
*/
tracking_type?: 'ON_PLATFORM' | 'OFF_PLATFORM'
/**
* Required when tracking_type is OFF_PLATFORM, null otherwise
*/
off_platform_used_time_off?: {
/**
* Array of time off entitlements for different tracking periods
*/
entitlements: {
/**
* Amount of time off used in the period
*/
used: number
/**
* Start date of the tracking period
*/
tracking_period: string
/**
* End date of the tracking period
*/
tracking_period_end_date: string
[k: string]: unknown
}[]
/**
* Total amount of time off scheduled until the end date
*/
total_scheduled: number
/**
* Unit of measurement for the time off entitlements
*/
entitlement_unit: 'BUSINESS_DAY' | 'CALENDAR_DAY' | 'HOUR' | 'WEEK' | 'MONTH' | 'YEAR'
[k: string]: unknown
}
[k: string]: unknown
}
/**
* The type of severance selected by the client. It's an optional field
*/
severance_type?: 'DAYS' | 'WEEKS' | 'MONTHS' | 'CASH'
/**
* The desired end date of the contract. If the date is not provided, Deel HRX team will select the nearest possible date.
*/
desired_end_date?: string
/**
* The amount of severance needed
*/
severance_amount?: number
/**
* An additional reason can be provided in case the reason selected is NO_LONGER_WISH_TO_WORK_WITH_DEEL
*/
additional_reason?:
| 'DISSATISFIED_WITH_DEEL_SERVICE'
| 'DISSATISFIED_WITH_DEEL_PRICING'
| 'DISSATISFIED_WITH_DEEL_PRODUCT'
/**
* Additional notes can be provided regarding the termination for Deel, like questions and doubts
*/
termination_notes?: string[]
/**
* Parameter to inform whether it would be possible for the client to hire the employee again
*/
eligible_for_rehire?: 'YES' | 'NO' | 'DONT_KNOW'
/**
* Defines if employee was informed by client or not before the termination
*/
is_employee_notified: boolean
/**
* For some countries some data is needed to help to process the termination. The questions comes from another endpoint to get the required information. See GET /eor/:oid/offboarding/required-information to get the questions.
*/
required_information?: {
/**
* The answer to the question
*/
answer: boolean
/**
* The question to be answered
*/
question: string
[k: string]: unknown
}[]
/**
* Termination impact data if there is some configured on HR module
*/
termination_impact_id?: string
/**
* If it's an termination contract ending and employee was already informed, should detail the notification to the employee
*/
employee_notification_detail?: string
/**
* This field allows for uploading multiple files at once. Any proof such as correspondence, documentation of previous warnings or attendance records for the reason select above. Includes common image formats (JPG, JPEG, PNG, HEIC) and PDF documents.
*/
additional_supporting_documents?: string
[k: string]: unknown
}
[k: string]: unknown
}
Submitted by hugo697 235 days ago