merge release/dyn-2664_technical-card-nsib

This commit is contained in:
vchikalkin 2023-04-03 10:26:17 +03:00
parent 7ad5ed941f
commit d5362d8275
4 changed files with 135 additions and 41 deletions

View File

@ -116,9 +116,9 @@ export default function (this: ICalculationStore): PreparedData {
preparedValues.subsidySum =
parseInt(values.subsidySum) / (1 + valuesConstants.VAT);
preparedValues.subsidyPaymentNumber =
this.getOption('selectSubsidy')?.evo_get_subsidy_payment;
this.getOption('selectSubsidy')?.evo_get_subsidy_payment || 0;
preparedValues.fuelCardSum =
this.getOption('selectFuelCard')?.evo_graph_price_withoutnds;
this.getOption('selectFuelCard')?.evo_graph_price_withoutnds || 0;
preparedValues.scheduleOfPayments = values.graphType;
preparedValues.comissionRub =
(values.comissionRub as number) / (1 + valuesConstants.VAT);
@ -846,19 +846,7 @@ export default function (this: ICalculationStore): PreparedData {
//
const nsibBaseValue =
((preparedValues.plPrice || 0) -
(preparedValues.importProgramSum || 0) +
(preparedValues.insuranceContract +
(preparedValues.rats || 0) +
(preparedValues.registration || 0) +
(preparedValues.trackerCost || 0) +
(preparedValues.tLMCost || 0) +
(preparedValues.transportTaxGr || 0) +
(preparedValues.tlmCostPaymentSum || 0) +
(preparedValues.gpsCostPaymentSum || 0)) *
preparedValues.leasing0K -
preparedValues.firstPaymentSum -
(values.product === 'LEASING0' ? 0 : preparedValues.discount || 0)) *
((preparedValues.plPrice || 0) - preparedValues.firstPaymentSum) *
(1 + valuesConstants.VAT);
if (nsibBaseValue > valuesConstants.NSIB_MAX) {

View File

@ -43,9 +43,13 @@ const customConditions: Partial<Record<ElementsNames, ValidationCondition>> = {
tbxVehicleTaxInYear: calculationStore => {
const objectRegistration = calculationStore.getValue('objectRegistration');
const vehicleTaxInYear = calculationStore.getValue('vehicleTaxInYear');
const vehicleTaxInLeasingPeriod = calculationStore.getValue(
'vehicleTaxInLeasingPeriod',
);
if (
objectRegistration === 100000001 &&
CONDITIONS.LESS_OR_EQUALS_ZERO(vehicleTaxInYear)
(CONDITIONS.LESS_OR_EQUALS_ZERO(vehicleTaxInLeasingPeriod) ||
CONDITIONS.LESS_OR_EQUALS_ZERO(vehicleTaxInYear))
) {
return {
isValid: false,

View File

@ -404,17 +404,36 @@ const reactionEffects: IReactionEffect[] = [
calculationStore => ({
expression: () => {
const { leasingPeriod } = calculationStore.values;
return leasingPeriod;
const { leasingPeriod, leasingWithoutKasko } = calculationStore.values;
const kaskoInsured =
calculationStore.tables.tableInsurance.rows[1].insured?.value;
const fingapInsured =
calculationStore.tables.tableInsurance.rows[4].insured?.value;
return {
leasingPeriod,
leasingWithoutKasko,
kaskoInsured,
fingapInsured,
};
},
effect: leasingPeriod => {
if (leasingPeriod) {
if (parseInt(leasingPeriod) < 12) {
calculationStore.setValue('insNSIB', null);
calculationStore.setStatus('selectInsNSIB', ElementStatus.Disabled);
} else {
calculationStore.setStatus('selectInsNSIB', ElementStatus.Default);
}
effect: ({
leasingPeriod,
leasingWithoutKasko,
kaskoInsured,
fingapInsured,
}) => {
if (
leasingPeriod < 12 ||
leasingWithoutKasko ||
kaskoInsured === 100_000_001 ||
(fingapInsured === 100_000_001 && leasingPeriod < 36)
) {
calculationStore.setValue('insNSIB', null);
calculationStore.setStatus('selectInsNSIB', ElementStatus.Disabled);
} else {
calculationStore.setStatus('selectInsNSIB', ElementStatus.Default);
}
},
options: {
@ -422,6 +441,69 @@ const reactionEffects: IReactionEffect[] = [
},
}),
calculationStore => ({
expression: () => {
//@ts-ignore
const plPriceRub = calculationStore.plPriceRub();
//@ts-ignore
const discountRub = calculationStore.discountRub();
//@ts-ignore
const importProgramSum: number = calculationStore.importProgramSum();
const {
leasingPeriod,
leaseObjectType,
addEquipmentPrice,
firstPaymentPerc,
} = calculationStore.values;
return {
leasingPeriod,
leaseObjectType,
plPriceRub,
discountRub,
addEquipmentPrice,
importProgramSum,
firstPaymentPerc,
};
},
effect: ({
leasingPeriod = 0,
leaseObjectType,
plPriceRub = 0,
discountRub = 0,
addEquipmentPrice = 0,
importProgramSum = 0,
firstPaymentPerc = 0,
}) => {
calculationStore.setFilter('selectInsNSIB', options =>
options.filter(
x =>
x?.evo_max_period !== undefined &&
x?.evo_min_period !== undefined &&
x.evo_max_period >= leasingPeriod &&
x.evo_min_period <= leasingPeriod &&
x?.evo_max_price !== undefined &&
x?.evo_min_price !== undefined &&
x.evo_max_price >=
plPriceRub - discountRub - importProgramSum + addEquipmentPrice &&
x.evo_min_price <=
plPriceRub - discountRub - importProgramSum + addEquipmentPrice &&
x.evo_leasingobject_types?.find(
x => x.evo_leasingobject_typeid === leaseObjectType,
) &&
x.evo_visible_calc &&
x.evo_min_first_payment_perc !== undefined &&
x.evo_min_first_payment_perc <= firstPaymentPerc &&
x.evo_max_first_payment_perc !== undefined &&
x.evo_max_first_payment_perc >= firstPaymentPerc,
),
);
},
options: {
fireImmediately: true,
},
}),
// calculationStore => ({
// expression: () => {
// const { leasingPeriod } = calculationStore.values;
@ -800,22 +882,28 @@ const reactionEffects: IReactionEffect[] = [
calculationStore => ({
expression: () => {
const { leasingPeriod, leaseObjectType } = calculationStore.values;
return { leasingPeriod, leaseObjectType };
const { leasingPeriod, leaseObjectType, maxMass } =
calculationStore.values;
return { leasingPeriod, leaseObjectType, maxMass };
},
effect: ({ leasingPeriod, leaseObjectType }) => {
calculationStore.setFilter('selectTechnicalCard', options =>
options.filter(
x =>
x?.evo_max_period &&
x?.evo_min_period &&
x.evo_max_period >= leasingPeriod &&
x.evo_min_period <= leasingPeriod &&
x.evo_leasingobject_types?.find(
x => x.evo_leasingobject_typeid === leaseObjectType,
),
),
);
effect: ({ leasingPeriod, leaseObjectType, maxMass }) => {
if (maxMass >= 40000) {
calculationStore.setFilter('selectTechnicalCard', () => []);
calculationStore.setValue('technicalCard', null);
} else {
calculationStore.setFilter('selectTechnicalCard', options =>
options.filter(
x =>
x?.evo_max_period &&
x?.evo_min_period &&
x.evo_max_period >= leasingPeriod &&
x.evo_min_period <= leasingPeriod &&
x.evo_leasingobject_types?.find(
x => x.evo_leasingobject_typeid === leaseObjectType,
),
),
);
}
},
options: {
fireImmediately: true,

View File

@ -116,6 +116,20 @@ query GetMainOptions(
evo_dateto_param: { gte: $currentDate }
) {
...evo_addproduct_types_fields
evo_leasingobject_types {
evo_leasingobject_typeid
}
evo_visible_calc
evo_min_price
evo_max_price
evo_loss_kv
evo_min_first_payment_perc
evo_max_first_payment_perc
evo_models {
evo_modelid
}
evo_evokasko_calc_type
evo_price_service_provider_withoutnds
}
selectTracker: evo_addproduct_types(
statecode: $statecode