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,
});
Comment on lines +24 to +33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "netsuite.app.mjs" | head -5

Repository: PipedreamHQ/pipedream

Length of output: 103


🏁 Script executed:

cat -n ./components/netsuite/netsuite.app.mjs | head -150

Repository: PipedreamHQ/pipedream

Length of output: 5400


🏁 Script executed:

rg -n "deleteInvoice|_makeRequest" ./components/netsuite/netsuite.app.mjs | head -30

Repository: PipedreamHQ/pipedream

Length of output: 561


🏁 Script executed:

sed -n '187,195p' ./components/netsuite/netsuite.app.mjs

Repository: PipedreamHQ/pipedream

Length of output: 268


🏁 Script executed:

sed -n '265,273p' ./components/netsuite/netsuite.app.mjs

Repository: PipedreamHQ/pipedream

Length of output: 253


🏁 Script executed:

sed -n '197,210p' ./components/netsuite/netsuite.app.mjs

Repository: PipedreamHQ/pipedream

Length of output: 366


🏁 Script executed:

rg -n "createInvoice|updateInvoice" ./components/netsuite/netsuite.app.mjs

Repository: PipedreamHQ/pipedream

Length of output: 123


🏁 Script executed:

sed -n '249,273p' ./components/netsuite/netsuite.app.mjs

Repository: PipedreamHQ/pipedream

Length of output: 589


🏁 Script executed:

cat -n ./components/netsuite/actions/delete-invoice/delete-invoice.mjs

Repository: PipedreamHQ/pipedream

Length of output: 1179


🏁 Script executed:

cat -n ./components/netsuite/actions/create-invoice/create-invoice.mjs | head -50

Repository: PipedreamHQ/pipedream

Length of output: 1941


🏁 Script executed:

sed -n '60,90p' ./components/netsuite/actions/create-invoice/create-invoice.mjs

Repository: PipedreamHQ/pipedream

Length of output: 935


🏁 Script executed:

sed -n '85,130p' ./components/netsuite/actions/create-invoice/create-invoice.mjs

Repository: PipedreamHQ/pipedream

Length of output: 971


🏁 Script executed:

sed -n '20,60p' ./components/netsuite/actions/update-invoice/update-invoice.mjs

Repository: PipedreamHQ/pipedream

Length of output: 1118


🏁 Script executed:

grep -n "async run" ./components/netsuite/actions/update-invoice/update-invoice.mjs

Repository: PipedreamHQ/pipedream

Length of output: 89


🏁 Script executed:

sed -n '118,155p' ./components/netsuite/actions/update-invoice/update-invoice.mjs

Repository: PipedreamHQ/pipedream

Length of output: 896


🏁 Script executed:

rg -A 3 "async run\(\{ \$ \}\)" ./components/netsuite/actions/*/update-invoice/update-invoice.mjs | head -20

Repository: PipedreamHQ/pipedream

Length of output: 170


$ is ignored by deleteInvoice with current app signature

deleteInvoice is declared as ({ invoiceId, opts } = {}), so passing { $, invoiceId } here sets only invoiceId; $ is dropped and _makeRequest falls back to $ = this. The DELETE request will still execute, but step context and logging are lost. To fix, nest $ under opts:

    const response = await app.deleteInvoice({
-     $,
      invoiceId,
+     opts: {
+       $,
+     },
    });

Alternatively, update deleteInvoice in netsuite.app.mjs to accept top-level options like createInvoice does (signature: createInvoice(opts = {})), which would provide consistency across all invoice methods.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async run({ $ }) {
const {
app,
invoiceId,
} = this;
const response = await app.deleteInvoice({
$,
invoiceId,
});
async run({ $ }) {
const {
app,
invoiceId,
} = this;
const response = await app.deleteInvoice({
invoiceId,
opts: {
$,
},
});
🤖 Prompt for AI Agents
In components/netsuite/actions/delete-invoice/delete-invoice.mjs around lines 24
to 33, the call to app.deleteInvoice currently passes $ at the top-level which
is ignored because deleteInvoice signature is ({ invoiceId, opts } = {}); update
the call to pass the step context inside opts (i.e., call deleteInvoice with
invoiceId and opts: { $ }) so _makeRequest receives the step context and logging
remains intact; alternatively, modify netsuite.app.mjs to change deleteInvoice
to accept a single opts object similar to createInvoice (signature like
deleteInvoice(opts = {})) so top-level options including $ are honored
consistently across invoice methods.


$.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