Rule gallery

The rules products quietly depend on.

Starter rules from every pack, in plain language. In Invarly each one becomes a query against your own tables.

Balances and payoutsCoupons and promotionsOrders and refundsInventoryPlans and entitlementsAccess and tenancy
pack 01

Balances and payouts

balance-matches-ledger
balance == sum(ledger)

A cached balance always equals the sum of its ledger entries.

catches · Missed writes, migrations, admin tools
payout-equals-net
payout == sales − fees − refunds

Each payout equals what was earned, minus fees and refunds.

catches · Refunds after payout calculation
no-negative-balance
balance >= 0

Accounts without credit never go below zero.

catches · Race conditions, async checks
pack 02

Coupons and promotions

coupon-max-uses
uses <= max_uses

A coupon is never used more than its cap.

catches · Cached or stale counts
one-redemption-per-user
one redemption per user

Single-use codes are redeemed once per customer.

catches · Parallel checkouts, new accounts
discount-within-cart
discount <= cart_total

A discount never exceeds what it applies to.

catches · Stacked promotions
pack 03

Orders and refunds

refunded-at-most-once
refunded at most once

An order is refunded no more than once in total.

catches · Manual and automatic refunds racing
no-ship-after-cancel
cancelled ⇒ not shipped

Cancelled orders never get a shipment.

catches · Late webhooks, retries
payment-has-order
every payment has an order

No money is taken without an order behind it.

catches · Failed order creation after capture
pack 04

Inventory

stock-not-negative
stock >= 0

Stock on hand never goes negative.

catches · Overselling across channels
sold-within-stock
sold <= stock

Units sold never exceed units available.

catches · Stale stock reads
expired-holds-released
expired holds are released

Reservations past their expiry free their units.

catches · Failed cleanup jobs
pack 05

Plans and entitlements

paid-feature-needs-plan
paid feature ⇒ active plan

Paid features are only on for accounts with an active plan.

catches · Downgrades, cached flags
seats-within-plan
seats_used <= plan.seats

Active seats stay within the plan.

catches · SSO and SCIM syncs
trial-end-downgrades
trial ended ⇒ downgraded

Accounts whose trial ended lose trial access.

catches · Missed scheduled jobs
pack 06

Access and tenancy

row-org-matches-parent
row.org_id == parent.org_id

Child rows always belong to the same tenant as their parent.

catches · Imports and jobs using the wrong org
admin-in-approved-list
admin ∈ approved_admins

Admin rights exist only for approved users.

catches · Privilege creep, leftover test users
rls-on-every-table
RLS enabled on every table

Every table with tenant data has a row-level security policy.

catches · New tables shipped without policies

Have a rule that isn’t here?

Tell us. The best ones become part of the starter packs.

Join waitlist