1 | |
2 | type SageIntacct = { |
3 | token: string |
4 | } |
5 | |
6 | * Update an employee expense line |
7 | * Updates an existing employee expense line by setting field values. Any fields not provided remain unchanged. |
8 |
|
9 |
|
10 | Permissions and other requirements |
11 |
|
12 | SubscriptionTime & Expenses |
13 | User typeBusiness, Employee, Project Manager (Projects subscription) |
14 | PermissionsList, View, Edit Expenses |
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 | entryDate?: string |
28 | baseCurrency?: string |
29 | baseAmount?: string |
30 | reimbursementCurrency?: string |
31 | reimbursementAmount?: string |
32 | txnCurrency?: string |
33 | txnAmount?: string |
34 | totalSelected?: string |
35 | totalPaid?: string |
36 | quantity?: string |
37 | unitRate?: string |
38 | paidTo?: string |
39 | paidFor?: string |
40 | glAccount?: { key?: string; id?: string; name?: string; href?: string } |
41 | expenseType?: { key?: string; id?: string; href?: string } |
42 | lineNumber?: number |
43 | reimburseToBaseConversion?: { |
44 | exchangeRateDate?: string |
45 | exchangeRateTypeId?: string |
46 | exchangeRate?: string |
47 | } |
48 | transactionToReimburseConversion?: { |
49 | exchangeRate?: string |
50 | exchangeRateDate?: string |
51 | exchangeRateTypeId?: string |
52 | } |
53 | state?: |
54 | | 'draft' |
55 | | 'submitted' |
56 | | 'partiallyApproved' |
57 | | 'partiallyDeclined' |
58 | | 'approved' |
59 | | 'posted' |
60 | | 'declined' |
61 | | 'reversalPending' |
62 | | 'reversed' |
63 | | 'reversal' |
64 | | 'paid' |
65 | | 'confirmed' |
66 | | 'voided' |
67 | | 'partiallyPaid' |
68 | | 'saved' |
69 | isBillable?: false | true |
70 | isBilled?: false | true |
71 | form1099?: { isForm1099?: string; type?: string; box?: string } |
72 | paymentType?: { |
73 | key?: string |
74 | id?: string |
75 | isNonReimbursable?: false | true |
76 | href?: string |
77 | } |
78 | electronicReceipt?: { id?: string; key?: string; href?: string } |
79 | electronicReceiptLine?: { id?: string; key?: string; href?: string } |
80 | audit?: { |
81 | createdDateTime?: string |
82 | modifiedDateTime?: string |
83 | createdBy?: string |
84 | modifiedBy?: string |
85 | } |
86 | dimensions?: { |
87 | location?: { key?: string; id?: string; name?: string; href?: string } |
88 | department?: { key?: string; id?: string; name?: string; href?: string } |
89 | employee?: { key?: string; id?: string; name?: string; href?: string } |
90 | project?: { key?: string; id?: string; name?: string; href?: string } |
91 | customer?: { key?: string; id?: string; name?: string; href?: string } |
92 | vendor?: { key?: string; id?: string; name?: string; href?: string } |
93 | item?: { key?: string; id?: string; name?: string; href?: string } |
94 | warehouse?: { key?: string; id?: string; name?: string; href?: string } |
95 | class?: { key?: string; id?: string; name?: string; href?: string } |
96 | task?: { id?: string; key?: string; name?: string; href?: string } |
97 | costType?: { id?: string; key?: string; name?: string; href?: string } |
98 | asset?: { id?: string; key?: string; name?: string; href?: string } |
99 | contract?: { id?: string; key?: string; name?: string; href?: string } |
100 | affiliateEntity?: { |
101 | key?: string |
102 | id?: string |
103 | href?: string |
104 | name?: string |
105 | } |
106 | } & { |
107 | location?: { key?: string; id?: string; name?: string; href?: string } |
108 | department?: { key?: string; id?: string; name?: string; href?: string } |
109 | } |
110 | employeeExpense?: { id?: string; key?: string; href?: string } |
111 | } |
112 | ) { |
113 | const url = new URL( |
114 | `https://api.intacct.com/ia/api/v1/objects/expenses/employee-expense-line/${key}` |
115 | ) |
116 |
|
117 | const response = await fetch(url, { |
118 | method: 'PATCH', |
119 | headers: { |
120 | 'Content-Type': 'application/json', |
121 | Authorization: 'Bearer ' + auth.token |
122 | }, |
123 | body: JSON.stringify(body) |
124 | }) |
125 | if (!response.ok) { |
126 | const text = await response.text() |
127 | throw new Error(`${response.status} ${text}`) |
128 | } |
129 | return await response.json() |
130 | } |
131 |
|