selectTechnicalCard reactions
This commit is contained in:
parent
97527caefb
commit
14134e0dd9
@ -308,11 +308,11 @@ const sections: ISection[] = [
|
||||
{
|
||||
elements: [
|
||||
'selectRegistration',
|
||||
'selectTechnicalCard',
|
||||
'selectInsNSIB',
|
||||
'radioRequirementTelematic',
|
||||
'selectTracker',
|
||||
// 'selectTelematic',
|
||||
// 'selectTechnicalCard',
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@ -195,6 +195,9 @@ const query = gql`
|
||||
evo_min_period
|
||||
evo_controls_program
|
||||
evo_helpcard_type
|
||||
evo_leasingobject_types {
|
||||
evo_leasingobject_typeid
|
||||
}
|
||||
}
|
||||
selectTarif: evo_tarifs(
|
||||
statecode: $statecode
|
||||
|
||||
@ -3,6 +3,7 @@ import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { ElementStatus } from 'core/types/statuses';
|
||||
import { calcPrice, calculatePerc, calculateRub } from '../lib/tools';
|
||||
import { round } from 'lodash';
|
||||
|
||||
const reactionEffects: IReactionEffect[] = [
|
||||
// calculationStore => ({
|
||||
@ -1095,7 +1096,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
) {
|
||||
const max_sale_bonus =
|
||||
evo_coefficient_bonus.evo_sot_coefficient * 100;
|
||||
if (parseFloat(saleBonus) > max_sale_bonus) {
|
||||
if (parseFloat(saleBonus) > round(max_sale_bonus, 2)) {
|
||||
calculationStore.setValidation('tbxSaleBonus', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
@ -1768,6 +1769,80 @@ const reactionEffects: IReactionEffect[] = [
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { leasingPeriod, leaseObjectType } = calculationStore.values;
|
||||
return { leasingPeriod, leaseObjectType };
|
||||
},
|
||||
effect: ({ leasingPeriod, leaseObjectType }) => {
|
||||
calculationStore.setFilter('selectTechnicalCard', options =>
|
||||
options.filter(
|
||||
x =>
|
||||
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,
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { leaseObjectType } = calculationStore.values;
|
||||
return { leaseObjectType };
|
||||
},
|
||||
effect: () => {
|
||||
calculationStore.setValue('technicalCard', null);
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { leasingPeriod } = calculationStore.values;
|
||||
return leasingPeriod;
|
||||
},
|
||||
effect: () => {
|
||||
const { technicalCard: technicalCardId } = calculationStore.values;
|
||||
|
||||
const technicalCard = calculationStore.options.selectTechnicalCard?.find(
|
||||
x => x.evo_addproduct_typeid === technicalCardId,
|
||||
);
|
||||
|
||||
if (technicalCard) {
|
||||
const selectTechnicalCard_filter = calculationStore.getFilter(
|
||||
'selectTechnicalCard',
|
||||
);
|
||||
|
||||
const selectTechnicalCard_options = calculationStore.getOptions(
|
||||
'selectTechnicalCard',
|
||||
);
|
||||
|
||||
if (selectTechnicalCard_filter && selectTechnicalCard_options) {
|
||||
const new_technicalCard = selectTechnicalCard_filter(
|
||||
selectTechnicalCard_options,
|
||||
).find(
|
||||
x => x && x.evo_helpcard_type === technicalCard.evo_helpcard_type,
|
||||
);
|
||||
|
||||
if (new_technicalCard) {
|
||||
calculationStore.setValue(
|
||||
'technicalCard',
|
||||
new_technicalCard.evo_addproduct_typeid,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
export default reactionEffects;
|
||||
|
||||
@ -10,7 +10,6 @@ const initialStatuses: TElements<ElementStatus> = {
|
||||
tbxInsKaskoPriceLeasePeriod: ElementStatus.Disabled,
|
||||
selectClientType: ElementStatus.Disabled,
|
||||
selectTelematic: ElementStatus.Disabled,
|
||||
selectTechnicalCard: ElementStatus.Disabled,
|
||||
tbxImporterRewardRub: ElementStatus.Disabled,
|
||||
tbxImporterRewardPerc: ElementStatus.Disabled,
|
||||
tbxMaxPriceChange: ElementStatus.Disabled,
|
||||
|
||||
Reference in New Issue
Block a user