//native
type SageIntacct = {
token: string
}
/**
* Create a contract
* Creates a new contract.
`id` is required if document sequencing is not enabled for contracts. If document sequencing is enabled, you can provide an `id` value to use instead of the document sequence value.
*/
export async function main(
auth: SageIntacct,
body: {
key?: string
id?: string
href?: string
name?: string
parent?: { key?: string; id?: string; href?: string }
description?: string
status?: 'active' | 'inactive'
state?: 'draft' | 'inProgress' | 'renewed' | 'canceled' | 'notRenewed'
application?: 'contracts' | 'orderEntry'
startDate?: string
endDate?: string
contacts?: {
shipTo?: {
key?: string
id?: string
email1?: string
email2?: string
href?: string
}
billTo?: {
key?: string
id?: string
email1?: string
email2?: string
href?: string
}
additionalContact?: {
key?: string
id?: string
email1?: string
email2?: string
href?: string
}
}
cancellationDate?: string
billingFrequency?: 'monthly' | 'quarterly' | 'annually'
paymentTerm?: { key?: string; id?: string; href?: string }
billingPriceList?: { key?: string; id?: string; href?: string }
meaPriceList?: { key?: string; id?: string; href?: string }
holdBilling?: false | true
holdRevenue?: false | true
holdExpense?: false | true
currency?: {
exchangeRateType?: string
baseCurrency?: string
txnCurrency?: string
}
isRenewable?: false | true
renewedContract?: { key?: string; id?: string; href?: string }
renewal?: {
template?: string
contractTermType?: 'termed' | 'evergreen'
termLength?: number
termPeriod?: 'years' | 'months' | 'days'
triggerDate?: string
date?: string
billInAdvanceLength?: number
billInAdvancePeriod?: 'months' | 'days'
}
billInAdvanceLength?: number
billInAdvancePeriod?: 'months' | 'days'
contractType?: { key?: string; name?: string; href?: string }
deferEstimatedTimeBasedRevenueBy?: 'project' | 'projectAndItem' | 'projectAndTask'
contractTotalAmount?: string
billedAmount?: string
attachment?: { key?: string; id?: string; href?: string }
postMemo?: string
dimensions?: {
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 }
task?: { id?: string; key?: string; name?: string; href?: string }
vendor?: { key?: string; id?: string; name?: string; href?: string }
customer?: { key?: string; id?: string; name?: string; href?: string }
project?: { key?: string; id?: string; name?: string; href?: string }
employee?: { key?: string; id?: string; name?: string; href?: string }
}
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
createdByUser?: { key?: string; id?: string; href?: string }
modifiedByUser?: { key?: string; id?: string; href?: string }
}
} & {}
) {
const url = new URL(`https://api.intacct.com/ia/api/v1/objects/contracts/contract`)
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