//native
type SageIntacct = {
token: string
}
/**
* Update an advance
* Updates an existing advance by setting field values. Any fields not provided remain unchanged. Advances that have not yet been applied to an invoice can be updated. The General Ledger account book for the advance must also be open. If an advance was applied to an invoice and later unapplied, it cannot be updated.
Permissions and other requirements
SubscriptionAccounts Receivable
User typeBusiness, Employee, Project Manager, and Warehouse users
PermissionsList, View, Edit Advances
*/
export async function main(
auth: SageIntacct,
key: string,
body: {
key?: string
id?: string
recordType?: string
href?: string
referenceNumber?: string
description?: string
state?:
| 'reversed'
| 'reversal'
| 'draft'
| 'reconciled'
| 'fullyApplied'
| 'partiallyApplied'
| 'posted'
| 'selected'
totalEntered?: string
txnTotalEntered?: string
paymentInformation?: {
paymentDate?: string
totalPaid?: string
totalSelected?: string
txnTotalSelected?: string
txnTotalPaid?: string
totalDue?: string
totalTxnAmountDue?: string
paymentMethod?: 'printedCheck' | 'creditCard' | 'eft' | 'cash' | 'ach'
receiptDate?: string
financialEntity?: { key?: string; id?: string; href?: string }
currency?: {
exchangeRateDate?: string
exchangeRateTypeId?: string
exchangeRate?: number
baseCurrency?: string
txnCurrency?: string
}
}
reconciliationGroup?: {
clearingDate?: string
cleared?: 'true' | 'false' | 'matched'
}
isSystemGenerated?: false | true
createdDate?: string
deposit?: { key?: string; id?: string; href?: string }
advanceSummary?: { href?: string; key?: string; id?: string }
customer?: { href?: string; id?: string; key?: string; name?: string }
glAccount?: {
href?: string
id?: string
key?: string
undepositedGLAccountNumber?: string
}
attachment?: { key?: string; id?: string; href?: string }
items?: {
key?: string
id?: string
href?: string
baseAmount?: string
txnAmount?: string
memo?: string
currency?: {
baseCurrency?: string
txnCurrency?: string
exchangeRate?: { date?: string; rate?: number; typeId?: string }
}
lineNumber?: number
paymentInformation?: {
totalPaid?: string
txnTotalPaid?: string
totalSelected?: string
txnTotalSelected?: string
}
baseLocation?: {
key?: string
id?: string
name?: string
href?: string
} & { key?: string }
accountLabel?: {
key?: string
id?: string
name?: string
href?: string
}
glAccount?: { key?: string; id?: string; name?: string; href?: string }
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
}
}
arAdvance?: {
id?: string
key?: string
href?: string
recordType?: string
}
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
}[]
entity?: { key?: string; id?: string; name?: string; href?: string }
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
} & { id?: {} }
) {
const url = new URL(
`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/advance/${key}`
)
const response = await fetch(url, {
method: 'PATCH',
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