couponTermsFor (coupons/coupon-terms.ts)

rekey · apps/api/src/modules/coupons/coupon-terms.ts · typescript · MIT
payments, tag:knn-classified

Normalises and validates coupon discount terms for percent or amount coupons across multiple currencies.

// Source: https://github.com/rekey-dev/rekey | License: MIT | Copyright 2026 Rekey
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * What a coupon takes off, and in which currencies.
 *
 * A PERCENT coupon carries `basisPoints` and applies to a price in any
 * currency, unless `currencies` limits it. An AMOUNT coupon carries one
 * amount per currency and applies only in those. Operators price per country
 * for purchasing power, so an amount is never converted and never reused in
 * another currency.
 *
 * Pure: nothing here reads the database.
 */

import type { Coupon, CouponAmount, CouponDiscountType } from '@prisma/client';
import { chargeableStep, isSellableCurrency, percentageDiscount, validatePriceAmount } from '@rekey.dev/shared-types';
import { RekeyError }

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key