Files
yara724api/src/constants/repair-amount-limits.ts
T

37 lines
1.3 KiB
TypeScript

/**
* Per-line and total caps for repair money. All values are **Toman** (no unit conversion in the API).
*/
export const REPAIR_LINE_AMOUNT_TOMAN = { // IT IS RIAL FROM NOW ON
/** Below this is not credible for a priced repair line (e.g. 1,000 Toman). */
MIN: 100_000,
/** Aligns with the total assessment cap; rejects absurd values (e.g. 100bn). */
MAX: 530_000_000,
} as const;
/** Max sum of all priced + factor lines in one V1 expert reply / validation (Rial). */
export const CLAIM_V2_TOTAL_PAYMENT_CAP_TOMAN = REPAIR_LINE_AMOUNT_TOMAN.MAX;
const ENABLED_VALUES = new Set(["1", "true", "yes", "on", "enabled"]);
/**
* Returns null when the V1 claim total cap is disabled.
*
* Set CLAIM_V2_TOTAL_PAYMENT_CAP_ENABLED=true to enforce the cap again.
* Optionally set CLAIM_V2_TOTAL_PAYMENT_CAP_TOMAN to override the amount.
*/
export function getClaimV2TotalPaymentCapToman(): number | null {
const capEnabled = ENABLED_VALUES.has(
String(process.env.CLAIM_V2_TOTAL_PAYMENT_CAP_ENABLED ?? "")
.trim()
.toLowerCase(),
);
if (!capEnabled) return null;
const configuredCap = Number(process.env.CLAIM_V2_TOTAL_PAYMENT_CAP_TOMAN);
return Number.isFinite(configuredCap) && configuredCap > 0
? configuredCap
: CLAIM_V2_TOTAL_PAYMENT_CAP_TOMAN;
}