1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create a deposit |
7 | * Creates a new deposit. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionCash Management |
13 | User typeBusiness |
14 | PermissionsList, Add Deposits |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | body: { |
23 | key?: string |
24 | id?: string |
25 | depositId?: string |
26 | txnDate?: string |
27 | description?: string |
28 | baseCurrency?: string |
29 | txnCurrency?: string |
30 | totalEntered?: string |
31 | txnTotalEntered?: string |
32 | state?: 'void' | 'approve' |
33 | reconciliationState?: 'cleared' | 'uncleared' | 'matched' |
34 | bankAccount?: { key?: string; id?: string; name?: string; href?: string } |
35 | reversalDate?: string |
36 | reversedDate?: string |
37 | reversedVoidPaymentKey?: string |
38 | voidPaymentKey?: string |
39 | postingDate?: string |
40 | attachment?: { key?: string; id?: string; href?: string } |
41 | lines?: { |
42 | key?: string |
43 | id?: string |
44 | amount?: string |
45 | txnAmount?: string |
46 | description?: string |
47 | currency?: { |
48 | baseCurrency?: string |
49 | txnCurrency?: string |
50 | exchangeRate?: { date?: string; rate?: number; typeId?: string } |
51 | } |
52 | baseLocation?: { |
53 | key?: string |
54 | id?: string |
55 | name?: string |
56 | href?: string |
57 | } & { key?: string } |
58 | arAccountLabel?: { |
59 | key?: string |
60 | id?: string |
61 | label?: string |
62 | href?: string |
63 | } |
64 | glAccount?: { |
65 | key?: string |
66 | id?: string |
67 | accountNumber?: string |
68 | name?: string |
69 | href?: string |
70 | } |
71 | dimensions?: { |
72 | location?: { key?: string; id?: string; name?: string; href?: string } |
73 | department?: { |
74 | key?: string |
75 | id?: string |
76 | name?: string |
77 | href?: string |
78 | } |
79 | employee?: { key?: string; id?: string; name?: string; href?: string } |
80 | project?: { key?: string; id?: string; name?: string; href?: string } |
81 | customer?: { key?: string; id?: string; name?: string; href?: string } |
82 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
83 | item?: { key?: string; id?: string; name?: string; href?: string } |
84 | warehouse?: { key?: string; id?: string; name?: string; href?: string } |
85 | class?: { key?: string; id?: string; name?: string; href?: string } |
86 | task?: { id?: string; key?: string; name?: string; href?: string } |
87 | costType?: { id?: string; key?: string; name?: string; href?: string } |
88 | asset?: { id?: string; key?: string; name?: string; href?: string } |
89 | contract?: { id?: string; key?: string; name?: string; href?: string } |
90 | affiliateEntity?: { |
91 | key?: string |
92 | id?: string |
93 | href?: string |
94 | name?: string |
95 | } |
96 | } & { |
97 | location?: { key?: string; id?: string; name?: string; href?: string } |
98 | department?: { |
99 | key?: string |
100 | id?: string |
101 | name?: string |
102 | href?: string |
103 | } |
104 | } |
105 | deposit?: { |
106 | key?: string |
107 | id?: string |
108 | depositType?: string |
109 | href?: string |
110 | } |
111 | status?: 'active' | 'inactive' |
112 | audit?: { |
113 | createdDateTime?: string |
114 | modifiedDateTime?: string |
115 | createdBy?: string |
116 | modifiedBy?: string |
117 | } |
118 | }[] |
119 | details?: { |
120 | key?: string |
121 | id?: string |
122 | href?: string |
123 | summary?: string |
124 | customer?: { key?: string; id?: string; name?: string; href?: string } |
125 | payee?: string |
126 | totalEntered?: string |
127 | txnTotalEntered?: string |
128 | currency?: string |
129 | paymentMethod?: 'check' | 'chargeCard' | 'onlineChargeCard' | 'recordTransfer' | 'cash' |
130 | documentNumber?: string |
131 | state?: 'undeposited' | 'deposited' |
132 | deposit?: { key?: string; id?: string; href?: string } |
133 | status?: 'active' | 'inactive' |
134 | audit?: { |
135 | createdDateTime?: string |
136 | modifiedDateTime?: string |
137 | createdBy?: string |
138 | modifiedBy?: string |
139 | } |
140 | }[] |
141 | audit?: { |
142 | createdDateTime?: string |
143 | modifiedDateTime?: string |
144 | createdBy?: string |
145 | modifiedBy?: string |
146 | } & { createdDateTime?: string } |
147 | entity?: { key?: string; id?: string; name?: string; href?: string } |
148 | } & { details?: {}[] } |
149 | ) { |
150 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/cash-management/deposit`) |
151 |
|
152 | const response = await fetch(url, { |
153 | method: 'POST', |
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 |
|