forked from Yara724/api
fanavaran parsian done
This commit is contained in:
@@ -10,3 +10,27 @@ export const REPAIR_LINE_AMOUNT_TOMAN = {
|
||||
|
||||
/** 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user