//native
type SageIntacct = {
token: string
}
/**
* Update an account
* Updates an existing account by setting field values.
*/
export async function main(
auth: SageIntacct,
key: string,
body: {
key?: string
id?: string
name?: string
accountType?: 'balanceSheet' | 'incomeStatement'
normalBalance?: 'debit' | 'credit'
closingType?: 'nonClosingAccount' | 'closingAccount' | 'closedToAccount'
closeToGLAccount?: { key?: string; id?: string; href?: string }
alternativeGLAccount?: 'none' | 'payablesAccount' | 'receivablesAccount'
disallowDirectPosting?: false | true
status?: 'active' | 'inactive'
requireDimensions?: {
class?: false | true
contract?: false | true
customer?: false | true
department?: false | true
employee?: false | true
item?: false | true
location?: false | true
project?: false | true
vendor?: false | true
warehouse?: false | true
asset?: false | true
affiliateEntity?: false | true
}
category?: string
isTaxable?: false | true
taxCode?: string
mrcCode?: string
entity?: { key?: string; id?: string; name?: string; href?: string }
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
href?: string
}
) {
const url = new URL(`https://api.intacct.com/ia/api/v1/objects/general-ledger/account/${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