Prepare quote line items with n8n and a fixed price list

Build an n8n workflow that validates service codes and quantities, calculates line prices and produces a CSV for review. Includes copyable code and test cases.

What you will build

A manual workflow turns known service codes into checked quote lines and a downloadable draft CSV.

Intermediate, includes a short JavaScript step. Start with the supplied example, check the result, then adapt it to your work.

Download the starting files

Two Code node examples, the node order and expected results. This is a copy-and-build guide, not an importable n8n workflow.

How it works

From service codes to draft quote lines

Use a fixed price list to calculate line items. This version does not send a quote.

From service codes to draft quote lines. Use a fixed price list to calculate line items. This version does not send a quote.
  1. You + n8n: Start the workflow. Run the Manual Trigger with the sample lines.
  2. n8n Code node: Read the quote lines. Take the reference, service code and quantity.
  3. n8n Code node: Valid codes and amounts?. Reject unknown codes and invalid quantities. Alternative route (No): Stop with an error. Correct the input. No new CSV should be produced by the rejected run. Main route (Yes): continue to the next step.
  4. n8n: Price and export. Calculate using cents and create the draft CSV.
  5. You: Check the draft lines. Review the file before using it in a customer quote.

Free automation ROI calculator

Could this workflow give you time back?

Compare quote preparation time with an assisted workflow, including the review you need before a quote goes to a customer.

Try the free calculator

Free to use. No signup.

Keep pricing in a rule you can inspect

A request for one setup service and two support units should not need someone to find prices and calculate each line again. This example matches service codes to a fixed sample price list, validates the quantity and creates a draft file.

You need access to an n8n instance where the JavaScript Code node is enabled. Use a manual workflow so it only runs when you ask. This example needs no AI model, email connection, external API key or live customer record.

The prices are fictional and used only for practice. The output contains line items, not a complete customer quote. Taxes, discounts, payment terms and delivery dates are outside this first version.

Create the trigger and sample input

Create a new workflow. Add a Manual Trigger, then a Code node named Sample quote lines. Set the Code node language to JavaScript and its mode to Run Once for All Items. Replace the default code with the sample below.

Run the step and check that its output contains two items. Each has the same quote reference, a service code and a numeric quantity. The shape is important because the next node handles each item as one line.

Code node: Sample quote lines
return [
  { json: { quote_ref: 'DRAFT-104', sku: 'SETUP', quantity: 1 } },
  { json: { quote_ref: 'DRAFT-104', sku: 'SUPPORT', quantity: 2 } }
];

Validate the input before calculating

Add a second Code node called Validate and price. Use JavaScript and Run Once for All Items again. Paste the code below. It uses integer cents for the calculation, then formats the exported values to two decimal places.

The service lookup is exact. An unknown code stops the run instead of quietly using a zero price. Quantity must already be a number, and it must be a whole number between 1 and 1000. The sample also rejects mixed quote references.

Code node: Validate and price
// Run Once for All Items. Fictional practice prices in euro cents.
const prices = { SETUP: 4500, SUPPORT: 2500 };
const items = $input.all();
if (!items.length) throw new Error('The quote has no lines.');
const refs = new Set(items.map(item => item.json.quote_ref));
if (refs.size !== 1) throw new Error('Use one quote reference per run.');

return items.map((item, index) => {
  const { quote_ref, sku, quantity } = item.json;
  if (typeof quote_ref !== 'string' || !/^DRAFT-[0-9]+$/.test(quote_ref)) {
    throw new Error('Use a reference such as DRAFT-104.');
  }
  if (typeof sku !== 'string' || !Object.hasOwn(prices, sku)) {
    throw new Error('Unknown service code on line ' + (index + 1));
  }
  if (typeof quantity !== 'number' || !Number.isInteger(quantity)
      || quantity < 1 || quantity > 1000) {
    throw new Error('Quantity must be a whole number from 1 to 1000.');
  }
  const unitCents = prices[sku];
  return {
    json: {
      quote_ref, sku, quantity, currency: 'EUR',
      unit_price: (unitCents / 100).toFixed(2),
      line_total: (unitCents * quantity / 100).toFixed(2),
      status: 'draft'
    },
    pairedItem: { item: index }
  };
});

Turn the checked lines into a CSV

Connect a Convert to File node after Validate and price. Choose Convert to CSV. Set the output binary field to data and use quote-draft.csv as the filename in the node options. Enable the header row if that option is shown.

Execute the workflow. In the final node’s output, open the binary result and download the CSV. It should contain the quote reference, service code, quantity, currency, unit price, line total and draft status.

The first line is EUR 45.00. Two support units at EUR 25.00 produce EUR 50.00. The sample line totals sum to EUR 95.00. That sum is a check for this guide; the file itself contains individual lines.

Make the wrong inputs fail visibly

Change one value in the sample node, run the workflow and compare the result. Reset the sample before trying the next case. In a rejected run, the export step should not execute. Do not mistake a previous run’s CSV for a newly generated result.

Input changeExpected result
Original two linesLine totals 45.00 and 50.00
SUPPORT quantity becomes 3Second line 75.00; sum 120.00
SKU becomes UNKNOWNValidation error
Quantity becomes 0 or 1.5Validation error
Quantity becomes the text "2"Validation error
Different quote referencesValidation error
Reference starts with a spreadsheet formulaRejected by reference validation

Connect a real source after the rules are clear

The next version could read approved line items from a form or CRM and prices from a controlled catalogue. Preserve the validation step between the incoming data and the generated document. Convert incoming types explicitly instead of relying on whatever the form happened to send.

Use a stable quote ID and save the source price-list version. Decide how revisions work and when an earlier draft becomes obsolete. A CSV copied into a document is useful, but a complete quote workflow also needs approval and a record of what was sent.

Keep sending out of the first workflow. Once the lines and document are correct, add the delivery step with an explicit approval rule and duplicate protection. That way a retried request does not send the same quote twice.

Take this into your own business.

For a connected setup, see zapier, make and n8n. I can adapt the workflow to your tools and the people using it.

If you want to build it yourself, bring your questions to a one-hour consultation or work through it over several coaching sessions.

Ask about your version