Skip to content

Commit 1d006eb

Browse files
authored
E_conomic - new components (#18918)
* wip * new components * pnpm-lock.yaml * fix invoiceType prop * remove totals option
1 parent 9346674 commit 1d006eb

File tree

9 files changed

+1094
-6
lines changed

9 files changed

+1094
-6
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import economic from "../../e_conomic.app.mjs";
2+
3+
export default {
4+
key: "e_conomic-book-invoice",
5+
name: "Book Invoice",
6+
description: "Books an invoice. [See the documentation](https://restdocs.e-conomic.com/#post-invoices-booked)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
economic,
16+
draftInvoiceNumber: {
17+
propDefinition: [
18+
economic,
19+
"draftInvoiceNumber",
20+
],
21+
},
22+
sendByEan: {
23+
type: "boolean",
24+
label: "Send by EAN",
25+
description: "Send your invoice electronically via EAN (European Article Numbering)",
26+
optional: true,
27+
},
28+
},
29+
async run({ $ }) {
30+
const response = await this.economic.bookInvoice({
31+
$,
32+
data: {
33+
draftInvoice: {
34+
draftInvoiceNumber: this.draftInvoiceNumber,
35+
},
36+
sendBy: this.sendByEan
37+
? "ean"
38+
: undefined,
39+
},
40+
});
41+
$.export("$summary", "Successfully booked invoice.");
42+
return response;
43+
},
44+
};
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import economic from "../../e_conomic.app.mjs";
2+
3+
export default {
4+
key: "e_conomic-create-customer",
5+
name: "Create Customer",
6+
description: "Creates a new customer. [See the documentation](https://restdocs.e-conomic.com/#post-customers)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
economic,
16+
name: {
17+
propDefinition: [
18+
economic,
19+
"name",
20+
],
21+
},
22+
currency: {
23+
propDefinition: [
24+
economic,
25+
"currencyCode",
26+
],
27+
},
28+
customerGroupNumber: {
29+
propDefinition: [
30+
economic,
31+
"customerGroupNumber",
32+
],
33+
},
34+
paymentTermNumber: {
35+
propDefinition: [
36+
economic,
37+
"paymentTermNumber",
38+
],
39+
},
40+
vatZoneNumber: {
41+
propDefinition: [
42+
economic,
43+
"vatZoneNumber",
44+
],
45+
},
46+
email: {
47+
propDefinition: [
48+
economic,
49+
"email",
50+
],
51+
},
52+
mobilePhone: {
53+
propDefinition: [
54+
economic,
55+
"mobilePhone",
56+
],
57+
},
58+
website: {
59+
propDefinition: [
60+
economic,
61+
"website",
62+
],
63+
},
64+
ean: {
65+
propDefinition: [
66+
economic,
67+
"ean",
68+
],
69+
},
70+
address: {
71+
propDefinition: [
72+
economic,
73+
"streetAddress",
74+
],
75+
},
76+
city: {
77+
propDefinition: [
78+
economic,
79+
"city",
80+
],
81+
},
82+
zip: {
83+
propDefinition: [
84+
economic,
85+
"zip",
86+
],
87+
},
88+
country: {
89+
propDefinition: [
90+
economic,
91+
"country",
92+
],
93+
},
94+
},
95+
async run({ $ }) {
96+
const response = await this.economic.createCustomer({
97+
$,
98+
data: {
99+
name: this.name,
100+
currency: this.currency,
101+
customerGroup: {
102+
customerGroupNumber: this.customerGroupNumber,
103+
},
104+
paymentTerms: {
105+
paymentTermsNumber: this.paymentTermNumber,
106+
},
107+
vatZone: {
108+
vatZoneNumber: this.vatZoneNumber,
109+
},
110+
email: this.email,
111+
mobilePhone: this.mobilePhone,
112+
website: this.website,
113+
ean: this.ean,
114+
address: this.address,
115+
city: this.city,
116+
zip: this.zip,
117+
country: this.country,
118+
},
119+
});
120+
$.export("$summary", "Successfully created customer.");
121+
return response;
122+
},
123+
};
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import economic from "../../e_conomic.app.mjs";
2+
3+
export default {
4+
key: "e_conomic-create-invoice",
5+
name: "Create Invoice",
6+
description: "Creates a new draft invoice. [See the documentation](https://restdocs.e-conomic.com/#post-invoices-drafts)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
economic,
16+
currency: {
17+
propDefinition: [
18+
economic,
19+
"currencyCode",
20+
],
21+
},
22+
customerNumber: {
23+
propDefinition: [
24+
economic,
25+
"customerNumber",
26+
],
27+
},
28+
date: {
29+
type: "string",
30+
label: "Date",
31+
description: "The date of the invoice in the format YYYY-MM-DD",
32+
},
33+
layoutNumber: {
34+
propDefinition: [
35+
economic,
36+
"layoutNumber",
37+
],
38+
},
39+
paymentTermNumber: {
40+
propDefinition: [
41+
economic,
42+
"paymentTermNumber",
43+
],
44+
},
45+
recipientNmae: {
46+
type: "string",
47+
label: "Recipient Name",
48+
description: "The name of the recipient of the invoice",
49+
},
50+
recipientVatZoneNumber: {
51+
propDefinition: [
52+
economic,
53+
"vatZoneNumber",
54+
],
55+
},
56+
productNumbers: {
57+
propDefinition: [
58+
economic,
59+
"productNumbers",
60+
],
61+
withLabel: true,
62+
reloadProps: true,
63+
},
64+
},
65+
async additionalProps() {
66+
const props = {};
67+
if (!this.productNumbers?.length) {
68+
return props;
69+
}
70+
for (const productNumber of this.productNumbers) {
71+
props[`${productNumber.value || productNumber}_quantity`] = {
72+
type: "string",
73+
label: `Quantity for Product ${productNumber.label || productNumber}`,
74+
description: `The quantity of the product ${productNumber.label || productNumber} to add to the invoice`,
75+
};
76+
}
77+
return props;
78+
},
79+
async run({ $ }) {
80+
const lines = [];
81+
for (let i = 0; i < this.productNumbers.length; i++) {
82+
const productNumber = this.productNumbers[i].value || this.productNumbers[i];
83+
lines.push({
84+
lineNumber: i + 1,
85+
product: {
86+
productNumber,
87+
},
88+
quantity: parseFloat(this[`${productNumber}_quantity`]),
89+
});
90+
}
91+
92+
const response = await this.economic.createDraftInvoice({
93+
$,
94+
data: {
95+
currency: this.currency,
96+
customer: {
97+
customerNumber: this.customerNumber,
98+
},
99+
date: this.date,
100+
layout: {
101+
layoutNumber: this.layoutNumber,
102+
},
103+
paymentTerms: {
104+
paymentTermsNumber: this.paymentTermNumber,
105+
},
106+
recipient: {
107+
name: this.recipientName,
108+
vatZone: {
109+
vatZoneNumber: this.recipientVatZoneNumber,
110+
},
111+
},
112+
lines,
113+
},
114+
});
115+
$.export("$summary", "Successfully created invoice.");
116+
return response;
117+
},
118+
};

0 commit comments

Comments
 (0)