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