Skip to content

Commit 34a9c2b

Browse files
authored
New Components - dolibarr (#17030)
* new components * pnpm-lock.yaml * updates * update * pnpm-lock.yaml * pnpm-lock.yaml * pnpm-lock.yaml * updates
1 parent 9c2132a commit 34a9c2b

File tree

14 files changed

+1127
-8
lines changed

14 files changed

+1127
-8
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import dolibarr from "../../dolibarr.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "dolibarr-create-order",
6+
name: "Create Order",
7+
description: "Create a new order in Dolibarr.",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
dolibarr,
12+
thirdPartyId: {
13+
propDefinition: [
14+
dolibarr,
15+
"thirdPartyId",
16+
],
17+
},
18+
date: {
19+
type: "string",
20+
label: "Date",
21+
description: "The date of the order in YYYY-MM-DD format",
22+
},
23+
deliveryDate: {
24+
type: "string",
25+
label: "Delivery Date",
26+
description: "The expecteddelivery date of the order in YYYY-MM-DD format",
27+
optional: true,
28+
},
29+
paymentMethodCode: {
30+
propDefinition: [
31+
dolibarr,
32+
"paymentMethodCode",
33+
],
34+
},
35+
paymentTermCode: {
36+
propDefinition: [
37+
dolibarr,
38+
"paymentTermCode",
39+
],
40+
},
41+
notePublic: {
42+
type: "string",
43+
label: "Note Public",
44+
description: "A public note to add to the order",
45+
optional: true,
46+
},
47+
notePrivate: {
48+
type: "string",
49+
label: "Note Private",
50+
description: "A private note to add to the order",
51+
optional: true,
52+
},
53+
additionalProperties: {
54+
propDefinition: [
55+
dolibarr,
56+
"additionalProperties",
57+
],
58+
},
59+
},
60+
async run({ $ }) {
61+
const response = await this.dolibarr.createOrder({
62+
$,
63+
data: {
64+
socid: this.thirdPartyId,
65+
date: Date.parse(this.date) / 1000,
66+
deliverydate: this.deliveryDate
67+
? Date.parse(this.deliveryDate) / 1000
68+
: undefined,
69+
mode_reglement_code: this.paymentMethodCode,
70+
cond_reglement_code: this.paymentTermCode,
71+
note_public: this.notePublic,
72+
note_private: this.notePrivate,
73+
...parseObject(this.additionalProperties),
74+
},
75+
});
76+
$.export("$summary", `Successfully created order ${response}`);
77+
return response;
78+
},
79+
};
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import dolibarr from "../../dolibarr.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "dolibarr-create-thirdparty",
6+
name: "Create Third Party",
7+
description: "Create a new third party in Dolibarr.",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
dolibarr,
12+
name: {
13+
type: "string",
14+
label: "Name",
15+
description: "The name of the third party",
16+
},
17+
email: {
18+
type: "string",
19+
label: "Email",
20+
description: "The email address of the third party",
21+
optional: true,
22+
},
23+
phone: {
24+
type: "string",
25+
label: "Phone",
26+
description: "The phone number of the third party",
27+
optional: true,
28+
},
29+
streetAddress: {
30+
type: "string",
31+
label: "Street Address",
32+
description: "The street address of the third party",
33+
optional: true,
34+
},
35+
zip: {
36+
type: "string",
37+
label: "Zip",
38+
description: "The zip code of the third party",
39+
optional: true,
40+
},
41+
town: {
42+
type: "string",
43+
label: "Town",
44+
description: "The city or town of the third party",
45+
optional: true,
46+
},
47+
additionalProperties: {
48+
propDefinition: [
49+
dolibarr,
50+
"additionalProperties",
51+
],
52+
},
53+
},
54+
async run({ $ }) {
55+
const response = await this.dolibarr.createThirdParty({
56+
$,
57+
data: {
58+
name: this.name,
59+
email: this.email,
60+
phone: this.phone,
61+
address: this.streetAddress,
62+
zip: this.zip,
63+
town: this.town,
64+
...parseObject(this.additionalProperties),
65+
},
66+
});
67+
$.export("$summary", `Successfully created third party with ID${response}`);
68+
return response;
69+
},
70+
};
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import dolibarr from "../../dolibarr.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "dolibarr-create-user",
6+
name: "Create User",
7+
description: "Create a new user in Dolibarr.",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
dolibarr,
12+
firstName: {
13+
type: "string",
14+
label: "First Name",
15+
description: "The first name of the user",
16+
optional: true,
17+
},
18+
lastName: {
19+
type: "string",
20+
label: "Last Name",
21+
description: "The last name of the user",
22+
},
23+
login: {
24+
type: "string",
25+
label: "Login",
26+
description: "The login name of the user. Must be unique.",
27+
},
28+
password: {
29+
type: "string",
30+
label: "Password",
31+
description: "The password of the user",
32+
},
33+
email: {
34+
type: "string",
35+
label: "Email",
36+
description: "The email address of the user",
37+
optional: true,
38+
},
39+
officePhone: {
40+
type: "string",
41+
label: "Office Phone",
42+
description: "The office phone number of the user",
43+
optional: true,
44+
},
45+
jobPosition: {
46+
type: "string",
47+
label: "Job Position",
48+
description: "The job position of the user",
49+
optional: true,
50+
},
51+
isAdmin: {
52+
type: "boolean",
53+
label: "Is Admin",
54+
description: "Whether the user is an administrator",
55+
optional: true,
56+
},
57+
streetAddress: {
58+
type: "string",
59+
label: "Street Address",
60+
description: "The street address of the user",
61+
optional: true,
62+
},
63+
zip: {
64+
type: "string",
65+
label: "Zip",
66+
description: "The zip code of the user",
67+
optional: true,
68+
},
69+
town: {
70+
type: "string",
71+
label: "Town",
72+
description: "The city or town of the user",
73+
optional: true,
74+
},
75+
additionalProperties: {
76+
propDefinition: [
77+
dolibarr,
78+
"additionalProperties",
79+
],
80+
},
81+
},
82+
async run({ $ }) {
83+
const response = await this.dolibarr.createUser({
84+
$,
85+
data: {
86+
firstname: this.firstName,
87+
lastname: this.lastName,
88+
login: this.login,
89+
password: this.password,
90+
email: this.email,
91+
office_phone: this.officePhone,
92+
job: this.jobPosition,
93+
admin: this.isAdmin
94+
? 1
95+
: 0,
96+
address: this.streetAddress,
97+
zip: this.zip,
98+
town: this.town,
99+
...parseObject(this.additionalProperties),
100+
},
101+
});
102+
$.export("$summary", `Successfully created user ${response}`);
103+
return response;
104+
},
105+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export function parseObject(obj) {
2+
if (!obj) {
3+
return {};
4+
}
5+
if (typeof obj === "string") {
6+
try {
7+
return JSON.parse(obj);
8+
} catch (e) {
9+
return obj;
10+
}
11+
}
12+
if (Array.isArray(obj)) {
13+
return obj.map(parseObject);
14+
}
15+
if (typeof obj === "object") {
16+
return Object.fromEntries(
17+
Object.entries(obj).map(([
18+
key,
19+
value,
20+
]) => [
21+
key,
22+
parseObject(value),
23+
]),
24+
);
25+
}
26+
return obj;
27+
}

0 commit comments

Comments
 (0)