@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,25 @@
|
|
|
1
|
+
export declare const createSalesOrderAction: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
2
|
+
document_nr: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
3
|
+
title: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
contact_id: import("@agnocon/pieces-framework").DropdownProperty<number, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
5
|
+
contact_sub_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
6
|
+
user_id: import("@agnocon/pieces-framework").DropdownProperty<number, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
7
|
+
pr_project_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
8
|
+
language_id: import("@agnocon/pieces-framework").DropdownProperty<number, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
9
|
+
bank_account_id: import("@agnocon/pieces-framework").DropdownProperty<number, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
10
|
+
currency_id: import("@agnocon/pieces-framework").DropdownProperty<number, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
11
|
+
payment_type_id: import("@agnocon/pieces-framework").DropdownProperty<number, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
12
|
+
header: import("@agnocon/pieces-framework").LongTextProperty<false>;
|
|
13
|
+
footer: import("@agnocon/pieces-framework").LongTextProperty<false>;
|
|
14
|
+
mwst_type: import("@agnocon/pieces-framework").StaticDropdownProperty<number, true>;
|
|
15
|
+
mwst_is_net: import("@agnocon/pieces-framework").CheckboxProperty<false>;
|
|
16
|
+
show_position_taxes: import("@agnocon/pieces-framework").CheckboxProperty<false>;
|
|
17
|
+
is_valid_from: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
18
|
+
contact_address_manual: import("@agnocon/pieces-framework").LongTextProperty<false>;
|
|
19
|
+
delivery_address_type: import("@agnocon/pieces-framework").StaticDropdownProperty<number, false>;
|
|
20
|
+
delivery_address_manual_text: import("@agnocon/pieces-framework").LongTextProperty<false>;
|
|
21
|
+
api_reference: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
22
|
+
template_slug: import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
23
|
+
positionFields: import("@agnocon/pieces-framework").DynamicProperties<true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
24
|
+
}>;
|
|
25
|
+
//# sourceMappingURL=create-sales-order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-sales-order.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/create-sales-order.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;EA2qBjC,CAAC"}
|
|
@@ -0,0 +1,642 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSalesOrderAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/bexio/src/lib/actions/create-sales-order.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const auth_1 = require("../auth");
|
|
9
|
+
const client_1 = require("../common/client");
|
|
10
|
+
exports.createSalesOrderAction = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: auth_1.bexioAuth,
|
|
12
|
+
name: 'create_sales_order',
|
|
13
|
+
displayName: 'Create Sales Order',
|
|
14
|
+
description: 'Create a new product-based sales order',
|
|
15
|
+
audience: 'both',
|
|
16
|
+
aiMetadata: { description: 'Creates a new sales order in Bexio from one or more line-item positions (custom, article, text, subtotal, discount, or page-break). Use when confirming an order for products or services; pick Create Sales Invoice to bill instead. Requires a contact, user, language, bank account, currency, payment type, tax handling, a valid-from date, and at least one position; supports a separate delivery address. Not idempotent: each call creates a separate order.', idempotent: false },
|
|
17
|
+
props: {
|
|
18
|
+
document_nr: pieces_framework_1.Property.ShortText({
|
|
19
|
+
displayName: 'Document Number',
|
|
20
|
+
description: 'Order number (required if automatic numbering is disabled)',
|
|
21
|
+
required: false,
|
|
22
|
+
}),
|
|
23
|
+
title: pieces_framework_1.Property.ShortText({
|
|
24
|
+
displayName: 'Title',
|
|
25
|
+
description: 'Order title',
|
|
26
|
+
required: false,
|
|
27
|
+
}),
|
|
28
|
+
contact_id: pieces_framework_1.Property.Dropdown({
|
|
29
|
+
auth: auth_1.bexioAuth,
|
|
30
|
+
displayName: 'Contact',
|
|
31
|
+
description: 'The contact for this order',
|
|
32
|
+
required: true,
|
|
33
|
+
refreshers: [],
|
|
34
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
35
|
+
if (!auth) {
|
|
36
|
+
return {
|
|
37
|
+
disabled: true,
|
|
38
|
+
placeholder: 'Connect your Bexio account first',
|
|
39
|
+
options: [],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const client = new client_1.BexioClient(auth);
|
|
44
|
+
const contacts = yield client.get('/2.0/contact');
|
|
45
|
+
return {
|
|
46
|
+
disabled: false,
|
|
47
|
+
options: contacts.map((contact) => {
|
|
48
|
+
const name = contact.name_2
|
|
49
|
+
? `${contact.name_2} ${contact.name_1}`
|
|
50
|
+
: contact.name_1;
|
|
51
|
+
const label = contact.nr ? `${name} (#${contact.nr})` : name;
|
|
52
|
+
return {
|
|
53
|
+
label,
|
|
54
|
+
value: contact.id,
|
|
55
|
+
};
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
return {
|
|
61
|
+
disabled: true,
|
|
62
|
+
placeholder: 'Failed to load contacts',
|
|
63
|
+
options: [],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
}),
|
|
68
|
+
contact_sub_id: pieces_framework_1.Property.Dropdown({
|
|
69
|
+
auth: auth_1.bexioAuth,
|
|
70
|
+
displayName: 'Contact Sub',
|
|
71
|
+
description: 'Contact sub-address (optional)',
|
|
72
|
+
required: false,
|
|
73
|
+
refreshers: [],
|
|
74
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
75
|
+
if (!auth) {
|
|
76
|
+
return {
|
|
77
|
+
disabled: true,
|
|
78
|
+
placeholder: 'Connect your Bexio account first',
|
|
79
|
+
options: [],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const client = new client_1.BexioClient(auth);
|
|
84
|
+
const contacts = yield client.get('/2.0/contact');
|
|
85
|
+
return {
|
|
86
|
+
disabled: false,
|
|
87
|
+
options: contacts.map((contact) => {
|
|
88
|
+
const name = contact.name_2
|
|
89
|
+
? `${contact.name_2} ${contact.name_1}`
|
|
90
|
+
: contact.name_1;
|
|
91
|
+
const label = contact.nr ? `${name} (#${contact.nr})` : name;
|
|
92
|
+
return {
|
|
93
|
+
label,
|
|
94
|
+
value: contact.id,
|
|
95
|
+
};
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
return {
|
|
101
|
+
disabled: true,
|
|
102
|
+
placeholder: 'Failed to load contacts',
|
|
103
|
+
options: [],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}),
|
|
107
|
+
}),
|
|
108
|
+
user_id: pieces_framework_1.Property.Dropdown({
|
|
109
|
+
auth: auth_1.bexioAuth,
|
|
110
|
+
displayName: 'User',
|
|
111
|
+
description: 'User responsible for this order',
|
|
112
|
+
required: true,
|
|
113
|
+
refreshers: [],
|
|
114
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
115
|
+
if (!auth) {
|
|
116
|
+
return {
|
|
117
|
+
disabled: true,
|
|
118
|
+
placeholder: 'Connect your Bexio account first',
|
|
119
|
+
options: [],
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const client = new client_1.BexioClient(auth);
|
|
124
|
+
const users = yield client.get('/3.0/users');
|
|
125
|
+
return {
|
|
126
|
+
disabled: false,
|
|
127
|
+
options: users.map((user) => {
|
|
128
|
+
const name = user.firstname && user.lastname
|
|
129
|
+
? `${user.firstname} ${user.lastname}`
|
|
130
|
+
: user.email;
|
|
131
|
+
return {
|
|
132
|
+
label: name,
|
|
133
|
+
value: user.id,
|
|
134
|
+
};
|
|
135
|
+
}),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
return {
|
|
140
|
+
disabled: true,
|
|
141
|
+
placeholder: 'Failed to load users',
|
|
142
|
+
options: [],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}),
|
|
146
|
+
}),
|
|
147
|
+
pr_project_id: pieces_framework_1.Property.Dropdown({
|
|
148
|
+
auth: auth_1.bexioAuth,
|
|
149
|
+
displayName: 'Project',
|
|
150
|
+
description: 'Project associated with this order',
|
|
151
|
+
required: false,
|
|
152
|
+
refreshers: [],
|
|
153
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
154
|
+
if (!auth) {
|
|
155
|
+
return {
|
|
156
|
+
disabled: true,
|
|
157
|
+
placeholder: 'Connect your Bexio account first',
|
|
158
|
+
options: [],
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
try {
|
|
162
|
+
const client = new client_1.BexioClient(auth);
|
|
163
|
+
const projects = yield client.get('/2.0/pr_project');
|
|
164
|
+
return {
|
|
165
|
+
disabled: false,
|
|
166
|
+
options: projects.map((project) => ({
|
|
167
|
+
label: project.nr ? `${project.name} (#${project.nr})` : project.name,
|
|
168
|
+
value: project.id,
|
|
169
|
+
})),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
return {
|
|
174
|
+
disabled: true,
|
|
175
|
+
placeholder: 'Failed to load projects',
|
|
176
|
+
options: [],
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}),
|
|
180
|
+
}),
|
|
181
|
+
language_id: pieces_framework_1.Property.Dropdown({
|
|
182
|
+
auth: auth_1.bexioAuth,
|
|
183
|
+
displayName: 'Language',
|
|
184
|
+
description: 'Language for the order',
|
|
185
|
+
required: true,
|
|
186
|
+
refreshers: [],
|
|
187
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
188
|
+
if (!auth) {
|
|
189
|
+
return {
|
|
190
|
+
disabled: true,
|
|
191
|
+
placeholder: 'Connect your Bexio account first',
|
|
192
|
+
options: [],
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
const client = new client_1.BexioClient(auth);
|
|
197
|
+
const languages = yield client.get('/2.0/language');
|
|
198
|
+
return {
|
|
199
|
+
disabled: false,
|
|
200
|
+
options: languages.map((lang) => ({
|
|
201
|
+
label: lang.name,
|
|
202
|
+
value: lang.id,
|
|
203
|
+
})),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
return {
|
|
208
|
+
disabled: true,
|
|
209
|
+
placeholder: 'Failed to load languages',
|
|
210
|
+
options: [],
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}),
|
|
214
|
+
}),
|
|
215
|
+
bank_account_id: pieces_framework_1.Property.Dropdown({
|
|
216
|
+
auth: auth_1.bexioAuth,
|
|
217
|
+
displayName: 'Bank Account',
|
|
218
|
+
description: 'Bank account for payment',
|
|
219
|
+
required: true,
|
|
220
|
+
refreshers: [],
|
|
221
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
222
|
+
if (!auth) {
|
|
223
|
+
return {
|
|
224
|
+
disabled: true,
|
|
225
|
+
placeholder: 'Connect your Bexio account first',
|
|
226
|
+
options: [],
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
const client = new client_1.BexioClient(auth);
|
|
231
|
+
const bankAccounts = yield client.get('/3.0/banking/accounts');
|
|
232
|
+
return {
|
|
233
|
+
disabled: false,
|
|
234
|
+
options: bankAccounts.map((account) => {
|
|
235
|
+
const iban = account.iban_nr || account.bank_account_nr;
|
|
236
|
+
return {
|
|
237
|
+
label: iban ? `${account.name} (${iban})` : account.name,
|
|
238
|
+
value: account.id,
|
|
239
|
+
};
|
|
240
|
+
}),
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
return {
|
|
245
|
+
disabled: true,
|
|
246
|
+
placeholder: 'Failed to load bank accounts',
|
|
247
|
+
options: [],
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}),
|
|
251
|
+
}),
|
|
252
|
+
currency_id: pieces_framework_1.Property.Dropdown({
|
|
253
|
+
auth: auth_1.bexioAuth,
|
|
254
|
+
displayName: 'Currency',
|
|
255
|
+
description: 'Currency for this order',
|
|
256
|
+
required: true,
|
|
257
|
+
refreshers: [],
|
|
258
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
259
|
+
if (!auth) {
|
|
260
|
+
return {
|
|
261
|
+
disabled: true,
|
|
262
|
+
placeholder: 'Connect your Bexio account first',
|
|
263
|
+
options: [],
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
const client = new client_1.BexioClient(auth);
|
|
268
|
+
const currencies = yield client.get('/currencies');
|
|
269
|
+
return {
|
|
270
|
+
disabled: false,
|
|
271
|
+
options: currencies.map((currency) => ({
|
|
272
|
+
label: currency.name,
|
|
273
|
+
value: currency.id,
|
|
274
|
+
})),
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
return {
|
|
279
|
+
disabled: true,
|
|
280
|
+
placeholder: 'Failed to load currencies',
|
|
281
|
+
options: [],
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
}),
|
|
285
|
+
}),
|
|
286
|
+
payment_type_id: pieces_framework_1.Property.Dropdown({
|
|
287
|
+
auth: auth_1.bexioAuth,
|
|
288
|
+
displayName: 'Payment Type',
|
|
289
|
+
description: 'Payment type for this order',
|
|
290
|
+
required: true,
|
|
291
|
+
refreshers: [],
|
|
292
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
293
|
+
if (!auth) {
|
|
294
|
+
return {
|
|
295
|
+
disabled: true,
|
|
296
|
+
placeholder: 'Connect your Bexio account first',
|
|
297
|
+
options: [],
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
try {
|
|
301
|
+
const client = new client_1.BexioClient(auth);
|
|
302
|
+
const paymentTypes = yield client.get('/2.0/payment_type');
|
|
303
|
+
return {
|
|
304
|
+
disabled: false,
|
|
305
|
+
options: paymentTypes.map((type) => ({
|
|
306
|
+
label: type.name,
|
|
307
|
+
value: type.id,
|
|
308
|
+
})),
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
return {
|
|
313
|
+
disabled: true,
|
|
314
|
+
placeholder: 'Failed to load payment types',
|
|
315
|
+
options: [],
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}),
|
|
319
|
+
}),
|
|
320
|
+
header: pieces_framework_1.Property.LongText({
|
|
321
|
+
displayName: 'Header',
|
|
322
|
+
description: 'Header text for the order',
|
|
323
|
+
required: false,
|
|
324
|
+
}),
|
|
325
|
+
footer: pieces_framework_1.Property.LongText({
|
|
326
|
+
displayName: 'Footer',
|
|
327
|
+
description: 'Footer text for the order',
|
|
328
|
+
required: false,
|
|
329
|
+
}),
|
|
330
|
+
mwst_type: pieces_framework_1.Property.StaticDropdown({
|
|
331
|
+
displayName: 'Tax Type',
|
|
332
|
+
description: 'How taxes are handled',
|
|
333
|
+
required: true,
|
|
334
|
+
defaultValue: 0,
|
|
335
|
+
options: {
|
|
336
|
+
disabled: false,
|
|
337
|
+
options: [
|
|
338
|
+
{ label: 'Including taxes', value: 0 },
|
|
339
|
+
{ label: 'Excluding taxes', value: 1 },
|
|
340
|
+
{ label: 'Exempt from taxes', value: 2 },
|
|
341
|
+
],
|
|
342
|
+
},
|
|
343
|
+
}),
|
|
344
|
+
mwst_is_net: pieces_framework_1.Property.Checkbox({
|
|
345
|
+
displayName: 'Tax is Net',
|
|
346
|
+
description: 'If taxes are included, set to true to add taxes to total, false to include in total',
|
|
347
|
+
required: false,
|
|
348
|
+
defaultValue: false,
|
|
349
|
+
}),
|
|
350
|
+
show_position_taxes: pieces_framework_1.Property.Checkbox({
|
|
351
|
+
displayName: 'Show Position Taxes',
|
|
352
|
+
description: 'Show taxes for each position',
|
|
353
|
+
required: false,
|
|
354
|
+
defaultValue: false,
|
|
355
|
+
}),
|
|
356
|
+
is_valid_from: pieces_framework_1.Property.ShortText({
|
|
357
|
+
displayName: 'Valid From',
|
|
358
|
+
description: 'Order valid from date (YYYY-MM-DD)',
|
|
359
|
+
required: true,
|
|
360
|
+
}),
|
|
361
|
+
contact_address_manual: pieces_framework_1.Property.LongText({
|
|
362
|
+
displayName: 'Manual Contact Address',
|
|
363
|
+
description: 'Override contact address (leave empty to use contact address)',
|
|
364
|
+
required: false,
|
|
365
|
+
}),
|
|
366
|
+
delivery_address_type: pieces_framework_1.Property.StaticDropdown({
|
|
367
|
+
displayName: 'Delivery Address Type',
|
|
368
|
+
description: 'Type of delivery address',
|
|
369
|
+
required: false,
|
|
370
|
+
defaultValue: 0,
|
|
371
|
+
options: {
|
|
372
|
+
disabled: false,
|
|
373
|
+
options: [
|
|
374
|
+
{ label: 'Use Invoice Address', value: 0 },
|
|
375
|
+
{ label: 'Use Custom Address', value: 1 },
|
|
376
|
+
],
|
|
377
|
+
},
|
|
378
|
+
}),
|
|
379
|
+
delivery_address_manual_text: pieces_framework_1.Property.LongText({
|
|
380
|
+
displayName: 'Manual Delivery Address',
|
|
381
|
+
description: 'Custom delivery address (only used if delivery address type is set to custom)',
|
|
382
|
+
required: false,
|
|
383
|
+
}),
|
|
384
|
+
api_reference: pieces_framework_1.Property.ShortText({
|
|
385
|
+
displayName: 'API Reference',
|
|
386
|
+
description: 'Reference for API use (can only be edited via API)',
|
|
387
|
+
required: false,
|
|
388
|
+
}),
|
|
389
|
+
template_slug: pieces_framework_1.Property.Dropdown({
|
|
390
|
+
auth: auth_1.bexioAuth,
|
|
391
|
+
displayName: 'Document Template',
|
|
392
|
+
description: 'Document template for the order',
|
|
393
|
+
required: false,
|
|
394
|
+
refreshers: [],
|
|
395
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
396
|
+
if (!auth) {
|
|
397
|
+
return {
|
|
398
|
+
disabled: true,
|
|
399
|
+
placeholder: 'Connect your Bexio account first',
|
|
400
|
+
options: [],
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
try {
|
|
404
|
+
const client = new client_1.BexioClient(auth);
|
|
405
|
+
const templates = yield client.get('/3.0/document_templates');
|
|
406
|
+
return {
|
|
407
|
+
disabled: false,
|
|
408
|
+
options: templates.map((template) => ({
|
|
409
|
+
label: template.is_default ? `${template.name} (Default)` : template.name,
|
|
410
|
+
value: template.template_slug,
|
|
411
|
+
})),
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
return {
|
|
416
|
+
disabled: true,
|
|
417
|
+
placeholder: 'Failed to load templates',
|
|
418
|
+
options: [],
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
}),
|
|
422
|
+
}),
|
|
423
|
+
positionFields: pieces_framework_1.Property.DynamicProperties({
|
|
424
|
+
auth: auth_1.bexioAuth,
|
|
425
|
+
displayName: 'Order Positions',
|
|
426
|
+
description: 'Configure order line items',
|
|
427
|
+
required: true,
|
|
428
|
+
refreshers: ['auth'],
|
|
429
|
+
props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
430
|
+
let units = [];
|
|
431
|
+
let accounts = [];
|
|
432
|
+
let taxes = [];
|
|
433
|
+
if (auth) {
|
|
434
|
+
try {
|
|
435
|
+
const client = new client_1.BexioClient(auth);
|
|
436
|
+
units = yield client.get('/2.0/unit').catch(() => []);
|
|
437
|
+
accounts = yield client.get('/accounts').catch(() => []);
|
|
438
|
+
const taxesResponse = yield client.get('/3.0/taxes?types=sales_tax&scope=active').catch(() => []);
|
|
439
|
+
taxes = taxesResponse.map((tax) => ({
|
|
440
|
+
id: tax.id,
|
|
441
|
+
name: tax.display_name || tax.name,
|
|
442
|
+
percentage: tax.value.toString(),
|
|
443
|
+
}));
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
// Ignore error, use empty array as fallback
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
const unitOptions = units.map((unit) => ({ label: unit.name, value: unit.id }));
|
|
450
|
+
const accountOptions = accounts.map((acc) => ({ label: `${acc.account_no} - ${acc.name}`, value: acc.id }));
|
|
451
|
+
const taxOptions = taxes.map((tax) => ({ label: `${tax.name} (${tax.percentage}%)`, value: tax.id }));
|
|
452
|
+
return {
|
|
453
|
+
positions: pieces_framework_1.Property.Array({
|
|
454
|
+
displayName: 'Positions',
|
|
455
|
+
description: 'Order line items',
|
|
456
|
+
required: true,
|
|
457
|
+
properties: {
|
|
458
|
+
type: pieces_framework_1.Property.StaticDropdown({
|
|
459
|
+
displayName: 'Position Type',
|
|
460
|
+
description: 'Type of order position',
|
|
461
|
+
required: true,
|
|
462
|
+
defaultValue: 'KbPositionCustom',
|
|
463
|
+
options: {
|
|
464
|
+
disabled: false,
|
|
465
|
+
options: [
|
|
466
|
+
{ label: 'Custom Position', value: 'KbPositionCustom' },
|
|
467
|
+
{ label: 'Article Position', value: 'KbPositionArticle' },
|
|
468
|
+
{ label: 'Text Position', value: 'KbPositionText' },
|
|
469
|
+
{ label: 'Subtotal Position', value: 'KbPositionSubtotal' },
|
|
470
|
+
{ label: 'Page Break Position', value: 'KbPositionPagebreak' },
|
|
471
|
+
{ label: 'Discount Position', value: 'KbPositionDiscount' },
|
|
472
|
+
],
|
|
473
|
+
},
|
|
474
|
+
}),
|
|
475
|
+
amount: pieces_framework_1.Property.ShortText({
|
|
476
|
+
displayName: 'Amount',
|
|
477
|
+
description: 'Quantity/amount',
|
|
478
|
+
required: true,
|
|
479
|
+
}),
|
|
480
|
+
unit_id: unitOptions.length > 0
|
|
481
|
+
? pieces_framework_1.Property.StaticDropdown({
|
|
482
|
+
displayName: 'Unit',
|
|
483
|
+
description: 'Unit of measurement',
|
|
484
|
+
required: false,
|
|
485
|
+
options: {
|
|
486
|
+
disabled: false,
|
|
487
|
+
options: unitOptions,
|
|
488
|
+
},
|
|
489
|
+
})
|
|
490
|
+
: pieces_framework_1.Property.Number({
|
|
491
|
+
displayName: 'Unit ID',
|
|
492
|
+
description: 'Unit ID (use List Units action to find IDs)',
|
|
493
|
+
required: false,
|
|
494
|
+
}),
|
|
495
|
+
account_id: accountOptions.length > 0
|
|
496
|
+
? pieces_framework_1.Property.StaticDropdown({
|
|
497
|
+
displayName: 'Account',
|
|
498
|
+
description: 'Account for this position',
|
|
499
|
+
required: false,
|
|
500
|
+
options: {
|
|
501
|
+
disabled: false,
|
|
502
|
+
options: accountOptions,
|
|
503
|
+
},
|
|
504
|
+
})
|
|
505
|
+
: pieces_framework_1.Property.Number({
|
|
506
|
+
displayName: 'Account ID',
|
|
507
|
+
description: 'Account ID (use List Accounts action to find IDs)',
|
|
508
|
+
required: false,
|
|
509
|
+
}),
|
|
510
|
+
tax_id: taxOptions.length > 0
|
|
511
|
+
? pieces_framework_1.Property.StaticDropdown({
|
|
512
|
+
displayName: 'Tax',
|
|
513
|
+
description: 'Tax rate (only active sales taxes)',
|
|
514
|
+
required: false,
|
|
515
|
+
options: {
|
|
516
|
+
disabled: false,
|
|
517
|
+
options: taxOptions,
|
|
518
|
+
},
|
|
519
|
+
})
|
|
520
|
+
: pieces_framework_1.Property.Number({
|
|
521
|
+
displayName: 'Tax ID',
|
|
522
|
+
description: 'Tax ID (use List Taxes action to find IDs)',
|
|
523
|
+
required: false,
|
|
524
|
+
}),
|
|
525
|
+
text: pieces_framework_1.Property.LongText({
|
|
526
|
+
displayName: 'Description',
|
|
527
|
+
description: 'Position description/text',
|
|
528
|
+
required: false,
|
|
529
|
+
}),
|
|
530
|
+
unit_price: pieces_framework_1.Property.ShortText({
|
|
531
|
+
displayName: 'Unit Price',
|
|
532
|
+
description: 'Price per unit (max 6 decimals)',
|
|
533
|
+
required: false,
|
|
534
|
+
}),
|
|
535
|
+
discount_in_percent: pieces_framework_1.Property.ShortText({
|
|
536
|
+
displayName: 'Discount (%)',
|
|
537
|
+
description: 'Discount percentage (max 6 decimals)',
|
|
538
|
+
required: false,
|
|
539
|
+
}),
|
|
540
|
+
parent_id: pieces_framework_1.Property.Number({
|
|
541
|
+
displayName: 'Parent ID',
|
|
542
|
+
description: 'Parent position ID (for grouped positions)',
|
|
543
|
+
required: false,
|
|
544
|
+
}),
|
|
545
|
+
},
|
|
546
|
+
}),
|
|
547
|
+
};
|
|
548
|
+
}),
|
|
549
|
+
}),
|
|
550
|
+
},
|
|
551
|
+
run(context) {
|
|
552
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
553
|
+
const client = new client_1.BexioClient(context.auth);
|
|
554
|
+
const props = context.propsValue;
|
|
555
|
+
const requestBody = {
|
|
556
|
+
contact_id: props['contact_id'],
|
|
557
|
+
user_id: props['user_id'],
|
|
558
|
+
language_id: props['language_id'],
|
|
559
|
+
bank_account_id: props['bank_account_id'],
|
|
560
|
+
currency_id: props['currency_id'],
|
|
561
|
+
payment_type_id: props['payment_type_id'],
|
|
562
|
+
mwst_type: props['mwst_type'],
|
|
563
|
+
is_valid_from: props['is_valid_from'],
|
|
564
|
+
};
|
|
565
|
+
if (props['document_nr']) {
|
|
566
|
+
requestBody['document_nr'] = props['document_nr'];
|
|
567
|
+
}
|
|
568
|
+
if (props['title'] !== undefined) {
|
|
569
|
+
requestBody['title'] = props['title'] || null;
|
|
570
|
+
}
|
|
571
|
+
if (props['contact_sub_id']) {
|
|
572
|
+
requestBody['contact_sub_id'] = props['contact_sub_id'];
|
|
573
|
+
}
|
|
574
|
+
if (props['pr_project_id']) {
|
|
575
|
+
requestBody['pr_project_id'] = props['pr_project_id'];
|
|
576
|
+
}
|
|
577
|
+
if (props['header']) {
|
|
578
|
+
requestBody['header'] = props['header'];
|
|
579
|
+
}
|
|
580
|
+
if (props['footer']) {
|
|
581
|
+
requestBody['footer'] = props['footer'];
|
|
582
|
+
}
|
|
583
|
+
if (props['mwst_is_net'] !== undefined) {
|
|
584
|
+
requestBody['mwst_is_net'] = props['mwst_is_net'];
|
|
585
|
+
}
|
|
586
|
+
if (props['show_position_taxes'] !== undefined) {
|
|
587
|
+
requestBody['show_position_taxes'] = props['show_position_taxes'];
|
|
588
|
+
}
|
|
589
|
+
if (props['contact_address_manual']) {
|
|
590
|
+
requestBody['contact_address_manual'] = props['contact_address_manual'];
|
|
591
|
+
}
|
|
592
|
+
if (props['delivery_address_type'] !== undefined) {
|
|
593
|
+
requestBody['delivery_address_type'] = props['delivery_address_type'];
|
|
594
|
+
}
|
|
595
|
+
if (props['delivery_address_manual_text']) {
|
|
596
|
+
requestBody['delivery_address_manual'] = props['delivery_address_manual_text'];
|
|
597
|
+
}
|
|
598
|
+
if (props['api_reference']) {
|
|
599
|
+
requestBody['api_reference'] = props['api_reference'];
|
|
600
|
+
}
|
|
601
|
+
if (props['template_slug']) {
|
|
602
|
+
requestBody['template_slug'] = props['template_slug'];
|
|
603
|
+
}
|
|
604
|
+
const positionFields = props['positionFields'];
|
|
605
|
+
if (positionFields && positionFields['positions'] && Array.isArray(positionFields['positions'])) {
|
|
606
|
+
requestBody['positions'] = positionFields['positions'].map((position) => {
|
|
607
|
+
const pos = {
|
|
608
|
+
type: position['type'] || 'KbPositionCustom',
|
|
609
|
+
};
|
|
610
|
+
if (position['amount']) {
|
|
611
|
+
pos['amount'] = position['amount'];
|
|
612
|
+
}
|
|
613
|
+
if (position['unit_id']) {
|
|
614
|
+
pos['unit_id'] = position['unit_id'];
|
|
615
|
+
}
|
|
616
|
+
if (position['account_id']) {
|
|
617
|
+
pos['account_id'] = position['account_id'];
|
|
618
|
+
}
|
|
619
|
+
if (position['tax_id']) {
|
|
620
|
+
pos['tax_id'] = position['tax_id'];
|
|
621
|
+
}
|
|
622
|
+
if (position['text']) {
|
|
623
|
+
pos['text'] = position['text'];
|
|
624
|
+
}
|
|
625
|
+
if (position['unit_price']) {
|
|
626
|
+
pos['unit_price'] = position['unit_price'];
|
|
627
|
+
}
|
|
628
|
+
if (position['discount_in_percent']) {
|
|
629
|
+
pos['discount_in_percent'] = position['discount_in_percent'];
|
|
630
|
+
}
|
|
631
|
+
if (position['parent_id']) {
|
|
632
|
+
pos['parent_id'] = position['parent_id'];
|
|
633
|
+
}
|
|
634
|
+
return pos;
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
const response = yield client.post('/2.0/kb_order', requestBody);
|
|
638
|
+
return response;
|
|
639
|
+
});
|
|
640
|
+
},
|
|
641
|
+
});
|
|
642
|
+
//# sourceMappingURL=create-sales-order.js.map
|