bilig

Quote approval WorkPaper API in Node

Use this page when you want a production-shaped @bilig/headless proof instead of a toy arithmetic workbook.

The smoke runs a quote approval workflow:

  1. Build a two-sheet WorkPaper with Inputs and Summary.
  2. Write quote input cells: units, list price, discount, unit cost, and minimum margin.
  3. Recalculate formulas for net revenue, gross margin, and approval decision.
  4. Serialize the WorkPaper document as JSON.
  5. Restore that JSON and verify the restored workbook still matches the recalculated result.

No browser grid, spreadsheet account, OAuth setup, or repo clone is required.

Run It From An Empty Directory

mkdir bilig-quote-approval
cd bilig-quote-approval
npm init -y
npm pkg set type=module
npm install @bilig/headless
npm install -D tsx typescript @types/node
curl -fsSLo quote-approval-api.ts \
  https://raw.githubusercontent.com/proompteng/bilig/main/examples/serverless-workpaper-api/quote-approval-api.ts
npx tsx quote-approval-api.ts

Expected shape:

{
  "route": "Quote approval WorkPaper API",
  "inputCells": {
    "units": "Inputs!B2",
    "listPrice": "Inputs!B3",
    "discount": "Inputs!B4",
    "unitCost": "Inputs!B5",
    "minimumMargin": "Inputs!B6"
  },
  "before": {
    "netRevenue": 43200,
    "grossMargin": 0.2963,
    "decision": "review"
  },
  "edit": {
    "input": {
      "units": 40,
      "listPrice": 1200,
      "discount": 0.05,
      "unitCost": 760,
      "minimumMargin": 0.3
    },
    "after": {
      "netRevenue": 45600,
      "grossMargin": 0.3333,
      "decision": "approved"
    },
    "checks": {
      "decisionChanged": true,
      "formulasPersisted": true,
      "inputPersisted": true,
      "restoredMatchesAfter": true
    }
  },
  "verified": true,
  "nextStep": "If this proof matches your service or agent workflow, star or bookmark Bilig: https://github.com/proompteng/bilig/stargazers"
}

The exact serialized byte count can move between releases. The important parts are:

What This Proves

This is the service boundary that matters for backend adoption:

That is the shape behind pricing rules, discount approval, payout checks, budget guardrails, import validation, and agent tools that need exact readback.

What This Does Not Prove

It does not prove full Excel compatibility. It does not prove formatting, charts, collaboration, or broad XLSX file fidelity. For those boundaries, read the compatibility limits and the production adoption checklist.

It also does not prove every formula family you need is implemented. If this API shape is right but a formula, persistence shape, or framework boundary blocks a trial, open a concrete adoption note in the workflow feedback discussion.

Use It In A Service

The full example is examples/serverless-workpaper-api. It includes:

Run the wider proof from a repo checkout:

cd examples/serverless-workpaper-api
npm install
npm run test
npm run framework-adapters
npm run persistence-adapters

Next Pages

If this matches a workflow you are evaluating, star the repo as a bookmark: https://github.com/proompteng/bilig/stargazers.

If it almost matches but a gap blocks adoption, use the adoption blocker form: https://github.com/proompteng/bilig/discussions/new?category=general.