@agnocon/piece-bexio 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.MIT-AP +24 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions/create-company.d.ts +28 -0
- package/dist/lib/actions/create-company.d.ts.map +1 -0
- package/dist/lib/actions/create-company.js +461 -0
- package/dist/lib/actions/create-company.js.map +1 -0
- package/dist/lib/actions/create-file.d.ts +4 -0
- package/dist/lib/actions/create-file.d.ts.map +1 -0
- package/dist/lib/actions/create-file.js +48 -0
- package/dist/lib/actions/create-file.js.map +1 -0
- package/dist/lib/actions/create-manual-entry.d.ts +7 -0
- package/dist/lib/actions/create-manual-entry.d.ts.map +1 -0
- package/dist/lib/actions/create-manual-entry.js +426 -0
- package/dist/lib/actions/create-manual-entry.js.map +1 -0
- package/dist/lib/actions/create-person.d.ts +30 -0
- package/dist/lib/actions/create-person.d.ts.map +1 -0
- package/dist/lib/actions/create-person.js +477 -0
- package/dist/lib/actions/create-person.js.map +1 -0
- package/dist/lib/actions/create-product.d.ts +34 -0
- package/dist/lib/actions/create-product.d.ts.map +1 -0
- package/dist/lib/actions/create-product.js +527 -0
- package/dist/lib/actions/create-product.js.map +1 -0
- package/dist/lib/actions/create-project.d.ts +17 -0
- package/dist/lib/actions/create-project.d.ts.map +1 -0
- package/dist/lib/actions/create-project.js +316 -0
- package/dist/lib/actions/create-project.js.map +1 -0
- package/dist/lib/actions/create-sales-invoice.d.ts +25 -0
- package/dist/lib/actions/create-sales-invoice.d.ts.map +1 -0
- package/dist/lib/actions/create-sales-invoice.js +615 -0
- package/dist/lib/actions/create-sales-invoice.js.map +1 -0
- package/dist/lib/actions/create-sales-order.d.ts +25 -0
- package/dist/lib/actions/create-sales-order.d.ts.map +1 -0
- package/dist/lib/actions/create-sales-order.js +642 -0
- package/dist/lib/actions/create-sales-order.js.map +1 -0
- package/dist/lib/actions/create-sales-quote.d.ts +28 -0
- package/dist/lib/actions/create-sales-quote.d.ts.map +1 -0
- package/dist/lib/actions/create-sales-quote.js +666 -0
- package/dist/lib/actions/create-sales-quote.js.map +1 -0
- package/dist/lib/actions/create-time-tracking.d.ts +17 -0
- package/dist/lib/actions/create-time-tracking.d.ts.map +1 -0
- package/dist/lib/actions/create-time-tracking.js +380 -0
- package/dist/lib/actions/create-time-tracking.js.map +1 -0
- package/dist/lib/actions/export-invoice-pdf.d.ts +5 -0
- package/dist/lib/actions/export-invoice-pdf.d.ts.map +1 -0
- package/dist/lib/actions/export-invoice-pdf.js +94 -0
- package/dist/lib/actions/export-invoice-pdf.js.map +1 -0
- package/dist/lib/actions/find-account.d.ts +6 -0
- package/dist/lib/actions/find-account.d.ts.map +1 -0
- package/dist/lib/actions/find-account.js +107 -0
- package/dist/lib/actions/find-account.js.map +1 -0
- package/dist/lib/actions/find-company.d.ts +8 -0
- package/dist/lib/actions/find-company.d.ts.map +1 -0
- package/dist/lib/actions/find-company.js +160 -0
- package/dist/lib/actions/find-company.js.map +1 -0
- package/dist/lib/actions/find-country.d.ts +7 -0
- package/dist/lib/actions/find-country.d.ts.map +1 -0
- package/dist/lib/actions/find-country.js +125 -0
- package/dist/lib/actions/find-country.js.map +1 -0
- package/dist/lib/actions/find-person.d.ts +9 -0
- package/dist/lib/actions/find-person.d.ts.map +1 -0
- package/dist/lib/actions/find-person.js +175 -0
- package/dist/lib/actions/find-person.js.map +1 -0
- package/dist/lib/actions/find-product.d.ts +7 -0
- package/dist/lib/actions/find-product.d.ts.map +1 -0
- package/dist/lib/actions/find-product.js +124 -0
- package/dist/lib/actions/find-product.js.map +1 -0
- package/dist/lib/actions/search-invoice.d.ts +7 -0
- package/dist/lib/actions/search-invoice.d.ts.map +1 -0
- package/dist/lib/actions/search-invoice.js +140 -0
- package/dist/lib/actions/search-invoice.js.map +1 -0
- package/dist/lib/actions/search-order.d.ts +7 -0
- package/dist/lib/actions/search-order.d.ts.map +1 -0
- package/dist/lib/actions/search-order.js +139 -0
- package/dist/lib/actions/search-order.js.map +1 -0
- package/dist/lib/actions/search-quote.d.ts +7 -0
- package/dist/lib/actions/search-quote.d.ts.map +1 -0
- package/dist/lib/actions/search-quote.js +140 -0
- package/dist/lib/actions/search-quote.js.map +1 -0
- package/dist/lib/actions/send-sales-invoice.d.ts +9 -0
- package/dist/lib/actions/send-sales-invoice.d.ts.map +1 -0
- package/dist/lib/actions/send-sales-invoice.js +110 -0
- package/dist/lib/actions/send-sales-invoice.js.map +1 -0
- package/dist/lib/actions/update-company.d.ts +29 -0
- package/dist/lib/actions/update-company.d.ts.map +1 -0
- package/dist/lib/actions/update-company.js +506 -0
- package/dist/lib/actions/update-company.js.map +1 -0
- package/dist/lib/actions/update-person.d.ts +31 -0
- package/dist/lib/actions/update-person.d.ts.map +1 -0
- package/dist/lib/actions/update-person.js +524 -0
- package/dist/lib/actions/update-person.js.map +1 -0
- package/dist/lib/actions/update-product.d.ts +34 -0
- package/dist/lib/actions/update-product.d.ts.map +1 -0
- package/dist/lib/actions/update-product.js +556 -0
- package/dist/lib/actions/update-product.js.map +1 -0
- package/dist/lib/auth.d.ts +2 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +51 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/common/client.d.ts +13 -0
- package/dist/lib/common/client.d.ts.map +1 -0
- package/dist/lib/common/client.js +64 -0
- package/dist/lib/common/client.js.map +1 -0
- package/dist/lib/common/index.d.ts +5 -0
- package/dist/lib/common/index.d.ts.map +1 -0
- package/dist/lib/common/index.js +10 -0
- package/dist/lib/common/index.js.map +1 -0
- package/dist/lib/common/props.d.ts +14 -0
- package/dist/lib/common/props.d.ts.map +1 -0
- package/dist/lib/common/props.js +118 -0
- package/dist/lib/common/props.js.map +1 -0
- package/dist/lib/common/types.d.ts +89 -0
- package/dist/lib/common/types.d.ts.map +1 -0
- package/dist/lib/common/types.js +6 -0
- package/dist/lib/common/types.js.map +1 -0
- package/dist/lib/triggers/new-order.d.ts +11 -0
- package/dist/lib/triggers/new-order.d.ts.map +1 -0
- package/dist/lib/triggers/new-order.js +152 -0
- package/dist/lib/triggers/new-order.js.map +1 -0
- package/dist/lib/triggers/new-product.d.ts +3 -0
- package/dist/lib/triggers/new-product.d.ts.map +1 -0
- package/dist/lib/triggers/new-product.js +111 -0
- package/dist/lib/triggers/new-product.js.map +1 -0
- package/dist/lib/triggers/new-project.d.ts +11 -0
- package/dist/lib/triggers/new-project.d.ts.map +1 -0
- package/dist/lib/triggers/new-project.js +141 -0
- package/dist/lib/triggers/new-project.js.map +1 -0
- package/dist/lib/triggers/new-quote.d.ts +11 -0
- package/dist/lib/triggers/new-quote.d.ts.map +1 -0
- package/dist/lib/triggers/new-quote.js +153 -0
- package/dist/lib/triggers/new-quote.js.map +1 -0
- package/dist/lib/triggers/new-sales-invoice.d.ts +11 -0
- package/dist/lib/triggers/new-sales-invoice.d.ts.map +1 -0
- package/dist/lib/triggers/new-sales-invoice.js +153 -0
- package/dist/lib/triggers/new-sales-invoice.js.map +1 -0
- package/dist/lib/triggers/new-updated-company.d.ts +3 -0
- package/dist/lib/triggers/new-updated-company.d.ts.map +1 -0
- package/dist/lib/triggers/new-updated-company.js +122 -0
- package/dist/lib/triggers/new-updated-company.js.map +1 -0
- package/dist/lib/triggers/new-updated-person.d.ts +3 -0
- package/dist/lib/triggers/new-updated-person.d.ts.map +1 -0
- package/dist/lib/triggers/new-updated-person.js +122 -0
- package/dist/lib/triggers/new-updated-person.js.map +1 -0
- package/package.json +48 -0
- package/src/index.ts +89 -0
- package/src/lib/actions/create-company.ts +464 -0
- package/src/lib/actions/create-file.ts +62 -0
- package/src/lib/actions/create-manual-entry.ts +445 -0
- package/src/lib/actions/create-person.ts +481 -0
- package/src/lib/actions/create-product.ts +563 -0
- package/src/lib/actions/create-project.ts +344 -0
- package/src/lib/actions/create-sales-invoice.ts +656 -0
- package/src/lib/actions/create-sales-order.ts +689 -0
- package/src/lib/actions/create-sales-quote.ts +713 -0
- package/src/lib/actions/create-time-tracking.ts +418 -0
- package/src/lib/actions/export-invoice-pdf.ts +104 -0
- package/src/lib/actions/find-account.ts +114 -0
- package/src/lib/actions/find-company.ts +193 -0
- package/src/lib/actions/find-country.ts +127 -0
- package/src/lib/actions/find-person.ts +208 -0
- package/src/lib/actions/find-product.ts +161 -0
- package/src/lib/actions/search-invoice.ts +157 -0
- package/src/lib/actions/search-order.ts +155 -0
- package/src/lib/actions/search-quote.ts +157 -0
- package/src/lib/actions/send-sales-invoice.ts +118 -0
- package/src/lib/actions/update-company.ts +518 -0
- package/src/lib/actions/update-person.ts +536 -0
- package/src/lib/actions/update-product.ts +594 -0
- package/src/lib/auth.ts +44 -0
- package/src/lib/common/client.ts +65 -0
- package/src/lib/common/index.ts +5 -0
- package/src/lib/common/props.ts +127 -0
- package/src/lib/common/types.ts +99 -0
- package/src/lib/triggers/new-order.ts +184 -0
- package/src/lib/triggers/new-product.ts +154 -0
- package/src/lib/triggers/new-project.ts +165 -0
- package/src/lib/triggers/new-quote.ts +186 -0
- package/src/lib/triggers/new-sales-invoice.ts +186 -0
- package/src/lib/triggers/new-updated-company.ts +161 -0
- package/src/lib/triggers/new-updated-person.ts +161 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { createAction, Property, OAuth2PropertyValue } from '@agnocon/pieces-framework';
|
|
2
|
+
import { bexioAuth } from '../auth';
|
|
3
|
+
import { BexioClient } from '../common/client';
|
|
4
|
+
|
|
5
|
+
export const createProjectAction = createAction({
|
|
6
|
+
auth: bexioAuth,
|
|
7
|
+
name: 'create_project',
|
|
8
|
+
displayName: 'Create Project',
|
|
9
|
+
description: 'Create a new project',
|
|
10
|
+
audience: 'both',
|
|
11
|
+
aiMetadata: { description: 'Creates a new Bexio project linked to a contact, with status, type, responsible user, optional dates, and optional invoicing/budget settings. Use to set up a project before tracking time or billing against it. Requires a name, project status, project type, contact, and user. Not idempotent: each call creates a separate project.', idempotent: false },
|
|
12
|
+
props: {
|
|
13
|
+
document_nr: Property.ShortText({
|
|
14
|
+
displayName: 'Document Number',
|
|
15
|
+
description: 'Project number (required if automatic numbering is disabled)',
|
|
16
|
+
required: false,
|
|
17
|
+
}),
|
|
18
|
+
name: Property.ShortText({
|
|
19
|
+
displayName: 'Project Name',
|
|
20
|
+
description: 'Name of the project',
|
|
21
|
+
required: true,
|
|
22
|
+
}),
|
|
23
|
+
start_date: Property.DateTime({
|
|
24
|
+
displayName: 'Start Date',
|
|
25
|
+
description: 'Project start date',
|
|
26
|
+
required: false,
|
|
27
|
+
}),
|
|
28
|
+
end_date: Property.DateTime({
|
|
29
|
+
displayName: 'End Date',
|
|
30
|
+
description: 'Project end date',
|
|
31
|
+
required: false,
|
|
32
|
+
}),
|
|
33
|
+
comment: Property.LongText({
|
|
34
|
+
displayName: 'Comment',
|
|
35
|
+
description: 'Project comment/description',
|
|
36
|
+
required: false,
|
|
37
|
+
}),
|
|
38
|
+
pr_state_id: Property.Dropdown({
|
|
39
|
+
auth: bexioAuth,
|
|
40
|
+
displayName: 'Project Status',
|
|
41
|
+
description: 'Status of the project',
|
|
42
|
+
required: true,
|
|
43
|
+
refreshers: [],
|
|
44
|
+
options: async ({ auth }) => {
|
|
45
|
+
if (!auth) {
|
|
46
|
+
return {
|
|
47
|
+
disabled: true,
|
|
48
|
+
placeholder: 'Connect your Bexio account first',
|
|
49
|
+
options: [],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const client = new BexioClient(auth);
|
|
55
|
+
const states = await client.get<Array<{ id: number; name: string }>>('/2.0/pr_project_state');
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
disabled: false,
|
|
59
|
+
options: states.map((state) => ({
|
|
60
|
+
label: state.name,
|
|
61
|
+
value: state.id,
|
|
62
|
+
})),
|
|
63
|
+
};
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return {
|
|
66
|
+
disabled: true,
|
|
67
|
+
placeholder: 'Failed to load project statuses',
|
|
68
|
+
options: [],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
pr_project_type_id: Property.Dropdown({
|
|
74
|
+
auth: bexioAuth,
|
|
75
|
+
displayName: 'Project Type',
|
|
76
|
+
description: 'Type of project',
|
|
77
|
+
required: true,
|
|
78
|
+
refreshers: [],
|
|
79
|
+
options: async ({ auth }) => {
|
|
80
|
+
if (!auth) {
|
|
81
|
+
return {
|
|
82
|
+
disabled: true,
|
|
83
|
+
placeholder: 'Connect your Bexio account first',
|
|
84
|
+
options: [],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
const client = new BexioClient(auth);
|
|
90
|
+
const types = await client.get<Array<{ id: number; name: string }>>('/2.0/pr_project_type');
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
disabled: false,
|
|
94
|
+
options: types.map((type) => ({
|
|
95
|
+
label: type.name,
|
|
96
|
+
value: type.id,
|
|
97
|
+
})),
|
|
98
|
+
};
|
|
99
|
+
} catch (error) {
|
|
100
|
+
return {
|
|
101
|
+
disabled: true,
|
|
102
|
+
placeholder: 'Failed to load project types',
|
|
103
|
+
options: [],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
}),
|
|
108
|
+
contact_id: Property.Dropdown({
|
|
109
|
+
auth: bexioAuth,
|
|
110
|
+
displayName: 'Contact',
|
|
111
|
+
description: 'Contact associated with this project',
|
|
112
|
+
required: true,
|
|
113
|
+
refreshers: [],
|
|
114
|
+
options: async ({ auth }) => {
|
|
115
|
+
if (!auth) {
|
|
116
|
+
return {
|
|
117
|
+
disabled: true,
|
|
118
|
+
placeholder: 'Connect your Bexio account first',
|
|
119
|
+
options: [],
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
const client = new BexioClient(auth);
|
|
125
|
+
const contacts = await client.get<Array<{
|
|
126
|
+
id: number;
|
|
127
|
+
contact_type_id: number;
|
|
128
|
+
name_1: string;
|
|
129
|
+
name_2?: string | null;
|
|
130
|
+
nr?: string | null;
|
|
131
|
+
}>>('/2.0/contact');
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
disabled: false,
|
|
135
|
+
options: contacts.map((contact) => {
|
|
136
|
+
const name = contact.name_2
|
|
137
|
+
? `${contact.name_2} ${contact.name_1}`
|
|
138
|
+
: contact.name_1;
|
|
139
|
+
const label = contact.nr ? `${name} (#${contact.nr})` : name;
|
|
140
|
+
return {
|
|
141
|
+
label,
|
|
142
|
+
value: contact.id,
|
|
143
|
+
};
|
|
144
|
+
}),
|
|
145
|
+
};
|
|
146
|
+
} catch (error) {
|
|
147
|
+
return {
|
|
148
|
+
disabled: true,
|
|
149
|
+
placeholder: 'Failed to load contacts',
|
|
150
|
+
options: [],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
}),
|
|
155
|
+
contact_sub_id: Property.Dropdown({
|
|
156
|
+
auth: bexioAuth,
|
|
157
|
+
displayName: 'Contact Sub',
|
|
158
|
+
description: 'Contact sub-address (optional)',
|
|
159
|
+
required: false,
|
|
160
|
+
refreshers: [],
|
|
161
|
+
options: async ({ auth }) => {
|
|
162
|
+
if (!auth) {
|
|
163
|
+
return {
|
|
164
|
+
disabled: true,
|
|
165
|
+
placeholder: 'Connect your Bexio account first',
|
|
166
|
+
options: [],
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
const client = new BexioClient(auth);
|
|
172
|
+
const contacts = await client.get<Array<{
|
|
173
|
+
id: number;
|
|
174
|
+
contact_type_id: number;
|
|
175
|
+
name_1: string;
|
|
176
|
+
name_2?: string | null;
|
|
177
|
+
nr?: string | null;
|
|
178
|
+
}>>('/2.0/contact');
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
disabled: false,
|
|
182
|
+
options: contacts.map((contact) => {
|
|
183
|
+
const name = contact.name_2
|
|
184
|
+
? `${contact.name_2} ${contact.name_1}`
|
|
185
|
+
: contact.name_1;
|
|
186
|
+
const label = contact.nr ? `${name} (#${contact.nr})` : name;
|
|
187
|
+
return {
|
|
188
|
+
label,
|
|
189
|
+
value: contact.id,
|
|
190
|
+
};
|
|
191
|
+
}),
|
|
192
|
+
};
|
|
193
|
+
} catch (error) {
|
|
194
|
+
return {
|
|
195
|
+
disabled: true,
|
|
196
|
+
placeholder: 'Failed to load contacts',
|
|
197
|
+
options: [],
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
}),
|
|
202
|
+
pr_invoice_type_id: Property.StaticDropdown({
|
|
203
|
+
displayName: 'Invoice Type',
|
|
204
|
+
description: 'Type of invoicing for this project',
|
|
205
|
+
required: false,
|
|
206
|
+
options: {
|
|
207
|
+
disabled: false,
|
|
208
|
+
options: [
|
|
209
|
+
{ label: 'Hourly rate for client services', value: 1 },
|
|
210
|
+
{ label: 'Hourly rate for employee', value: 2 },
|
|
211
|
+
{ label: 'Hourly rate for project', value: 3 },
|
|
212
|
+
{ label: 'Fix price for project', value: 4 },
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
|
+
}),
|
|
216
|
+
pr_invoice_type_amount: Property.ShortText({
|
|
217
|
+
displayName: 'Invoice Type Amount',
|
|
218
|
+
description: 'Amount for invoice type (only for hourly rate project or fix price)',
|
|
219
|
+
required: false,
|
|
220
|
+
}),
|
|
221
|
+
pr_budget_type_id: Property.StaticDropdown({
|
|
222
|
+
displayName: 'Budget Type',
|
|
223
|
+
description: 'Type of budget for this project',
|
|
224
|
+
required: false,
|
|
225
|
+
options: {
|
|
226
|
+
disabled: false,
|
|
227
|
+
options: [
|
|
228
|
+
{ label: 'Total budget costs', value: 1 },
|
|
229
|
+
{ label: 'Total budget hours', value: 2 },
|
|
230
|
+
{ label: 'Budget for each client services', value: 3 },
|
|
231
|
+
{ label: 'Budget for each employee', value: 4 },
|
|
232
|
+
],
|
|
233
|
+
},
|
|
234
|
+
}),
|
|
235
|
+
pr_budget_type_amount: Property.ShortText({
|
|
236
|
+
displayName: 'Budget Type Amount',
|
|
237
|
+
description: 'Amount for budget type (only for total budget costs or total budget hours)',
|
|
238
|
+
required: false,
|
|
239
|
+
}),
|
|
240
|
+
user_id: Property.Dropdown({
|
|
241
|
+
auth: bexioAuth,
|
|
242
|
+
displayName: 'User',
|
|
243
|
+
description: 'User responsible for this project',
|
|
244
|
+
required: true,
|
|
245
|
+
refreshers: [],
|
|
246
|
+
options: async ({ auth }) => {
|
|
247
|
+
if (!auth) {
|
|
248
|
+
return {
|
|
249
|
+
disabled: true,
|
|
250
|
+
placeholder: 'Connect your Bexio account first',
|
|
251
|
+
options: [],
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
try {
|
|
256
|
+
const client = new BexioClient(auth);
|
|
257
|
+
const users = await client.get<Array<{
|
|
258
|
+
id: number;
|
|
259
|
+
firstname?: string | null;
|
|
260
|
+
lastname?: string | null;
|
|
261
|
+
email: string;
|
|
262
|
+
}>>('/3.0/users');
|
|
263
|
+
|
|
264
|
+
return {
|
|
265
|
+
disabled: false,
|
|
266
|
+
options: users.map((user) => {
|
|
267
|
+
const name = user.firstname && user.lastname
|
|
268
|
+
? `${user.firstname} ${user.lastname}`
|
|
269
|
+
: user.email;
|
|
270
|
+
return {
|
|
271
|
+
label: name,
|
|
272
|
+
value: user.id,
|
|
273
|
+
};
|
|
274
|
+
}),
|
|
275
|
+
};
|
|
276
|
+
} catch (error) {
|
|
277
|
+
return {
|
|
278
|
+
disabled: true,
|
|
279
|
+
placeholder: 'Failed to load users',
|
|
280
|
+
options: [],
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
}),
|
|
285
|
+
},
|
|
286
|
+
async run({ auth, propsValue }) {
|
|
287
|
+
const client = new BexioClient(auth);
|
|
288
|
+
const props = propsValue;
|
|
289
|
+
|
|
290
|
+
const requestBody: Record<string, unknown> = {
|
|
291
|
+
name: props['name'],
|
|
292
|
+
pr_state_id: props['pr_state_id'],
|
|
293
|
+
pr_project_type_id: props['pr_project_type_id'],
|
|
294
|
+
contact_id: props['contact_id'],
|
|
295
|
+
user_id: props['user_id'],
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
if (props['document_nr']) {
|
|
299
|
+
requestBody['document_nr'] = props['document_nr'];
|
|
300
|
+
}
|
|
301
|
+
if (props['start_date']) {
|
|
302
|
+
// Convert DateTime to ISO string format expected by API
|
|
303
|
+
const startDate = props['start_date'] as string;
|
|
304
|
+
requestBody['start_date'] = startDate;
|
|
305
|
+
}
|
|
306
|
+
if (props['end_date']) {
|
|
307
|
+
// Convert DateTime to ISO string format expected by API
|
|
308
|
+
const endDate = props['end_date'] as string;
|
|
309
|
+
requestBody['end_date'] = endDate;
|
|
310
|
+
}
|
|
311
|
+
if (props['comment']) {
|
|
312
|
+
requestBody['comment'] = props['comment'];
|
|
313
|
+
}
|
|
314
|
+
if (props['contact_sub_id']) {
|
|
315
|
+
requestBody['contact_sub_id'] = props['contact_sub_id'];
|
|
316
|
+
}
|
|
317
|
+
if (props['pr_invoice_type_id']) {
|
|
318
|
+
requestBody['pr_invoice_type_id'] = props['pr_invoice_type_id'];
|
|
319
|
+
}
|
|
320
|
+
if (props['pr_invoice_type_amount']) {
|
|
321
|
+
requestBody['pr_invoice_type_amount'] = props['pr_invoice_type_amount'];
|
|
322
|
+
}
|
|
323
|
+
if (props['pr_budget_type_id']) {
|
|
324
|
+
requestBody['pr_budget_type_id'] = props['pr_budget_type_id'];
|
|
325
|
+
}
|
|
326
|
+
if (props['pr_budget_type_amount']) {
|
|
327
|
+
requestBody['pr_budget_type_amount'] = props['pr_budget_type_amount'];
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const response = await client.post<{
|
|
331
|
+
id: number;
|
|
332
|
+
uuid: string;
|
|
333
|
+
nr: string;
|
|
334
|
+
name: string;
|
|
335
|
+
pr_state_id: number;
|
|
336
|
+
pr_project_type_id: number;
|
|
337
|
+
contact_id: number;
|
|
338
|
+
user_id: number;
|
|
339
|
+
}>('/2.0/pr_project', requestBody);
|
|
340
|
+
|
|
341
|
+
return response;
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
|