1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update an other receipts object |
7 | * Updates an existing other receipts object by setting field values. Any fields not provided remain unchanged. Only transactions in an open sub-ledger period, which have not yet been deposited, can be updated. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionCash Management |
13 | User typeBusiness |
14 | PermissionsList, Edit Other receipts |
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 | recordType?: string |
27 | payer?: string |
28 | txnDate?: string |
29 | txnPaidDate?: string |
30 | txnNumber?: string |
31 | description?: string |
32 | arSummary?: { key?: string; id?: string; date?: string; href?: string } |
33 | baseCurrency?: string |
34 | currency?: string |
35 | totalEntered?: string |
36 | txnTotalEntered?: string |
37 | reconciliationDate?: string |
38 | state?: 'approved' | 'reversed' | 'reversal' | 'reconciled' | 'deposited' |
39 | reconciliationState?: 'cleared' | 'uncleared' | 'matched' |
40 | parentDeposit?: { href?: string; key?: string; id?: string } |
41 | isInclusiveTax?: false | true |
42 | bankAccount?: { |
43 | key?: string |
44 | id?: string |
45 | name?: string |
46 | currency?: string |
47 | href?: string |
48 | } |
49 | undepositedAccount?: { key?: string; id?: string; href?: string } |
50 | depositDate?: string |
51 | exchangeRate?: { date?: string; rate?: number; typeId?: string } |
52 | paymentMethod?: 'printedCheck' | 'creditCard' | 'eft' | 'cash' |
53 | reversalDate?: string |
54 | reversedDate?: string |
55 | reversedVoidPaymentKey?: string |
56 | taxSolution?: { |
57 | key?: string |
58 | id?: string |
59 | enableMultilineTax?: false | true |
60 | taxCalculationMethod?: string |
61 | href?: string |
62 | } |
63 | voidPaymentKey?: string |
64 | href?: string |
65 | audit?: { |
66 | createdDateTime?: string |
67 | modifiedDateTime?: string |
68 | createdBy?: string |
69 | modifiedBy?: string |
70 | } & { createdDateTime?: string } |
71 | lines?: { |
72 | key?: string |
73 | id?: string |
74 | href?: string |
75 | amount?: string |
76 | totalTxnAmount?: string |
77 | txnAmount?: string |
78 | description?: string |
79 | exchangeRate?: { date?: string; rate?: number; typeId?: string } |
80 | lineNumber?: number |
81 | baseCurrency?: string |
82 | currency?: string |
83 | isTax?: false | true |
84 | arAccountLabel?: { key?: string; id?: string; href?: string } |
85 | glAccount?: { key?: string; id?: string; href?: string } |
86 | dimensions?: { |
87 | location?: { key?: string; id?: string; name?: string; href?: string } |
88 | department?: { |
89 | key?: string |
90 | id?: string |
91 | name?: string |
92 | href?: string |
93 | } |
94 | employee?: { key?: string; id?: string; name?: string; href?: string } |
95 | project?: { key?: string; id?: string; name?: string; href?: string } |
96 | customer?: { key?: string; id?: string; name?: string; href?: string } |
97 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
98 | item?: { key?: string; id?: string; name?: string; href?: string } |
99 | warehouse?: { key?: string; id?: string; name?: string; href?: string } |
100 | class?: { key?: string; id?: string; name?: string; href?: string } |
101 | task?: { id?: string; key?: string; name?: string; href?: string } |
102 | costType?: { id?: string; key?: string; name?: string; href?: string } |
103 | asset?: { id?: string; key?: string; name?: string; href?: string } |
104 | contract?: { id?: string; key?: string; name?: string; href?: string } |
105 | affiliateEntity?: { |
106 | key?: string |
107 | id?: string |
108 | href?: string |
109 | name?: string |
110 | } |
111 | } & { |
112 | location?: { key?: string; id?: string; name?: string; href?: string } |
113 | department?: { |
114 | key?: string |
115 | id?: string |
116 | number?: string |
117 | name?: string |
118 | href?: string |
119 | } |
120 | } |
121 | otherReceipts?: { |
122 | key?: string |
123 | id?: string |
124 | recordType?: string |
125 | href?: string |
126 | } |
127 | status?: 'active' | 'inactive' |
128 | audit?: { |
129 | createdDateTime?: string |
130 | modifiedDateTime?: string |
131 | createdBy?: string |
132 | modifiedBy?: string |
133 | } |
134 | taxEntries?: { |
135 | key?: string |
136 | id?: string |
137 | baseTaxAmount?: string |
138 | txnTaxAmount?: string |
139 | taxRate?: number |
140 | } & { |
141 | taxDetail?: { key?: string; id?: string; href?: string } |
142 | otherReceiptLine?: { id?: string; key?: string; href?: string } |
143 | }[] |
144 | }[] |
145 | entity?: { key?: string; id?: string; name?: string; href?: string } |
146 | } & { id?: {} } |
147 | ) { |
148 | const url = new URL( |
149 | `https://api.intacct.com/ia/api/v1/objects/cash-management/other-receipt/${key}` |
150 | ) |
151 |
|
152 | const response = await fetch(url, { |
153 | method: 'PATCH', |
154 | headers: { |
155 | 'Content-Type': 'application/json', |
156 | Authorization: 'Bearer ' + auth.token |
157 | }, |
158 | body: JSON.stringify(body) |
159 | }) |
160 | if (!response.ok) { |
161 | const text = await response.text() |
162 | throw new Error(`${response.status} ${text}`) |
163 | } |
164 | return await response.json() |
165 | } |
166 |
|