1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create an item |
7 | * Creates a new item. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | body: { |
12 | key?: string |
13 | id?: string |
14 | name?: string |
15 | status?: 'active' | 'inactive' |
16 | itemType?: |
17 | | 'inventory' |
18 | | 'nonInventory' |
19 | | 'purchaseOnlyNonInventory' |
20 | | 'salesOnlyNonInventory' |
21 | | 'kit' |
22 | | 'stockableKit' |
23 | enableFulfillment?: false | true |
24 | isItemEnabledForMRR?: false | true |
25 | productLine?: { key?: string; id?: string; href?: string } |
26 | costMethod?: 'standard' | 'average' | 'FIFO' | 'LIFO' |
27 | extendedDescription?: string |
28 | poDescription?: string |
29 | soDescription?: string |
30 | unitOfMeasureGroup?: { key?: string; id?: string; href?: string } |
31 | notes?: string |
32 | dateLastSold?: string |
33 | dateLastReceived?: string |
34 | isSuppliesItem?: false | true |
35 | quantityOnOrder?: string |
36 | quantityInTransit?: string |
37 | quantityOnHand?: string |
38 | quantityOnHold?: string |
39 | quantityReserved?: string |
40 | quantityAllocated?: string |
41 | quantityUncommitted?: string |
42 | inventory?: { |
43 | shippingWeight?: number |
44 | autoPrintLabel?: false | true |
45 | glGroup?: { |
46 | id?: string |
47 | key?: string |
48 | defaultRevenueRecognitionTemplate?: string |
49 | incomeGLAccount?: string |
50 | inventoryGLAccount?: string |
51 | expenseGLAccount?: string |
52 | cogsGLAccount?: string |
53 | arGLAccountNumber?: string |
54 | apGLAccountNumber?: string |
55 | deferredRevenueGLAccountNumber?: string |
56 | href?: string |
57 | } |
58 | } |
59 | vsoeCategory?: |
60 | | 'productSpecified' |
61 | | 'software' |
62 | | 'productUnspecified' |
63 | | 'upgradeUnspecified' |
64 | | 'upgradeSpecified' |
65 | | 'services' |
66 | | 'postContractSupport' |
67 | vsoeDefaultDeliveryStatus?: 'delivered' | 'undelivered' |
68 | vsoeDefaultDeferralStatus?: 'deferUntilItemIsDelivered' | 'deferBundleUntilItemIsDelivered' |
69 | substituteItemId?: string |
70 | tracking?: { |
71 | enableSerialNo?: false | true |
72 | serialMask?: string |
73 | enableLotCategory?: false | true |
74 | lotCategory?: string |
75 | enableBins?: false | true |
76 | enableExpiration?: false | true |
77 | } |
78 | precision?: { |
79 | upc?: string |
80 | inventoryPrecision?: number |
81 | salesPrecision?: number |
82 | purchasingPrecision?: number |
83 | } |
84 | landedCost?: { enableLandedCost?: false | true } |
85 | itemLandedCost?: { |
86 | key?: string |
87 | id?: string |
88 | href?: string |
89 | distributionMethod?: 'volume' | 'weight' | 'count' |
90 | distributionMethodBaseUnit?: string |
91 | landedCostValue?: string |
92 | active?: false | true |
93 | item?: { key?: string; id?: string; href?: string } |
94 | }[] |
95 | replenishment?: { |
96 | enableReplenishment?: false | true |
97 | unitOfMeasureDefault?: string |
98 | safetyStock?: number |
99 | maximumOrderQuantity?: number |
100 | replenishmentMethod?: |
101 | | '' |
102 | | 'demandForecastBySingleValue' |
103 | | 'reorderPoint' |
104 | | 'demandForecastByFluctuatingValues' |
105 | reorderPoint?: number |
106 | reorderQuantity?: number |
107 | forecastDemandInLeadTime?: number |
108 | } |
109 | itemDetails?: { |
110 | primaryCountryOfOrigin?: string |
111 | condition?: string |
112 | engineeringAlert?: string |
113 | specification1?: string |
114 | specification2?: string |
115 | specification3?: string |
116 | universalProductCode?: number |
117 | internationalArticleNumber?: number |
118 | isSafetyItem?: false | true |
119 | isRestrictedItem?: false | true |
120 | isCompliantItem?: false | true |
121 | isApprovedByEngineering?: false | true |
122 | isApprovedByQualityControl?: false | true |
123 | isApprovedBySales?: false | true |
124 | } |
125 | measurements?: { |
126 | weightUnitOfMeasure?: { id?: string; key?: string; href?: string } |
127 | netWeight?: number |
128 | lengthWidthHeightUnitOfMeasure?: { |
129 | id?: string |
130 | key?: string |
131 | href?: string |
132 | } |
133 | length?: number |
134 | width?: number |
135 | height?: number |
136 | thicknessUnitOfMeasure?: { id?: string; key?: string; href?: string } |
137 | thickness?: number |
138 | minimumThickness?: number |
139 | maximumThickness?: number |
140 | areaUnitOfMeasure?: { id?: string; key?: string; href?: string } |
141 | area?: number |
142 | volumeUnitOfMeasure?: { id?: string; key?: string; href?: string } |
143 | volume?: number |
144 | densityUnitOfMeasure?: string |
145 | density?: number |
146 | durometerUnitOfMeasure?: string |
147 | diameterUnitOfMeasure?: { id?: string; key?: string; href?: string } |
148 | innerDiameter?: number |
149 | outerDiameter?: number |
150 | } |
151 | commercial?: { |
152 | brand?: string |
153 | subBrand?: string |
154 | category?: string |
155 | subCategory?: string |
156 | catalogReference?: string |
157 | color?: string |
158 | size1?: string |
159 | size2?: string |
160 | style?: string |
161 | webName?: string |
162 | webShortDiscription?: string |
163 | webLongDescription?: string |
164 | isGiftCard?: false | true |
165 | isWebEnabled?: false | true |
166 | } |
167 | defaultConversionType?: 'quantity' | 'price' |
168 | purchasing?: { standardCost?: string } |
169 | sales?: { |
170 | isTaxable?: false | true |
171 | basePrice?: string |
172 | isAvailableForDropShip?: false | true |
173 | isAvailableForBuyToOrder?: false | true |
174 | taxGroup?: { key?: string; id?: string; href?: string } |
175 | taxSolution?: { key?: string; id?: string; href?: string } |
176 | allowMultipleTaxGroups?: false | true |
177 | } |
178 | itemTaxMap?: { |
179 | key?: string |
180 | id?: string |
181 | href?: string |
182 | item?: { key?: string; id?: string; href?: string } |
183 | taxSolution?: { key?: string; id?: string; href?: string } |
184 | taxGroup?: { key?: string; id?: string; href?: string } |
185 | }[] |
186 | warehouseInfo?: { |
187 | key?: string |
188 | id?: string |
189 | item?: { key?: string; id?: string; href?: string } |
190 | warehouse?: { key?: string; id?: string; href?: string } |
191 | storageArea?: string |
192 | inventoryCycle?: { key?: string; id?: string; href?: string } |
193 | economicOrderQuantity?: number |
194 | standardCost?: string |
195 | lastCost?: string |
196 | averageCost?: string |
197 | reorderMethod?: 'reorderPoint' | 'economicQuantity' | 'maxStockLevel' |
198 | reorderPoint?: number |
199 | reorderQuantity?: number |
200 | minOrderQuantity?: number |
201 | maxOrderQuantity?: number |
202 | maximumStock?: number |
203 | minimumStock?: number |
204 | lastSoldDate?: string |
205 | lastReceivedDate?: string |
206 | defaultBin?: { key?: string; id?: string; href?: string } |
207 | warehouseLocation?: { |
208 | key?: string |
209 | id?: string |
210 | currency?: string |
211 | href?: string |
212 | } |
213 | safetyStock?: number |
214 | replenishmentMethod?: |
215 | | 'demandForecastBySingleValue' |
216 | | 'reorderPoint' |
217 | | 'demandForecastByFluctuatingValues' |
218 | enableReplenishment?: false | true |
219 | onOrder?: number |
220 | inTransit?: number |
221 | onHand?: number |
222 | onHold?: number |
223 | reserved?: number |
224 | allocated?: number |
225 | unCommitted?: number |
226 | href?: string |
227 | itemWarehouseVendor?: { |
228 | key?: string |
229 | id?: string |
230 | itemWarehouse?: { key?: string; id?: string; href?: string } |
231 | vendor?: { key?: string; id?: string; href?: string } |
232 | stockNumber?: string |
233 | leadTime?: number |
234 | demandForecastDuringLeadTime?: number |
235 | economicalOrderQuantity?: number |
236 | vendorMinimumOrderQuantity?: number |
237 | bestPrice?: string |
238 | latestPrice?: string |
239 | unitOfMeasure?: { key?: string; id?: string; href?: string } |
240 | conversionFactor?: string |
241 | isPreferredVendor?: false | true |
242 | href?: string |
243 | }[] |
244 | standardCostEntries?: { |
245 | key?: string |
246 | id?: string |
247 | href?: string |
248 | effectiveStartDate?: string |
249 | standardCost?: string |
250 | itemWarehouse?: { |
251 | key?: string |
252 | id?: string |
253 | href?: string |
254 | itemId?: string |
255 | warehouseId?: string |
256 | } |
257 | audit?: { |
258 | createdDateTime?: string |
259 | modifiedDateTime?: string |
260 | createdBy?: string |
261 | modifiedBy?: string |
262 | } |
263 | }[] |
264 | audit?: { |
265 | createdDateTime?: string |
266 | modifiedDateTime?: string |
267 | createdBy?: string |
268 | modifiedBy?: string |
269 | } |
270 | }[] |
271 | itemVendor?: { |
272 | key?: string |
273 | id?: string |
274 | item?: { key?: string; id?: string; href?: string } |
275 | vendor?: { key?: string; id?: string; href?: string } |
276 | stockNumber?: string |
277 | leadTime?: number |
278 | demandForecastDuringLeadTime?: number |
279 | economicalOrderQuantity?: number |
280 | vendorMinimumOrderQuantity?: number |
281 | bestPrice?: string |
282 | latestPrice?: string |
283 | unitOfMeasure?: { key?: string; id?: string; href?: string } |
284 | conversionFactor?: string |
285 | isPreferredVendor?: false | true |
286 | href?: string |
287 | }[] |
288 | isEnabledForContracts?: false | true |
289 | kitRevenuePosting?: 'componentLevel' | 'kitLevel' |
290 | kitRevenuePrinting?: 'kit' | 'individualComponents' |
291 | kitComponents?: { |
292 | key?: string |
293 | id?: string |
294 | kit?: { key?: string; id?: string; href?: string } |
295 | component?: { |
296 | key?: string |
297 | id?: string |
298 | href?: string |
299 | name?: string |
300 | costMethod?: 'standard' | 'average' | 'FIFO' | 'LIFO' |
301 | itemType?: |
302 | | 'inventory' |
303 | | 'nonInventory' |
304 | | 'purchaseOnlyNonInventory' |
305 | | 'salesOnlyNonInventory' |
306 | | 'kit' |
307 | | 'stockableKit' |
308 | standardCost?: string |
309 | unitOfMeasure?: string |
310 | } |
311 | numberOfUnits?: number |
312 | revenuePercentage?: number |
313 | defaultDeliveryStatus?: 'delivered' | 'undelivered' |
314 | defaultDeferralStatus?: 'deferUntilItemIsDelivered' | 'deferBundleUntilItemIsDelivered' |
315 | lineNumber?: number |
316 | href?: string |
317 | audit?: { |
318 | createdDateTime?: string |
319 | modifiedDateTime?: string |
320 | createdBy?: string |
321 | modifiedBy?: string |
322 | } |
323 | }[] |
324 | contractTerm?: { |
325 | isStartDateAndEndDateEnabled?: false | true |
326 | periodsMeasuredIn?: 'days' | 'weeks' | 'months' | 'years' |
327 | numberOfPeriods?: number |
328 | isProratedPricingAllowed?: false | true |
329 | defaultRenewalTemplate?: { key?: string; id?: string; href?: string } |
330 | } |
331 | contractDefault?: { |
332 | billingTemplate?: { key?: string; id?: string; href?: string } |
333 | revRecTemplate1?: { key?: string; id?: string; href?: string } |
334 | revRecTemplate2?: { key?: string; id?: string; href?: string } |
335 | expenseTemplate1?: { key?: string; id?: string; href?: string } |
336 | expenseTemplate2?: { key?: string; id?: string; href?: string } |
337 | contractFairValueCategory?: { key?: string; id?: string; href?: string } |
338 | defaultContractDeliveryStatus?: 'delivered' | 'undelivered' |
339 | defaultContractDeferralStatus?: |
340 | | 'deferRevenueUntilItemIsDelivered' |
341 | | 'deferRevenueUntilAllItemsAreDelivered' |
342 | isDefaultBundle?: false | true |
343 | } |
344 | itemCrossReference?: { |
345 | key?: string |
346 | id?: string |
347 | href?: string |
348 | referenceType?: 'customer' | 'vendor' | 'substitute' | 'upgrade' | 'downgrade' | 'complement' |
349 | itemAliasId?: string |
350 | itemAliasDescription?: string |
351 | unitOfMeasure?: { key?: string; id?: string; href?: string } |
352 | referenceTypeContext?: 'internal' | 'external' |
353 | alternateItem?: { |
354 | key?: string |
355 | id?: string |
356 | name?: string |
357 | href?: string |
358 | } |
359 | customer?: { key?: string; id?: string; name?: string; href?: string } |
360 | item?: { key?: string; id?: string; name?: string; href?: string } |
361 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
362 | audit?: { |
363 | createdDateTime?: string |
364 | modifiedDateTime?: string |
365 | createdBy?: string |
366 | modifiedBy?: string |
367 | } |
368 | }[] |
369 | href?: string |
370 | entity?: { key?: string; id?: string; name?: string; href?: string } |
371 | audit?: { |
372 | createdDateTime?: string |
373 | modifiedDateTime?: string |
374 | createdBy?: string |
375 | modifiedBy?: string |
376 | } |
377 | } & {} |
378 | ) { |
379 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/inventory-control/item`) |
380 |
|
381 | const response = await fetch(url, { |
382 | method: 'POST', |
383 | headers: { |
384 | 'Content-Type': 'application/json', |
385 | Authorization: 'Bearer ' + auth.token |
386 | }, |
387 | body: JSON.stringify(body) |
388 | }) |
389 | if (!response.ok) { |
390 | const text = await response.text() |
391 | throw new Error(`${response.status} ${text}`) |
392 | } |
393 | return await response.json() |
394 | } |
395 |
|