//native
type SageIntacct = {
token: string
}
/**
* Create a bill
* Creates a new bill. After you create a bill, it can be moved through the normal Accounts Payable workflow.
Permissions and other requirements
SubscriptionAccounts Payable
User typeBusiness
PermissionsList, View, Add Bills
*/
export async function main(
auth: SageIntacct,
body: {
key?: string
id?: string
href?: string
billNumber?: string
state?:
| 'reversed'
| 'reversal'
| 'analyzing'
| 'partiallyApproved'
| 'submitted'
| 'declined'
| 'noValue'
| 'posted'
| 'paid'
| 'partiallyPaid'
| 'selected'
| 'draft'
recordType?: string
vendor?: {
key?: string
id?: string
name?: string
href?: string
vendorDue?: string
form1099?: {
type?: string
box?: string
vendorTypeForm1099Type?: string
}
}
term?: { key?: string; id?: string; href?: string }
referenceNumber?: string
description?: string
dueInDays?: string
postingDate?: string
discountCutOffDate?: string
dueDate?: string
recommendedPaymentDate?: string
createdDate?: string
isOnHold?: false | true
isTaxInclusive?: false | true
paymentPriority?: 'urgent' | 'high' | 'normal' | 'low'
totalBaseAmount?: string
totalBaseAmountDue?: string
totalTxnAmount?: string
totalTxnAmountDue?: string
isSystemGenerated?: false | true
purchasing?: { id?: string; key?: string; href?: string }
recurringSchedule?: { key?: string; id?: string; href?: string }
contacts?: {
payTo?: {
key?: string
id?: string
tax?: {
taxId?: string
group?: { key?: string; id?: string; href?: string }
}
href?: string
}
returnTo?: { key?: string; id?: string; href?: string }
}
currency?: {
baseCurrency?: string
txnCurrency?: string
exchangeRate?: { date?: string; rate?: number; typeId?: string }
}
taxSolution?: {
key?: string
id?: string
showMultiLineTax?: string
taxCalculationMethod?: string
method?: string
href?: string
}
billSummary?: {
key?: string
id?: string
name?: string
isSummaryOpen?: 'open' | 'closed'
isSummaryPosted?: string
href?: string
}
sourceModule?: 'accountsPayable' | 'purchasing'
paymentInformation?: {
fullyPaidDate?: string
totalBaseAmountPaid?: string
totalBaseAmountSelectedForPayment?: string
totalTxnAmountSelectedForPayment?: string
totalTxnAmountPaid?: string
}
retainage?: {
defaultPercentage?: string
totalTxnAmountRetained?: string
totalTxnAmountReleased?: string
totalBaseAmountRetained?: string
}
billBackTemplate?: {
key?: string
id?: string
enableInterEntityPostings?: false | true
href?: string
}
attachment?: { key?: string; id?: string; href?: string }
location?: { key?: string; id?: string; name?: string; href?: string }
lines?: {
id?: string
key?: string
href?: string
lineNumber?: string
hasForm1099?: string
form1099?: { type?: string; box?: string }
createdDate?: string
glAccount?: { key?: string; id?: string; name?: string; href?: string }
overrideOffsetGLAccount?: {
key?: string
id?: string
name?: string
href?: string
}
accountLabel?: { key?: string; id?: string; href?: string }
baseAmount?: string
txnAmount?: string
totalTxnAmount?: string
memo?: string
allocation?: { key?: string; id?: string; href?: string }
currency?: {
baseCurrency?: string
txnCurrency?: string
exchangeRate?: { date?: string; rate?: number; typeId?: string }
}
paymentInformation?: {
totalBaseAmountPaid?: string
totalTxnAmountPaid?: string
totalBaseAmountSelectedForPayment?: string
totalTxnAmountSelectedForPayment?: string
}
releaseToPay?: false | true
isSubTotal?: 'subtotal' | 'tax'
baseLocation?: {
key?: string
id?: string
name?: string
href?: string
} & { key?: string }
retainage?: {
hasRetainage?: false | true
percentage?: string
baseAmountRetained?: string
txnAmountRetained?: string
txnAmountReleased?: string
release?: false | true
}
project?: { isBillable?: false | true; isBilled?: false | true }
fixedAsset?: {
nameOfAcquiredAsset?: string
includeTaxInAssetCost?: false | true
}
purchasing?: {
document?: { key?: string; id?: string; href?: string }
documentLine?: { key?: string; id?: string; href?: string }
}
taxEntries?: {
key?: string
id?: string
baseTaxAmount?: string
txnTaxAmount?: string
taxRate?: number
} & {
purchasingTaxDetail?: { key?: string; id?: string; href?: string }
billLine?: { id?: string; key?: string; href?: string }
isPartialExemption?: false | true
}[]
dimensions?: {
location?: { key?: string; id?: string; name?: string; href?: string }
department?: {
key?: string
id?: string
name?: string
href?: string
}
employee?: { key?: string; id?: string; name?: string; href?: string }
project?: { key?: string; id?: string; name?: string; href?: string }
customer?: { key?: string; id?: string; name?: string; href?: string }
vendor?: { key?: string; id?: string; name?: string; href?: string }
item?: { key?: string; id?: string; name?: string; href?: string }
warehouse?: { 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 }
costType?: { id?: string; key?: string; name?: string; href?: string }
asset?: { id?: string; key?: string; name?: string; href?: string }
contract?: { id?: string; key?: string; name?: string; href?: string }
affiliateEntity?: {
key?: string
id?: string
href?: string
name?: string
}
} & {
location?: { key?: string; id?: string; name?: string; href?: string }
department?: {
key?: string
id?: string
name?: string
href?: string
}
}
bill?: { id?: string; key?: string; href?: string }
}[]
entity?: { key?: string; id?: string; name?: string; href?: string }
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
} & { vendor?: {}; currency?: {}; lines?: { dimensions?: {} }[] }
) {
const url = new URL(`https://api.intacct.com/ia/api/v1/objects/accounts-payable/bill`)
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