{
  "schema": "leumas.docs.page/1",
  "id": "adapter:domain/discount-designer",
  "slug": "adapters/domain/discount-designer",
  "kind": "capabilities",
  "bucket": "package",
  "title": "discount-designer",
  "name": "Discount Designer",
  "eyebrow": null,
  "chip": null,
  "summary": "Discount, promotion and pricing-strategy metrics pack for ecommerce, retail and marketing teams designing offers without eroding margin: apply a percentage-off discount (percentOff) or a...",
  "keywords": [
    "discount-designer",
    "percentoff",
    "fixedoff",
    "bogo",
    "effective",
    "quantity-break",
    "best-tier",
    "bundleprice"
  ],
  "audience": "both",
  "funnel": {
    "product": null,
    "cta": null
  },
  "body": "# discount-designer\n\nPromotion, pricing & discount-strategy intelligence pack. Deterministic promo/margin math for\necommerce, retail and marketing teams, with an optional AI coupon-copy layer on `couponPlan` that\nactivates only when a model is reachable (and silently falls back to the heuristic core otherwise).\n\n**Every discount tool folds in a MARGIN GUARD** — post-discount margin, markup and (optionally) an\nabove-floor check — so a promotion can never quietly go underwater.\n\n**Pricing math only** — not tax, accounting or legal advice.\n\n## Tools\n\n| Tool | Args | Does |\n|---|---|---|\n| `percentOff` | `{price, percent, cost?, marginFloor?}` | % off → discounted price, saved, guard. |\n| `fixedOff` | `{price, amount, cost?}` | $ off (clamped ≥0) + effective %. |\n| `bogo` | `{price, qty, buy?, get?, getDiscount?}` | Buy X Get Y at Z% off; blended unit price + effective %. |\n| `tiered` | `{tiers:[{min,price\\|discount}], qty, options?}` | Volume/quantity-break pricing, flat best-tier or `mode:'incremental'`. |\n| `bundlePrice` | `{items:[{price,cost?,qty?}], bundleDiscount\\|bundlePrice}` | Bundle/kit price + savings + blended margin. |\n| `marginSafeCheck` | `{cost, price, discount, marginFloor?}` | `{ ok }` guardrail + max safe discount / min safe price. |\n| `couponPlan` | `{type, value, avgOrderValue, cost?, usageCap?, validDays?, options?}` | Full coupon spec + per-order economics. `options.advise` adds AI copy. |\n| `loyaltyPoints` | `{spend?, points?, pointsPerCurrency?, redeemRate?, tier?}` | Earn points from spend / value a balance, with tier multipliers. |\n\nOnly `couponPlan` has an AI path; its result is tagged `{ mode: 'heuristic' | 'llm' }`. Any tool given a\n`cost` returns a `guard` block (`unitProfit`, `marginPct`, `markupPct`, `breakEven`, `aboveFloor`).\n\n## Example\n\n```js\nimport pack from './index.js';\nawait pack.adapters.percentOff({ price: 100, percent: 20, cost: 60, marginFloor: 30 });\n// { discountedPrice:80, amountSaved:20, guard:{ marginPct:25, aboveFloor:false, … } }\n\nawait pack.adapters.marginSafeCheck({ cost: 60, price: 100, discount: 20, marginFloor: 30 });\n// { ok:false, resultingMarginPct:25, maxSafeDiscountPct≈14.29, minSafePrice≈85.71, verdict:'Unsafe: …' }\n\nawait pack.adapters.bogo({ price: 40, qty: 4 });\n// buy 1 get 1 free over 4 units → blendedUnitPrice:20, effectivePct:50, …\n```\n\n## DRY boundaries\n\n- **`numbers`** owns generic scalar math; **`finance`** owns time-value-of-money; **`tax`** owns tax\n  lines; **`invoice`** owns billing documents; **`saas-metrics`** owns recurring-revenue metrics. This\n  pack owns *promotion/pricing composition* — percent/fixed off, BOGO, tiered/volume pricing, bundle\n  pricing, margin guardrails, coupon plans and loyalty points — which none of those own.\n- Self-contained: the only cross-pack import is `../_shared/llm.js` for the optional AI layer.\n\n## Hybrid intelligence\n\nEvery deterministic core runs offline with no model. `couponPlan` accepts `options.advise:true` to\nrequest LLM promo copy; with no model configured/reachable it returns the exact same campaign spec\ntagged `mode:'heuristic'`. A down model never throws.\n",
  "source": {
    "path": "shared/engines/adapters/domain/discount-designer/README.md",
    "blobSha": "",
    "commit": "",
    "committedAt": "",
    "provenance": "no-git",
    "bytes": 3367,
    "hash": "0bbdefc19b30871ccdac90fa9325cc9df455d3a8"
  },
  "urls": {
    "html": "/p/adapters/domain/discount-designer",
    "json": "/docs/adapters/domain/discount-designer.json",
    "md": "/docs/adapters/domain/discount-designer.md"
  },
  "links": {
    "composes": [],
    "usedBy": [],
    "product": [],
    "howTo": [],
    "skills": []
  }
}
