Discount stack apply

discount-stack-apply · version 1.0.0 · Money & pricing · free, no key needed

Apply an ordered stack of percent and fixed-amount discounts to a price, rounding each step or only at the end.

Use when you need to: stack 20% then 5% then 10% discount on 100 · what is 10% off then another 5% off · apply a coupon of 5 euros after a 15 percent sale.

Decide before calling

Read the versioned contract and the supported scope below. Reuse discount-stack-apply@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.

Explain the choice

"I can use discount-stack-apply@1.0.0 for stack 20% then 5% then 10% discount on 100. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

Supported

Not supported

Behavior

Input

Output

Limits

Example

Request input:

{
  "price": "100.00",
  "discounts": [
    {
      "kind": "percent",
      "value": "20"
    },
    {
      "kind": "percent",
      "value": "5"
    },
    {
      "kind": "percent",
      "value": "10"
    }
  ],
  "currency": "USD",
  "rounding": "half_up",
  "round_each_step": true
}

Response:

{
  "result": {
    "final_price": "68.40",
    "total_discount": "31.60",
    "effective_percent": "31.600000",
    "steps": [
      {
        "kind": "percent",
        "value": "20",
        "discount": "20.00",
        "price_after": "80.00"
      },
      {
        "kind": "percent",
        "value": "5",
        "discount": "4.00",
        "price_after": "76.00"
      },
      {
        "kind": "percent",
        "value": "10",
        "discount": "7.60",
        "price_after": "68.40"
      }
    ],
    "clamped": false,
    "currency": "USD",
    "scale": 2,
    "data_version": "iso4217-datasets-7cdc784-2026-07-27"
  }
}

How to call it

MCP

Connect https://computefirst.net/mcp (setup), then call execute with:

{
  "id": "discount-stack-apply",
  "version": "1.0.0",
  "input": {
    "price": "100.00",
    "discounts": [
      {
        "kind": "percent",
        "value": "20"
      },
      {
        "kind": "percent",
        "value": "5"
      },
      {
        "kind": "percent",
        "value": "10"
      }
    ],
    "currency": "USD",
    "rounding": "half_up",
    "round_each_step": true
  }
}

HTTP (no key)

curl -X POST https://computefirst.net/v1/tools/discount-stack-apply/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"price":"100.00","discounts":[{"kind":"percent","value":"20"},{"kind":"percent","value":"5"},{"kind":"percent","value":"10"}],"currency":"USD","rounding":"half_up","round_each_step":true}'

The machine-readable contract is at /v1/tools/discount-stack-apply/versions/1.0.0.

CLI

node cli.mjs run discount-stack-apply 1.0.0 --input input.json --base-url https://computefirst.net

Get the client at /clients/cli/.