Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions components/netsuite/actions/create-invoice/create-invoice.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import app from "../../netsuite.app.mjs";
import utils from "../../common/utils.mjs";

export default {
key: "netsuite-create-invoice",
name: "Create Invoice",
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)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: false,
destructiveHint: false,
openWorldHint: true,
idempotentHint: false,
},
props: {
app,
customerId: {
propDefinition: [
app,
"customerId",
],
},
tranDate: {
type: "string",
label: "Transaction Date",
description: "The posting date of this invoice (format: `YYYY-MM-DD`). Defaults to today's date if not specified.",
optional: true,
},
subsidiaryId: {
propDefinition: [
app,
"subsidiaryId",
],
optional: true,
},
items: {
type: "string[]",
label: "Items",
description: `Array of item objects to add to the invoice. Each item should be a JSON object with the following properties:

**Required:**
- \`item\` - Item ID or reference object (e.g., \`{ "id": "123" }\`)
- \`quantity\` - Quantity to invoice (number)

**Important Optional:**
- \`rate\` - Price per unit (number)
- \`amount\` - Total line amount (number, usually \`quantity * rate\`)
- \`description\` - Custom description for the line item (string)
- \`taxCode\` - Tax code ID or reference object

**Example:**
\`\`\`json
[
{
"item": { "id": "456" },
"quantity": 2,
"rate": 99.99,
"amount": 199.98,
"description": "Professional services",
"taxCode": { "id": "5" }
}
]
\`\`\``,
optional: true,
},
memo: {
type: "string",
label: "Memo",
description: "A memo to describe this invoice.",
optional: true,
},
otherRefNum: {
type: "string",
label: "PO/Reference Number",
description: "Customer's purchase order number or other reference number.",
optional: true,
},
additionalFields: {
type: "object",
label: "Additional Fields",
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.",
optional: true,
},
replace: {
propDefinition: [
app,
"replace",
],
},
propertyNameValidation: {
propDefinition: [
app,
"propertyNameValidation",
],
},
propertyValueValidation: {
propDefinition: [
app,
"propertyValueValidation",
],
},
},
async run({ $ }) {
const {
app,
customerId,
tranDate,
subsidiaryId,
items,
memo,
otherRefNum,
additionalFields,
replace,
propertyNameValidation,
propertyValueValidation,
} = this;

const response = await app.createInvoice({
$,
headers: {
"X-NetSuite-PropertyNameValidation": propertyNameValidation,
"X-NetSuite-PropertyValueValidation": propertyValueValidation,
},
params: {
replace,
},
data: {
entity: {
id: customerId,
},
tranDate,
...(subsidiaryId && {
subsidiary: {
id: subsidiaryId,
},
}),
...(items && {
item: {
items: utils.parseJson(items),
},
}),
memo,
otherRefNum,
...(additionalFields && utils.parseJson(additionalFields)),
},
});

$.export("$summary", "Successfully created invoice");
return response;
},
};
128 changes: 128 additions & 0 deletions components/netsuite/actions/create-sales-order/create-sales-order.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import app from "../../netsuite.app.mjs";
import utils from "../../common/utils.mjs";

export default {
key: "netsuite-create-sales-order",
name: "Create Sales Order",
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)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: false,
destructiveHint: false,
openWorldHint: true,
idempotentHint: false,
},
props: {
app,
customerId: {
propDefinition: [
app,
"customerId",
],
},
tranDate: {
type: "string",
label: "Transaction Date",
description: "The posting date of this sales order (format: `YYYY-MM-DD`). Defaults to today's date if not specified.",
optional: true,
},
subsidiaryId: {
propDefinition: [
app,
"subsidiaryId",
],
optional: true,
},
items: {
propDefinition: [
app,
"items",
],
},
memo: {
type: "string",
label: "Memo",
description: "A memo to describe this sales order. It will appear on reports such as the 2-line Sales Orders register.",
optional: true,
},
otherRefNum: {
type: "string",
label: "PO/Check Number",
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.",
optional: true,
},
additionalFields: {
type: "object",
label: "Additional Fields",
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.",
optional: true,
},
replace: {
propDefinition: [
app,
"replace",
],
},
propertyNameValidation: {
propDefinition: [
app,
"propertyNameValidation",
],
},
propertyValueValidation: {
propDefinition: [
app,
"propertyValueValidation",
],
},
},
async run({ $ }) {
const {
app,
customerId,
tranDate,
subsidiaryId,
items,
memo,
otherRefNum,
additionalFields,
replace,
propertyNameValidation,
propertyValueValidation,
} = this;

const response = await app.createSalesOrder({
$,
headers: {
"X-NetSuite-PropertyNameValidation": propertyNameValidation,
"X-NetSuite-PropertyValueValidation": propertyValueValidation,
},
params: {
replace,
},
data: {
entity: {
id: customerId,
},
tranDate,
...(subsidiaryId && {
subsidiary: {
id: subsidiaryId,
},
}),
...(items && {
item: {
items: utils.parseJson(items),
},
}),
memo,
otherRefNum,
...(additionalFields && utils.parseJson(additionalFields)),
},
});

$.export("$summary", "Successfully created sales order");
return response;
},
};
38 changes: 38 additions & 0 deletions components/netsuite/actions/delete-invoice/delete-invoice.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import app from "../../netsuite.app.mjs";

export default {
key: "netsuite-delete-invoice",
name: "Delete Invoice",
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)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: false,
destructiveHint: true,
openWorldHint: true,
idempotentHint: true,
},
props: {
app,
invoiceId: {
propDefinition: [
app,
"invoiceId",
],
},
},
async run({ $ }) {
const {
app,
invoiceId,
} = this;

const response = await app.deleteInvoice({
$,
invoiceId,
});

$.export("$summary", `Successfully deleted invoice with ID ${invoiceId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import app from "../../netsuite.app.mjs";

export default {
key: "netsuite-delete-sales-order",
name: "Delete Sales Order",
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)",
version: "0.0.1",
type: "action",
annotations: {
readOnlyHint: false,
destructiveHint: true,
openWorldHint: true,
idempotentHint: true,
},
props: {
app,
salesOrderId: {
propDefinition: [
app,
"salesOrderId",
],
},
},
async run({ $ }) {
const {
app,
salesOrderId,
} = this;

const response = await app.deleteSalesOrder({
$,
salesOrderId,
});

$.export("$summary", `Successfully deleted sales order with ID ${salesOrderId}`);
return response;
},
};
Loading
Loading