1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Create a bank transaction rule |
7 | * Creates a new bank transaction rule. |
8 | */ |
9 | export async function main( |
10 | auth: SageIntacct, |
11 | body: { |
12 | key?: string |
13 | id?: string |
14 | href?: string |
15 | ruleId?: string |
16 | name?: string |
17 | description?: string |
18 | ruleType?: 'match' | 'create' |
19 | location?: { key?: string; id?: string; href?: string } |
20 | rulesetCount?: number |
21 | filterAttributes?: { |
22 | key?: string |
23 | id?: string |
24 | href?: string |
25 | dataSource?: 'intacctTransaction' | 'bankTransaction' |
26 | intacctTxnAttribute?: |
27 | | 'transactionType' |
28 | | 'documentNumber' |
29 | | 'documentDate' |
30 | | 'transactionAmount' |
31 | | 'baseAmount' |
32 | | 'transactionCurrency' |
33 | | 'baseCurrency' |
34 | | 'postingDate' |
35 | | 'description' |
36 | bankTxnAttribute?: |
37 | | 'transactionType' |
38 | | 'documentNumber' |
39 | | 'postingDate' |
40 | | 'description' |
41 | | 'documentType' |
42 | | 'amount' |
43 | | 'currency' |
44 | | 'feedType' |
45 | operator?: |
46 | | 'equals' |
47 | | 'contains' |
48 | | 'within' |
49 | | 'notContains' |
50 | | 'beginsWith' |
51 | | 'endsWith' |
52 | | 'greaterThan' |
53 | | 'lessThan' |
54 | value?: string |
55 | order?: number |
56 | audit?: { |
57 | createdDateTime?: string |
58 | modifiedDateTime?: string |
59 | createdBy?: string |
60 | modifiedBy?: string |
61 | } |
62 | bankTransactionRule?: { id?: string; key?: string; href?: string } |
63 | }[] |
64 | groupAttributes?: { |
65 | key?: string |
66 | id?: string |
67 | href?: string |
68 | dataSource?: 'intacctTransaction' | 'bankTransaction' |
69 | intacctTxnAttribute?: 'documentNumber' | 'postingDate' |
70 | bankTxnAttribute?: 'documentNumber' | 'postingDate' |
71 | order?: number |
72 | audit?: { |
73 | createdDateTime?: string |
74 | modifiedDateTime?: string |
75 | createdBy?: string |
76 | modifiedBy?: string |
77 | } |
78 | bankTransactionRule?: { id?: string; key?: string; href?: string } |
79 | }[] |
80 | status?: 'active' | 'inactive' |
81 | matchRuleAttributes?: { |
82 | key?: string |
83 | id?: string |
84 | intacctTxnAttribute?: 'documentNumber' | 'postingDate' | 'description' | 'amount' |
85 | bankTxnAttribute?: |
86 | | 'documentNumber' |
87 | | 'postingDate' |
88 | | 'description' |
89 | | 'amount' |
90 | | 'documentNumberLeadingZerosRemoved' |
91 | operator?: 'equals' | 'contains' | 'within' |
92 | value?: string |
93 | order?: number |
94 | audit?: { |
95 | createdDateTime?: string |
96 | modifiedDateTime?: string |
97 | createdBy?: string |
98 | modifiedBy?: string |
99 | } |
100 | bankTransactionRule?: { id?: string; key?: string; href?: string } |
101 | }[] |
102 | createRuleObject?: { |
103 | objectType?: 'cctransaction' | 'journalEntry' |
104 | journalEntryTemplate?: { id?: string; key?: string; href?: string } |
105 | creditCardTxnTemplate?: { id?: string; key?: string; href?: string } |
106 | } |
107 | audit?: { |
108 | createdDateTime?: string |
109 | modifiedDateTime?: string |
110 | createdBy?: string |
111 | modifiedBy?: string |
112 | } |
113 | entity?: { key?: string; id?: string; name?: string; href?: string } |
114 | } & {} |
115 | ) { |
116 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/cash-management/bank-txn-rule`) |
117 |
|
118 | const response = await fetch(url, { |
119 | method: 'POST', |
120 | headers: { |
121 | 'Content-Type': 'application/json', |
122 | Authorization: 'Bearer ' + auth.token |
123 | }, |
124 | body: JSON.stringify(body) |
125 | }) |
126 | if (!response.ok) { |
127 | const text = await response.text() |
128 | throw new Error(`${response.status} ${text}`) |
129 | } |
130 | return await response.json() |
131 | } |
132 |
|