Skip to content

Commit a4e6ce2

Browse files
committed
[ACTIONS] Netsuite - new components
1 parent 6512c92 commit a4e6ce2

File tree

14 files changed

+1289
-5
lines changed

14 files changed

+1289
-5
lines changed
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
import app from "../../netsuite.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "netsuite-create-invoice",
6+
name: "Create Invoice",
7+
description: "Creates a new invoice. [See the documentation](https://system.netsuite.com/help/helpcenter/en_US/APIs/REST_API_Browser/record/v1/2025.2/index.html#tag-invoice)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
readOnlyHint: false,
12+
destructiveHint: false,
13+
openWorldHint: true,
14+
idempotentHint: false,
15+
},
16+
props: {
17+
app,
18+
customerId: {
19+
propDefinition: [
20+
app,
21+
"customerId",
22+
],
23+
},
24+
tranDate: {
25+
type: "string",
26+
label: "Transaction Date",
27+
description: "The posting date of this invoice (format: `YYYY-MM-DD`). Defaults to today's date if not specified.",
28+
optional: true,
29+
},
30+
subsidiaryId: {
31+
propDefinition: [
32+
app,
33+
"subsidiaryId",
34+
],
35+
optional: true,
36+
},
37+
items: {
38+
type: "string[]",
39+
label: "Items",
40+
description: `Array of item objects to add to the invoice. Each item should be a JSON object with the following properties:
41+
42+
**Required:**
43+
- \`item\` - Item ID or reference object (e.g., \`{ "id": "123" }\`)
44+
- \`quantity\` - Quantity to invoice (number)
45+
46+
**Important Optional:**
47+
- \`rate\` - Price per unit (number)
48+
- \`amount\` - Total line amount (number, usually \`quantity * rate\`)
49+
- \`description\` - Custom description for the line item (string)
50+
- \`taxCode\` - Tax code ID or reference object
51+
52+
**Example:**
53+
\`\`\`json
54+
[
55+
{
56+
"item": { "id": "456" },
57+
"quantity": 2,
58+
"rate": 99.99,
59+
"amount": 199.98,
60+
"description": "Professional services",
61+
"taxCode": { "id": "5" }
62+
}
63+
]
64+
\`\`\``,
65+
optional: true,
66+
},
67+
memo: {
68+
type: "string",
69+
label: "Memo",
70+
description: "A memo to describe this invoice.",
71+
optional: true,
72+
},
73+
otherRefNum: {
74+
type: "string",
75+
label: "PO/Reference Number",
76+
description: "Customer's purchase order number or other reference number.",
77+
optional: true,
78+
},
79+
additionalFields: {
80+
type: "object",
81+
label: "Additional Fields",
82+
description: "Additional fields to include in the invoice as a JSON object. [See the documentation](https://system.netsuite.com/help/helpcenter/en_US/APIs/REST_API_Browser/record/v1/2025.2/index.html) for available fields.",
83+
optional: true,
84+
},
85+
replace: {
86+
propDefinition: [
87+
app,
88+
"replace",
89+
],
90+
},
91+
propertyNameValidation: {
92+
propDefinition: [
93+
app,
94+
"propertyNameValidation",
95+
],
96+
},
97+
propertyValueValidation: {
98+
propDefinition: [
99+
app,
100+
"propertyValueValidation",
101+
],
102+
},
103+
},
104+
async run({ $ }) {
105+
const {
106+
app,
107+
customerId,
108+
tranDate,
109+
subsidiaryId,
110+
items,
111+
memo,
112+
otherRefNum,
113+
additionalFields,
114+
replace,
115+
propertyNameValidation,
116+
propertyValueValidation,
117+
} = this;
118+
119+
const response = await app.createInvoice({
120+
$,
121+
headers: {
122+
"X-NetSuite-PropertyNameValidation": propertyNameValidation,
123+
"X-NetSuite-PropertyValueValidation": propertyValueValidation,
124+
},
125+
params: {
126+
replace,
127+
},
128+
data: {
129+
entity: {
130+
id: customerId,
131+
},
132+
tranDate,
133+
...(subsidiaryId && {
134+
subsidiary: {
135+
id: subsidiaryId,
136+
},
137+
}),
138+
...(items && {
139+
item: {
140+
items: utils.parseJson(items),
141+
},
142+
}),
143+
memo,
144+
otherRefNum,
145+
...(additionalFields && utils.parseJson(additionalFields)),
146+
},
147+
});
148+
149+
$.export("$summary", "Successfully created invoice");
150+
return response;
151+
},
152+
};
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import app from "../../netsuite.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "netsuite-create-sales-order",
6+
name: "Create Sales Order",
7+
description: "Creates a new sales order. [See the documentation](https://system.netsuite.com/help/helpcenter/en_US/APIs/REST_API_Browser/record/v1/2025.2/index.html#tag-salesOrder)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
readOnlyHint: false,
12+
destructiveHint: false,
13+
openWorldHint: true,
14+
idempotentHint: false,
15+
},
16+
props: {
17+
app,
18+
customerId: {
19+
propDefinition: [
20+
app,
21+
"customerId",
22+
],
23+
},
24+
tranDate: {
25+
type: "string",
26+
label: "Transaction Date",
27+
description: "The posting date of this sales order (format: `YYYY-MM-DD`). Defaults to today's date if not specified.",
28+
optional: true,
29+
},
30+
subsidiaryId: {
31+
propDefinition: [
32+
app,
33+
"subsidiaryId",
34+
],
35+
optional: true,
36+
},
37+
items: {
38+
propDefinition: [
39+
app,
40+
"items",
41+
],
42+
},
43+
memo: {
44+
type: "string",
45+
label: "Memo",
46+
description: "A memo to describe this sales order. It will appear on reports such as the 2-line Sales Orders register.",
47+
optional: true,
48+
},
49+
otherRefNum: {
50+
type: "string",
51+
label: "PO/Check Number",
52+
description: "If your customer is paying by check, enter the number here. If your customer is issuing a purchase order, enter the PO number here.",
53+
optional: true,
54+
},
55+
additionalFields: {
56+
type: "object",
57+
label: "Additional Fields",
58+
description: "Additional fields to include in the sales order as a JSON object. [See the documentation](https://system.netsuite.com/help/helpcenter/en_US/APIs/REST_API_Browser/record/v1/2025.2/index.html) for available fields.",
59+
optional: true,
60+
},
61+
replace: {
62+
propDefinition: [
63+
app,
64+
"replace",
65+
],
66+
},
67+
propertyNameValidation: {
68+
propDefinition: [
69+
app,
70+
"propertyNameValidation",
71+
],
72+
},
73+
propertyValueValidation: {
74+
propDefinition: [
75+
app,
76+
"propertyValueValidation",
77+
],
78+
},
79+
},
80+
async run({ $ }) {
81+
const {
82+
app,
83+
customerId,
84+
tranDate,
85+
subsidiaryId,
86+
items,
87+
memo,
88+
otherRefNum,
89+
additionalFields,
90+
replace,
91+
propertyNameValidation,
92+
propertyValueValidation,
93+
} = this;
94+
95+
const response = await app.createSalesOrder({
96+
$,
97+
headers: {
98+
"X-NetSuite-PropertyNameValidation": propertyNameValidation,
99+
"X-NetSuite-PropertyValueValidation": propertyValueValidation,
100+
},
101+
params: {
102+
replace,
103+
},
104+
data: {
105+
entity: {
106+
id: customerId,
107+
},
108+
tranDate,
109+
...(subsidiaryId && {
110+
subsidiary: {
111+
id: subsidiaryId,
112+
},
113+
}),
114+
...(items && {
115+
item: {
116+
items: utils.parseJson(items),
117+
},
118+
}),
119+
memo,
120+
otherRefNum,
121+
...(additionalFields && utils.parseJson(additionalFields)),
122+
},
123+
});
124+
125+
$.export("$summary", "Successfully created sales order");
126+
return response;
127+
},
128+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import app from "../../netsuite.app.mjs";
2+
3+
export default {
4+
key: "netsuite-delete-invoice",
5+
name: "Delete Invoice",
6+
description: "Deletes an existing invoice. [See the documentation](https://system.netsuite.com/help/helpcenter/en_US/APIs/REST_API_Browser/record/v1/2025.2/index.html#tag-invoice)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
readOnlyHint: false,
11+
destructiveHint: true,
12+
openWorldHint: true,
13+
idempotentHint: true,
14+
},
15+
props: {
16+
app,
17+
invoiceId: {
18+
propDefinition: [
19+
app,
20+
"invoiceId",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const {
26+
app,
27+
invoiceId,
28+
} = this;
29+
30+
const response = await app.deleteInvoice({
31+
$,
32+
invoiceId,
33+
});
34+
35+
$.export("$summary", `Successfully deleted invoice with ID ${invoiceId}`);
36+
return response;
37+
},
38+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import app from "../../netsuite.app.mjs";
2+
3+
export default {
4+
key: "netsuite-delete-sales-order",
5+
name: "Delete Sales Order",
6+
description: "Deletes an existing sales order in NetSuite. [See the documentation](https://system.netsuite.com/help/helpcenter/en_US/APIs/REST_API_Browser/record/v1/2025.2/index.html)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
readOnlyHint: false,
11+
destructiveHint: true,
12+
openWorldHint: true,
13+
idempotentHint: true,
14+
},
15+
props: {
16+
app,
17+
salesOrderId: {
18+
propDefinition: [
19+
app,
20+
"salesOrderId",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const {
26+
app,
27+
salesOrderId,
28+
} = this;
29+
30+
const response = await app.deleteSalesOrder({
31+
$,
32+
salesOrderId,
33+
});
34+
35+
$.export("$summary", `Successfully deleted sales order with ID ${salesOrderId}`);
36+
return response;
37+
},
38+
};

0 commit comments

Comments
 (0)