@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,157 @@
|
|
|
1
|
+
import { createAction, Property, OAuth2PropertyValue } from '@agnocon/pieces-framework';
|
|
2
|
+
import { bexioAuth } from '../auth';
|
|
3
|
+
import { BexioClient } from '../common/client';
|
|
4
|
+
|
|
5
|
+
export const searchInvoiceAction = createAction({
|
|
6
|
+
auth: bexioAuth,
|
|
7
|
+
name: 'search_invoice',
|
|
8
|
+
displayName: 'Search Invoice',
|
|
9
|
+
description: 'Search for invoices using various criteria',
|
|
10
|
+
audience: 'both',
|
|
11
|
+
aiMetadata: { description: 'Searches Bexio sales invoices by one or more field criteria (document number, contact, status, totals, dates, etc.) with operators such as contains, equals, or comparison, with ordering and paging. Use to locate invoices before exporting, sending, or reconciling them; pick Search Order or Search Quote for those document types. Read-only and idempotent.', idempotent: true },
|
|
12
|
+
props: {
|
|
13
|
+
search_criteria: Property.Array({
|
|
14
|
+
displayName: 'Search Criteria',
|
|
15
|
+
description: 'Search criteria for finding invoices',
|
|
16
|
+
required: true,
|
|
17
|
+
properties: {
|
|
18
|
+
field: Property.StaticDropdown({
|
|
19
|
+
displayName: 'Search Field',
|
|
20
|
+
description: 'Field to search in',
|
|
21
|
+
required: true,
|
|
22
|
+
options: {
|
|
23
|
+
disabled: false,
|
|
24
|
+
options: [
|
|
25
|
+
{ label: 'ID', value: 'id' },
|
|
26
|
+
{ label: 'Status ID', value: 'kb_item_status_id' },
|
|
27
|
+
{ label: 'Document Number', value: 'document_nr' },
|
|
28
|
+
{ label: 'Title', value: 'title' },
|
|
29
|
+
{ label: 'API Reference', value: 'api_reference' },
|
|
30
|
+
{ label: 'Contact ID', value: 'contact_id' },
|
|
31
|
+
{ label: 'Sub Contact ID', value: 'contact_sub_id' },
|
|
32
|
+
{ label: 'User ID', value: 'user_id' },
|
|
33
|
+
{ label: 'Currency ID', value: 'currency_id' },
|
|
34
|
+
{ label: 'Total Gross', value: 'total_gross' },
|
|
35
|
+
{ label: 'Total Net', value: 'total_net' },
|
|
36
|
+
{ label: 'Total', value: 'total' },
|
|
37
|
+
{ label: 'Valid From', value: 'is_valid_from' },
|
|
38
|
+
{ label: 'Valid To', value: 'is_valid_to' },
|
|
39
|
+
{ label: 'Updated At', value: 'updated_at' },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
value: Property.ShortText({
|
|
44
|
+
displayName: 'Search Value',
|
|
45
|
+
description: 'Value to search for',
|
|
46
|
+
required: true,
|
|
47
|
+
}),
|
|
48
|
+
criteria: Property.StaticDropdown({
|
|
49
|
+
displayName: 'Criteria',
|
|
50
|
+
description: 'Search criteria type',
|
|
51
|
+
required: false,
|
|
52
|
+
defaultValue: 'like',
|
|
53
|
+
options: {
|
|
54
|
+
disabled: false,
|
|
55
|
+
options: [
|
|
56
|
+
{ label: 'Contains (like)', value: 'like' },
|
|
57
|
+
{ label: 'Exact match (=)', value: '=' },
|
|
58
|
+
{ label: 'Exact match (equal)', value: 'equal' },
|
|
59
|
+
{ label: 'Not equal (!=)', value: '!=' },
|
|
60
|
+
{ label: 'Not equal (not_equal)', value: 'not_equal' },
|
|
61
|
+
{ label: 'Greater than (>)', value: '>' },
|
|
62
|
+
{ label: 'Greater than (greater_than)', value: 'greater_than' },
|
|
63
|
+
{ label: 'Greater or equal (>=)', value: '>=' },
|
|
64
|
+
{ label: 'Greater or equal (greater_equal)', value: 'greater_equal' },
|
|
65
|
+
{ label: 'Less than (<)', value: '<' },
|
|
66
|
+
{ label: 'Less than (less_than)', value: 'less_than' },
|
|
67
|
+
{ label: 'Less or equal (<=)', value: '<=' },
|
|
68
|
+
{ label: 'Less or equal (less_equal)', value: 'less_equal' },
|
|
69
|
+
{ label: 'Does not contain (not_like)', value: 'not_like' },
|
|
70
|
+
{ label: 'Is NULL', value: 'is_null' },
|
|
71
|
+
{ label: 'Is not NULL', value: 'not_null' },
|
|
72
|
+
{ label: 'In (array)', value: 'in' },
|
|
73
|
+
{ label: 'Not in (array)', value: 'not_in' },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
order_by: Property.StaticDropdown({
|
|
80
|
+
displayName: 'Order By',
|
|
81
|
+
description: 'Field to order results by',
|
|
82
|
+
required: false,
|
|
83
|
+
defaultValue: 'id',
|
|
84
|
+
options: {
|
|
85
|
+
disabled: false,
|
|
86
|
+
options: [
|
|
87
|
+
{ label: 'ID', value: 'id' },
|
|
88
|
+
{ label: 'Total', value: 'total' },
|
|
89
|
+
{ label: 'Total Net', value: 'total_net' },
|
|
90
|
+
{ label: 'Total Gross', value: 'total_gross' },
|
|
91
|
+
{ label: 'Updated At', value: 'updated_at' },
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
}),
|
|
95
|
+
limit: Property.Number({
|
|
96
|
+
displayName: 'Limit',
|
|
97
|
+
description: 'Maximum number of results to return (max 2000)',
|
|
98
|
+
required: false,
|
|
99
|
+
defaultValue: 500,
|
|
100
|
+
}),
|
|
101
|
+
offset: Property.Number({
|
|
102
|
+
displayName: 'Offset',
|
|
103
|
+
description: 'Number of results to skip',
|
|
104
|
+
required: false,
|
|
105
|
+
defaultValue: 0,
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
108
|
+
async run({ auth, propsValue }) {
|
|
109
|
+
const client = new BexioClient(auth);
|
|
110
|
+
const searchCriteria = propsValue['search_criteria'] as Array<Record<string, unknown>>;
|
|
111
|
+
const orderBy = propsValue['order_by'] as string | undefined;
|
|
112
|
+
const limit = propsValue['limit'] as number | undefined;
|
|
113
|
+
const offset = propsValue['offset'] as number | undefined;
|
|
114
|
+
|
|
115
|
+
const searchBody = searchCriteria.map((criteria) => ({
|
|
116
|
+
field: criteria['field'] as string,
|
|
117
|
+
value: criteria['value'] as string,
|
|
118
|
+
criteria: (criteria['criteria'] as string) || 'like',
|
|
119
|
+
}));
|
|
120
|
+
|
|
121
|
+
const queryParams: Record<string, string> = {};
|
|
122
|
+
if (orderBy) {
|
|
123
|
+
queryParams['order_by'] = orderBy;
|
|
124
|
+
}
|
|
125
|
+
if (limit !== undefined) {
|
|
126
|
+
queryParams['limit'] = limit.toString();
|
|
127
|
+
}
|
|
128
|
+
if (offset !== undefined) {
|
|
129
|
+
queryParams['offset'] = offset.toString();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const response = await client.post<Array<{
|
|
133
|
+
id: number;
|
|
134
|
+
document_nr: string;
|
|
135
|
+
title: string | null;
|
|
136
|
+
contact_id: number | null;
|
|
137
|
+
contact_sub_id: number | null;
|
|
138
|
+
user_id: number;
|
|
139
|
+
project_id: number | null;
|
|
140
|
+
language_id: number;
|
|
141
|
+
bank_account_id: number;
|
|
142
|
+
currency_id: number;
|
|
143
|
+
payment_type_id: number;
|
|
144
|
+
total_gross: string;
|
|
145
|
+
total_net: string;
|
|
146
|
+
total_taxes: string;
|
|
147
|
+
total: string;
|
|
148
|
+
kb_item_status_id: number;
|
|
149
|
+
is_valid_from: string;
|
|
150
|
+
is_valid_to: string | null;
|
|
151
|
+
updated_at: string;
|
|
152
|
+
}>>('/2.0/kb_invoice/search', searchBody, queryParams);
|
|
153
|
+
|
|
154
|
+
return response;
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { createAction, Property, OAuth2PropertyValue } from '@agnocon/pieces-framework';
|
|
2
|
+
import { bexioAuth } from '../auth';
|
|
3
|
+
import { BexioClient } from '../common/client';
|
|
4
|
+
|
|
5
|
+
export const searchOrderAction = createAction({
|
|
6
|
+
auth: bexioAuth,
|
|
7
|
+
name: 'search_order',
|
|
8
|
+
displayName: 'Search Order',
|
|
9
|
+
description: 'Search for orders using various criteria',
|
|
10
|
+
audience: 'both',
|
|
11
|
+
aiMetadata: { description: 'Searches Bexio sales orders by one or more field criteria (document number, contact, status, totals, dates, etc.) with operators such as contains, equals, or comparison, with ordering and paging. Use to locate orders before referencing or processing them; pick Search Invoice or Search Quote for those document types. Read-only and idempotent.', idempotent: true },
|
|
12
|
+
props: {
|
|
13
|
+
search_criteria: Property.Array({
|
|
14
|
+
displayName: 'Search Criteria',
|
|
15
|
+
description: 'Search criteria for finding orders',
|
|
16
|
+
required: true,
|
|
17
|
+
properties: {
|
|
18
|
+
field: Property.StaticDropdown({
|
|
19
|
+
displayName: 'Search Field',
|
|
20
|
+
description: 'Field to search in',
|
|
21
|
+
required: true,
|
|
22
|
+
options: {
|
|
23
|
+
disabled: false,
|
|
24
|
+
options: [
|
|
25
|
+
{ label: 'ID', value: 'id' },
|
|
26
|
+
{ label: 'Status ID', value: 'kb_item_status_id' },
|
|
27
|
+
{ label: 'Document Number', value: 'document_nr' },
|
|
28
|
+
{ label: 'Title', value: 'title' },
|
|
29
|
+
{ label: 'Contact ID', value: 'contact_id' },
|
|
30
|
+
{ label: 'Sub Contact ID', value: 'contact_sub_id' },
|
|
31
|
+
{ label: 'User ID', value: 'user_id' },
|
|
32
|
+
{ label: 'Currency ID', value: 'currency_id' },
|
|
33
|
+
{ label: 'Total Gross', value: 'total_gross' },
|
|
34
|
+
{ label: 'Total Net', value: 'total_net' },
|
|
35
|
+
{ label: 'Total', value: 'total' },
|
|
36
|
+
{ label: 'Valid From', value: 'is_valid_from' },
|
|
37
|
+
{ label: 'Valid To', value: 'is_valid_to' },
|
|
38
|
+
{ label: 'Updated At', value: 'updated_at' },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
value: Property.ShortText({
|
|
43
|
+
displayName: 'Search Value',
|
|
44
|
+
description: 'Value to search for',
|
|
45
|
+
required: true,
|
|
46
|
+
}),
|
|
47
|
+
criteria: Property.StaticDropdown({
|
|
48
|
+
displayName: 'Criteria',
|
|
49
|
+
description: 'Search criteria type',
|
|
50
|
+
required: false,
|
|
51
|
+
defaultValue: 'like',
|
|
52
|
+
options: {
|
|
53
|
+
disabled: false,
|
|
54
|
+
options: [
|
|
55
|
+
{ label: 'Contains (like)', value: 'like' },
|
|
56
|
+
{ label: 'Exact match (=)', value: '=' },
|
|
57
|
+
{ label: 'Exact match (equal)', value: 'equal' },
|
|
58
|
+
{ label: 'Not equal (!=)', value: '!=' },
|
|
59
|
+
{ label: 'Not equal (not_equal)', value: 'not_equal' },
|
|
60
|
+
{ label: 'Greater than (>)', value: '>' },
|
|
61
|
+
{ label: 'Greater than (greater_than)', value: 'greater_than' },
|
|
62
|
+
{ label: 'Greater or equal (>=)', value: '>=' },
|
|
63
|
+
{ label: 'Greater or equal (greater_equal)', value: 'greater_equal' },
|
|
64
|
+
{ label: 'Less than (<)', value: '<' },
|
|
65
|
+
{ label: 'Less than (less_than)', value: 'less_than' },
|
|
66
|
+
{ label: 'Less or equal (<=)', value: '<=' },
|
|
67
|
+
{ label: 'Less or equal (less_equal)', value: 'less_equal' },
|
|
68
|
+
{ label: 'Does not contain (not_like)', value: 'not_like' },
|
|
69
|
+
{ label: 'Is NULL', value: 'is_null' },
|
|
70
|
+
{ label: 'Is not NULL', value: 'not_null' },
|
|
71
|
+
{ label: 'In (array)', value: 'in' },
|
|
72
|
+
{ label: 'Not in (array)', value: 'not_in' },
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
order_by: Property.StaticDropdown({
|
|
79
|
+
displayName: 'Order By',
|
|
80
|
+
description: 'Field to order results by',
|
|
81
|
+
required: false,
|
|
82
|
+
defaultValue: 'id',
|
|
83
|
+
options: {
|
|
84
|
+
disabled: false,
|
|
85
|
+
options: [
|
|
86
|
+
{ label: 'ID', value: 'id' },
|
|
87
|
+
{ label: 'Total', value: 'total' },
|
|
88
|
+
{ label: 'Total Net', value: 'total_net' },
|
|
89
|
+
{ label: 'Total Gross', value: 'total_gross' },
|
|
90
|
+
{ label: 'Updated At', value: 'updated_at' },
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
limit: Property.Number({
|
|
95
|
+
displayName: 'Limit',
|
|
96
|
+
description: 'Maximum number of results to return (max 2000)',
|
|
97
|
+
required: false,
|
|
98
|
+
defaultValue: 500,
|
|
99
|
+
}),
|
|
100
|
+
offset: Property.Number({
|
|
101
|
+
displayName: 'Offset',
|
|
102
|
+
description: 'Number of results to skip',
|
|
103
|
+
required: false,
|
|
104
|
+
defaultValue: 0,
|
|
105
|
+
}),
|
|
106
|
+
},
|
|
107
|
+
async run({ auth, propsValue }) {
|
|
108
|
+
const client = new BexioClient(auth);
|
|
109
|
+
const searchCriteria = propsValue['search_criteria'] as Array<Record<string, unknown>>;
|
|
110
|
+
const orderBy = propsValue['order_by'] as string | undefined;
|
|
111
|
+
const limit = propsValue['limit'] as number | undefined;
|
|
112
|
+
const offset = propsValue['offset'] as number | undefined;
|
|
113
|
+
|
|
114
|
+
const searchBody = searchCriteria.map((criteria) => ({
|
|
115
|
+
field: criteria['field'] as string,
|
|
116
|
+
value: criteria['value'] as string,
|
|
117
|
+
criteria: (criteria['criteria'] as string) || 'like',
|
|
118
|
+
}));
|
|
119
|
+
|
|
120
|
+
const queryParams: Record<string, string> = {};
|
|
121
|
+
if (orderBy) {
|
|
122
|
+
queryParams['order_by'] = orderBy;
|
|
123
|
+
}
|
|
124
|
+
if (limit !== undefined) {
|
|
125
|
+
queryParams['limit'] = limit.toString();
|
|
126
|
+
}
|
|
127
|
+
if (offset !== undefined) {
|
|
128
|
+
queryParams['offset'] = offset.toString();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const response = await client.post<Array<{
|
|
132
|
+
id: number;
|
|
133
|
+
document_nr: string;
|
|
134
|
+
title: string | null;
|
|
135
|
+
contact_id: number | null;
|
|
136
|
+
contact_sub_id: number | null;
|
|
137
|
+
user_id: number;
|
|
138
|
+
project_id: number | null;
|
|
139
|
+
language_id: number;
|
|
140
|
+
bank_account_id: number;
|
|
141
|
+
currency_id: number;
|
|
142
|
+
payment_type_id: number;
|
|
143
|
+
total_gross: string;
|
|
144
|
+
total_net: string;
|
|
145
|
+
total_taxes: string;
|
|
146
|
+
total: string;
|
|
147
|
+
kb_item_status_id: number;
|
|
148
|
+
is_valid_from: string;
|
|
149
|
+
updated_at: string;
|
|
150
|
+
}>>('/2.0/kb_order/search', searchBody, queryParams);
|
|
151
|
+
|
|
152
|
+
return response;
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { bexioAuth } from '../auth';
|
|
3
|
+
import { BexioClient } from '../common/client';
|
|
4
|
+
|
|
5
|
+
export const searchQuoteAction = createAction({
|
|
6
|
+
auth: bexioAuth,
|
|
7
|
+
name: 'search_quote',
|
|
8
|
+
displayName: 'Search Quote',
|
|
9
|
+
description: 'Search for quotes using various criteria',
|
|
10
|
+
audience: 'both',
|
|
11
|
+
aiMetadata: { description: 'Searches Bexio quotes (offers) by one or more field criteria (document number, contact, status, totals, dates, valid-until, etc.) with operators such as contains, equals, or comparison, with ordering and paging. Use to locate quotes before referencing or following up on them; pick Search Invoice or Search Order for those document types. Read-only and idempotent.', idempotent: true },
|
|
12
|
+
props: {
|
|
13
|
+
search_criteria: Property.Array({
|
|
14
|
+
displayName: 'Search Criteria',
|
|
15
|
+
description: 'Search criteria for finding quotes',
|
|
16
|
+
required: true,
|
|
17
|
+
properties: {
|
|
18
|
+
field: Property.StaticDropdown({
|
|
19
|
+
displayName: 'Search Field',
|
|
20
|
+
description: 'Field to search in',
|
|
21
|
+
required: true,
|
|
22
|
+
options: {
|
|
23
|
+
disabled: false,
|
|
24
|
+
options: [
|
|
25
|
+
{ label: 'ID', value: 'id' },
|
|
26
|
+
{ label: 'Status ID', value: 'kb_item_status_id' },
|
|
27
|
+
{ label: 'Document Number', value: 'document_nr' },
|
|
28
|
+
{ label: 'Title', value: 'title' },
|
|
29
|
+
{ label: 'Contact ID', value: 'contact_id' },
|
|
30
|
+
{ label: 'Sub Contact ID', value: 'contact_sub_id' },
|
|
31
|
+
{ label: 'User ID', value: 'user_id' },
|
|
32
|
+
{ label: 'Currency ID', value: 'currency_id' },
|
|
33
|
+
{ label: 'Total Gross', value: 'total_gross' },
|
|
34
|
+
{ label: 'Total Net', value: 'total_net' },
|
|
35
|
+
{ label: 'Total', value: 'total' },
|
|
36
|
+
{ label: 'Valid From', value: 'is_valid_from' },
|
|
37
|
+
{ label: 'Valid To', value: 'is_valid_to' },
|
|
38
|
+
{ label: 'Valid Until', value: 'is_valid_until' },
|
|
39
|
+
{ label: 'Updated At', value: 'updated_at' },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
value: Property.ShortText({
|
|
44
|
+
displayName: 'Search Value',
|
|
45
|
+
description: 'Value to search for',
|
|
46
|
+
required: true,
|
|
47
|
+
}),
|
|
48
|
+
criteria: Property.StaticDropdown({
|
|
49
|
+
displayName: 'Criteria',
|
|
50
|
+
description: 'Search criteria type',
|
|
51
|
+
required: false,
|
|
52
|
+
defaultValue: 'like',
|
|
53
|
+
options: {
|
|
54
|
+
disabled: false,
|
|
55
|
+
options: [
|
|
56
|
+
{ label: 'Contains (like)', value: 'like' },
|
|
57
|
+
{ label: 'Exact match (=)', value: '=' },
|
|
58
|
+
{ label: 'Exact match (equal)', value: 'equal' },
|
|
59
|
+
{ label: 'Not equal (!=)', value: '!=' },
|
|
60
|
+
{ label: 'Not equal (not_equal)', value: 'not_equal' },
|
|
61
|
+
{ label: 'Greater than (>)', value: '>' },
|
|
62
|
+
{ label: 'Greater than (greater_than)', value: 'greater_than' },
|
|
63
|
+
{ label: 'Greater or equal (>=)', value: '>=' },
|
|
64
|
+
{ label: 'Greater or equal (greater_equal)', value: 'greater_equal' },
|
|
65
|
+
{ label: 'Less than (<)', value: '<' },
|
|
66
|
+
{ label: 'Less than (less_than)', value: 'less_than' },
|
|
67
|
+
{ label: 'Less or equal (<=)', value: '<=' },
|
|
68
|
+
{ label: 'Less or equal (less_equal)', value: 'less_equal' },
|
|
69
|
+
{ label: 'Does not contain (not_like)', value: 'not_like' },
|
|
70
|
+
{ label: 'Is NULL', value: 'is_null' },
|
|
71
|
+
{ label: 'Is not NULL', value: 'not_null' },
|
|
72
|
+
{ label: 'In (array)', value: 'in' },
|
|
73
|
+
{ label: 'Not in (array)', value: 'not_in' },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
order_by: Property.StaticDropdown({
|
|
80
|
+
displayName: 'Order By',
|
|
81
|
+
description: 'Field to order results by',
|
|
82
|
+
required: false,
|
|
83
|
+
defaultValue: 'id',
|
|
84
|
+
options: {
|
|
85
|
+
disabled: false,
|
|
86
|
+
options: [
|
|
87
|
+
{ label: 'ID', value: 'id' },
|
|
88
|
+
{ label: 'Total', value: 'total' },
|
|
89
|
+
{ label: 'Total Net', value: 'total_net' },
|
|
90
|
+
{ label: 'Total Gross', value: 'total_gross' },
|
|
91
|
+
{ label: 'Updated At', value: 'updated_at' },
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
}),
|
|
95
|
+
limit: Property.Number({
|
|
96
|
+
displayName: 'Limit',
|
|
97
|
+
description: 'Maximum number of results to return (max 2000)',
|
|
98
|
+
required: false,
|
|
99
|
+
defaultValue: 500,
|
|
100
|
+
}),
|
|
101
|
+
offset: Property.Number({
|
|
102
|
+
displayName: 'Offset',
|
|
103
|
+
description: 'Number of results to skip',
|
|
104
|
+
required: false,
|
|
105
|
+
defaultValue: 0,
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
108
|
+
async run({ auth, propsValue }) {
|
|
109
|
+
const client = new BexioClient(auth);
|
|
110
|
+
const searchCriteria = propsValue['search_criteria'] as Array<Record<string, unknown>>;
|
|
111
|
+
const orderBy = propsValue['order_by'] as string | undefined;
|
|
112
|
+
const limit = propsValue['limit'] as number | undefined;
|
|
113
|
+
const offset = propsValue['offset'] as number | undefined;
|
|
114
|
+
|
|
115
|
+
const searchBody = searchCriteria.map((criteria) => ({
|
|
116
|
+
field: criteria['field'] as string,
|
|
117
|
+
value: criteria['value'] as string,
|
|
118
|
+
criteria: (criteria['criteria'] as string) || 'like',
|
|
119
|
+
}));
|
|
120
|
+
|
|
121
|
+
const queryParams: Record<string, string> = {};
|
|
122
|
+
if (orderBy) {
|
|
123
|
+
queryParams['order_by'] = orderBy;
|
|
124
|
+
}
|
|
125
|
+
if (limit !== undefined) {
|
|
126
|
+
queryParams['limit'] = limit.toString();
|
|
127
|
+
}
|
|
128
|
+
if (offset !== undefined) {
|
|
129
|
+
queryParams['offset'] = offset.toString();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const response = await client.post<Array<{
|
|
133
|
+
id: number;
|
|
134
|
+
document_nr: string;
|
|
135
|
+
title: string | null;
|
|
136
|
+
contact_id: number | null;
|
|
137
|
+
contact_sub_id: number | null;
|
|
138
|
+
user_id: number;
|
|
139
|
+
project_id: number | null;
|
|
140
|
+
language_id: number;
|
|
141
|
+
bank_account_id: number;
|
|
142
|
+
currency_id: number;
|
|
143
|
+
payment_type_id: number;
|
|
144
|
+
total_gross: string;
|
|
145
|
+
total_net: string;
|
|
146
|
+
total_taxes: string;
|
|
147
|
+
total: string;
|
|
148
|
+
kb_item_status_id: number;
|
|
149
|
+
is_valid_from: string;
|
|
150
|
+
is_valid_until: string | null;
|
|
151
|
+
updated_at: string;
|
|
152
|
+
}>>('/2.0/kb_offer/search', searchBody, queryParams);
|
|
153
|
+
|
|
154
|
+
return response;
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { createAction, Property, OAuth2PropertyValue } from '@agnocon/pieces-framework';
|
|
2
|
+
import { bexioAuth } from '../auth';
|
|
3
|
+
import { BexioClient } from '../common/client';
|
|
4
|
+
|
|
5
|
+
export const sendSalesInvoiceAction = createAction({
|
|
6
|
+
auth: bexioAuth,
|
|
7
|
+
name: 'send_sales_invoice',
|
|
8
|
+
displayName: 'Send Sales Invoice',
|
|
9
|
+
description: 'Send a sales invoice to an email address',
|
|
10
|
+
audience: 'both',
|
|
11
|
+
aiMetadata: { description: 'Emails an existing Bexio sales invoice to a recipient, with subject and message body, optionally marking the invoice as open and attaching the PDF. Use to deliver an invoice to a customer; pick Export Invoice to PDF if you only need the file. Requires the invoice id and a recipient email, and the message must contain a "[Network Link]" placeholder. Not idempotent: each call sends another email.', idempotent: false },
|
|
12
|
+
props: {
|
|
13
|
+
invoice_id: Property.Dropdown({
|
|
14
|
+
auth: bexioAuth,
|
|
15
|
+
displayName: 'Invoice',
|
|
16
|
+
description: 'Select the invoice to send',
|
|
17
|
+
required: true,
|
|
18
|
+
refreshers: [],
|
|
19
|
+
options: async ({ auth }) => {
|
|
20
|
+
if (!auth) {
|
|
21
|
+
return {
|
|
22
|
+
disabled: true,
|
|
23
|
+
placeholder: 'Connect your Bexio account first',
|
|
24
|
+
options: [],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const client = new BexioClient(auth);
|
|
30
|
+
const invoices = await client.get<Array<{
|
|
31
|
+
id: number;
|
|
32
|
+
document_nr: string;
|
|
33
|
+
title?: string | null;
|
|
34
|
+
contact_id?: number | null;
|
|
35
|
+
total?: string;
|
|
36
|
+
kb_item_status_id?: number;
|
|
37
|
+
}>>('/2.0/kb_invoice');
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
disabled: false,
|
|
41
|
+
options: invoices.map((invoice) => {
|
|
42
|
+
const label = invoice.title
|
|
43
|
+
? `${invoice.document_nr} - ${invoice.title}`
|
|
44
|
+
: invoice.document_nr;
|
|
45
|
+
return {
|
|
46
|
+
label,
|
|
47
|
+
value: invoice.id,
|
|
48
|
+
};
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return {
|
|
53
|
+
disabled: true,
|
|
54
|
+
placeholder: 'Failed to load invoices',
|
|
55
|
+
options: [],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
recipient_email: Property.ShortText({
|
|
61
|
+
displayName: 'Recipient Email',
|
|
62
|
+
description: 'Email address to send the invoice to',
|
|
63
|
+
required: true,
|
|
64
|
+
}),
|
|
65
|
+
subject: Property.ShortText({
|
|
66
|
+
displayName: 'Subject',
|
|
67
|
+
description: 'Email subject line',
|
|
68
|
+
required: true,
|
|
69
|
+
}),
|
|
70
|
+
message: Property.LongText({
|
|
71
|
+
displayName: 'Message',
|
|
72
|
+
description: 'Email message body. Must include "[Network Link]" placeholder',
|
|
73
|
+
required: true,
|
|
74
|
+
}),
|
|
75
|
+
mark_as_open: Property.Checkbox({
|
|
76
|
+
displayName: 'Mark as Open',
|
|
77
|
+
description: 'Mark the invoice as open',
|
|
78
|
+
required: false,
|
|
79
|
+
defaultValue: false,
|
|
80
|
+
}),
|
|
81
|
+
attach_pdf: Property.Checkbox({
|
|
82
|
+
displayName: 'Attach PDF',
|
|
83
|
+
description: 'Attach PDF directly to the email',
|
|
84
|
+
required: false,
|
|
85
|
+
defaultValue: false,
|
|
86
|
+
}),
|
|
87
|
+
},
|
|
88
|
+
async run({ auth, propsValue }) {
|
|
89
|
+
const client = new BexioClient(auth);
|
|
90
|
+
const invoiceId = propsValue['invoice_id'] as number;
|
|
91
|
+
const recipientEmail = propsValue['recipient_email'] as string;
|
|
92
|
+
const subject = propsValue['subject'] as string;
|
|
93
|
+
const message = propsValue['message'] as string;
|
|
94
|
+
const markAsOpen = propsValue['mark_as_open'] as boolean | undefined;
|
|
95
|
+
const attachPdf = propsValue['attach_pdf'] as boolean | undefined;
|
|
96
|
+
|
|
97
|
+
const requestBody: Record<string, unknown> = {
|
|
98
|
+
recipient_email: recipientEmail,
|
|
99
|
+
subject,
|
|
100
|
+
message,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
if (markAsOpen !== undefined) {
|
|
104
|
+
requestBody['mark_as_open'] = markAsOpen;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (attachPdf !== undefined) {
|
|
108
|
+
requestBody['attach_pdf'] = attachPdf;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const response = await client.post<{
|
|
112
|
+
success: boolean;
|
|
113
|
+
}>(`/2.0/kb_invoice/${invoiceId}/send`, requestBody);
|
|
114
|
+
|
|
115
|
+
return response;
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|