1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create an adjustment |
7 | * Creates a new adjustment. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionAccounts Receivable |
13 | User typeBusiness |
14 | PermissionsList, View, and Add Adjustments |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | body: { |
23 | key?: string |
24 | id?: string |
25 | txnType?: string |
26 | adjustmentNumber?: string |
27 | href?: string |
28 | contacts?: { |
29 | billTo?: { key?: string; id?: string; href?: string } |
30 | shipTo?: { |
31 | key?: string |
32 | id?: string |
33 | href?: string |
34 | tax?: { |
35 | taxId?: string |
36 | group?: { key?: string; id?: string; href?: string } |
37 | } |
38 | } |
39 | } |
40 | state?: |
41 | | 'reversed' |
42 | | 'reversal' |
43 | | 'draft' |
44 | | 'noValue' |
45 | | 'posted' |
46 | | 'paid' |
47 | | 'partiallyPaid' |
48 | | 'selected' |
49 | description?: string |
50 | documentNumber?: string |
51 | baseCurrency?: { |
52 | currency?: string |
53 | totalPaid?: string |
54 | totalSelected?: string |
55 | totalDue?: string |
56 | totalAmountEntered?: string |
57 | paidDate?: string |
58 | } |
59 | txnCurrency?: { |
60 | currency?: string |
61 | totalEntered?: string |
62 | totalSelected?: string |
63 | totalPaid?: string |
64 | totalDue?: string |
65 | } |
66 | exchangeRate?: { date?: string; rate?: string; typeId?: string } |
67 | moduleKey?: string |
68 | customer?: { |
69 | key?: string |
70 | id?: string |
71 | name?: string |
72 | totalDue?: string |
73 | href?: string |
74 | } |
75 | createdDate?: string |
76 | glPostingDate?: string |
77 | taxSolution?: { key?: string; id?: string; href?: string } |
78 | attachment?: { key?: string; id?: string; href?: string } |
79 | adjustmentSummary?: { href?: string; key?: number; id?: string } |
80 | lines?: { |
81 | id?: string |
82 | key?: string |
83 | memo?: string |
84 | lineNumber?: string |
85 | baseCurrency?: { currency?: string; amount?: string } |
86 | txnCurrency?: { currency?: string; amount?: string } |
87 | exchangeRate?: { date?: string; rate?: string; typeId?: string } |
88 | adjustmentType?: string |
89 | isTax?: false | true |
90 | accountLabel?: { key?: string; id?: string; href?: string } |
91 | taxEntries?: { |
92 | key?: string |
93 | id?: string |
94 | baseTaxAmount?: string |
95 | txnTaxAmount?: string |
96 | taxRate?: number |
97 | } & { |
98 | orderEntryTaxDetail?: { key?: string; id?: string; href?: string } |
99 | adjustmentLine?: { id?: string; key?: string; href?: string } |
100 | }[] |
101 | arAdjustment?: { key?: string; id?: string; href?: string } |
102 | dimensions?: { |
103 | location?: { key?: string; id?: string; name?: string; href?: string } |
104 | department?: { |
105 | key?: string |
106 | id?: string |
107 | name?: string |
108 | href?: string |
109 | } |
110 | employee?: { key?: string; id?: string; name?: string; href?: string } |
111 | project?: { key?: string; id?: string; name?: string; href?: string } |
112 | customer?: { key?: string; id?: string; name?: string; href?: string } |
113 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
114 | item?: { key?: string; id?: string; name?: string; href?: string } |
115 | warehouse?: { key?: string; id?: string; name?: string; href?: string } |
116 | class?: { key?: string; id?: string; name?: string; href?: string } |
117 | task?: { id?: string; key?: string; name?: string; href?: string } |
118 | costType?: { id?: string; key?: string; name?: string; href?: string } |
119 | asset?: { id?: string; key?: string; name?: string; href?: string } |
120 | contract?: { id?: string; key?: string; name?: string; href?: string } |
121 | affiliateEntity?: { |
122 | key?: string |
123 | id?: string |
124 | href?: string |
125 | name?: string |
126 | } |
127 | } & { |
128 | department?: { |
129 | key?: string |
130 | id?: string |
131 | name?: string |
132 | href?: string |
133 | } |
134 | location?: { key?: string; id?: string; name?: string; href?: string } |
135 | } |
136 | glAccount?: { key?: string; id?: string; name?: string; href?: string } |
137 | audit?: { |
138 | createdDateTime?: string |
139 | modifiedDateTime?: string |
140 | createdBy?: string |
141 | modifiedBy?: string |
142 | } |
143 | }[] |
144 | audit?: { |
145 | createdDateTime?: string |
146 | modifiedDateTime?: string |
147 | createdBy?: string |
148 | modifiedBy?: string |
149 | } & { createdDateTime?: string } |
150 | entity?: { key?: string; id?: string; name?: string; href?: string } |
151 | } & { |
152 | customer?: {} |
153 | txnCurrency?: {} |
154 | adjustmentSummary?: {} |
155 | lines?: { |
156 | glAccount?: {} |
157 | txnCurrency?: {} |
158 | dimensions?: { location?: {} } |
159 | }[] |
160 | } |
161 | ) { |
162 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/adjustment`) |
163 |
|
164 | const response = await fetch(url, { |
165 | method: 'POST', |
166 | headers: { |
167 | 'Content-Type': 'application/json', |
168 | Authorization: 'Bearer ' + auth.token |
169 | }, |
170 | body: JSON.stringify(body) |
171 | }) |
172 | if (!response.ok) { |
173 | const text = await response.text() |
174 | throw new Error(`${response.status} ${text}`) |
175 | } |
176 | return await response.json() |
177 | } |
178 |
|