1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update a term |
7 | * Updates an existing AR term by setting field values. Any fields not provided remain unchanged. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionAccounts Receivable |
13 | User typeBusiness |
14 | PermissionsList, View, Edit AR terms |
15 |
|
16 |
|
17 |
|
18 |
|
19 | */ |
20 | export async function main( |
21 | auth: SageIntacct, |
22 | key: string, |
23 | body: { |
24 | key?: string |
25 | id?: string |
26 | href?: string |
27 | status?: 'active' | 'inactive' |
28 | description?: string |
29 | audit?: { |
30 | createdDateTime?: string |
31 | modifiedDateTime?: string |
32 | createdBy?: string |
33 | modifiedBy?: string |
34 | } |
35 | due?: { |
36 | days?: number |
37 | from?: |
38 | | 'fromInvoiceDate' |
39 | | 'ofTheMonthOfInvoiceDate' |
40 | | 'ofNextMonthFromInvoiceDate' |
41 | | 'of2ndMonthFromInvoiceDate' |
42 | | 'of3rdMonthFromInvoiceDate' |
43 | | 'of4thMonthFromInvoiceDate' |
44 | | 'of5thMonthFromInvoiceDate' |
45 | | 'of6thMonthFromInvoiceDate' |
46 | | 'afterEndOfMonthOfInvoiceDate' |
47 | | 'fromInvoiceDateExtendingToEom' |
48 | } |
49 | discount?: { |
50 | days?: number |
51 | amount?: number |
52 | from?: |
53 | | 'fromInvoiceDate' |
54 | | 'ofTheMonthOfInvoiceDate' |
55 | | 'ofNextMonthFromInvoiceDate' |
56 | | 'of2ndMonthFromInvoiceDate' |
57 | | 'of3rdMonthFromInvoiceDate' |
58 | | 'of4thMonthFromInvoiceDate' |
59 | | 'of5thMonthFromInvoiceDate' |
60 | | 'of6thMonthFromInvoiceDate' |
61 | | 'afterEndOfMonthOfInvoiceDate' |
62 | | 'fromInvoiceDateExtendingToEom' |
63 | unit?: 'amount' | 'percentage' |
64 | graceDays?: number |
65 | value?: string |
66 | calculateOn?: 'lineItemsTotal' | 'invoiceTotal' |
67 | } |
68 | penalty?: { |
69 | cycle?: |
70 | | 'noPenalty' |
71 | | 'daily' |
72 | | 'weekly' |
73 | | 'biweekly' |
74 | | 'monthly' |
75 | | 'bimonthly' |
76 | | 'quarterly' |
77 | | 'halfYearly' |
78 | | 'annually' |
79 | amount?: number |
80 | unit?: 'amount' | 'percentage' |
81 | graceDays?: number |
82 | } |
83 | } & { id?: {} } |
84 | ) { |
85 | const url = new URL(`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/term/${key}`) |
86 |
|
87 | const response = await fetch(url, { |
88 | method: 'PATCH', |
89 | headers: { |
90 | 'Content-Type': 'application/json', |
91 | Authorization: 'Bearer ' + auth.token |
92 | }, |
93 | body: JSON.stringify(body) |
94 | }) |
95 | if (!response.ok) { |
96 | const text = await response.text() |
97 | throw new Error(`${response.status} ${text}`) |
98 | } |
99 | return await response.json() |
100 | } |
101 |
|