//native
type SageIntacct = {
token: string
}
/**
* Update an account group
* Updates an existing account group by setting field values. Any fields not provided remain unchanged.
*/
export async function main(
auth: SageIntacct,
key: string,
body: {
key?: string
id?: string
title?: string
displayTotalLineAs?: string
manager?: string
calculationMethod?: 'period' | 'startOfPeriod' | 'endOfPeriod'
normalBalance?: 'debit' | 'credit'
groupType?:
| 'accounts'
| 'groups'
| 'statisticalAccounts'
| 'computation'
| 'category'
| 'statisticalCategory'
isKPI?: false | true
includeChildAmount?: false | true
accountGroupPurpose?: { key?: string; id?: string; href?: string }
reportFilters?: {
location?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue'
debitOrCredit?: 'both' | 'debitOnly' | 'creditOnly'
department?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue'
vendor?: 'noFilter' | 'specificHierarchy' | 'specific' | 'unspecified'
customer?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue'
project?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue'
employee?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue'
item?: 'noFilter' | 'specific' | 'nullValue'
class?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue'
contract?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue'
task?: 'noFilter' | 'nullValue'
warehouse?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue'
costType?: 'noFilter' | 'nullValue'
asset?: 'noFilter' | 'specificHierarchy' | 'specific' | 'nullValue'
affiliateEntity?: 'noFilter' | 'specific' | 'nullValue'
}
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 }
locationGroup?: {
key?: string
id?: string
name?: string
href?: string
}
department?: { key?: string; id?: string; name?: string; href?: string }
departmentGroup?: {
key?: string
id?: string
name?: string
href?: string
}
}
accountRanges?: {
key?: string
id?: string
sortOrder?: number
rangeFrom?: string
rangeTo?: string
glAccountGroup?: { key?: string; id?: string; href?: string }
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
href?: string
}[]
statisticalAccountRanges?: {
key?: string
id?: string
sortOrder?: number
rangeFrom?: string
rangeTo?: string
glAccountGroup?: { key?: string; id?: string; href?: string }
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
href?: string
}[]
accountGroupMembers?: {
key?: string
id?: string
href?: string
sortOrder?: number
accountGroup?: { key?: string; id?: string; href?: string }
glAccountGroup?: { key?: string; id?: string; href?: string }
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
}[]
accountGroupCategoryMembers?: {
key?: string
id?: string
href?: string
sortOrder?: number
accountCategory?: { key?: string; id?: string; href?: string }
glAccountGroup?: { key?: string; id?: string; href?: string }
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
}[]
statisticalAccountGroupCategoryMembers?: {
key?: string
id?: string
href?: string
sortOrder?: number
accountCategory?: { key?: string; id?: string; href?: string }
glAccountGroup?: { key?: string; id?: string; href?: string }
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
}[]
accountGroupComputation?: {
key?: string
id?: string
href?: string
formulaLeft?:
| { glAccountGroup?: { id?: string; key?: string; href?: string } }
| {
glAccount?: {
id?: string
key?: string
name?: string
href?: string
}
asOf?: 'startOfPeriod' | 'endOfPeriod' | 'forPeriod'
}
| { constant?: string }
operator?: 'add' | 'subtract' | 'multiply' | 'divide'
formulaRight?:
| { glAccountGroup?: { id?: string; key?: string; href?: string } }
| {
glAccount?: {
id?: string
key?: string
name?: string
href?: string
}
asOf?: 'startOfPeriod' | 'endOfPeriod' | 'forPeriod'
}
| { constant?: string }
numberOfDecimalPlaces?: number
displayAs?:
| 'number'
| 'percent'
| 'ratioWithDecimals'
| 'ratioWithoutDecimals'
| 'dailyAverage'
| 'weeklyAverage'
| 'monthlyAverage'
| 'quarterlyAverage'
unit?: string
unitPlacement?: 'left' | 'right'
glAccountGroup?: { key?: string; id?: string; href?: string }
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
}[]
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
href?: string
} & { id?: {} }
) {
const url = new URL(
`https://api.intacct.com/ia/api/v1/objects/general-ledger/account-group/${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