//native
type SageIntacct = {
token: string
}
/**
* Create an employee
* Creates a new employee. If the employee is also a user in Sage Intacct (which is required if they will be entering time or expenses), set the `primaryContact` to the same contact that is associated with the user.
Permissions and other requirements
SubscriptionCompany
User typeBusiness user with admin privileges
PermissionsAdd Employees
*/
export async function main(
auth: SageIntacct,
body: {
key?: string
id?: string
name?: string
startDate?: string
jobTitle?: string
status?: 'active' | 'inactive'
birthDate?: string
endDate?: string
postActualCostWithVariance?: false | true
mergePaymentRequests?: false | true
sendAutomaticPaymentNotification?: false | true
manager?: { key?: string; id?: string; name?: string; href?: string }
gender?: 'female' | 'male'
location?: { key?: string; id?: string; name?: string; href?: string }
department?: { key?: string; id?: string; name?: string; href?: string }
class?: { key?: string; id?: string; name?: string; href?: string }
defaultCurrency?: string
primaryContact?: {
key?: string
id?: string
lastName?: string
firstName?: string
middleName?: string
prefix?: string
email1?: string
email2?: string
phone1?: string
phone2?: string
mobile?: string
pager?: string
fax?: string
URL1?: string
URL2?: string
companyName?: string
printAs?: string
mailingAddress?: {
addressLine1?: string
addressLine2?: string
city?: string
state?: string
postCode?: string
country?: string
isoCountryCode?: string
}
href?: string
}
employeeType?: { key?: string; id?: string; href?: string }
earningType?: { key?: string; id?: string; href?: string }
SSN?: string
employeePosition?: {
key?: string
id?: string
name?: string
href?: string
}
terminationType?: 'voluntary' | 'involuntary' | 'deceased' | 'disability' | 'retired'
form1099?: { name?: string; type?: string; box?: string }
ach?: {
enabled?: false | true
bankRoutingNumber?: string
accountNumber?: string
accountType?: 'checkingAccount' | 'savingsAccount'
remittanceType?: 'personalPPD' | 'businessCCD' | 'businessCTX'
}
isPlaceholderResource?: false | true
filePaymentService?: 'ach' | 'bankFile' | 'none'
bankFile?: {
paymentCountryCode?:
| 'us'
| 'af'
| 'ax'
| 'al'
| 'dz'
| 'as'
| 'ad'
| 'ao'
| 'ai'
| 'aq'
| 'ag'
| 'ar'
| 'am'
| 'aw'
| 'au'
| 'at'
| 'az'
| 'bs'
| 'bh'
| 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om'
| 'pk'
| 'pw'
| 'ps'
| 'pa'
| 'pg'
| 'py'
| 'pe'
| 'ph'
| 'pn'
| 'pl'
| 'pt'
| 'pr'
| 'qa'
| 're'
| 'ro'
| 'ru'
| 'rw'
| 'bl'
| 'sh'
| 'kn'
| 'lc'
| 'mf'
| 'pm'
| 'vc'
| 'ws'
| 'sm'
| 'st'
| 'sa'
| 'sn'
| 'rs'
| 'sc'
| 'sl'
| 'sg'
| 'sx'
| 'sk'
| 'si'
| 'sb'
| 'so'
| 'za'
| 'gs'
| 'es'
| 'lk'
| 'sd'
| 'ss'
| 'sr'
| 'sj'
| 'se'
| 'ch'
| 'sy'
| 'tw'
| 'tj'
| 'tz'
| 'th'
| 'tl'
| 'tg'
| 'tk'
| 'to'
| 'tt'
| 'tn'
| 'tr'
| 'tm'
| 'tc'
| 'tv'
| 'ug'
| 'ua'
| 'ae'
| 'gb'
| 'um'
| 'uy'
| 'uz'
| 'vu'
| 'va'
| 've'
| 'vn'
| 'vg'
| 'vi'
| 'wf'
| 'eh'
| 'ye'
| 'zm'
| 'zw'
paymentCurrency?: string
}
bankFileSetup?: {
key?: string
id?: string
bankAccountNumber?: string
bankAccountName?: string
bsbNumber?: string
sortCode?: string
paymentReference?: string
branchCode?: string
bankAccountType?: string
bankAccountCode?: string
printPaymentProof?: false | true
businessIdCode?: string
creditorCode?: string
secondaryIdentifier?: string
employee?: { key?: string; id?: string; href?: string }
href?: string
}[]
preferredPaymentMethod?: 'ach' | 'printedCheck' | 'eft' | 'cash'
attachmentFolder?: { key?: string; id?: string; href?: string }
employeeRates?: {
key?: string
id?: string
href?: string
hourlyRate?: string
annualSalary?: string
startDate?: string
endDate?: string
employee?: { id?: string; key?: string; name?: string; href?: string }
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
}[]
positionSkills?: { key?: string; id?: string; href?: string }[]
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
entity?: { key?: string; id?: string; name?: string; href?: string }
href?: string
} & {}
) {
const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/employee`)
const response = await fetch(url, {
method: 'POST',
headers: {
'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 235 days ago