1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update an account |
7 | * Updates an existing account by setting field values. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | key: string, |
12 | body: { |
13 | key?: string |
14 | id?: string |
15 | name?: string |
16 | accountType?: 'balanceSheet' | 'incomeStatement' |
17 | normalBalance?: 'debit' | 'credit' |
18 | closingType?: 'nonClosingAccount' | 'closingAccount' | 'closedToAccount' |
19 | closeToGLAccount?: { key?: string; id?: string; href?: string } |
20 | alternativeGLAccount?: 'none' | 'payablesAccount' | 'receivablesAccount' |
21 | disallowDirectPosting?: false | true |
22 | status?: 'active' | 'inactive' |
23 | requireDimensions?: { |
24 | class?: false | true |
25 | contract?: false | true |
26 | customer?: false | true |
27 | department?: false | true |
28 | employee?: false | true |
29 | item?: false | true |
30 | location?: false | true |
31 | project?: false | true |
32 | vendor?: false | true |
33 | warehouse?: false | true |
34 | asset?: false | true |
35 | affiliateEntity?: false | true |
36 | } |
37 | category?: string |
38 | isTaxable?: false | true |
39 | taxCode?: string |
40 | mrcCode?: string |
41 | entity?: { key?: string; id?: string; name?: string; href?: string } |
42 | audit?: { |
43 | createdDateTime?: string |
44 | modifiedDateTime?: string |
45 | createdBy?: string |
46 | modifiedBy?: string |
47 | } |
48 | href?: string |
49 | } |
50 | ) { |
51 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/general-ledger/account/${key}`) |
52 |
|
53 | const response = await fetch(url, { |
54 | method: 'PATCH', |
55 | headers: { |
56 | 'Content-Type': 'application/json', |
57 | Authorization: 'Bearer ' + auth.token |
58 | }, |
59 | body: JSON.stringify(body) |
60 | }) |
61 | if (!response.ok) { |
62 | const text = await response.text() |
63 | throw new Error(`${response.status} ${text}`) |
64 | } |
65 | return await response.json() |
66 | } |
67 |
|