---
title: "Runs the price rule engine over a proposed set of line items without persisting. Used by the invoice grid to show rule discounts (BOGO, spend thresholds, etc.) live as the user edits, while keeping the server as the single source of truth for the math — no client-side evaluator to drift."
method: POST
path: "/Invoices/preview-rules"
tags: ["Invoices"]
---

# Runs the price rule engine over a proposed set of line items without persisting. Used by the invoice grid to show rule discounts (BOGO, spend thresholds, etc.) live as the user edits, while keeping the server as the single source of truth for the math — no client-side evaluator to drift.

`POST /Invoices/preview-rules`

## Request

- Base URL: `https://api.clinicos.vet/backend/business`
- URL: `https://api.clinicos.vet/backend/business/Invoices/preview-rules`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/clinicos/apis/pawthosx-business-api-v1/docs/Invoices/preview-rules/post.ts> (a function with typed inputs; its response is checked against the schema)

## Request body

- PreviewPriceRulesRequestDto: Request body for `POST /invoices/preview-rules`. The client sends its proposed line items; the server runs the engine over them without persisting and returns the per-line + order-level rule discounts.
  - `items` PreviewLineItemDto[]
    - `localId` string: Caller-supplied id used to map results back. Not persisted.
    - `unitPrice` union
      - number, double
      - string, double
    - `quantity` union
      - number, double
      - string, double
    - `discount` union
      - number, double
      - string, double
    - `dispenseFee` union
      - number, double
      - string, double
    - `groupCodeId` string, nullable
    - `serviceCatalogItemId` string, nullable
    - `retailItemId` string, nullable
    - `inventoryItemId` string, nullable
  - `clientId` string, nullable: Estimate's client, used to resolve customer-tag rule gating in preview. Optional — when absent, client-tag-gated rules are simply not previewed.
  - `patientId` string, nullable: Invoice's patient — their tags also satisfy tag gating (ITE-660: plan-member pricing is a patient-assigned tag). Optional, same preview-only semantics.

## Response `200`

OK

- PreviewPriceRulesResponseDto
  - `lineRuleDiscounts` LineRuleDiscountDto[]
    - `localId` string
    - `amount` union
      - number, double
      - string, double
  - `ruleOrderDiscountAmount` union
    - number, double
    - string, double

## Changes

- **2026-09-11** `503cd0546309`: 3 info
  - added the new optional request property `patientId` (media type: application/json)
  - added the new optional request property `patientId` (media type: text/json)
  - added the new optional request property `patientId` (media type: application/*+json)

[Operation history](https://skmtc.dev/clinicos/apis/pawthosx-business-api-v1/changes/Invoices/preview-rules/post.md)

---

[API](https://skmtc.dev/clinicos/apis/pawthosx-business-api-v1.md) - [All operations](https://skmtc.dev/clinicos/apis/pawthosx-business-api-v1/llms.txt) - [OpenAPI document](https://skmtc.dev/clinicos/apis/pawthosx-business-api-v1/revisions/099cf36186e0?raw)
