forked from Yara724/api
Removed some validations that were unneccesary for expert submit
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { REPAIR_LINE_AMOUNT_TOMAN } from "src/constants/repair-amount-limits";
|
||||
import { DaghiOption } from "src/Types&Enums/claim-request-management/daghi-option.enum";
|
||||
import { TypeOfDamage } from "src/Types&Enums/claim-request-management/type-of-damage.enum";
|
||||
import { parseMoneyAmountToman } from "src/utils/unicode-digits";
|
||||
@@ -59,33 +58,22 @@ export function getExpertReplyPricingValidationError(
|
||||
part.price != null &&
|
||||
(typeof part.price !== "string" || part.price.trim() !== "");
|
||||
|
||||
const splitAmountIsValid = (amount: number | null) =>
|
||||
amount !== null &&
|
||||
(amount === 0 ||
|
||||
(amount >= REPAIR_LINE_AMOUNT_TOMAN.MIN &&
|
||||
amount <= REPAIR_LINE_AMOUNT_TOMAN.MAX));
|
||||
const totalIsValid =
|
||||
totalPayment !== null &&
|
||||
totalPayment >= 0 &&
|
||||
totalPayment <= REPAIR_LINE_AMOUNT_TOMAN.MAX;
|
||||
const priceIsRequired = part.typeOfDamage === TypeOfDamage.Repair;
|
||||
const priceIsValid =
|
||||
!hasPrice || (price !== null && splitAmountIsValid(price));
|
||||
const amountIsValid = (amount: number | null) => amount !== null;
|
||||
const priceIsRequired = part.typeOfDamage === TypeOfDamage.Change;
|
||||
const priceIsValid = !hasPrice || amountIsValid(price);
|
||||
|
||||
if (
|
||||
!splitAmountIsValid(salary) ||
|
||||
!totalIsValid ||
|
||||
(priceIsRequired && !splitAmountIsValid(price)) ||
|
||||
!amountIsValid(salary) ||
|
||||
!amountIsValid(totalPayment) ||
|
||||
(priceIsRequired && !amountIsValid(price)) ||
|
||||
!priceIsValid
|
||||
) {
|
||||
return `${label} requires valid salary and totalPayment; price is also required for '${TypeOfDamage.Repair}' damage. Price and salary may be 0; totalPayment may be 0.`;
|
||||
return `${label} requires valid salary and totalPayment; price is also required for '${TypeOfDamage.Change}' damage. Price, salary, and totalPayment may be 0.`;
|
||||
}
|
||||
|
||||
if (
|
||||
daghi?.option === DaghiOption.RECYCLED_PARTS_VALUE &&
|
||||
(daghiPrice === null ||
|
||||
daghiPrice < REPAIR_LINE_AMOUNT_TOMAN.MIN ||
|
||||
daghiPrice > REPAIR_LINE_AMOUNT_TOMAN.MAX)
|
||||
daghiPrice === null
|
||||
) {
|
||||
return `${label} requires a valid daghi price when option is '${DaghiOption.RECYCLED_PARTS_VALUE}'.`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user