Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions components/e_conomic/actions/book-invoice/book-invoice.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import economic from "../../e_conomic.app.mjs";

export default {
key: "e_conomic-book-invoice",
name: "Book Invoice",
description: "Books an invoice. [See the documentation](https://restdocs.e-conomic.com/#post-invoices-booked)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
economic,
draftInvoiceNumber: {
propDefinition: [
economic,
"draftInvoiceNumber",
],
},
sendByEan: {
type: "boolean",
label: "Send by EAN",
description: "Send your invoice electronically via EAN (European Article Numbering)",
optional: true,
},
},
async run({ $ }) {
const response = await this.economic.bookInvoice({
$,
data: {
draftInvoice: {
draftInvoiceNumber: this.draftInvoiceNumber,
},
sendBy: this.sendByEan
? "ean"
: undefined,
},
});
$.export("$summary", "Successfully booked invoice.");
return response;
},
};
123 changes: 123 additions & 0 deletions components/e_conomic/actions/create-customer/create-customer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import economic from "../../e_conomic.app.mjs";

export default {
key: "e_conomic-create-customer",
name: "Create Customer",
description: "Creates a new customer. [See the documentation](https://restdocs.e-conomic.com/#post-customers)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
economic,
name: {
propDefinition: [
economic,
"name",
],
},
currency: {
propDefinition: [
economic,
"currencyCode",
],
},
customerGroupNumber: {
propDefinition: [
economic,
"customerGroupNumber",
],
},
paymentTermNumber: {
propDefinition: [
economic,
"paymentTermNumber",
],
},
vatZoneNumber: {
propDefinition: [
economic,
"vatZoneNumber",
],
},
email: {
propDefinition: [
economic,
"email",
],
},
mobilePhone: {
propDefinition: [
economic,
"mobilePhone",
],
},
website: {
propDefinition: [
economic,
"website",
],
},
ean: {
propDefinition: [
economic,
"ean",
],
},
address: {
propDefinition: [
economic,
"streetAddress",
],
},
city: {
propDefinition: [
economic,
"city",
],
},
zip: {
propDefinition: [
economic,
"zip",
],
},
country: {
propDefinition: [
economic,
"country",
],
},
},
async run({ $ }) {
const response = await this.economic.createCustomer({
$,
data: {
name: this.name,
currency: this.currency,
customerGroup: {
customerGroupNumber: this.customerGroupNumber,
},
paymentTerms: {
paymentTermsNumber: this.paymentTermNumber,
},
vatZone: {
vatZoneNumber: this.vatZoneNumber,
},
email: this.email,
mobilePhone: this.mobilePhone,
website: this.website,
ean: this.ean,
address: this.address,
city: this.city,
zip: this.zip,
country: this.country,
},
});
$.export("$summary", "Successfully created customer.");
return response;
},
};
118 changes: 118 additions & 0 deletions components/e_conomic/actions/create-invoice/create-invoice.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import economic from "../../e_conomic.app.mjs";

export default {
key: "e_conomic-create-invoice",
name: "Create Invoice",
description: "Creates a new draft invoice. [See the documentation](https://restdocs.e-conomic.com/#post-invoices-drafts)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
economic,
currency: {
propDefinition: [
economic,
"currencyCode",
],
},
customerNumber: {
propDefinition: [
economic,
"customerNumber",
],
},
date: {
type: "string",
label: "Date",
description: "The date of the invoice in the format YYYY-MM-DD",
},
layoutNumber: {
propDefinition: [
economic,
"layoutNumber",
],
},
paymentTermNumber: {
propDefinition: [
economic,
"paymentTermNumber",
],
},
recipientNmae: {
type: "string",
label: "Recipient Name",
description: "The name of the recipient of the invoice",
},
recipientVatZoneNumber: {
propDefinition: [
economic,
"vatZoneNumber",
],
},
productNumbers: {
propDefinition: [
economic,
"productNumbers",
],
withLabel: true,
reloadProps: true,
},
},
async additionalProps() {
const props = {};
if (!this.productNumbers?.length) {
return props;
}
for (const productNumber of this.productNumbers) {
props[`${productNumber.value || productNumber}_quantity`] = {
type: "string",
label: `Quantity for Product ${productNumber.label || productNumber}`,
description: `The quantity of the product ${productNumber.label || productNumber} to add to the invoice`,
};
}
return props;
},
async run({ $ }) {
const lines = [];
for (let i = 0; i < this.productNumbers.length; i++) {
const productNumber = this.productNumbers[i].value || this.productNumbers[i];
lines.push({
lineNumber: i + 1,
product: {
productNumber,
},
quantity: parseFloat(this[`${productNumber}_quantity`]),
});
}

const response = await this.economic.createDraftInvoice({
$,
data: {
currency: this.currency,
customer: {
customerNumber: this.customerNumber,
},
date: this.date,
layout: {
layoutNumber: this.layoutNumber,
},
paymentTerms: {
paymentTermsNumber: this.paymentTermNumber,
},
recipient: {
name: this.recipientName,
vatZone: {
vatZoneNumber: this.recipientVatZoneNumber,
},
},
lines,
},
});
$.export("$summary", "Successfully created invoice.");
return response;
},
};
Loading
Loading