Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -25,29 +25,17 @@ 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,
"customerNumber",
],
optional: true,
},
dueDate: {
type: "string",
label: "Due Date",
description: "The due date of the invoice",
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: {
Expand Down Expand Up @@ -78,9 +66,7 @@ export default {
Amount: this.amount
? +this.amount
: undefined,
Booked: this.booked,
InvoiceCustomerNumber: this.customerNumber,
InvoiceDueDate: this.dueDate,
InvoiceTotal: this.invoiceTotal
? +this.invoiceTotal
: undefined,
Expand Down
22 changes: 4 additions & 18 deletions components/fortnox/actions/create-invoice/create-invoice.mjs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -53,7 +53,7 @@ export default {
dueDate: {
type: "string",
label: "Due Date",
description: "The due date of the invoice",
description: "The due date of the invoice. **Format: YYYY-MM-DD**",
optional: true,
},
invoiceRows: {
Expand Down Expand Up @@ -105,18 +105,6 @@ 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",
optional: true,
},
termsOfPayment: {
type: "string",
label: "Terms of Payment",
description: "The terms of payment of the invoice",
optional: true,
},
},
async run({ $ }) {
const response = await this.fortnox.createInvoice({
Expand All @@ -143,12 +131,10 @@ export default {
Freight: this.freight
? +this.freight
: undefined,
TermsOfDelivery: this.termsOfDelivery,
TermsOfPayment: this.termsOfPayment,
},
},
});
$.export("$summary", `Successfully created invoice with ID \`${response.Invoice.InvoiceNumber}\``);
$.export("$summary", `Successfully created invoice with ID \`${response.Invoice.DocumentNumber}\``);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -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;
},
};
27 changes: 27 additions & 0 deletions components/fortnox/actions/list-accounts/list-accounts.mjs
Original file line number Diff line number Diff line change
@@ -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: accounts } = await this.app.listAccounts({
$,
});

$.export("$summary", `Successfully retrieved ${accounts.length} account${accounts.length === 1
? ""
: "s"}`);
return accounts;
},
};
109 changes: 109 additions & 0 deletions components/fortnox/actions/list-articles/list-articles.mjs
Original file line number Diff line number Diff line change
@@ -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;
},
};
Loading
Loading