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