Skip to content

Commit 43d05d0

Browse files
Enhance Fortnox component with new actions and properties (#19208)
* Enhance Fortnox component with new actions and properties - Added new actions: `listAccounts`, `listFinancialYears`, `listSupplierInvoices`, `getSupplierInvoice`, `listArticles`, `listCustomers`, `listInvoices`, `listSuppliers`, and `sendInvoice`. - Introduced a new property for `supplierInvoiceNumber` in the Fortnox app. - Updated existing actions to version 0.0.2 and incremented the package version to 0.2.0 in package.json. - Improved request headers for better API compatibility. This update expands the functionality of the Fortnox component, allowing users to manage and retrieve various financial records more effectively. * Update components/fortnox/actions/list-invoices/list-invoices.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Add new properties to list-customers action in Fortnox component - Introduced `gln`, `glndelivery`, `lastmodified`, and `sortby` properties to enhance customer data handling. - This update improves the functionality and flexibility of the list-customers action. * Refactor Fortnox actions for improved clarity and functionality - Removed the `booked` property from the `create-invoice-payment` action. - Updated descriptions in the `list-supplier-invoices` action to clarify invoice filtering options, correcting grammatical errors for better readability. These changes enhance the usability and accuracy of the Fortnox component. * Update components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Add terms of delivery and payment to Fortnox component - Introduced `termsOfDeliveries` and `termsOfPayments` properties in the Fortnox app for invoice handling. - Added corresponding methods to fetch delivery and payment terms asynchronously. - Updated `create-invoice` action to utilize the new properties. This enhancement improves the invoice creation process by allowing users to specify terms of delivery and payment more effectively. * Update due date description in create-invoice action and remove dueDate property from create-invoice-payment action - Enhanced the description for the due date in the create-invoice action to specify the required format (YYYY-MM-DD). - Removed the dueDate property from the create-invoice-payment action to streamline the payment process. These changes improve clarity and usability in the Fortnox component. * Remove terms of delivery and payment from Fortnox component - Eliminated `termsOfDeliveries` and `termsOfPayments` properties from the Fortnox app and the create-invoice action to streamline the invoice creation process. - Updated the create-invoice action to reflect these changes, ensuring a more focused and simplified interface. This refactor enhances the clarity and usability of the Fortnox component. * Refactor create-invoice-payment action in Fortnox component - Removed unnecessary properties: `customerNumber`, `invoiceTotal`, and `modeOfPayment` from the create-invoice-payment action to simplify the payment process. - Updated the action's payload structure to reflect these changes, enhancing clarity and usability. This refactor streamlines the invoice payment process within the Fortnox component. * Update payment date format description in create-invoice-payment action - Changed the description of the paymentDate property to specify the required format as YYYY-MM-DD, enhancing clarity for users. This update improves the usability of the Fortnox component by providing clear formatting instructions. --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent aa4b84a commit 43d05d0

File tree

17 files changed

+708
-65
lines changed

17 files changed

+708
-65
lines changed

components/fortnox/actions/create-article/create-article.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "fortnox-create-article",
55
name: "Create Article",
66
description: "Creates a new article in the Fortnox API. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Articles/operation/1_create_3).",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
annotations: {
1010
destructiveHint: false,

components/fortnox/actions/create-customer/create-customer.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "fortnox-create-customer",
55
name: "Create Customer",
66
description: "Creates a new customer in the Fortnox API. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Customers/operation/create_16).",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
annotations: {
1010
destructiveHint: false,

components/fortnox/actions/create-invoice-payment/create-invoice-payment.mjs

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "fortnox-create-invoice-payment",
55
name: "Create Invoice Payment",
66
description: "Creates a new invoice payment in the Fortnox API. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_InvoicePayments/operation/create_22).",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
annotations: {
1010
destructiveHint: false,
@@ -25,41 +25,10 @@ export default {
2525
description: "The amount of the payment",
2626
optional: true,
2727
},
28-
booked: {
29-
type: "boolean",
30-
label: "Booked",
31-
description: "Whether the payment is booked",
32-
optional: true,
33-
},
34-
customerNumber: {
35-
propDefinition: [
36-
fortnox,
37-
"customerNumber",
38-
],
39-
optional: true,
40-
},
41-
dueDate: {
42-
type: "string",
43-
label: "Due Date",
44-
description: "The due date of the invoice",
45-
optional: true,
46-
},
4728
paymentDate: {
4829
type: "string",
4930
label: "Payment Date",
50-
description: "The date of the payment",
51-
optional: true,
52-
},
53-
invoiceTotal: {
54-
type: "string",
55-
label: "Invoice Total",
56-
description: "The total of the invoice",
57-
optional: true,
58-
},
59-
modeOfPayment: {
60-
type: "string",
61-
label: "Mode of Payment",
62-
description: "The mode of payment",
31+
description: "The date of the payment. **Format YYYY-MM-DD**",
6332
optional: true,
6433
},
6534
voucherNumber: {
@@ -78,13 +47,6 @@ export default {
7847
Amount: this.amount
7948
? +this.amount
8049
: undefined,
81-
Booked: this.booked,
82-
InvoiceCustomerNumber: this.customerNumber,
83-
InvoiceDueDate: this.dueDate,
84-
InvoiceTotal: this.invoiceTotal
85-
? +this.invoiceTotal
86-
: undefined,
87-
ModeOfPayment: this.modeOfPayment,
8850
PaymentDate: this.paymentDate,
8951
VoucherNumber: this.voucherNumber,
9052
},

components/fortnox/actions/create-invoice/create-invoice.mjs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import fortnox from "../../fortnox.app.mjs";
21
import { parseObject } from "../../common/utils.mjs";
2+
import fortnox from "../../fortnox.app.mjs";
33

44
export default {
55
key: "fortnox-create-invoice",
66
name: "Create Invoice",
77
description: "Creates a new invoice in the Fortnox API. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Invoices/operation/create_23).",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
annotations: {
1111
destructiveHint: false,
@@ -53,7 +53,7 @@ export default {
5353
dueDate: {
5454
type: "string",
5555
label: "Due Date",
56-
description: "The due date of the invoice",
56+
description: "The due date of the invoice. **Format: YYYY-MM-DD**",
5757
optional: true,
5858
},
5959
invoiceRows: {
@@ -105,18 +105,6 @@ export default {
105105
description: "The freight of the invoice",
106106
optional: true,
107107
},
108-
termsOfDelivery: {
109-
type: "string",
110-
label: "Terms of Delivery",
111-
description: "The terms of delivery of the invoice",
112-
optional: true,
113-
},
114-
termsOfPayment: {
115-
type: "string",
116-
label: "Terms of Payment",
117-
description: "The terms of payment of the invoice",
118-
optional: true,
119-
},
120108
},
121109
async run({ $ }) {
122110
const response = await this.fortnox.createInvoice({
@@ -143,12 +131,10 @@ export default {
143131
Freight: this.freight
144132
? +this.freight
145133
: undefined,
146-
TermsOfDelivery: this.termsOfDelivery,
147-
TermsOfPayment: this.termsOfPayment,
148134
},
149135
},
150136
});
151-
$.export("$summary", `Successfully created invoice with ID \`${response.Invoice.InvoiceNumber}\``);
137+
$.export("$summary", `Successfully created invoice with ID \`${response.Invoice.DocumentNumber}\``);
152138
return response;
153139
},
154140
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import app from "../../fortnox.app.mjs";
2+
3+
export default {
4+
key: "fortnox-get-supplier-invoice",
5+
name: "Get Supplier Invoice",
6+
description: "Retrieve a supplier invoice. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_SupplierInvoices/operation/get_39)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
app,
16+
supplierInvoiceNumber: {
17+
propDefinition: [
18+
app,
19+
"supplierInvoiceNumber",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const { SupplierInvoice } = await this.app.getSupplierInvoice({
25+
$,
26+
supplierInvoiceNumber: this.supplierInvoiceNumber,
27+
});
28+
29+
$.export("$summary", `Successfully retrieved supplier invoice with number ${this.supplierInvoiceNumber}`);
30+
return SupplierInvoice;
31+
},
32+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import app from "../../fortnox.app.mjs";
2+
3+
export default {
4+
key: "fortnox-list-accounts",
5+
name: "List Accounts",
6+
description: "List all accounts in Fortnox. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Accounts/operation/list_2)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
app,
16+
},
17+
async run({ $ }) {
18+
const { Accounts: accounts } = await this.app.listAccounts({
19+
$,
20+
});
21+
22+
$.export("$summary", `Successfully retrieved ${accounts.length} account${accounts.length === 1
23+
? ""
24+
: "s"}`);
25+
return accounts;
26+
},
27+
};
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import app from "../../fortnox.app.mjs";
2+
3+
export default {
4+
key: "fortnox-list-articles",
5+
name: "List Articles",
6+
description: "List all articles in Fortnox. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Articles/operation/list_4)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
app,
16+
filter: {
17+
type: "string",
18+
label: "Filter",
19+
description: "Filter the articles by Active or Inactive",
20+
options: [
21+
"active",
22+
"inactive",
23+
],
24+
optional: true,
25+
},
26+
articlenumber: {
27+
type: "string",
28+
label: "Article Number",
29+
description: "Filter by article number",
30+
optional: true,
31+
},
32+
description: {
33+
type: "string",
34+
label: "Description",
35+
description: "Filter by description",
36+
optional: true,
37+
},
38+
ean: {
39+
type: "string",
40+
label: "EAN",
41+
description: "Filter by EAN",
42+
optional: true,
43+
},
44+
suppliernumber: {
45+
type: "string",
46+
label: "Supplier Number",
47+
description: "Filter by supplier number",
48+
optional: true,
49+
},
50+
manufacturer: {
51+
type: "string",
52+
label: "Manufacturer",
53+
description: "Filter by manufacturer",
54+
optional: true,
55+
},
56+
manufacturerarticlenumber: {
57+
type: "string",
58+
label: "Manufacturer Article Number",
59+
description: "Filter by manufacturer article number",
60+
optional: true,
61+
},
62+
webshop: {
63+
type: "string",
64+
label: "Webshop",
65+
description: "Filter by web shop",
66+
optional: true,
67+
},
68+
lastmodified: {
69+
type: "string",
70+
label: "Last Modified",
71+
description: "Filter by last modified date",
72+
optional: true,
73+
},
74+
sortby: {
75+
type: "string",
76+
label: "Sort By",
77+
description: "Sort the articles by the specified field",
78+
optional: true,
79+
options: [
80+
"articlenumber",
81+
"quantityinstock",
82+
"reservedquantity",
83+
"stockvalue",
84+
],
85+
},
86+
},
87+
async run({ $ }) {
88+
const { Articles } = await this.app.listArticles({
89+
$,
90+
params: {
91+
filter: this.filter,
92+
articlenumber: this.articlenumber,
93+
description: this.description,
94+
ean: this.ean,
95+
suppliernumber: this.suppliernumber,
96+
manufacturer: this.manufacturer,
97+
manufacturerarticlenumber: this.manufacturerarticlenumber,
98+
webshop: this.webshop,
99+
lastmodified: this.lastmodified,
100+
sortby: this.sortby,
101+
},
102+
});
103+
104+
$.export("$summary", `Successfully retrieved ${Articles.length} article${Articles.length === 1
105+
? ""
106+
: "s"}`);
107+
return Articles;
108+
},
109+
};

0 commit comments

Comments
 (0)