Skip to content

Commit c8a05aa

Browse files
authored
Fortnox - new components (#19057)
* new components * pnpm-lock.yaml
1 parent 0a09fa5 commit c8a05aa

File tree

11 files changed

+1236
-15
lines changed

11 files changed

+1236
-15
lines changed
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
import fortnox from "../../fortnox.app.mjs";
2+
3+
export default {
4+
key: "fortnox-create-article",
5+
name: "Create Article",
6+
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",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
fortnox,
16+
description: {
17+
propDefinition: [
18+
fortnox,
19+
"articleDescription",
20+
],
21+
},
22+
ean: {
23+
propDefinition: [
24+
fortnox,
25+
"ean",
26+
],
27+
},
28+
directCost: {
29+
propDefinition: [
30+
fortnox,
31+
"directCost",
32+
],
33+
},
34+
freightCost: {
35+
propDefinition: [
36+
fortnox,
37+
"freightCost",
38+
],
39+
},
40+
purchasePrice: {
41+
propDefinition: [
42+
fortnox,
43+
"purchasePrice",
44+
],
45+
},
46+
salesPrice: {
47+
propDefinition: [
48+
fortnox,
49+
"salesPrice",
50+
],
51+
},
52+
manufacturer: {
53+
propDefinition: [
54+
fortnox,
55+
"manufacturer",
56+
],
57+
},
58+
quantityInStock: {
59+
propDefinition: [
60+
fortnox,
61+
"quantityInStock",
62+
],
63+
},
64+
supplierNumber: {
65+
propDefinition: [
66+
fortnox,
67+
"supplierNumber",
68+
],
69+
},
70+
type: {
71+
propDefinition: [
72+
fortnox,
73+
"articleType",
74+
],
75+
},
76+
vat: {
77+
propDefinition: [
78+
fortnox,
79+
"articleVat",
80+
],
81+
},
82+
weight: {
83+
propDefinition: [
84+
fortnox,
85+
"weight",
86+
],
87+
},
88+
width: {
89+
propDefinition: [
90+
fortnox,
91+
"width",
92+
],
93+
},
94+
height: {
95+
propDefinition: [
96+
fortnox,
97+
"height",
98+
],
99+
},
100+
},
101+
async run({ $ }) {
102+
const response = await this.fortnox.createArticle({
103+
$,
104+
data: {
105+
Article: {
106+
Description: this.description,
107+
EAN: this.ean,
108+
DirectCost: this.directCost
109+
? +this.directCost
110+
: undefined,
111+
FreightCost: this.freightCost
112+
? +this.freightCost
113+
: undefined,
114+
PurchasePrice: this.purchasePrice
115+
? +this.purchasePrice
116+
: undefined,
117+
SalesPrice: this.salesPrice
118+
? +this.salesPrice
119+
: undefined,
120+
Manufacturer: this.manufacturer,
121+
QuantityInStock: this.quantityInStock
122+
? +this.quantityInStock
123+
: undefined,
124+
SupplierNumber: this.supplierNumber,
125+
Type: this.type,
126+
VAT: this.vat,
127+
Weight: this.weight
128+
? +this.weight
129+
: undefined,
130+
Width: this.width
131+
? +this.width
132+
: undefined,
133+
Height: this.height
134+
? +this.height
135+
: undefined,
136+
},
137+
},
138+
});
139+
$.export("$summary", `Successfully created article with ID \`${response.Article.ArticleNumber}\``);
140+
return response;
141+
},
142+
};
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import fortnox from "../../fortnox.app.mjs";
2+
3+
export default {
4+
key: "fortnox-create-customer",
5+
name: "Create Customer",
6+
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",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
fortnox,
16+
name: {
17+
propDefinition: [
18+
fortnox,
19+
"customerName",
20+
],
21+
},
22+
email: {
23+
propDefinition: [
24+
fortnox,
25+
"email",
26+
],
27+
},
28+
phone: {
29+
propDefinition: [
30+
fortnox,
31+
"phone",
32+
],
33+
},
34+
address1: {
35+
propDefinition: [
36+
fortnox,
37+
"address1",
38+
],
39+
},
40+
address2: {
41+
propDefinition: [
42+
fortnox,
43+
"address2",
44+
],
45+
},
46+
city: {
47+
propDefinition: [
48+
fortnox,
49+
"city",
50+
],
51+
},
52+
zipCode: {
53+
propDefinition: [
54+
fortnox,
55+
"zipCode",
56+
],
57+
},
58+
country: {
59+
propDefinition: [
60+
fortnox,
61+
"country",
62+
],
63+
},
64+
type: {
65+
propDefinition: [
66+
fortnox,
67+
"customerType",
68+
],
69+
},
70+
vat: {
71+
propDefinition: [
72+
fortnox,
73+
"customerVat",
74+
],
75+
},
76+
vatType: {
77+
propDefinition: [
78+
fortnox,
79+
"vatType",
80+
],
81+
},
82+
},
83+
async run({ $ }) {
84+
const response = await this.fortnox.createCustomer({
85+
$,
86+
data: {
87+
Customer: {
88+
Name: this.name,
89+
Email: this.email,
90+
Phone1: this.phone,
91+
Address1: this.address1,
92+
Address2: this.address2,
93+
City: this.city,
94+
ZipCode: this.zipCode,
95+
Country: this.country,
96+
Type: this.type,
97+
VAT: this.vat,
98+
VATType: this.vatType,
99+
},
100+
},
101+
});
102+
$.export("$summary", `Successfully created customer with ID \`${response.Customer.CustomerNumber}\``);
103+
return response;
104+
},
105+
};
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import fortnox from "../../fortnox.app.mjs";
2+
3+
export default {
4+
key: "fortnox-create-invoice-payment",
5+
name: "Create Invoice Payment",
6+
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",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
fortnox,
16+
invoiceNumber: {
17+
propDefinition: [
18+
fortnox,
19+
"invoiceNumber",
20+
],
21+
},
22+
amount: {
23+
type: "string",
24+
label: "Amount",
25+
description: "The amount of the payment",
26+
optional: true,
27+
},
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+
},
47+
paymentDate: {
48+
type: "string",
49+
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",
63+
optional: true,
64+
},
65+
voucherNumber: {
66+
propDefinition: [
67+
fortnox,
68+
"voucherNumber",
69+
],
70+
},
71+
},
72+
async run({ $ }) {
73+
const response = await this.fortnox.createInvoicePayment({
74+
$,
75+
data: {
76+
InvoicePayment: {
77+
InvoiceNumber: this.invoiceNumber,
78+
Amount: this.amount
79+
? +this.amount
80+
: 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,
88+
PaymentDate: this.paymentDate,
89+
VoucherNumber: this.voucherNumber,
90+
},
91+
},
92+
});
93+
$.export("$summary", `Successfully created invoice payment with ID \`${response.InvoicePayment.Number}\``);
94+
return response;
95+
},
96+
};

0 commit comments

Comments
 (0)