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