forked from Yara724/api
37 lines
1.2 KiB
TypeScript
37 lines
1.2 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 = {
|
|
/** Below this is not credible for a priced repair line (e.g. 1,000 Toman). */
|
|
MIN: 10_000,
|
|
/** Aligns with the total assessment cap; rejects absurd values (e.g. 100bn). */
|
|
MAX: 53_000_000,
|
|
} as const;
|
|
|
|
/** Max sum of all priced + factor lines in one expert reply / validation (Toman). */
|
|
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 claim v2 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;
|
|
}
|