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