1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Reclassify a journal entry |
7 | * Reclassifies a journal entry. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | body: { |
12 | key: string |
13 | id?: string |
14 | description?: string |
15 | referenceNumber?: string |
16 | attachment?: { key?: string; id?: string; href?: string } |
17 | state?: 'posted' |
18 | href?: string |
19 | lines?: { |
20 | key?: string |
21 | id?: string |
22 | lineNumber?: number |
23 | txnType?: 'debit' | 'credit' |
24 | txnAmount?: string |
25 | entryDate?: string |
26 | documentId?: string |
27 | description?: string |
28 | numberOfUnits?: number |
29 | reconciliationGroup?: { |
30 | clearingDate?: string |
31 | cleared?: 'true' | 'false' | 'matched' |
32 | reconciliationDate?: string |
33 | } |
34 | accountingPeriod?: number |
35 | isBillable?: false | true |
36 | isBilled?: false | true |
37 | baseAmount?: string |
38 | interEntityTxnType?: string |
39 | parent?: { key?: string; id?: string; href?: string } |
40 | state?: |
41 | | 'posted' |
42 | | 'draft' |
43 | | 'submitted' |
44 | | 'partiallyApproved' |
45 | | 'partiallyPaid' |
46 | | 'approved' |
47 | | 'paid' |
48 | | 'declined' |
49 | | 'reversalPending' |
50 | | 'reversed' |
51 | | 'reversal' |
52 | audit?: { |
53 | createdDateTime?: string |
54 | modifiedDateTime?: string |
55 | createdBy?: string |
56 | modifiedBy?: string |
57 | } |
58 | currency?: { |
59 | exchangeRateDate?: string |
60 | exchangeRateTypeId?: string |
61 | exchangeRate?: number |
62 | baseCurrency?: string |
63 | txnCurrency?: string |
64 | } |
65 | glAccount?: { key?: string; id?: string; name?: string; href?: string } |
66 | allocation?: { key?: string; id?: string; href?: string } |
67 | dimensions?: { |
68 | location?: { key?: string; id?: string; name?: string; href?: string } |
69 | department?: { |
70 | key?: string |
71 | id?: string |
72 | name?: string |
73 | href?: string |
74 | } |
75 | employee?: { key?: string; id?: string; name?: string; href?: string } |
76 | project?: { key?: string; id?: string; name?: string; href?: string } |
77 | customer?: { key?: string; id?: string; name?: string; href?: string } |
78 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
79 | item?: { key?: string; id?: string; name?: string; href?: string } |
80 | warehouse?: { key?: string; id?: string; name?: string; href?: string } |
81 | class?: { key?: string; id?: string; name?: string; href?: string } |
82 | task?: { id?: string; key?: string; name?: string; href?: string } |
83 | costType?: { id?: string; key?: string; name?: string; href?: string } |
84 | asset?: { id?: string; key?: string; name?: string; href?: string } |
85 | contract?: { id?: string; key?: string; name?: string; href?: string } |
86 | affiliateEntity?: { |
87 | key?: string |
88 | id?: string |
89 | href?: string |
90 | name?: string |
91 | } |
92 | } |
93 | href?: string |
94 | journalEntry?: { id?: string; key?: string; href?: string } |
95 | taxEntries?: { |
96 | key?: string |
97 | id?: string |
98 | baseTaxAmount?: string |
99 | txnTaxAmount?: string |
100 | taxRate?: number |
101 | } & { |
102 | taxDetail?: { key?: string; id?: string; href?: string } |
103 | journalEntryLine?: { id?: string; key?: string; href?: string } |
104 | }[] |
105 | }[] |
106 | } |
107 | ) { |
108 | const url = new URL( |
109 | `https://api.intacct.com/ia/api/v1/workflows/general-ledger/journal-entry/reclassify` |
110 | ) |
111 |
|
112 | const response = await fetch(url, { |
113 | method: 'POST', |
114 | headers: { |
115 | 'Content-Type': 'application/json', |
116 | Authorization: 'Bearer ' + auth.token |
117 | }, |
118 | body: JSON.stringify(body) |
119 | }) |
120 | if (!response.ok) { |
121 | const text = await response.text() |
122 | throw new Error(`${response.status} ${text}`) |
123 | } |
124 | return await response.json() |
125 | } |
126 |
|