1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update item warehouse inventory information |
7 | * Updates an existing item warehouse inventory information object by setting field values. Any fields not provided remain unchanged. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionInventory Control, Order Entry, or Purchasing |
13 | User typeBusiness, Project Manager, Employee, Warehouse |
14 | PermissionsAdd, Edit Items |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | key: string, |
23 | body: { |
24 | key?: string |
25 | id?: string |
26 | item?: { key?: string; id?: string; href?: string } |
27 | warehouse?: { key?: string; id?: string; href?: string } |
28 | storageArea?: string |
29 | inventoryCycle?: { key?: string; id?: string; href?: string } |
30 | economicOrderQuantity?: number |
31 | standardCost?: string |
32 | lastCost?: string |
33 | averageCost?: string |
34 | reorderMethod?: 'economicQuantity' | 'maxStockLevel' | 'reorderPoint' |
35 | reorderPoint?: number |
36 | reorderQuantity?: number |
37 | minOrderQuantity?: number |
38 | maxOrderQuantity?: number |
39 | maximumStock?: number |
40 | minimumStock?: number |
41 | lastSoldDate?: string |
42 | lastReceivedDate?: string |
43 | defaultBin?: { key?: string; id?: string; href?: string } |
44 | warehouseLocation?: { |
45 | key?: string |
46 | id?: string |
47 | currency?: string |
48 | href?: string |
49 | } |
50 | safetyStock?: number |
51 | replenishmentMethod?: |
52 | | 'reorderPoint' |
53 | | 'demandForecastBySingleValue' |
54 | | 'demandForecastByFluctuatingValues' |
55 | enableReplenishment?: false | true |
56 | onOrder?: number |
57 | inTransit?: number |
58 | onHand?: number |
59 | onHold?: number |
60 | reserved?: number |
61 | allocated?: number |
62 | unCommitted?: number |
63 | href?: string |
64 | itemWarehouseVendor?: { |
65 | key?: string |
66 | id?: string |
67 | itemWarehouse?: { key?: string; id?: string; href?: string } |
68 | vendor?: { key?: string; id?: string; href?: string } |
69 | stockNumber?: string |
70 | leadTime?: number |
71 | demandForecastDuringLeadTime?: number |
72 | economicalOrderQuantity?: number |
73 | vendorMinimumOrderQuantity?: number |
74 | bestPrice?: string |
75 | latestPrice?: string |
76 | unitOfMeasure?: { key?: string; id?: string; href?: string } |
77 | conversionFactor?: string |
78 | isPreferredVendor?: false | true |
79 | href?: string |
80 | }[] |
81 | standardCostEntries?: { |
82 | key?: string |
83 | id?: string |
84 | href?: string |
85 | effectiveStartDate?: string |
86 | standardCost?: string |
87 | itemWarehouse?: { |
88 | key?: string |
89 | id?: string |
90 | href?: string |
91 | itemId?: string |
92 | warehouseId?: string |
93 | } |
94 | audit?: { |
95 | createdDateTime?: string |
96 | modifiedDateTime?: string |
97 | createdBy?: string |
98 | modifiedBy?: string |
99 | } |
100 | }[] |
101 | audit?: { |
102 | createdDateTime?: string |
103 | modifiedDateTime?: string |
104 | createdBy?: string |
105 | modifiedBy?: string |
106 | } |
107 | } & { id?: {}; item?: {} } |
108 | ) { |
109 | const url = new URL( |
110 | `https://api.intacct.com/ia/api/v1/objects/inventory-control/item-warehouse-inventory/${key}` |
111 | ) |
112 |
|
113 | const response = await fetch(url, { |
114 | method: 'PATCH', |
115 | headers: { |
116 | 'Content-Type': 'application/json', |
117 | Authorization: 'Bearer ' + auth.token |
118 | }, |
119 | body: JSON.stringify(body) |
120 | }) |
121 | if (!response.ok) { |
122 | const text = await response.text() |
123 | throw new Error(`${response.status} ${text}`) |
124 | } |
125 | return await response.json() |
126 | } |
127 |
|