1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update an inventory transaction definition |
7 | * Updates an existing inventory transaction definition by setting field values. Any fields not provided remain unchanged. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | key: string, |
12 | body: { |
13 | key?: string |
14 | id?: string |
15 | href?: string |
16 | templateType?: 'quote' | 'order' | 'list' | 'invoice' | 'adjustment' | 'other' |
17 | description?: string |
18 | workflowCategory?: 'adjustment' | 'receipt' | 'transfer' | 'shipping' |
19 | reportingCategory?: |
20 | | 'inventoryAdjustment' |
21 | | 'buildKits' |
22 | | 'disassembleKits' |
23 | | 'inventoryDamagedGoods' |
24 | | 'inventoryReceipt' |
25 | | 'inventoryScrapOrSpoilage' |
26 | | 'inventoryShipper' |
27 | | 'warehouseTransfer' |
28 | status?: 'active' | 'inactive' |
29 | txnNumbering?: { |
30 | enableSequenceNumbering?: false | true |
31 | numberingSequence?: { key?: string; id?: string; href?: string } |
32 | preserveSequenceNumbers?: false | true |
33 | inheritSourceDocumentNumber?: false | true |
34 | } |
35 | inventoryControl?: { |
36 | enableWarnOnLowQty?: false | true |
37 | updatesInventory?: 'no' | 'quantity' | 'value' | 'quantityAndValue' |
38 | updatesCost?: false | true |
39 | increaseOrDecreaseInventory?: 'increase' | 'decrease' |
40 | warehouseSelectionMethod?: |
41 | | 'sortByID' |
42 | | 'sortByName' |
43 | | 'warehouseWithAvailableInventory' |
44 | | 'useTheDefaultWarehouse' |
45 | defaultWarehouse?: { key?: string; id?: string; href?: string } |
46 | } |
47 | accounting?: { |
48 | txnPosting?: 'postToGeneralLedger' | 'doNotPost' |
49 | isSubTotalsEnabled?: false | true |
50 | } |
51 | conversionType?: 'leaveTxnOpen' | 'closeTxn' |
52 | pricingAndTerms?: { |
53 | initialPriceList?: { key?: string; id?: string; href?: string } |
54 | specialPriceList?: { key?: string; id?: string; href?: string } |
55 | } |
56 | print?: { documentTemplate?: string; defaultText?: string } |
57 | enableUserOrGroupPermmission?: false | true |
58 | userOverrides?: { |
59 | allowDepartmentOverride?: false | true |
60 | allowLocationOverride?: false | true |
61 | } |
62 | documentPermissions?: { |
63 | editPolicy?: 'noEdit' | 'beforePrinting' | 'editInDraftOnly' | 'all' |
64 | deletePolicy?: 'beforePrinting' | 'all' | 'noDelete' | 'deleteInDraftOnly' |
65 | createPolicy?: 'newDocumentOrConvert' | 'convertOnly' |
66 | multiEntityRuleForTxn?: 'topLevelOrEntity' | 'topLevelOnly' | 'entityOnly' |
67 | } |
68 | inventoryTotalDetail?: { |
69 | key?: string |
70 | id?: string |
71 | href?: string |
72 | maintainType?: 'quantity' | 'value' | 'quantityAndValue' |
73 | operation?: 'add' | 'subtract' |
74 | inventoryTotal?: { key?: string; id?: string; href?: string } |
75 | inventoryTxnDefinition?: { key?: string; id?: string; href?: string } |
76 | }[] |
77 | subtotalDetail?: { |
78 | key?: string |
79 | id?: string |
80 | href?: string |
81 | inventoryTxnDefinition?: { key?: string; id?: string; href?: string } |
82 | lineNumber?: number |
83 | description?: string |
84 | subtotalType?: 'discount' | 'charge' |
85 | appliedToLineNumber?: number |
86 | valueType?: 'amount' | 'percent' |
87 | subtotalValue?: string |
88 | txnType?: '' | 'debit' | 'credit' |
89 | glAccount?: { href?: string; id?: string; key?: string } |
90 | offsetGlAccount?: { href?: string; id?: string; key?: string } |
91 | isTax?: false | true |
92 | enableAvaTax?: false | true |
93 | dimensions?: { |
94 | location?: { key?: string; id?: string; name?: string; href?: string } |
95 | department?: { |
96 | key?: string |
97 | id?: string |
98 | name?: string |
99 | href?: string |
100 | } |
101 | employee?: { key?: string; id?: string; name?: string; href?: string } |
102 | project?: { key?: string; id?: string; name?: string; href?: string } |
103 | customer?: { key?: string; id?: string; name?: string; href?: string } |
104 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
105 | item?: { key?: string; id?: string; name?: string; href?: string } |
106 | warehouse?: { key?: string; id?: string; name?: string; href?: string } |
107 | class?: { key?: string; id?: string; name?: string; href?: string } |
108 | task?: { id?: string; key?: string; name?: string; href?: string } |
109 | costType?: { id?: string; key?: string; name?: string; href?: string } |
110 | asset?: { id?: string; key?: string; name?: string; href?: string } |
111 | contract?: { id?: string; key?: string; name?: string; href?: string } |
112 | affiliateEntity?: { |
113 | key?: string |
114 | id?: string |
115 | href?: string |
116 | name?: string |
117 | } |
118 | } & { |
119 | department?: { |
120 | href?: string |
121 | id?: string |
122 | key?: string |
123 | name?: string |
124 | } |
125 | location?: { href?: string; id?: string; key?: string; name?: string } |
126 | } |
127 | }[] |
128 | sourceDocumentDetail?: { |
129 | key?: string |
130 | id?: string |
131 | href?: string |
132 | inventoryTxnDefinition?: { key?: string; id?: string; href?: string } |
133 | convertedFrom?: { key?: string; id?: string; href?: string } |
134 | }[] |
135 | inventoryAccountMapping?: { |
136 | key?: string |
137 | id?: string |
138 | href?: string |
139 | txnType?: 'debit' | 'credit' |
140 | moduleType?: 'subledger' | 'inventory' |
141 | lineNumber?: number |
142 | glAccount?: { key?: string; id?: string; href?: string } |
143 | dimensions?: { |
144 | location?: { key?: string; id?: string; name?: string; href?: string } |
145 | department?: { |
146 | key?: string |
147 | id?: string |
148 | name?: string |
149 | href?: string |
150 | } |
151 | employee?: { key?: string; id?: string; name?: string; href?: string } |
152 | project?: { key?: string; id?: string; name?: string; href?: string } |
153 | customer?: { key?: string; id?: string; name?: string; href?: string } |
154 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
155 | item?: { key?: string; id?: string; name?: string; href?: string } |
156 | warehouse?: { key?: string; id?: string; name?: string; href?: string } |
157 | class?: { key?: string; id?: string; name?: string; href?: string } |
158 | task?: { id?: string; key?: string; name?: string; href?: string } |
159 | costType?: { id?: string; key?: string; name?: string; href?: string } |
160 | asset?: { id?: string; key?: string; name?: string; href?: string } |
161 | contract?: { id?: string; key?: string; name?: string; href?: string } |
162 | affiliateEntity?: { |
163 | key?: string |
164 | id?: string |
165 | href?: string |
166 | name?: string |
167 | } |
168 | } & { |
169 | location?: { key?: string; id?: string; name?: string; href?: string } |
170 | department?: { |
171 | key?: string |
172 | id?: string |
173 | name?: string |
174 | href?: string |
175 | } |
176 | warehouse?: { key?: string; id?: string; href?: string } |
177 | } |
178 | itemGLGroup?: { key?: string; id?: string; href?: string } |
179 | inventoryTxnDefinition?: { key?: string; id?: string; href?: string } |
180 | }[] |
181 | entitySettingDetail?: { |
182 | key?: string |
183 | id?: string |
184 | href?: string |
185 | txnNumbering?: { |
186 | preserveSequenceNumbering?: false | true |
187 | inheritSourceDocumentNumber?: false | true |
188 | sequenceNumber?: { key?: string; href?: string; id?: string } |
189 | } |
190 | documentTemplate?: { key?: string; id?: string } |
191 | entity?: { href?: string; key?: string; id?: string } |
192 | inventoryTxnDefinition?: { key?: string; id?: string; href?: string } |
193 | }[] |
194 | audit?: { |
195 | createdDateTime?: string |
196 | modifiedDateTime?: string |
197 | createdBy?: string |
198 | modifiedBy?: string |
199 | } |
200 | entity?: { key?: string; id?: string; name?: string; href?: string } |
201 | } & { id?: {} } |
202 | ) { |
203 | const url = new URL( |
204 | `https://api.intacct.com/ia/api/v1/objects/inventory-control/txn-definition/${key}` |
205 | ) |
206 |
|
207 | const response = await fetch(url, { |
208 | method: 'PATCH', |
209 | headers: { |
210 | 'Content-Type': 'application/json', |
211 | Authorization: 'Bearer ' + auth.token |
212 | }, |
213 | body: JSON.stringify(body) |
214 | }) |
215 | if (!response.ok) { |
216 | const text = await response.text() |
217 | throw new Error(`${response.status} ${text}`) |
218 | } |
219 | return await response.json() |
220 | } |
221 |
|