From 603ba2089ab9f60be18046518595a192a80f4de8 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Mon, 24 Nov 2025 08:58:16 -0500 Subject: [PATCH 1/6] 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. --- .../actions/create-article/create-article.mjs | 2 +- .../create-customer/create-customer.mjs | 2 +- .../create-invoice-payment.mjs | 2 +- .../actions/create-invoice/create-invoice.mjs | 4 +- .../get-supplier-invoice.mjs | 32 +++ .../actions/list-accounts/list-accounts.mjs | 27 ++ .../actions/list-articles/list-articles.mjs | 109 ++++++++ .../actions/list-customers/list-customers.mjs | 117 +++++++++ .../list-financial-years.mjs | 36 +++ .../actions/list-invoices/list-invoices.mjs | 240 ++++++++++++++++++ .../list-supplier-invoices.mjs | 63 +++++ .../actions/list-suppliers/list-suppliers.mjs | 27 ++ .../actions/send-invoice/send-invoice.mjs | 2 +- .../actions/update-article/update-article.mjs | 2 +- .../update-customer/update-customer.mjs | 2 +- components/fortnox/fortnox.app.mjs | 42 ++- components/fortnox/package.json | 2 +- 17 files changed, 701 insertions(+), 10 deletions(-) create mode 100644 components/fortnox/actions/get-supplier-invoice/get-supplier-invoice.mjs create mode 100644 components/fortnox/actions/list-accounts/list-accounts.mjs create mode 100644 components/fortnox/actions/list-articles/list-articles.mjs create mode 100644 components/fortnox/actions/list-customers/list-customers.mjs create mode 100644 components/fortnox/actions/list-financial-years/list-financial-years.mjs create mode 100644 components/fortnox/actions/list-invoices/list-invoices.mjs create mode 100644 components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs create mode 100644 components/fortnox/actions/list-suppliers/list-suppliers.mjs diff --git a/components/fortnox/actions/create-article/create-article.mjs b/components/fortnox/actions/create-article/create-article.mjs index f9c9c80eaeebe..5bc7dcd7719b4 100644 --- a/components/fortnox/actions/create-article/create-article.mjs +++ b/components/fortnox/actions/create-article/create-article.mjs @@ -4,7 +4,7 @@ export default { key: "fortnox-create-article", name: "Create Article", description: "Creates a new article in the Fortnox API. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Articles/operation/1_create_3).", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/fortnox/actions/create-customer/create-customer.mjs b/components/fortnox/actions/create-customer/create-customer.mjs index 34010db7bc2d3..cf174ffb23f5f 100644 --- a/components/fortnox/actions/create-customer/create-customer.mjs +++ b/components/fortnox/actions/create-customer/create-customer.mjs @@ -4,7 +4,7 @@ export default { key: "fortnox-create-customer", name: "Create Customer", description: "Creates a new customer in the Fortnox API. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Customers/operation/create_16).", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/fortnox/actions/create-invoice-payment/create-invoice-payment.mjs b/components/fortnox/actions/create-invoice-payment/create-invoice-payment.mjs index e8a8181ef9fb6..2515bb89abe04 100644 --- a/components/fortnox/actions/create-invoice-payment/create-invoice-payment.mjs +++ b/components/fortnox/actions/create-invoice-payment/create-invoice-payment.mjs @@ -4,7 +4,7 @@ export default { key: "fortnox-create-invoice-payment", name: "Create Invoice Payment", description: "Creates a new invoice payment in the Fortnox API. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_InvoicePayments/operation/create_22).", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/fortnox/actions/create-invoice/create-invoice.mjs b/components/fortnox/actions/create-invoice/create-invoice.mjs index df0142bdfa426..09f1e12bc13ea 100644 --- a/components/fortnox/actions/create-invoice/create-invoice.mjs +++ b/components/fortnox/actions/create-invoice/create-invoice.mjs @@ -1,11 +1,11 @@ -import fortnox from "../../fortnox.app.mjs"; import { parseObject } from "../../common/utils.mjs"; +import fortnox from "../../fortnox.app.mjs"; export default { key: "fortnox-create-invoice", name: "Create Invoice", description: "Creates a new invoice in the Fortnox API. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Invoices/operation/create_23).", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/fortnox/actions/get-supplier-invoice/get-supplier-invoice.mjs b/components/fortnox/actions/get-supplier-invoice/get-supplier-invoice.mjs new file mode 100644 index 0000000000000..4c3689f714f43 --- /dev/null +++ b/components/fortnox/actions/get-supplier-invoice/get-supplier-invoice.mjs @@ -0,0 +1,32 @@ +import app from "../../fortnox.app.mjs"; + +export default { + key: "fortnox-get-supplier-invoice", + name: "Get Supplier Invoice", + description: "Retrieve a supplier invoice. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_SupplierInvoices/operation/get_39)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + app, + supplierInvoiceNumber: { + propDefinition: [ + app, + "supplierInvoiceNumber", + ], + }, + }, + async run({ $ }) { + const { SupplierInvoice } = await this.app.getSupplierInvoice({ + $, + supplierInvoiceNumber: this.supplierInvoiceNumber, + }); + + $.export("$summary", `Successfully retrieved supplier invoice with number ${this.supplierInvoiceNumber}`); + return SupplierInvoice; + }, +}; diff --git a/components/fortnox/actions/list-accounts/list-accounts.mjs b/components/fortnox/actions/list-accounts/list-accounts.mjs new file mode 100644 index 0000000000000..e2787b0bbb9f6 --- /dev/null +++ b/components/fortnox/actions/list-accounts/list-accounts.mjs @@ -0,0 +1,27 @@ +import app from "../../fortnox.app.mjs"; + +export default { + key: "fortnox-list-accounts", + name: "List Accounts", + description: "List all accounts in Fortnox. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Accounts/operation/list_2)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + app, + }, + async run({ $ }) { + const accounts = await this.app.listAccounts({ + $, + }); + + $.export("$summary", `Successfully retrieved ${accounts.length} account${accounts.length === 1 + ? "" + : "s"}`); + return accounts; + }, +}; diff --git a/components/fortnox/actions/list-articles/list-articles.mjs b/components/fortnox/actions/list-articles/list-articles.mjs new file mode 100644 index 0000000000000..8b45defeeb262 --- /dev/null +++ b/components/fortnox/actions/list-articles/list-articles.mjs @@ -0,0 +1,109 @@ +import app from "../../fortnox.app.mjs"; + +export default { + key: "fortnox-list-articles", + name: "List Articles", + description: "List all articles in Fortnox. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Articles/operation/list_4)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + app, + filter: { + type: "string", + label: "Filter", + description: "Filter the articles by Active or Inactive", + options: [ + "active", + "inactive", + ], + optional: true, + }, + articlenumber: { + type: "string", + label: "Article Number", + description: "Filter by article number", + optional: true, + }, + description: { + type: "string", + label: "Description", + description: "Filter by description", + optional: true, + }, + ean: { + type: "string", + label: "EAN", + description: "Filter by EAN", + optional: true, + }, + suppliernumber: { + type: "string", + label: "Supplier Number", + description: "Filter by supplier number", + optional: true, + }, + manufacturer: { + type: "string", + label: "Manufacturer", + description: "Filter by manufacturer", + optional: true, + }, + manufacturerarticlenumber: { + type: "string", + label: "Manufacturer Article Number", + description: "Filter by manufacturer article number", + optional: true, + }, + webshop: { + type: "string", + label: "Webshop", + description: "Filter by web shop", + optional: true, + }, + lastmodified: { + type: "string", + label: "Last Modified", + description: "Filter by last modified date", + optional: true, + }, + sortby: { + type: "string", + label: "Sort By", + description: "Sort the articles by the specified field", + optional: true, + options: [ + "articlenumber", + "quantityinstock", + "reservedquantity", + "stockvalue", + ], + }, + }, + async run({ $ }) { + const { Articles } = await this.app.listArticles({ + $, + params: { + filter: this.filter, + articlenumber: this.articlenumber, + description: this.description, + ean: this.ean, + suppliernumber: this.suppliernumber, + manufacturer: this.manufacturer, + manufacturerarticlenumber: this.manufacturerarticlenumber, + webshop: this.webshop, + lastmodified: this.lastmodified, + sortby: this.sortby, + }, + }); + + $.export("$summary", `Successfully retrieved ${Articles.length} article${Articles.length === 1 + ? "" + : "s"}`); + return Articles; + }, +}; diff --git a/components/fortnox/actions/list-customers/list-customers.mjs b/components/fortnox/actions/list-customers/list-customers.mjs new file mode 100644 index 0000000000000..c51dc169c25cf --- /dev/null +++ b/components/fortnox/actions/list-customers/list-customers.mjs @@ -0,0 +1,117 @@ +import app from "../../fortnox.app.mjs"; + +export default { + key: "fortnox-list-customers", + name: "List Customers", + description: "List all customers in Fortnox. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Customers/operation/list_15)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + app, + filter: { + type: "string", + label: "Filter", + description: "Filter the customers by Active or Inactive", + options: [ + "active", + "inactive", + ], + optional: true, + }, + customernumber: { + type: "string", + label: "Customer Number", + description: "Filter by customer number", + optional: true, + }, + name: { + type: "string", + label: "Name", + description: "Filter by name", + optional: true, + }, + zipcode: { + type: "string", + label: "Zip Code", + description: "Filter by zip code", + optional: true, + }, + city: { + type: "string", + label: "City", + description: "Filter by city", + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "Filter by email", + optional: true, + }, + phone: { + type: "string", + label: "Phone", + description: "Filter by phone", + optional: true, + }, + organisationnumber: { + type: "string", + label: "Organisation Number", + description: "Filter by organisation number", + optional: true, + }, + gln: { + type: "string", + label: "GLN", + description: "Filter by GLN", + optional: true, + }, + glndelivery: { + type: "string", + label: "GLN Delivery", + description: "Filter by GLN Delivery", + optional: true, + }, + lastmodified: { + type: "string", + label: "Last Modified", + description: "Filter by last modified date", + optional: true, + }, + sortby: { + type: "string", + label: "Sort By", + description: "Sort the customers by the specified field", + optional: true, + options: [ + "customernumber", + "name", + ], + }, + }, + async run({ $ }) { + const { Customers } = await this.app.listCustomers({ + $, + params: { + filter: this.filter, + customernumber: this.customernumber, + name: this.name, + zipcode: this.zipcode, + city: this.city, + email: this.email, + phone: this.phone, + organisationnumber: this.organisationnumber, + }, + }); + + $.export("$summary", `Successfully retrieved ${Customers.length} customer${Customers.length === 1 + ? "" + : "s"}`); + return Customers; + }, +}; diff --git a/components/fortnox/actions/list-financial-years/list-financial-years.mjs b/components/fortnox/actions/list-financial-years/list-financial-years.mjs new file mode 100644 index 0000000000000..ac832adf7dabe --- /dev/null +++ b/components/fortnox/actions/list-financial-years/list-financial-years.mjs @@ -0,0 +1,36 @@ +import app from "../../fortnox.app.mjs"; + +export default { + key: "fortnox-list-financial-years", + name: "List Financial Years", + description: "Retrieve a list of financial years. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_FinancialYears/operation/getByDate)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + app, + date: { + type: "string", + label: "Date", + description: "The date to retrieve the financial years for in **YYYY-MM-DD** format", + optional: true, + }, + }, + async run({ $ }) { + const { FinancialYears } = await this.app.listFinancialYears({ + $, + params: { + Date: this.date, + }, + }); + + $.export("$summary", `Successfully retrieved ${FinancialYears.length} financial year${FinancialYears.length === 1 + ? "" + : "s"}`); + return FinancialYears; + }, +}; diff --git a/components/fortnox/actions/list-invoices/list-invoices.mjs b/components/fortnox/actions/list-invoices/list-invoices.mjs new file mode 100644 index 0000000000000..42bc82b26096d --- /dev/null +++ b/components/fortnox/actions/list-invoices/list-invoices.mjs @@ -0,0 +1,240 @@ +import app from "../../fortnox.app.mjs"; + +export default { + key: "fortnox-list-invoices", + name: "List Invoices", + description: "List a list of invoices in Fortnox. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Invoices/operation/list_20)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + app, + filter: { + type: "string", + label: "Filter", + description: "Filter the invoices", + options: [ + "cancelled", + "fullpaid", + "unpaid", + "unpaidoverdue", + "unbooked", + ], + optional: true, + }, + costcenter: { + type: "string", + label: "Cost Center", + description: "Filter the invoices by cost center", + optional: true, + }, + customername: { + type: "string", + label: "Customer Name", + description: "Filter the invoices by customer name", + optional: true, + }, + customernumber: { + type: "string", + label: "Customer Number", + description: "Filter the invoices by customer number", + optional: true, + }, + label: { + type: "string", + label: "Label", + description: "Filter the invoices by label", + optional: true, + }, + documentnumber: { + type: "string", + label: "Document Number", + description: "Filter the invoices by document number", + optional: true, + }, + fromdate: { + type: "string", + label: "From Date", + description: "Filter the invoices by from date", + optional: true, + }, + todate: { + type: "string", + label: "To Date", + description: "Filter the invoices by to date", + optional: true, + }, + fromfinalpaydate: { + type: "string", + label: "From Final Pay Date", + description: "Filter the invoices by from final pay date", + optional: true, + }, + tofinalpaydate: { + type: "string", + label: "To Final Pay Date", + description: "Filter the invoices by to final pay date", + optional: true, + }, + lastmodified: { + type: "string", + label: "Last Modified", + description: "Filter the invoices by last modified", + optional: true, + }, + notcompleted: { + type: "string", + label: "Not Completed", + description: "Filter the invoices by not completed", + optional: true, + }, + ocr: { + type: "string", + label: "OCR", + description: "Filter the invoices by OCR", + optional: true, + }, + ourreference: { + type: "string", + label: "Our Reference", + description: "Filter the invoices by our reference", + optional: true, + }, + project: { + type: "string", + label: "Project", + description: "Filter the invoices by project", + optional: true, + }, + sent: { + type: "string", + label: "Sent", + description: "Filter the invoices by sent", + optional: true, + }, + externalinvoicereference1: { + type: "string", + label: "External Invoice Reference 1", + description: "Filter the invoices by external invoice reference 1", + optional: true, + }, + externalinvoicereference2: { + type: "string", + label: "External Invoice Reference 2", + description: "Filter the invoices by external invoice reference 2", + optional: true, + }, + yourreference: { + type: "string", + label: "Your Reference", + description: "Filter the invoices by your reference", + optional: true, + }, + invoicetype: { + type: "string", + label: "Invoice Type", + description: "Filter the invoices by invoice type", + optional: true, + }, + articlenumber: { + type: "string", + label: "Article Number", + description: "Filter the invoices by article number", + optional: true, + }, + articledescription: { + type: "string", + label: "Article Description", + description: "Filter the invoices by article description", + optional: true, + }, + currency: { + type: "string", + label: "Currency", + description: "Filter the invoices by currency", + optional: true, + }, + accountnumberfrom: { + type: "string", + label: "Account Number From", + description: "Filter the invoices by account number from", + optional: true, + }, + accountnumberto: { + type: "string", + label: "Account Number To", + description: "Filter the invoices by account number to", + optional: true, + }, + credit: { + type: "string", + label: "Credit", + description: "Filter the invoices by credit", + optional: true, + }, + sortby: { + type: "string", + label: "Sort By", + description: "Filter the invoices by sort by", + optional: true, + }, + sortorder: { + type: "string", + label: "Sort Order", + description: "Filter the invoices by sort order", + options: [ + "customername", + "customernumber", + "documentnumber", + "invoicedate", + "ocr", + "total", + ], + optional: true, + }, + }, + async run({ $ }) { + const { Invoices } = await this.app.listInvoices({ + $, + params: { + filter: this.filter, + costcenter: this.costcenter, + customername: this.customername, + customernumber: this.customernumber, + label: this.label, + documentnumber: this.documentnumber, + fromdate: this.fromdate, + todate: this.todate, + fromfinalpaydate: this.fromfinalpaydate, + tofinalpaydate: this.tofinalpaydate, + lastmodified: this.lastmodified, + notcompleted: this.notcompleted, + ocr: this.ocr, + ourreference: this.ourreference, + project: this.project, + sent: this.sent, + externalinvoicereference1: this.externalinvoicereference1, + externalinvoicereference2: this.externalinvoicereference2, + yourreference: this.yourreference, + invoicetype: this.invoicetype, + articlenumber: this.articlenumber, + articledescription: this.articledescription, + currency: this.currency, + accountnumberfrom: this.accountnumberfrom, + accountnumberto: this.accountnumberto, + credit: this.credit, + sortby: this.sortby, + sortorder: this.sortorder, + }, + }); + + $.export("$summary", `Successfully retrieved ${Invoices.length} invoice${Invoices.length === 1 + ? "" + : "s"}`); + return Invoices; + }, +}; diff --git a/components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs b/components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs new file mode 100644 index 0000000000000..5d499146c3a1a --- /dev/null +++ b/components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs @@ -0,0 +1,63 @@ +import app from "../../fortnox.app.mjs"; + +export default { + key: "fortnox-list-supplier-invoices", + name: "List Supplier Invoices", + description: "List all invoices for a supplier. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_SupplierInvoices/operation/list_39)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + app, + filter: { + type: "string", + label: "Filter", + description: "Filter the invoices by supplier number", + options: [ + { + label: "Retrieves all invoices with the status `cancelled`", + value: "cancelled", + }, + { + label: "Retrieves all invoices that has been fully paid", + value: "fullpaid", + }, + { + label: "Retrieves all invoices that is unpaid", + value: "unpaid", + }, + { + label: "Retrieves all invoices that is unpaid and overdue", + value: "unpaidoverdue", + }, + { + label: "Retrieves all invoices that is unbooked", + value: "unbooked", + }, + { + label: "Retrieves all invoices that has PaymentPending=true and is booked", + value: "pendingpayment", + }, + { + label: "Retrieves all invoices that has a waiting authorization pending", + value: "authorizepending", + }, + ], + optional: true, + }, + }, + async run({ $ }) { + const { SupplierInvoices } = await this.app.listSupplierInvoices({ + $, + }); + + $.export("$summary", `Successfully retrieved ${SupplierInvoices.length} supplier invoice${SupplierInvoices.length === 1 + ? "" + : "s"}`); + return SupplierInvoices; + }, +}; diff --git a/components/fortnox/actions/list-suppliers/list-suppliers.mjs b/components/fortnox/actions/list-suppliers/list-suppliers.mjs new file mode 100644 index 0000000000000..8a6376e91f1c8 --- /dev/null +++ b/components/fortnox/actions/list-suppliers/list-suppliers.mjs @@ -0,0 +1,27 @@ +import app from "../../fortnox.app.mjs"; + +export default { + key: "fortnox-list-suppliers", + name: "List Suppliers", + description: "List all suppliers in Fortnox. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Suppliers/operation/list_40)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + app, + }, + async run({ $ }) { + const { Suppliers } = await this.app.listSuppliers({ + $, + }); + + $.export("$summary", `Successfully retrieved ${Suppliers.length} supplier${Suppliers.length === 1 + ? "" + : "s"}`); + return Suppliers; + }, +}; diff --git a/components/fortnox/actions/send-invoice/send-invoice.mjs b/components/fortnox/actions/send-invoice/send-invoice.mjs index a781fe4948f60..cc257895ffaee 100644 --- a/components/fortnox/actions/send-invoice/send-invoice.mjs +++ b/components/fortnox/actions/send-invoice/send-invoice.mjs @@ -4,7 +4,7 @@ export default { key: "fortnox-send-invoice", name: "Send Invoice", description: "Sends an invoice in the Fortnox API. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Invoices/operation/eInvoice).", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/fortnox/actions/update-article/update-article.mjs b/components/fortnox/actions/update-article/update-article.mjs index cf8cbec3b8608..7a6acee8ef17f 100644 --- a/components/fortnox/actions/update-article/update-article.mjs +++ b/components/fortnox/actions/update-article/update-article.mjs @@ -4,7 +4,7 @@ export default { key: "fortnox-update-article", name: "Update Article", description: "Updates an existing article in the Fortnox API. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Articles/operation/1_update_2).", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: true, diff --git a/components/fortnox/actions/update-customer/update-customer.mjs b/components/fortnox/actions/update-customer/update-customer.mjs index be1515bd04055..00dbdb699c585 100644 --- a/components/fortnox/actions/update-customer/update-customer.mjs +++ b/components/fortnox/actions/update-customer/update-customer.mjs @@ -4,7 +4,7 @@ export default { key: "fortnox-update-customer", name: "Update Customer", description: "Updates an existing customer in the Fortnox API. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Customers/operation/update_14).", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: true, diff --git a/components/fortnox/fortnox.app.mjs b/components/fortnox/fortnox.app.mjs index 0a9278a21c501..1478b38311e79 100644 --- a/components/fortnox/fortnox.app.mjs +++ b/components/fortnox/fortnox.app.mjs @@ -106,6 +106,18 @@ export default { })) || []; }, }, + supplierInvoiceNumber: { + type: "string", + label: "Supplier Invoice Number", + description: "The number of the supplier invoice", + async options() { + const { SupplierInvoices: supplierInvoices } = await this.listSupplierInvoices(); + return supplierInvoices?.map((invoice) => ({ + label: `${invoice.InvoiceNumber} - ${invoice.Total}`, + value: invoice.GivenNumber, + })) || []; + }, + }, articleDescription: { type: "string", label: "Description", @@ -274,7 +286,9 @@ export default { return axios($, { url: `${this._baseUrl()}${path}`, headers: { - Authorization: `Bearer ${this.$auth.oauth_access_token}`, + "Authorization": `Bearer ${this.$auth.oauth_access_token}`, + "Content-Type": "application/json", + "Accept": "application/json", }, ...opts, }); @@ -379,5 +393,31 @@ export default { ...opts, }); }, + listAccounts(opts = {}) { + return this._makeRequest({ + path: "/accounts", + ...opts, + }); + }, + listFinancialYears(opts = {}) { + return this._makeRequest({ + path: "/financialyears", + ...opts, + }); + }, + listSupplierInvoices(opts = {}) { + return this._makeRequest({ + path: "/supplierinvoices", + ...opts, + }); + }, + getSupplierInvoice({ + supplierInvoiceNumber, ...opts + }) { + return this._makeRequest({ + path: `/supplierinvoices/${supplierInvoiceNumber}`, + ...opts, + }); + }, }, }; diff --git a/components/fortnox/package.json b/components/fortnox/package.json index 4ddb48c8058a6..3fdef1b0f271c 100644 --- a/components/fortnox/package.json +++ b/components/fortnox/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/fortnox", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream Fortnox Components", "main": "fortnox.app.mjs", "keywords": [ From cc19f4f4feb87824768347a0c5c4735bc2f5eb1d Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Mon, 24 Nov 2025 11:24:12 -0300 Subject: [PATCH 2/6] Update components/fortnox/actions/list-invoices/list-invoices.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- components/fortnox/actions/list-invoices/list-invoices.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/fortnox/actions/list-invoices/list-invoices.mjs b/components/fortnox/actions/list-invoices/list-invoices.mjs index 42bc82b26096d..14aa93e49c465 100644 --- a/components/fortnox/actions/list-invoices/list-invoices.mjs +++ b/components/fortnox/actions/list-invoices/list-invoices.mjs @@ -3,7 +3,7 @@ import app from "../../fortnox.app.mjs"; export default { key: "fortnox-list-invoices", name: "List Invoices", - description: "List a list of invoices in Fortnox. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Invoices/operation/list_20)", + description: "Retrieve a list of invoices in Fortnox. [See the documentation](https://api.fortnox.se/apidocs#tag/fortnox_Invoices/operation/list_20)", version: "0.0.1", type: "action", annotations: { From 9dfa75d49830bba49272fd5f486abb65e3e0f38b Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Mon, 24 Nov 2025 09:25:37 -0500 Subject: [PATCH 3/6] 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. --- components/fortnox/actions/list-customers/list-customers.mjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/fortnox/actions/list-customers/list-customers.mjs b/components/fortnox/actions/list-customers/list-customers.mjs index c51dc169c25cf..20a88154826e3 100644 --- a/components/fortnox/actions/list-customers/list-customers.mjs +++ b/components/fortnox/actions/list-customers/list-customers.mjs @@ -106,6 +106,10 @@ export default { email: this.email, phone: this.phone, organisationnumber: this.organisationnumber, + gln: this.gln, + glndelivery: this.glndelivery, + lastmodified: this.lastmodified, + sortby: this.sortby, }, }); From ac32c62a11c47930cb68255e9507578effa9770b Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Wed, 26 Nov 2025 17:03:42 -0500 Subject: [PATCH 4/6] 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. --- .../create-invoice-payment.mjs | 11 ++--------- .../list-supplier-invoices.mjs | 14 +++++++------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/components/fortnox/actions/create-invoice-payment/create-invoice-payment.mjs b/components/fortnox/actions/create-invoice-payment/create-invoice-payment.mjs index 2515bb89abe04..6f96092eb456f 100644 --- a/components/fortnox/actions/create-invoice-payment/create-invoice-payment.mjs +++ b/components/fortnox/actions/create-invoice-payment/create-invoice-payment.mjs @@ -25,12 +25,6 @@ export default { description: "The amount of the payment", optional: true, }, - booked: { - type: "boolean", - label: "Booked", - description: "Whether the payment is booked", - optional: true, - }, customerNumber: { propDefinition: [ fortnox, @@ -41,13 +35,13 @@ export default { dueDate: { type: "string", label: "Due Date", - description: "The due date of the invoice", + description: "The due date of the invoice. Format DD/MM/YYYY", optional: true, }, paymentDate: { type: "string", label: "Payment Date", - description: "The date of the payment", + description: "The date of the payment. Format DD/MM/YYYY", optional: true, }, invoiceTotal: { @@ -78,7 +72,6 @@ export default { Amount: this.amount ? +this.amount : undefined, - Booked: this.booked, InvoiceCustomerNumber: this.customerNumber, InvoiceDueDate: this.dueDate, InvoiceTotal: this.invoiceTotal diff --git a/components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs b/components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs index 5d499146c3a1a..c65be0e464af5 100644 --- a/components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs +++ b/components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs @@ -16,34 +16,34 @@ export default { filter: { type: "string", label: "Filter", - description: "Filter the invoices by supplier number", + description: "Filter the invoices by supplier status", options: [ { label: "Retrieves all invoices with the status `cancelled`", value: "cancelled", }, { - label: "Retrieves all invoices that has been fully paid", + label: "Retrieves all invoices that have been fully paid", value: "fullpaid", }, { - label: "Retrieves all invoices that is unpaid", + label: "Retrieves all invoices that are unpaid", value: "unpaid", }, { - label: "Retrieves all invoices that is unpaid and overdue", + label: "Retrieves all invoices that are unpaid and overdue", value: "unpaidoverdue", }, { - label: "Retrieves all invoices that is unbooked", + label: "Retrieves all invoices that are unbooked", value: "unbooked", }, { - label: "Retrieves all invoices that has PaymentPending=true and is booked", + label: "Retrieves all invoices that have PaymentPending=true and are booked", value: "pendingpayment", }, { - label: "Retrieves all invoices that has a waiting authorization pending", + label: "Retrieves all invoices that have a waiting authorization pending", value: "authorizepending", }, ], From 3c0c68dbdb6d2e6bc85127a57bdebfb7405fec81 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 27 Nov 2025 12:44:16 -0300 Subject: [PATCH 5/6] Update components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../actions/list-supplier-invoices/list-supplier-invoices.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs b/components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs index c65be0e464af5..64c895bf3a290 100644 --- a/components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs +++ b/components/fortnox/actions/list-supplier-invoices/list-supplier-invoices.mjs @@ -24,7 +24,7 @@ export default { }, { label: "Retrieves all invoices that have been fully paid", - value: "fullpaid", + value: "fullypaid", }, { label: "Retrieves all invoices that are unpaid", From 105a3e4bf9e97b01d764821cf4d3e5af5e660ca5 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 27 Nov 2025 11:27:24 -0500 Subject: [PATCH 6/6] 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. --- .../actions/create-invoice/create-invoice.mjs | 16 +++++---- .../actions/list-accounts/list-accounts.mjs | 2 +- components/fortnox/fortnox.app.mjs | 36 +++++++++++++++++++ 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/components/fortnox/actions/create-invoice/create-invoice.mjs b/components/fortnox/actions/create-invoice/create-invoice.mjs index 09f1e12bc13ea..e136bd2ea3eea 100644 --- a/components/fortnox/actions/create-invoice/create-invoice.mjs +++ b/components/fortnox/actions/create-invoice/create-invoice.mjs @@ -105,16 +105,18 @@ export default { description: "The freight of the invoice", optional: true, }, - termsOfDelivery: { - type: "string", - label: "Terms of Delivery", - description: "The terms of delivery of the invoice", + termsOfDeliveries: { + propDefinition: [ + fortnox, + "termsOfDeliveries", + ], optional: true, }, termsOfPayment: { - type: "string", - label: "Terms of Payment", - description: "The terms of payment of the invoice", + propDefinition: [ + fortnox, + "termsOfPayments", + ], optional: true, }, }, diff --git a/components/fortnox/actions/list-accounts/list-accounts.mjs b/components/fortnox/actions/list-accounts/list-accounts.mjs index e2787b0bbb9f6..59858fbf8d105 100644 --- a/components/fortnox/actions/list-accounts/list-accounts.mjs +++ b/components/fortnox/actions/list-accounts/list-accounts.mjs @@ -15,7 +15,7 @@ export default { app, }, async run({ $ }) { - const accounts = await this.app.listAccounts({ + const { Accounts: accounts } = await this.app.listAccounts({ $, }); diff --git a/components/fortnox/fortnox.app.mjs b/components/fortnox/fortnox.app.mjs index 1478b38311e79..46d50cb4103f9 100644 --- a/components/fortnox/fortnox.app.mjs +++ b/components/fortnox/fortnox.app.mjs @@ -118,6 +118,30 @@ export default { })) || []; }, }, + termsOfDeliveries: { + type: "string", + label: "Terms of Delivery", + description: "The terms of delivery of the invoice", + async options() { + const { TermsOfDeliveries: termsOfDeliveries } = await this.listTermsOfDeliveries(); + return termsOfDeliveries?.map((term) => ({ + label: term.Description, + value: term.Code, + })) || []; + }, + }, + termsOfPayments: { + type: "string", + label: "Terms of Payment", + description: "The terms of payment of the invoice", + async options() { + const { TermsOfPayments: termsOfPayments } = await this.listTermsOfPayments(); + return termsOfPayments?.map((term) => ({ + label: term.Description, + value: term.Code, + })) || []; + }, + }, articleDescription: { type: "string", label: "Description", @@ -419,5 +443,17 @@ export default { ...opts, }); }, + listTermsOfPayments(opts = {}) { + return this._makeRequest({ + path: "/termsofpayments", + ...opts, + }); + }, + listTermsOfDeliveries(opts = {}) { + return this._makeRequest({ + path: "/termsofdeliveries", + ...opts, + }); + }, }, };