merge refactor/store-functions
This commit is contained in:
parent
e36a5e3b52
commit
d85e751ec2
@ -1,8 +1,9 @@
|
|||||||
|
import { elementsValues } from 'client/Containers/Calculation/lib/elements/values';
|
||||||
import initialFilters from 'client/stores/CalculationStore/config/initialFilters';
|
import initialFilters from 'client/stores/CalculationStore/config/initialFilters';
|
||||||
import initialOptions from 'client/stores/CalculationStore/config/initialOptions';
|
import initialOptions from 'client/stores/CalculationStore/config/initialOptions';
|
||||||
import initialStatuses from 'client/stores/CalculationStore/config/initialStatuses';
|
import initialStatuses from 'client/stores/CalculationStore/config/initialStatuses';
|
||||||
import initialValues from 'client/stores/CalculationStore/config/initialValues';
|
import initialValues from 'client/stores/CalculationStore/config/initialValues';
|
||||||
import { isNil, mergeWith } from 'lodash';
|
import { find, isNil, mergeWith } from 'lodash';
|
||||||
|
|
||||||
const valuesData = {
|
const valuesData = {
|
||||||
values: initialValues,
|
values: initialValues,
|
||||||
@ -43,8 +44,40 @@ const valuesActions = {
|
|||||||
this.validations[elementName] = validation;
|
this.validations[elementName] = validation;
|
||||||
},
|
},
|
||||||
|
|
||||||
getOptions(elementName) {
|
getOption(elementName, fields) {
|
||||||
return this.options[elementName];
|
if (!this.options.elementName) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!fields) {
|
||||||
|
return this.getCurrentOption(elementName);
|
||||||
|
}
|
||||||
|
return this.options[elementName].find(option => {
|
||||||
|
return Object.keys(fields).every(
|
||||||
|
fieldName => option[fieldName] === fields[fieldName],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getOptions(elementName, fields) {
|
||||||
|
if (!this.options.elementName) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!fields) return this.options[elementName];
|
||||||
|
return this.options[elementName].filter(option => {
|
||||||
|
return Object.keys(fields).every(
|
||||||
|
fieldName => option[fieldName] === fields[fieldName],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getCurrentOption(elementName) {
|
||||||
|
const valueName = elementsValues[elementName];
|
||||||
|
const currentValue = this.values[valueName];
|
||||||
|
if (!currentValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const currentOption = this.options[elementName].find(
|
||||||
|
x => x.value === currentValue,
|
||||||
|
);
|
||||||
|
return currentOption;
|
||||||
},
|
},
|
||||||
setOptions(elementName, options) {
|
setOptions(elementName, options) {
|
||||||
this.options[elementName] = options;
|
this.options[elementName] = options;
|
||||||
|
|||||||
@ -4,16 +4,11 @@ export default ({
|
|||||||
}: {
|
}: {
|
||||||
calculationStore: ICalculationStore;
|
calculationStore: ICalculationStore;
|
||||||
}): any => {
|
}): any => {
|
||||||
const selectedTarifId = calculationStore.values.tarif;
|
const tarif = calculationStore.getOption('selectTarif');
|
||||||
if (selectedTarifId) {
|
if (tarif) {
|
||||||
const tarif = calculationStore.options.selectTarif?.find(
|
return {
|
||||||
x => x.evo_tarifid === selectedTarifId,
|
minCashflowMSFONominal: tarif.evo_min_irr,
|
||||||
);
|
maxCashflowMSFONominal: tarif.evo_max_irr,
|
||||||
if (tarif) {
|
};
|
||||||
return {
|
|
||||||
minCashflowMSFONominal: tarif.evo_min_irr,
|
|
||||||
maxCashflowMSFONominal: tarif.evo_max_irr,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -194,21 +194,16 @@ const validatePaymentsTable = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const highSeasonStart = parseInt(
|
const highSeasonStart = parseInt(
|
||||||
CalculationStore.options.selectHighSeasonStart?.find(
|
CalculationStore.getOption('selectHighSeasonStart')?.name || '2',
|
||||||
x => x.value === highSeasonStartId,
|
|
||||||
)?.name || '2',
|
|
||||||
);
|
);
|
||||||
const shiftNumber = highSeasonStart - 2;
|
const shiftNumber = highSeasonStart - 2;
|
||||||
const middleRows = payments.slice(1, PERIODS_NUMBER + 1);
|
const middleRows = payments.slice(1, PERIODS_NUMBER + 1);
|
||||||
const unshiftedMiddleRows = shiftRight(middleRows, shiftNumber);
|
const unshiftedMiddleRows = shiftRight(middleRows, shiftNumber);
|
||||||
|
|
||||||
const { seasonType } = CalculationStore.values;
|
const seasonTypeOptions = CalculationStore.getOption('selectSeasonType');
|
||||||
if (!seasonType) {
|
if (!seasonTypeOptions) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const seasonTypeOptions = CalculationStore.options.selectSeasonType?.find(
|
|
||||||
x => x.value === seasonType,
|
|
||||||
);
|
|
||||||
const startPositions =
|
const startPositions =
|
||||||
seasonTypeOptions && seasonTypeOptions.startPositions;
|
seasonTypeOptions && seasonTypeOptions.startPositions;
|
||||||
|
|
||||||
|
|||||||
@ -91,7 +91,7 @@ export default async () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
CalculationStore.setValue('recalcWithRevision', false);
|
CalculationStore.setValue('recalcWithRevision', false);
|
||||||
let quotes = toJS(CalculationStore.options.selectQuote);
|
let quotes = toJS(CalculationStore.getOptions('selectQuote'));
|
||||||
quotes = [new_quote].concat(quotes);
|
quotes = [new_quote].concat(quotes);
|
||||||
|
|
||||||
const { quote: selected_quoteid } = CalculationStore.values;
|
const { quote: selected_quoteid } = CalculationStore.values;
|
||||||
|
|||||||
@ -145,8 +145,11 @@ const autorunEffects: IAutorunEffect[] = [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const leaseObjectType = calculationStore.options.selectLeaseObjectType?.find(
|
const leaseObjectType = calculationStore.getOption(
|
||||||
x => x.evo_leasingobject_typeid === leaseObjectTypeId,
|
'selectLeaseObjectType',
|
||||||
|
{
|
||||||
|
evo_leasingobject_typeid: leaseObjectTypeId,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (leaseObjectType) {
|
if (leaseObjectType) {
|
||||||
|
|||||||
@ -8,64 +8,52 @@ const LEASE_OBJECT_RISK = {
|
|||||||
|
|
||||||
const computedEffects = {
|
const computedEffects = {
|
||||||
// leadName() {
|
// leadName() {
|
||||||
// const leadId = this.values.lead;
|
// const leadid = this.values.lead;
|
||||||
// if (this.options.selectLead && this.options.selectLead.length) {
|
// if (this.options.selectLead && this.options.selectLead.length) {
|
||||||
// const lead = this.options.selectLead?.find(x => x.leadid === leadId);
|
// const lead = this.getOption('selectLead', { leadid });
|
||||||
// if (lead) {
|
// if (lead) {
|
||||||
// return lead.name;
|
// return lead.name;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
// opportunityName() {
|
// opportunityName() {
|
||||||
// const opportunityId = this.values.opportunity;
|
// const opportunityid = this.values.opportunity;
|
||||||
// if (
|
// if (
|
||||||
// this.options.selectOpportunity &&
|
// this.options.selectOpportunity &&
|
||||||
// this.options.selectOpportunity.length > 0
|
// this.options.selectOpportunity.length > 0
|
||||||
// ) {
|
// ) {
|
||||||
// const opportunity = this.options.selectOpportunity?.find(
|
// const opportunity = this.getOption('selectOpportunity', {
|
||||||
// x => x.opportunityid === opportunityId,
|
// opportunityid,
|
||||||
// );
|
// });
|
||||||
// if (opportunity) {
|
// if (opportunity) {
|
||||||
// return opportunity.name;
|
// return opportunity.name;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
leaseObjectRiskName() {
|
leaseObjectRiskName() {
|
||||||
const configurationId = this.values.configuration;
|
const configuration = this.getOption('selectConfiguration');
|
||||||
if (configurationId) {
|
if (configuration) {
|
||||||
const configuration = this.options.selectConfiguration?.find(
|
if (configuration.evo_leasingobject_risk) {
|
||||||
x => x.evo_equipmentid === configurationId,
|
const res = LEASE_OBJECT_RISK[configuration.evo_leasingobject_risk];
|
||||||
);
|
return res;
|
||||||
if (configuration) {
|
|
||||||
if (configuration.evo_leasingobject_risk) {
|
|
||||||
const res = LEASE_OBJECT_RISK[configuration.evo_leasingobject_risk];
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const modelId = this.values.model;
|
const model = this.getOption('selectModel');
|
||||||
if (modelId) {
|
if (model) {
|
||||||
const model = this.options.selectModel?.find(
|
const evo_leasingobject_risk = model.evo_leasingobject_risk;
|
||||||
x => x.evo_modelid === modelId,
|
return LEASE_OBJECT_RISK[evo_leasingobject_risk];
|
||||||
);
|
|
||||||
if (model) {
|
|
||||||
const evo_leasingobject_risk = model.evo_leasingobject_risk;
|
|
||||||
return LEASE_OBJECT_RISK[evo_leasingobject_risk];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
insKaskoPriceLeasePeriod() {
|
insKaskoPriceLeasePeriod() {
|
||||||
return customValues.insKaskoPriceLeasePeriod.call(this).toFixed(2);
|
return customValues.insKaskoPriceLeasePeriod.call(this).toFixed(2);
|
||||||
},
|
},
|
||||||
irrInfo() {
|
irrInfo() {
|
||||||
const tarif = this.options.selectTarif?.find(
|
const tarif = this.getOption('selectTarif');
|
||||||
x => x.evo_tarifid === this.values.tarif,
|
|
||||||
);
|
|
||||||
if (tarif) {
|
if (tarif) {
|
||||||
return `Min: ${tarif.evo_min_irr}% - Max: ${tarif.evo_max_irr}%`;
|
return `Min: ${tarif.evo_min_irr}% - Max: ${tarif.evo_max_irr}%`;
|
||||||
}
|
}
|
||||||
return '-'
|
return '-';
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -85,17 +85,20 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
|||||||
|
|
||||||
let accountidData;
|
let accountidData;
|
||||||
if (lead) {
|
if (lead) {
|
||||||
const selected_lead = calculationStore.options.selectLead?.find(
|
const selected_lead = calculationStore.getOptions('selectLead', {
|
||||||
x => x.value === lead,
|
value: lead,
|
||||||
);
|
});
|
||||||
if (selected_lead && selected_lead.accountidData) {
|
if (selected_lead && selected_lead.accountidData) {
|
||||||
accountidData = selected_lead.accountidData;
|
accountidData = selected_lead.accountidData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opportunity) {
|
if (opportunity) {
|
||||||
const selected_opportunity = calculationStore.options.selectOpportunity?.find(
|
const selected_opportunity = calculationStore.getOption(
|
||||||
x => x.value === opportunity,
|
'selectOpportunity',
|
||||||
|
{
|
||||||
|
value: opportunity,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (selected_opportunity && selected_opportunity.accountidData) {
|
if (selected_opportunity && selected_opportunity.accountidData) {
|
||||||
accountidData = selected_opportunity.accountidData;
|
accountidData = selected_opportunity.accountidData;
|
||||||
@ -110,8 +113,11 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (evo_region_fias_id) {
|
if (evo_region_fias_id) {
|
||||||
const region = calculationStore.options.selectRegionRegistration?.find(
|
const region = calculationStore.getOption(
|
||||||
x => x.evo_fias_id === evo_region_fias_id,
|
'selectRegionRegistration',
|
||||||
|
{
|
||||||
|
evo_fias_id: evo_region_fias_id,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (region) {
|
if (region) {
|
||||||
regionRegistration = region.evo_regionid;
|
regionRegistration = region.evo_regionid;
|
||||||
@ -196,9 +202,9 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (evo_city_fias_id) {
|
if (evo_city_fias_id) {
|
||||||
const city = calculationStore.options.selectTownRegistration?.find(
|
const city = calculationStore.getOption('selectTownRegistration', {
|
||||||
x => x.evo_fias_id === evo_city_fias_id,
|
evo_fias_id: evo_city_fias_id,
|
||||||
);
|
});
|
||||||
if (city) {
|
if (city) {
|
||||||
townRegistration = city.evo_townid;
|
townRegistration = city.evo_townid;
|
||||||
}
|
}
|
||||||
@ -237,9 +243,9 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const base_product = calculationStore?.options?.selectProduct?.find(
|
const base_product = calculationStore.getOption('selectProduct', {
|
||||||
x => x.evo_baseproductid === newValues.product,
|
evo_baseproductid: newValues.product,
|
||||||
);
|
});
|
||||||
|
|
||||||
const addProducts = Object.assign(
|
const addProducts = Object.assign(
|
||||||
{},
|
{},
|
||||||
@ -266,13 +272,16 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
|||||||
const {
|
const {
|
||||||
evo_programsolution,
|
evo_programsolution,
|
||||||
evo_client_riskid,
|
evo_client_riskid,
|
||||||
} = calculationStore.options.selectOpportunity?.find(
|
} = calculationStore.getOption('selectOpportunity', {
|
||||||
x => x.value === opportunity,
|
value: opportunity,
|
||||||
);
|
});
|
||||||
|
|
||||||
if (evo_programsolution === 100000000) {
|
if (evo_programsolution === 100000000) {
|
||||||
const midClientRisk = calculationStore.options.selectClientRisk?.find(
|
const midClientRisk = calculationStore.getOption(
|
||||||
x => x.evo_id === '2',
|
'selectClientRisk',
|
||||||
|
{
|
||||||
|
evo_id: '2',
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (midClientRisk) {
|
if (midClientRisk) {
|
||||||
clientRisk = midClientRisk.evo_client_riskid;
|
clientRisk = midClientRisk.evo_client_riskid;
|
||||||
|
|||||||
@ -24,10 +24,10 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
const { opportunity } = calculationStore.values;
|
const { opportunity } = calculationStore.values;
|
||||||
return opportunity;
|
return opportunity;
|
||||||
},
|
},
|
||||||
effect: opportunityId => {
|
effect: opportunityid => {
|
||||||
const opportunity = calculationStore.options.selectOpportunity?.find(
|
const opportunity = calculationStore.getOption('selectOpportunity', {
|
||||||
x => x.opportunityid === opportunityId,
|
opportunityid,
|
||||||
);
|
});
|
||||||
|
|
||||||
if (opportunity) {
|
if (opportunity) {
|
||||||
calculationStore.setValue('lead', opportunity.evo_leadid);
|
calculationStore.setValue('lead', opportunity.evo_leadid);
|
||||||
@ -173,22 +173,20 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
ElementStatus.Disabled,
|
ElementStatus.Disabled,
|
||||||
);
|
);
|
||||||
|
|
||||||
const leadId = calculationStore.values.lead;
|
const lead = calculationStore.getOption('selectLead');
|
||||||
if (leadId) {
|
if (lead && !lead.evo_double_agent_accountid) {
|
||||||
const lead = calculationStore.options.selectLead?.find(
|
calculationStore.setValue('calcDoubleAgent', null);
|
||||||
x => x.leadid === leadId,
|
calculationStore.setStatus(
|
||||||
|
'selectCalcDoubleAgent',
|
||||||
|
ElementStatus.Disabled,
|
||||||
);
|
);
|
||||||
if (lead && !lead.evo_double_agent_accountid) {
|
|
||||||
calculationStore.setValue('calcDoubleAgent', null);
|
|
||||||
calculationStore.setStatus(
|
|
||||||
'selectCalcDoubleAgent',
|
|
||||||
ElementStatus.Disabled,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const indAgentRewardCondition = calculationStore.options.selectIndAgentRewardCondition?.find(
|
const indAgentRewardCondition = calculationStore.getOption(
|
||||||
x => x.evo_reward_conditionid === indAgentRewardConditionId,
|
'selectIndAgentRewardCondition',
|
||||||
|
{
|
||||||
|
evo_reward_conditionid: indAgentRewardConditionId,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (indAgentRewardCondition) {
|
if (indAgentRewardCondition) {
|
||||||
if (calculationProcess.process !== Process.LoadKp) {
|
if (calculationProcess.process !== Process.LoadKp) {
|
||||||
@ -206,10 +204,12 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
'selectCalcDoubleAgent',
|
'selectCalcDoubleAgent',
|
||||||
ElementStatus.Default,
|
ElementStatus.Default,
|
||||||
);
|
);
|
||||||
const doubleAgent = calculationStore.options.selectCalcDoubleAgent?.find(
|
|
||||||
x =>
|
const doubleAgent = calculationStore.getOption(
|
||||||
x.accountid ===
|
'selectCalcDoubleAgent',
|
||||||
indAgentRewardCondition?.evo_double_agent_accountid,
|
{
|
||||||
|
accountid: indAgentRewardCondition?.evo_double_agent_accountid,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (doubleAgent) {
|
if (doubleAgent) {
|
||||||
calculationStore.setOptions('selectCalcDoubleAgent', [
|
calculationStore.setOptions('selectCalcDoubleAgent', [
|
||||||
@ -248,22 +248,26 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
ElementStatus.Disabled,
|
ElementStatus.Disabled,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const calcDoubleAgentRewardCondition = calculationStore.options.selectCalcDoubleAgentRewardCondition?.find(
|
const calcDoubleAgentRewardCondition = calculationStore.getOption(
|
||||||
x => x.evo_reward_conditionid === calcDoubleAgentRewardConditionId,
|
'selectCalcDoubleAgentRewardCondition',
|
||||||
|
{
|
||||||
|
evo_reward_conditionid: calcDoubleAgentRewardConditionId,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (calcDoubleAgentRewardCondition) {
|
if (
|
||||||
if (calcDoubleAgentRewardCondition.evo_reward_summ) {
|
calcDoubleAgentRewardCondition &&
|
||||||
if (calculationProcess.process !== Process.LoadKp) {
|
calcDoubleAgentRewardCondition.evo_reward_summ
|
||||||
calculationStore.setValue(
|
) {
|
||||||
'calcDoubleAgentRewardSumm',
|
if (calculationProcess.process !== Process.LoadKp) {
|
||||||
calcDoubleAgentRewardCondition.evo_reward_summ,
|
calculationStore.setValue(
|
||||||
);
|
'calcDoubleAgentRewardSumm',
|
||||||
}
|
calcDoubleAgentRewardCondition.evo_reward_summ,
|
||||||
calculationStore.setStatus(
|
|
||||||
'tbxCalcDoubleAgentRewardSumm',
|
|
||||||
ElementStatus.Default,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
calculationStore.setStatus(
|
||||||
|
'tbxCalcDoubleAgentRewardSumm',
|
||||||
|
ElementStatus.Default,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -272,6 +276,7 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
//TODO: compose
|
||||||
(calculationStore, calculationProcess) => ({
|
(calculationStore, calculationProcess) => ({
|
||||||
expression: () => {
|
expression: () => {
|
||||||
const { calcBrokerRewardCondition } = calculationStore.values;
|
const { calcBrokerRewardCondition } = calculationStore.values;
|
||||||
@ -285,22 +290,26 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
ElementStatus.Disabled,
|
ElementStatus.Disabled,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const calcBrokerRewardCondition = calculationStore.options.selectCalcBrokerRewardCondition?.find(
|
const calcBrokerRewardCondition = calculationStore.getOption(
|
||||||
x => x.evo_reward_conditionid === calcBrokerRewardConditionId,
|
'selectCalcBrokerRewardCondition',
|
||||||
|
{
|
||||||
|
evo_reward_conditionid: calcBrokerRewardConditionId,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (calcBrokerRewardCondition) {
|
if (
|
||||||
if (calcBrokerRewardCondition.evo_reward_summ) {
|
calcBrokerRewardCondition &&
|
||||||
if (calculationProcess.process !== Process.LoadKp) {
|
calcBrokerRewardCondition.evo_reward_summ
|
||||||
calculationStore.setValue(
|
) {
|
||||||
'calcBrokerRewardSum',
|
if (calculationProcess.process !== Process.LoadKp) {
|
||||||
calcBrokerRewardCondition.evo_reward_summ,
|
calculationStore.setValue(
|
||||||
);
|
'calcBrokerRewardSum',
|
||||||
}
|
calcBrokerRewardCondition.evo_reward_summ,
|
||||||
calculationStore.setStatus(
|
|
||||||
'tbxCalcBrokerRewardSum',
|
|
||||||
ElementStatus.Default,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
calculationStore.setStatus(
|
||||||
|
'tbxCalcBrokerRewardSum',
|
||||||
|
ElementStatus.Default,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -322,22 +331,24 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
ElementStatus.Disabled,
|
ElementStatus.Disabled,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const finDepartmentRewardCondtion = calculationStore.options.selectFinDepartmentRewardCondtion?.find(
|
const finDepartmentRewardCondtion = calculationStore.getOption(
|
||||||
x => x.evo_reward_conditionid === finDepartmentRewardCondtionId,
|
'selectFinDepartmentRewardCondtion',
|
||||||
|
{ evo_reward_conditionid: finDepartmentRewardCondtionId },
|
||||||
);
|
);
|
||||||
if (finDepartmentRewardCondtion) {
|
if (
|
||||||
if (finDepartmentRewardCondtion.evo_reward_summ) {
|
finDepartmentRewardCondtion &&
|
||||||
if (calculationProcess.process !== Process.LoadKp) {
|
finDepartmentRewardCondtion.evo_reward_summ
|
||||||
calculationStore.setValue(
|
) {
|
||||||
'finDepartmentRewardSumm',
|
if (calculationProcess.process !== Process.LoadKp) {
|
||||||
finDepartmentRewardCondtion.evo_reward_summ,
|
calculationStore.setValue(
|
||||||
);
|
'finDepartmentRewardSumm',
|
||||||
}
|
finDepartmentRewardCondtion.evo_reward_summ,
|
||||||
calculationStore.setStatus(
|
|
||||||
'tbxFinDepartmentRewardSumm',
|
|
||||||
ElementStatus.Default,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
calculationStore.setStatus(
|
||||||
|
'tbxFinDepartmentRewardSumm',
|
||||||
|
ElementStatus.Default,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -352,16 +363,29 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
return indAgentRewardSumm;
|
return indAgentRewardSumm;
|
||||||
},
|
},
|
||||||
effect: indAgentRewardSumm => {
|
effect: indAgentRewardSumm => {
|
||||||
const indAgentRewardConditionId =
|
const indAgentRewardCondition = calculationStore.getOption(
|
||||||
calculationStore.values.indAgentRewardCondition;
|
'selectIndAgentRewardCondition',
|
||||||
if (indAgentRewardConditionId) {
|
);
|
||||||
const indAgentRewardCondition = calculationStore.options.selectIndAgentRewardCondition?.find(
|
if (indAgentRewardCondition) {
|
||||||
x => x.evo_reward_conditionid === indAgentRewardConditionId,
|
if (indAgentRewardCondition.evo_reward_summ) {
|
||||||
);
|
if (
|
||||||
if (indAgentRewardCondition) {
|
parseFloat(indAgentRewardSumm) >
|
||||||
if (indAgentRewardCondition.evo_reward_summ) {
|
indAgentRewardCondition.evo_reward_summ
|
||||||
|
) {
|
||||||
|
calculationStore.setValidation('tbxIndAgentRewardSumm', false);
|
||||||
|
openNotification({
|
||||||
|
type: 'error',
|
||||||
|
title: 'Ошибка',
|
||||||
|
description:
|
||||||
|
'Вознаграждение агента ФЛ указано больше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
||||||
|
})();
|
||||||
|
return;
|
||||||
|
} else if (
|
||||||
|
!indAgentRewardCondition.evo_reduce_reward &&
|
||||||
|
indAgentRewardCondition.evo_reward_summ
|
||||||
|
) {
|
||||||
if (
|
if (
|
||||||
parseFloat(indAgentRewardSumm) >
|
parseFloat(indAgentRewardSumm) <
|
||||||
indAgentRewardCondition.evo_reward_summ
|
indAgentRewardCondition.evo_reward_summ
|
||||||
) {
|
) {
|
||||||
calculationStore.setValidation('tbxIndAgentRewardSumm', false);
|
calculationStore.setValidation('tbxIndAgentRewardSumm', false);
|
||||||
@ -369,29 +393,12 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
type: 'error',
|
type: 'error',
|
||||||
title: 'Ошибка',
|
title: 'Ошибка',
|
||||||
description:
|
description:
|
||||||
'Вознаграждение агента ФЛ указано больше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
'Вознаграждение агента ФЛ указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
||||||
})();
|
})();
|
||||||
return;
|
return;
|
||||||
} else if (
|
|
||||||
!indAgentRewardCondition.evo_reduce_reward &&
|
|
||||||
indAgentRewardCondition.evo_reward_summ
|
|
||||||
) {
|
|
||||||
if (
|
|
||||||
parseFloat(indAgentRewardSumm) <
|
|
||||||
indAgentRewardCondition.evo_reward_summ
|
|
||||||
) {
|
|
||||||
calculationStore.setValidation('tbxIndAgentRewardSumm', false);
|
|
||||||
openNotification({
|
|
||||||
type: 'error',
|
|
||||||
title: 'Ошибка',
|
|
||||||
description:
|
|
||||||
'Вознаграждение агента ФЛ указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
|
||||||
})();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
calculationStore.setValidation('tbxIndAgentRewardSumm', true);
|
|
||||||
}
|
}
|
||||||
|
calculationStore.setValidation('tbxIndAgentRewardSumm', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -403,16 +410,32 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
return calcDoubleAgentRewardSumm;
|
return calcDoubleAgentRewardSumm;
|
||||||
},
|
},
|
||||||
effect: calcDoubleAgentRewardSumm => {
|
effect: calcDoubleAgentRewardSumm => {
|
||||||
const calcDoubleAgentRewardConditionId =
|
const selectCalcDoubleAgentRewardCondition = calculationStore.getOption(
|
||||||
calculationStore.values.calcDoubleAgentRewardCondition;
|
'selectCalcDoubleAgentRewardCondition',
|
||||||
if (calcDoubleAgentRewardConditionId) {
|
);
|
||||||
const selectCalcDoubleAgentRewardCondition = calculationStore.options.selectCalcDoubleAgentRewardCondition?.find(
|
if (selectCalcDoubleAgentRewardCondition) {
|
||||||
x => x.evo_reward_conditionid === calcDoubleAgentRewardConditionId,
|
if (selectCalcDoubleAgentRewardCondition.evo_reward_summ) {
|
||||||
);
|
if (
|
||||||
if (selectCalcDoubleAgentRewardCondition) {
|
parseFloat(calcDoubleAgentRewardSumm) >
|
||||||
if (selectCalcDoubleAgentRewardCondition.evo_reward_summ) {
|
selectCalcDoubleAgentRewardCondition.evo_reward_summ
|
||||||
|
) {
|
||||||
|
calculationStore.setValidation(
|
||||||
|
'tbxCalcDoubleAgentRewardSumm',
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
openNotification({
|
||||||
|
type: 'error',
|
||||||
|
title: 'Ошибка',
|
||||||
|
description:
|
||||||
|
'Вознаграждение двойного агента указано больше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
||||||
|
})();
|
||||||
|
return;
|
||||||
|
} else if (
|
||||||
|
!selectCalcDoubleAgentRewardCondition.evo_reduce_reward &&
|
||||||
|
selectCalcDoubleAgentRewardCondition.evo_reward_summ
|
||||||
|
) {
|
||||||
if (
|
if (
|
||||||
parseFloat(calcDoubleAgentRewardSumm) >
|
parseFloat(calcDoubleAgentRewardSumm) <
|
||||||
selectCalcDoubleAgentRewardCondition.evo_reward_summ
|
selectCalcDoubleAgentRewardCondition.evo_reward_summ
|
||||||
) {
|
) {
|
||||||
calculationStore.setValidation(
|
calculationStore.setValidation(
|
||||||
@ -423,35 +446,12 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
type: 'error',
|
type: 'error',
|
||||||
title: 'Ошибка',
|
title: 'Ошибка',
|
||||||
description:
|
description:
|
||||||
'Вознаграждение двойного агента указано больше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
'Вознаграждение двойного агента указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
||||||
})();
|
})();
|
||||||
return;
|
return;
|
||||||
} else if (
|
|
||||||
!selectCalcDoubleAgentRewardCondition.evo_reduce_reward &&
|
|
||||||
selectCalcDoubleAgentRewardCondition.evo_reward_summ
|
|
||||||
) {
|
|
||||||
if (
|
|
||||||
parseFloat(calcDoubleAgentRewardSumm) <
|
|
||||||
selectCalcDoubleAgentRewardCondition.evo_reward_summ
|
|
||||||
) {
|
|
||||||
calculationStore.setValidation(
|
|
||||||
'tbxCalcDoubleAgentRewardSumm',
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
openNotification({
|
|
||||||
type: 'error',
|
|
||||||
title: 'Ошибка',
|
|
||||||
description:
|
|
||||||
'Вознаграждение двойного агента указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
|
||||||
})();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
calculationStore.setValidation(
|
|
||||||
'tbxCalcDoubleAgentRewardSumm',
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
calculationStore.setValidation('tbxCalcDoubleAgentRewardSumm', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -463,16 +463,29 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
return calcBrokerRewardSum;
|
return calcBrokerRewardSum;
|
||||||
},
|
},
|
||||||
effect: calcBrokerRewardSum => {
|
effect: calcBrokerRewardSum => {
|
||||||
const calcBrokerRewardConditionId =
|
const selectCalcBrokerRewardCondition = calculationStore.getOption(
|
||||||
calculationStore.values.calcBrokerRewardCondition;
|
'selectCalcBrokerRewardCondition',
|
||||||
if (calcBrokerRewardConditionId) {
|
);
|
||||||
const selectCalcBrokerRewardCondition = calculationStore.options.selectCalcBrokerRewardCondition?.find(
|
if (selectCalcBrokerRewardCondition) {
|
||||||
x => x.evo_reward_conditionid === calcBrokerRewardConditionId,
|
if (selectCalcBrokerRewardCondition.evo_reward_summ) {
|
||||||
);
|
if (
|
||||||
if (selectCalcBrokerRewardCondition) {
|
parseFloat(calcBrokerRewardSum) >
|
||||||
if (selectCalcBrokerRewardCondition.evo_reward_summ) {
|
selectCalcBrokerRewardCondition.evo_reward_summ
|
||||||
|
) {
|
||||||
|
calculationStore.setValidation('tbxCalcBrokerRewardSum', false);
|
||||||
|
openNotification({
|
||||||
|
type: 'error',
|
||||||
|
title: 'Ошибка',
|
||||||
|
description:
|
||||||
|
'Вознаграждение брокера указано больше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
||||||
|
})();
|
||||||
|
return;
|
||||||
|
} else if (
|
||||||
|
!selectCalcBrokerRewardCondition.evo_reduce_reward &&
|
||||||
|
selectCalcBrokerRewardCondition.evo_reward_summ
|
||||||
|
) {
|
||||||
if (
|
if (
|
||||||
parseFloat(calcBrokerRewardSum) >
|
parseFloat(calcBrokerRewardSum) <
|
||||||
selectCalcBrokerRewardCondition.evo_reward_summ
|
selectCalcBrokerRewardCondition.evo_reward_summ
|
||||||
) {
|
) {
|
||||||
calculationStore.setValidation('tbxCalcBrokerRewardSum', false);
|
calculationStore.setValidation('tbxCalcBrokerRewardSum', false);
|
||||||
@ -480,29 +493,12 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
type: 'error',
|
type: 'error',
|
||||||
title: 'Ошибка',
|
title: 'Ошибка',
|
||||||
description:
|
description:
|
||||||
'Вознаграждение брокера указано больше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
'Вознаграждение брокера указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
||||||
})();
|
})();
|
||||||
return;
|
return;
|
||||||
} else if (
|
|
||||||
!selectCalcBrokerRewardCondition.evo_reduce_reward &&
|
|
||||||
selectCalcBrokerRewardCondition.evo_reward_summ
|
|
||||||
) {
|
|
||||||
if (
|
|
||||||
parseFloat(calcBrokerRewardSum) <
|
|
||||||
selectCalcBrokerRewardCondition.evo_reward_summ
|
|
||||||
) {
|
|
||||||
calculationStore.setValidation('tbxCalcBrokerRewardSum', false);
|
|
||||||
openNotification({
|
|
||||||
type: 'error',
|
|
||||||
title: 'Ошибка',
|
|
||||||
description:
|
|
||||||
'Вознаграждение брокера указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
|
||||||
})();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
calculationStore.setValidation('tbxCalcBrokerRewardSum', true);
|
|
||||||
}
|
}
|
||||||
|
calculationStore.setValidation('tbxCalcBrokerRewardSum', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -514,53 +510,44 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
return finDepartmentRewardSumm;
|
return finDepartmentRewardSumm;
|
||||||
},
|
},
|
||||||
effect: finDepartmentRewardSumm => {
|
effect: finDepartmentRewardSumm => {
|
||||||
const finDepartmentRewardCondtionid =
|
const selectFinDepartmentRewardCondtion = calculationStore.getOption(
|
||||||
calculationStore.values.finDepartmentRewardCondtion;
|
'selectFinDepartmentRewardCondtion',
|
||||||
if (finDepartmentRewardCondtionid) {
|
);
|
||||||
const selectFinDepartmentRewardCondtion = calculationStore.options.selectFinDepartmentRewardCondtion?.find(
|
if (
|
||||||
x => x.evo_reward_conditionid === finDepartmentRewardCondtionid,
|
selectFinDepartmentRewardCondtion &&
|
||||||
);
|
selectFinDepartmentRewardCondtion.evo_reward_summ
|
||||||
if (selectFinDepartmentRewardCondtion) {
|
) {
|
||||||
if (selectFinDepartmentRewardCondtion.evo_reward_summ) {
|
if (
|
||||||
if (
|
parseFloat(finDepartmentRewardSumm) >
|
||||||
parseFloat(finDepartmentRewardSumm) >
|
selectFinDepartmentRewardCondtion.evo_reward_summ
|
||||||
selectFinDepartmentRewardCondtion.evo_reward_summ
|
) {
|
||||||
) {
|
calculationStore.setValidation('tbxFinDepartmentRewardSumm', false);
|
||||||
calculationStore.setValidation(
|
openNotification({
|
||||||
'tbxFinDepartmentRewardSumm',
|
type: 'error',
|
||||||
false,
|
title: 'Ошибка',
|
||||||
);
|
description:
|
||||||
openNotification({
|
'Вознаграждение финотдела указано больше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
||||||
type: 'error',
|
})();
|
||||||
title: 'Ошибка',
|
return;
|
||||||
description:
|
} else if (
|
||||||
'Вознаграждение финотдела указано больше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
!selectFinDepartmentRewardCondtion.evo_reduce_reward &&
|
||||||
})();
|
selectFinDepartmentRewardCondtion.evo_reward_summ
|
||||||
return;
|
) {
|
||||||
} else if (
|
if (
|
||||||
!selectFinDepartmentRewardCondtion.evo_reduce_reward &&
|
parseFloat(finDepartmentRewardSumm) <
|
||||||
selectFinDepartmentRewardCondtion.evo_reward_summ
|
selectFinDepartmentRewardCondtion.evo_reward_summ
|
||||||
) {
|
) {
|
||||||
if (
|
calculationStore.setValidation('tbxFinDepartmentRewardSumm', false);
|
||||||
parseFloat(finDepartmentRewardSumm) <
|
openNotification({
|
||||||
selectFinDepartmentRewardCondtion.evo_reward_summ
|
type: 'error',
|
||||||
) {
|
title: 'Ошибка',
|
||||||
calculationStore.setValidation(
|
description:
|
||||||
'tbxFinDepartmentRewardSumm',
|
'Вознаграждение финотдела указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
||||||
false,
|
})();
|
||||||
);
|
return;
|
||||||
openNotification({
|
|
||||||
type: 'error',
|
|
||||||
title: 'Ошибка',
|
|
||||||
description:
|
|
||||||
'Вознаграждение финотдела указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
|
||||||
})();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
calculationStore.setValidation('tbxFinDepartmentRewardSumm', true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
calculationStore.setValidation('tbxFinDepartmentRewardSumm', true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@ -953,8 +940,9 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
ElementStatus.Disabled,
|
ElementStatus.Disabled,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const dealerRewardContition = calculationStore.options.selectDealerRewardCondition?.find(
|
const dealerRewardContition = calculationStore.getOption(
|
||||||
x => x.evo_reward_conditionid === dealerRewardConditionId,
|
'selectDealerRewardCondition',
|
||||||
|
{ evo_reward_conditionid: dealerRewardConditionId },
|
||||||
);
|
);
|
||||||
if (dealerRewardContition) {
|
if (dealerRewardContition) {
|
||||||
if (dealerRewardContition.evo_reward_summ) {
|
if (dealerRewardContition.evo_reward_summ) {
|
||||||
@ -1008,22 +996,24 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
ElementStatus.Disabled,
|
ElementStatus.Disabled,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const dealerBrokerRewardContition = calculationStore.options.selectDealerBrokerRewardCondition?.find(
|
const dealerBrokerRewardContition = calculationStore.getOption(
|
||||||
x => x.evo_reward_conditionid === dealerBrokerRewardConditionId,
|
'selectDealerBrokerRewardCondition',
|
||||||
|
{ evo_reward_conditionid: dealerBrokerRewardConditionId },
|
||||||
);
|
);
|
||||||
if (dealerBrokerRewardContition) {
|
if (
|
||||||
if (dealerBrokerRewardContition.evo_reward_summ) {
|
dealerBrokerRewardContition &&
|
||||||
if (calculationProcess.process !== Process.LoadKp) {
|
dealerBrokerRewardContition.evo_reward_summ
|
||||||
calculationStore.setValue(
|
) {
|
||||||
'dealerBrokerRewardSumm',
|
if (calculationProcess.process !== Process.LoadKp) {
|
||||||
dealerBrokerRewardContition.evo_reward_summ,
|
calculationStore.setValue(
|
||||||
);
|
'dealerBrokerRewardSumm',
|
||||||
}
|
dealerBrokerRewardContition.evo_reward_summ,
|
||||||
calculationStore.setStatus(
|
|
||||||
'tbxDealerBrokerRewardSumm',
|
|
||||||
ElementStatus.Default,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
calculationStore.setStatus(
|
||||||
|
'tbxDealerBrokerRewardSumm',
|
||||||
|
ElementStatus.Default,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1038,47 +1028,39 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
return dealerRewardSumm;
|
return dealerRewardSumm;
|
||||||
},
|
},
|
||||||
effect: dealerRewardSumm => {
|
effect: dealerRewardSumm => {
|
||||||
const dealerRewardConditionId =
|
const dealerRewardCondition = calculationStore.getOption(
|
||||||
calculationStore.values.dealerRewardCondition;
|
'selectDealerRewardCondition',
|
||||||
if (dealerRewardConditionId) {
|
);
|
||||||
const dealerRewardCondition = calculationStore.options.selectDealerRewardCondition?.find(
|
if (dealerRewardCondition && dealerRewardCondition.evo_reward_summ) {
|
||||||
x => x.evo_reward_conditionid === dealerRewardConditionId,
|
if (
|
||||||
);
|
parseFloat(dealerRewardSumm) > dealerRewardCondition.evo_reward_summ
|
||||||
if (dealerRewardCondition) {
|
) {
|
||||||
if (dealerRewardCondition.evo_reward_summ) {
|
calculationStore.setValidation('tbxDealerRewardSumm', false);
|
||||||
if (
|
openNotification({
|
||||||
parseFloat(dealerRewardSumm) >
|
type: 'error',
|
||||||
dealerRewardCondition.evo_reward_summ
|
title: 'Ошибка',
|
||||||
) {
|
description:
|
||||||
calculationStore.setValidation('tbxDealerRewardSumm', false);
|
'Вознаграждение ЮЛ поставщика указано больше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
||||||
openNotification({
|
})();
|
||||||
type: 'error',
|
return;
|
||||||
title: 'Ошибка',
|
} else if (
|
||||||
description:
|
!dealerRewardCondition.evo_reduce_reward &&
|
||||||
'Вознаграждение ЮЛ поставщика указано больше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
dealerRewardCondition.evo_reward_summ
|
||||||
})();
|
) {
|
||||||
return;
|
if (
|
||||||
} else if (
|
parseFloat(dealerRewardSumm) < dealerRewardCondition.evo_reward_summ
|
||||||
!dealerRewardCondition.evo_reduce_reward &&
|
) {
|
||||||
dealerRewardCondition.evo_reward_summ
|
calculationStore.setValidation('tbxDealerRewardSumm', false);
|
||||||
) {
|
openNotification({
|
||||||
if (
|
type: 'error',
|
||||||
parseFloat(dealerRewardSumm) <
|
title: 'Ошибка',
|
||||||
dealerRewardCondition.evo_reward_summ
|
description:
|
||||||
) {
|
'Вознаграждение ЮЛ поставщика указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
||||||
calculationStore.setValidation('tbxDealerRewardSumm', false);
|
})();
|
||||||
openNotification({
|
return;
|
||||||
type: 'error',
|
|
||||||
title: 'Ошибка',
|
|
||||||
description:
|
|
||||||
'Вознаграждение ЮЛ поставщика указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
|
||||||
})();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
calculationStore.setValidation('tbxDealerRewardSumm', true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
calculationStore.setValidation('tbxDealerRewardSumm', true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@ -1089,54 +1071,44 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
return dealerBrokerRewardSumm;
|
return dealerBrokerRewardSumm;
|
||||||
},
|
},
|
||||||
effect: dealerBrokerRewardSumm => {
|
effect: dealerBrokerRewardSumm => {
|
||||||
const dealerBrokerRewardConditionId =
|
const dealerBrokerRewardCondition = calculationStore.getOption(
|
||||||
calculationStore.values.dealerBrokerRewardCondition;
|
'selectDealerBrokerRewardCondition',
|
||||||
if (dealerBrokerRewardConditionId) {
|
);
|
||||||
const dealerBrokerRewardCondition = calculationStore.options.selectDealerBrokerRewardCondition?.find(
|
if (dealerBrokerRewardCondition) {
|
||||||
x => x.evo_reward_conditionid === dealerBrokerRewardConditionId,
|
if (dealerBrokerRewardCondition.evo_reward_summ) {
|
||||||
);
|
|
||||||
if (dealerBrokerRewardCondition) {
|
|
||||||
if (dealerBrokerRewardCondition.evo_reward_summ) {
|
|
||||||
if (
|
|
||||||
parseFloat(dealerBrokerRewardSumm) >
|
|
||||||
dealerBrokerRewardCondition.evo_reward_summ
|
|
||||||
) {
|
|
||||||
calculationStore.setValidation(
|
|
||||||
'tbxDealerBrokerRewardSumm',
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
openNotification({
|
|
||||||
type: 'error',
|
|
||||||
title: 'Ошибка',
|
|
||||||
description:
|
|
||||||
'Вознаграждение брокера поставщика указано больше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
|
||||||
})();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (
|
if (
|
||||||
!dealerBrokerRewardCondition.evo_reduce_reward &&
|
parseFloat(dealerBrokerRewardSumm) >
|
||||||
dealerBrokerRewardCondition.evo_reward_summ
|
dealerBrokerRewardCondition.evo_reward_summ
|
||||||
) {
|
) {
|
||||||
if (
|
calculationStore.setValidation('tbxDealerBrokerRewardSumm', false);
|
||||||
parseFloat(dealerBrokerRewardSumm) <
|
openNotification({
|
||||||
dealerBrokerRewardCondition.evo_reward_summ
|
type: 'error',
|
||||||
) {
|
title: 'Ошибка',
|
||||||
calculationStore.setValidation(
|
description:
|
||||||
'tbxDealerBrokerRewardSumm',
|
'Вознаграждение брокера поставщика указано больше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
||||||
false,
|
})();
|
||||||
);
|
return;
|
||||||
openNotification({
|
|
||||||
type: 'error',
|
|
||||||
title: 'Ошибка',
|
|
||||||
description:
|
|
||||||
'Вознаграждение брокера поставщика указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
|
||||||
})();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
calculationStore.setValidation('tbxDealerBrokerRewardSumm', true);
|
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
!dealerBrokerRewardCondition.evo_reduce_reward &&
|
||||||
|
dealerBrokerRewardCondition.evo_reward_summ
|
||||||
|
) {
|
||||||
|
if (
|
||||||
|
parseFloat(dealerBrokerRewardSumm) <
|
||||||
|
dealerBrokerRewardCondition.evo_reward_summ
|
||||||
|
) {
|
||||||
|
calculationStore.setValidation('tbxDealerBrokerRewardSumm', false);
|
||||||
|
openNotification({
|
||||||
|
type: 'error',
|
||||||
|
title: 'Ошибка',
|
||||||
|
description:
|
||||||
|
'Вознаграждение брокера поставщика указано меньше условия по агентскому договору! \nЗначение установлено по условию договора.',
|
||||||
|
})();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
calculationStore.setValidation('tbxDealerBrokerRewardSumm', true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@ -1147,18 +1119,20 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
return saleBonus;
|
return saleBonus;
|
||||||
},
|
},
|
||||||
effect: saleBonus => {
|
effect: saleBonus => {
|
||||||
const systemuser = calculationStore?.staticData?.systemuser;
|
const systemuser = calculationStore.getStaticData('systemuser');
|
||||||
|
|
||||||
if (systemuser) {
|
if (systemuser) {
|
||||||
const evo_sot_coefficient_type = calculationStore?.staticData?.evo_sot_coefficient_type?.find(
|
const evo_sot_coefficient_type = calculationStore
|
||||||
x => x.evo_id === 'BONUS_LEASING',
|
.getStaticData('evo_sot_coefficient_type')
|
||||||
);
|
.find(x => x.evo_id === 'BONUS_LEASING');
|
||||||
const evo_coefficient_bonus = calculationStore?.staticData?.evo_coefficient?.find(
|
const evo_coefficient_bonus = calculationStore
|
||||||
x =>
|
.getStaticData('evo_coefficient')
|
||||||
x.evo_job_titleid === systemuser[0].evo_job_titleid &&
|
.find(
|
||||||
x.evo_sot_coefficient_typeid ===
|
x =>
|
||||||
evo_sot_coefficient_type?.evo_sot_coefficient_typeid,
|
x.evo_job_titleid === systemuser[0].evo_job_titleid &&
|
||||||
);
|
x.evo_sot_coefficient_typeid ===
|
||||||
|
evo_sot_coefficient_type?.evo_sot_coefficient_typeid,
|
||||||
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
evo_coefficient_bonus &&
|
evo_coefficient_bonus &&
|
||||||
@ -1207,37 +1181,19 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
},
|
},
|
||||||
effect: ([modelId, configurationId]) => {
|
effect: ([modelId, configurationId]) => {
|
||||||
if (configurationId) {
|
if (configurationId) {
|
||||||
const configuration = calculationStore.options.selectConfiguration?.find(
|
const configuration = calculationStore.getOption(
|
||||||
x => x.evo_equipmentid === configurationId,
|
'selectConfiguration',
|
||||||
|
{
|
||||||
|
evo_equipmentid: configurationId,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (configuration) {
|
if (configuration && configuration.evo_impairment_groupid) {
|
||||||
if (configuration.evo_impairment_groupid) {
|
|
||||||
const evo_impairment_groups = calculationStore.getStaticData(
|
|
||||||
'evo_impairment_group',
|
|
||||||
);
|
|
||||||
const evo_impairment_group = evo_impairment_groups.find(
|
|
||||||
x =>
|
|
||||||
x.evo_impairment_groupid ===
|
|
||||||
configuration.evo_impairment_groupid,
|
|
||||||
);
|
|
||||||
calculationStore.setValue(
|
|
||||||
'depreciationGroup',
|
|
||||||
evo_impairment_group ? evo_impairment_group.evo_name : '',
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const model = calculationStore.options.selectModel?.find(
|
|
||||||
x => x.evo_modelid === modelId,
|
|
||||||
);
|
|
||||||
if (model)
|
|
||||||
if (model.evo_impairment_groupid) {
|
|
||||||
const evo_impairment_groups = calculationStore.getStaticData(
|
const evo_impairment_groups = calculationStore.getStaticData(
|
||||||
'evo_impairment_group',
|
'evo_impairment_group',
|
||||||
);
|
);
|
||||||
const evo_impairment_group = evo_impairment_groups.find(
|
const evo_impairment_group = evo_impairment_groups.find(
|
||||||
x => x.evo_impairment_groupid === model.evo_impairment_groupid,
|
x =>
|
||||||
|
x.evo_impairment_groupid === configuration.evo_impairment_groupid,
|
||||||
);
|
);
|
||||||
calculationStore.setValue(
|
calculationStore.setValue(
|
||||||
'depreciationGroup',
|
'depreciationGroup',
|
||||||
@ -1245,6 +1201,23 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
const model = calculationStore.getOption('selectModel', {
|
||||||
|
evo_modelid: modelId,
|
||||||
|
});
|
||||||
|
if (model && model.evo_impairment_groupid) {
|
||||||
|
const evo_impairment_groups = calculationStore.getStaticData(
|
||||||
|
'evo_impairment_group',
|
||||||
|
);
|
||||||
|
const evo_impairment_group = evo_impairment_groups.find(
|
||||||
|
x => x.evo_impairment_groupid === model.evo_impairment_groupid,
|
||||||
|
);
|
||||||
|
calculationStore.setValue(
|
||||||
|
'depreciationGroup',
|
||||||
|
evo_impairment_group ? evo_impairment_group.evo_name : '',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
calculationStore.setValue('depreciationGroup', null);
|
calculationStore.setValue('depreciationGroup', null);
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@ -1295,12 +1268,12 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
},
|
},
|
||||||
effect: ([brandId, modelId, leaseObjectUsed]) => {
|
effect: ([brandId, modelId, leaseObjectUsed]) => {
|
||||||
if (leaseObjectUsed === false) {
|
if (leaseObjectUsed === false) {
|
||||||
const model = calculationStore.options.selectModel?.find(
|
const model = calculationStore.getOption('selectModel', {
|
||||||
x => x.evo_modelid === modelId,
|
evo_modelid: modelId,
|
||||||
);
|
});
|
||||||
const brand = calculationStore.options.selectBrand?.find(
|
const brand = calculationStore.getOption('selectBrand', {
|
||||||
x => x.evo_brandid === brandId,
|
evo_brandid: brandId,
|
||||||
);
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
model &&
|
model &&
|
||||||
@ -1363,7 +1336,7 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
//TODO
|
// // TODO
|
||||||
// calculationStore => ({
|
// calculationStore => ({
|
||||||
// expression: () => {
|
// expression: () => {
|
||||||
// const { product } = calculationStore.values;
|
// const { product } = calculationStore.values;
|
||||||
@ -1371,9 +1344,9 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
// },
|
// },
|
||||||
// effect: productId => {
|
// effect: productId => {
|
||||||
// if (productId) {
|
// if (productId) {
|
||||||
// const product = calculationStore.options.selectProduct?.find(
|
// const product = calculationStore.getOption('selectProduct', {
|
||||||
// x => x.evo_id === productId,
|
// evo_id: productId,
|
||||||
// );
|
// });
|
||||||
// if (
|
// if (
|
||||||
// product &&
|
// product &&
|
||||||
// product.evo_leasingobject_types &&
|
// product.evo_leasingobject_types &&
|
||||||
@ -1395,12 +1368,15 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
},
|
},
|
||||||
effect: productId => {
|
effect: productId => {
|
||||||
if (productId) {
|
if (productId) {
|
||||||
const product = calculationStore.options.selectProduct?.find(
|
const product = calculationStore.getOption('selectProduct', {
|
||||||
x => x.evo_id === productId,
|
evo_id: productId,
|
||||||
);
|
});
|
||||||
if (product) {
|
if (product) {
|
||||||
const registraction_2020_3 = calculationStore.options.selectRegistration?.find(
|
const registraction_2020_3 = calculationStore.getOption(
|
||||||
x => x.evo_id === '2020_3',
|
'selectRegionRegistration',
|
||||||
|
{
|
||||||
|
evo_id: '2020_3',
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (registraction_2020_3) {
|
if (registraction_2020_3) {
|
||||||
calculationStore.setValue(
|
calculationStore.setValue(
|
||||||
@ -1420,10 +1396,9 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
},
|
},
|
||||||
effect: ({ product_evo_id, leasingPeriod }) => {
|
effect: ({ product_evo_id, leasingPeriod }) => {
|
||||||
if (product_evo_id && leasingPeriod) {
|
if (product_evo_id && leasingPeriod) {
|
||||||
const product = calculationStore.options.selectProduct?.find(
|
const product = calculationStore.getOption('selectProduct', {
|
||||||
x => x.evo_id === product_evo_id,
|
evo_id: product_evo_id,
|
||||||
);
|
});
|
||||||
|
|
||||||
if (product) {
|
if (product) {
|
||||||
const tarif = calculationStore.options.selectTarif?.find(
|
const tarif = calculationStore.options.selectTarif?.find(
|
||||||
x =>
|
x =>
|
||||||
@ -1451,9 +1426,9 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tarif = calculationStore.options.selectTarif?.find(
|
const tarif = calculationStore.getOption('selectTarif', {
|
||||||
x => x.evo_tarifid === tarif_evo_id,
|
evo_tarifid: tarif_evo_id,
|
||||||
);
|
});
|
||||||
|
|
||||||
if (tarif) {
|
if (tarif) {
|
||||||
calculationStore.setValue('IRR_Perc', tarif.evo_irr);
|
calculationStore.setValue('IRR_Perc', tarif.evo_irr);
|
||||||
@ -1509,11 +1484,7 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { technicalCard: technicalCardId } = calculationStore.values;
|
const technicalCard = calculationStore.getOption('selectTechnicalCard');
|
||||||
|
|
||||||
const technicalCard = calculationStore.options.selectTechnicalCard?.find(
|
|
||||||
x => x.evo_addproduct_typeid === technicalCardId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (technicalCard) {
|
if (technicalCard) {
|
||||||
const selectTechnicalCard_filter = calculationStore.getFilter(
|
const selectTechnicalCard_filter = calculationStore.getFilter(
|
||||||
@ -1542,6 +1513,7 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
//TODO: global setFilter => reset Value
|
||||||
calculationStore => ({
|
calculationStore => ({
|
||||||
expression: () => {
|
expression: () => {
|
||||||
const { selectLeaseObjectCategory } = calculationStore.filters;
|
const { selectLeaseObjectCategory } = calculationStore.filters;
|
||||||
@ -1551,7 +1523,7 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
const { leaseObjectCategory } = calculationStore.values;
|
const { leaseObjectCategory } = calculationStore.values;
|
||||||
if (
|
if (
|
||||||
!selectLeaseObjectCategoryFilter(
|
!selectLeaseObjectCategoryFilter(
|
||||||
calculationStore.options.selectLeaseObjectCategory,
|
calculationStore.getOptions('selectLeaseObjectCategory'),
|
||||||
).some(x => x.value === leaseObjectCategory)
|
).some(x => x.value === leaseObjectCategory)
|
||||||
) {
|
) {
|
||||||
calculationStore.setValue('leaseObjectCategory', null);
|
calculationStore.setValue('leaseObjectCategory', null);
|
||||||
@ -1578,8 +1550,11 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const leaseObjectType = calculationStore.options.selectLeaseObjectType?.find(
|
const leaseObjectType = calculationStore.getOption(
|
||||||
x => x.evo_leasingobject_typeid === leaseObjectTypeId,
|
'selectLeaseObjectType',
|
||||||
|
{
|
||||||
|
evo_leasingobject_typeid: leaseObjectTypeId,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (leaseObjectType) {
|
if (leaseObjectType) {
|
||||||
|
|||||||
@ -244,7 +244,7 @@ export default [
|
|||||||
const { supplierCurrency: supplierCurrencyId } = calculationStore.values;
|
const { supplierCurrency: supplierCurrencyId } = calculationStore.values;
|
||||||
const supplierCurrency = calculationStore
|
const supplierCurrency = calculationStore
|
||||||
.getOptions('selectSupplierCurrency')
|
.getOptions('selectSupplierCurrency')
|
||||||
.find(x => x.transactioncurrencyid === supplierCurrencyId);
|
?.find(x => x.transactioncurrencyid === supplierCurrencyId);
|
||||||
const evo_currencychange = calculationStore
|
const evo_currencychange = calculationStore
|
||||||
.getStaticData('evo_currencychange')
|
.getStaticData('evo_currencychange')
|
||||||
?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId);
|
?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId);
|
||||||
@ -281,7 +281,7 @@ export default [
|
|||||||
const { supplierCurrency: supplierCurrencyId } = calculationStore.values;
|
const { supplierCurrency: supplierCurrencyId } = calculationStore.values;
|
||||||
const supplierCurrency = calculationStore
|
const supplierCurrency = calculationStore
|
||||||
.getOptions('selectSupplierCurrency')
|
.getOptions('selectSupplierCurrency')
|
||||||
.find(x => x.transactioncurrencyid === supplierCurrencyId);
|
?.find(x => x.transactioncurrencyid === supplierCurrencyId);
|
||||||
const evo_currencychange = calculationStore
|
const evo_currencychange = calculationStore
|
||||||
.getStaticData('evo_currencychange')
|
.getStaticData('evo_currencychange')
|
||||||
?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId);
|
?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId);
|
||||||
|
|||||||
@ -36,7 +36,7 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
}
|
}
|
||||||
const supplierCurrency = calculationStore
|
const supplierCurrency = calculationStore
|
||||||
.getOptions('selectSupplierCurrency')
|
.getOptions('selectSupplierCurrency')
|
||||||
.find(x => x.transactioncurrencyid === supplierCurrencyId);
|
?.find(x => x.transactioncurrencyid === supplierCurrencyId);
|
||||||
const evo_currencychange = calculationStore
|
const evo_currencychange = calculationStore
|
||||||
.getStaticData('evo_currencychange')
|
.getStaticData('evo_currencychange')
|
||||||
?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId);
|
?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId);
|
||||||
@ -112,7 +112,7 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
|
|
||||||
const supplierCurrency = calculationStore
|
const supplierCurrency = calculationStore
|
||||||
.getOptions('selectSupplierCurrency')
|
.getOptions('selectSupplierCurrency')
|
||||||
.find(x => x.transactioncurrencyid === supplierCurrencyId);
|
?.find(x => x.transactioncurrencyid === supplierCurrencyId);
|
||||||
const evo_currencychange = calculationStore
|
const evo_currencychange = calculationStore
|
||||||
.getStaticData('evo_currencychange')
|
.getStaticData('evo_currencychange')
|
||||||
?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId);
|
?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId);
|
||||||
@ -124,11 +124,7 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
evo_currencychangeValue,
|
evo_currencychangeValue,
|
||||||
);
|
);
|
||||||
|
|
||||||
const { quote: quoteId } = calculationStore.values;
|
const quote = calculationStore.getOption('selectQuote');
|
||||||
const quote = calculationStore.options.selectQuote?.find(
|
|
||||||
x => x.value === quoteId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (quote && quote.evo_max_price_change) {
|
if (quote && quote.evo_max_price_change) {
|
||||||
if (price - supplierDiscountRub > quote.evo_max_price_change) {
|
if (price - supplierDiscountRub > quote.evo_max_price_change) {
|
||||||
calculationStore.setValidation('tbxLeaseObjectPrice', false);
|
calculationStore.setValidation('tbxLeaseObjectPrice', false);
|
||||||
@ -157,10 +153,7 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { quote: quoteId } = calculationStore.values;
|
const quote = calculationStore.getOption('selectQuote');
|
||||||
const quote = calculationStore.options.selectQuote?.find(
|
|
||||||
x => x.quoteid === quoteId,
|
|
||||||
);
|
|
||||||
if (quote && quote.evo_approved_first_payment) {
|
if (quote && quote.evo_approved_first_payment) {
|
||||||
if (firstPaymentPerc < quote.evo_approved_first_payment) {
|
if (firstPaymentPerc < quote.evo_approved_first_payment) {
|
||||||
calculationStore.setValidation('tbxFirstPaymentPerc', false);
|
calculationStore.setValidation('tbxFirstPaymentPerc', false);
|
||||||
@ -188,11 +181,7 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { quote: quoteId } = calculationStore.values;
|
const quote = calculationStore.getOption('selectQuote');
|
||||||
const quote = calculationStore.options.selectQuote?.find(
|
|
||||||
x => x.quoteid === quoteId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (quote && quote.evo_recalc_limit) {
|
if (quote && quote.evo_recalc_limit) {
|
||||||
if (leaseObjectCount > quote.evo_recalc_limit) {
|
if (leaseObjectCount > quote.evo_recalc_limit) {
|
||||||
calculationStore.setValidation('tbxLeaseObjectCount', false);
|
calculationStore.setValidation('tbxLeaseObjectCount', false);
|
||||||
@ -214,10 +203,8 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
const { quote, recalcWithRevision } = calculationStore.values;
|
const { quote, recalcWithRevision } = calculationStore.values;
|
||||||
return [quote, recalcWithRevision];
|
return [quote, recalcWithRevision];
|
||||||
},
|
},
|
||||||
effect: ([quoteId, recalcWithRevision]) => {
|
effect: ([quoteid, recalcWithRevision]) => {
|
||||||
const quote = calculationStore.options.selectQuote?.find(
|
const quote = calculationStore.getOption('selectQuote', { quoteid });
|
||||||
x => x.quoteid === quoteId,
|
|
||||||
);
|
|
||||||
if (recalcWithRevision) {
|
if (recalcWithRevision) {
|
||||||
if (quote && quote.evo_recalc_limit) {
|
if (quote && quote.evo_recalc_limit) {
|
||||||
calculationStore.setValue('leaseObjectCount', quote.evo_recalc_limit);
|
calculationStore.setValue('leaseObjectCount', quote.evo_recalc_limit);
|
||||||
@ -237,10 +224,7 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
},
|
},
|
||||||
effect: ({ maxMass, recalcWithRevision }) => {
|
effect: ({ maxMass, recalcWithRevision }) => {
|
||||||
if (recalcWithRevision) {
|
if (recalcWithRevision) {
|
||||||
const { quote: quoteId } = calculationStore.values;
|
const quote = calculationStore.getOption('selectQuote');
|
||||||
const quote = calculationStore.options.selectQuote?.find(
|
|
||||||
x => x.value === quoteId,
|
|
||||||
);
|
|
||||||
if (quote && quote.evo_max_mass)
|
if (quote && quote.evo_max_mass)
|
||||||
if (
|
if (
|
||||||
(maxMass < valuesConstants.MAX_VEHICLE_MASS &&
|
(maxMass < valuesConstants.MAX_VEHICLE_MASS &&
|
||||||
@ -277,10 +261,7 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
},
|
},
|
||||||
effect: ({ countSeats, leaseObjectCategory, recalcWithRevision }) => {
|
effect: ({ countSeats, leaseObjectCategory, recalcWithRevision }) => {
|
||||||
if (recalcWithRevision && leaseObjectCategory === 100000003) {
|
if (recalcWithRevision && leaseObjectCategory === 100000003) {
|
||||||
const { quote: quoteId } = calculationStore.values;
|
const quote = calculationStore.getOption('selectQuote');
|
||||||
const quote = calculationStore.options.selectQuote?.find(
|
|
||||||
x => x.value === quoteId,
|
|
||||||
);
|
|
||||||
if (quote && quote?.evo_seats)
|
if (quote && quote?.evo_seats)
|
||||||
if (
|
if (
|
||||||
(countSeats < valuesConstants.MAX_VEHICLE_SEATS &&
|
(countSeats < valuesConstants.MAX_VEHICLE_SEATS &&
|
||||||
@ -327,10 +308,7 @@ const reactionEffects: IReactionEffect[] = [
|
|||||||
effect: ({ leaseObjectYear, recalcWithRevision }) => {
|
effect: ({ leaseObjectYear, recalcWithRevision }) => {
|
||||||
const { leaseObjectUsed } = calculationStore.values;
|
const { leaseObjectUsed } = calculationStore.values;
|
||||||
if (recalcWithRevision && !leaseObjectUsed && leaseObjectYear) {
|
if (recalcWithRevision && !leaseObjectUsed && leaseObjectYear) {
|
||||||
const { quote: quoteId } = calculationStore.values;
|
const quote = calculationStore.getOption('selectQuote');
|
||||||
const quote = calculationStore.options.selectQuote?.find(
|
|
||||||
x => x.value === quoteId,
|
|
||||||
);
|
|
||||||
if (quote && quote.evo_year)
|
if (quote && quote.evo_year)
|
||||||
if (leaseObjectYear >= quote.evo_year) {
|
if (leaseObjectYear >= quote.evo_year) {
|
||||||
calculationStore.setValidation('tbxLeaseObjectYear', undefined);
|
calculationStore.setValidation('tbxLeaseObjectYear', undefined);
|
||||||
|
|||||||
@ -12,11 +12,11 @@ export default [
|
|||||||
const { values } = calculationStore;
|
const { values } = calculationStore;
|
||||||
return values.lead;
|
return values.lead;
|
||||||
},
|
},
|
||||||
effect: async leadId => {
|
effect: async leadid => {
|
||||||
if (calculationProcess.process === Process.LoadKp) {
|
if (calculationProcess.process === Process.LoadKp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!leadId) {
|
if (!leadid) {
|
||||||
calculationStore.setValue('opportunity', null);
|
calculationStore.setValue('opportunity', null);
|
||||||
calculationStore.setFilter('selectOpportunity', undefined);
|
calculationStore.setFilter('selectOpportunity', undefined);
|
||||||
calculationStore.setValue('quote', null);
|
calculationStore.setValue('quote', null);
|
||||||
@ -31,10 +31,8 @@ export default [
|
|||||||
calculationStore.setValue('calcFinDepartment', null);
|
calculationStore.setValue('calcFinDepartment', null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const lead = calculationStore.options.selectLead?.find(
|
|
||||||
x => x.leadid === leadId,
|
|
||||||
);
|
|
||||||
|
|
||||||
|
const lead = calculationStore.getOption('selectLead', { leadid });
|
||||||
if (lead) {
|
if (lead) {
|
||||||
if (lead.evo_opportunityid) {
|
if (lead.evo_opportunityid) {
|
||||||
calculationStore.setValue('opportunity', lead.evo_opportunityid);
|
calculationStore.setValue('opportunity', lead.evo_opportunityid);
|
||||||
@ -58,7 +56,7 @@ export default [
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
variables: {
|
variables: {
|
||||||
leadid: leadId,
|
leadid: leadid,
|
||||||
},
|
},
|
||||||
toOptions: ['quote'],
|
toOptions: ['quote'],
|
||||||
}).then(({ entities }) => {
|
}).then(({ entities }) => {
|
||||||
@ -226,9 +224,9 @@ export default [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (opportunityid) {
|
if (opportunityid) {
|
||||||
const opportunity = calculationStore.options.selectOpportunity?.find(
|
const opportunity = calculationStore.getOption('selectOpportunity', {
|
||||||
x => x.opportunityid === opportunityid,
|
opportunityid,
|
||||||
);
|
});
|
||||||
if (opportunity) {
|
if (opportunity) {
|
||||||
if (opportunity.evo_client_riskid) {
|
if (opportunity.evo_client_riskid) {
|
||||||
calculationStore.setValue(
|
calculationStore.setValue(
|
||||||
@ -260,32 +258,30 @@ export default [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (leadid && !opportunityid) {
|
} else if (leadid && !opportunityid) {
|
||||||
const lead = calculationStore.options.selectLead?.find(
|
const lead = calculationStore.getOption('selectLead', {
|
||||||
x => x.leadid === leadid,
|
leadid,
|
||||||
);
|
});
|
||||||
if (lead) {
|
if (lead && lead.customerid) {
|
||||||
if (lead.customerid) {
|
CrmService.crmgqlquery({
|
||||||
CrmService.crmgqlquery({
|
query: gql`
|
||||||
query: gql`
|
query($customerid: Uuid!) {
|
||||||
query($customerid: Uuid!) {
|
account(accountid: $customerid) {
|
||||||
account(accountid: $customerid) {
|
evo_client_riskid
|
||||||
evo_client_riskid
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
`,
|
}
|
||||||
variables: { customerid: lead.customerid },
|
`,
|
||||||
}).then(({ entities }) => {
|
variables: { customerid: lead.customerid },
|
||||||
if (
|
}).then(({ entities }) => {
|
||||||
entities.account &&
|
if (
|
||||||
!Array.isArray(entities.account) &&
|
entities.account &&
|
||||||
entities.account.evo_client_riskid
|
!Array.isArray(entities.account) &&
|
||||||
)
|
entities.account.evo_client_riskid
|
||||||
calculationStore.setValue(
|
)
|
||||||
'clientRisk',
|
calculationStore.setValue(
|
||||||
entities.account.evo_client_riskid,
|
'clientRisk',
|
||||||
);
|
entities.account.evo_client_riskid,
|
||||||
});
|
);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
calculationStore.setValue('clientRisk', null);
|
calculationStore.setValue('clientRisk', null);
|
||||||
@ -564,9 +560,9 @@ export default [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (dealerId) {
|
if (dealerId) {
|
||||||
const dealer = calculationStore.options.selectDealer?.find(
|
const dealer = calculationStore.getOption('selectDealer', {
|
||||||
x => x.accountid === dealerId,
|
accountid: dealerId,
|
||||||
);
|
});
|
||||||
if (dealer) {
|
if (dealer) {
|
||||||
CrmService.crmgqlquery({
|
CrmService.crmgqlquery({
|
||||||
query: gql`
|
query: gql`
|
||||||
@ -633,9 +629,9 @@ export default [
|
|||||||
calculationStore.setValue('dealerBroker', null);
|
calculationStore.setValue('dealerBroker', null);
|
||||||
calculationStore.setStatus('selectDealerBroker', ElementStatus.Disabled);
|
calculationStore.setStatus('selectDealerBroker', ElementStatus.Disabled);
|
||||||
if (dealerPersonId) {
|
if (dealerPersonId) {
|
||||||
const dealerPerson = calculationStore.options.selectDealerPerson?.find(
|
const dealerPerson = calculationStore.getOption('selectDealerPerson', {
|
||||||
x => x.accountid === dealerPersonId,
|
accountid: dealerPersonId,
|
||||||
);
|
});
|
||||||
if (dealerPerson && dealerPerson.evo_broker_accountid) {
|
if (dealerPerson && dealerPerson.evo_broker_accountid) {
|
||||||
CrmService.crmgqlquery({
|
CrmService.crmgqlquery({
|
||||||
query: gql`
|
query: gql`
|
||||||
@ -680,9 +676,9 @@ export default [
|
|||||||
},
|
},
|
||||||
effect: dealerBrokerId => {
|
effect: dealerBrokerId => {
|
||||||
if (dealerBrokerId) {
|
if (dealerBrokerId) {
|
||||||
const dealerBroker = calculationStore.options.selectDealerBroker?.find(
|
const dealerBroker = calculationStore.getOption('selectDealerBroker', {
|
||||||
x => x.accountid === dealerBrokerId,
|
accountid: dealerBrokerId,
|
||||||
);
|
});
|
||||||
if (dealerBroker) {
|
if (dealerBroker) {
|
||||||
calculationStore.setStatus(
|
calculationStore.setStatus(
|
||||||
'selectDealerBrokerRewardCondition',
|
'selectDealerBrokerRewardCondition',
|
||||||
@ -860,9 +856,9 @@ export default [
|
|||||||
calculationStore.setValue('configuration', null);
|
calculationStore.setValue('configuration', null);
|
||||||
|
|
||||||
if (modelId) {
|
if (modelId) {
|
||||||
const model = calculationStore.options.selectModel?.find(
|
const model = calculationStore.getOptions('selectModel', {
|
||||||
x => x.evo_modelid === modelId,
|
evo_modelid: modelId,
|
||||||
);
|
});
|
||||||
if (model) {
|
if (model) {
|
||||||
CrmService.crmgqlquery({
|
CrmService.crmgqlquery({
|
||||||
query: gql`
|
query: gql`
|
||||||
@ -920,9 +916,9 @@ export default [
|
|||||||
calculationStore.setOptions('selectFinDepartment', []);
|
calculationStore.setOptions('selectFinDepartment', []);
|
||||||
calculationStore.setValue('finDepartment', null);
|
calculationStore.setValue('finDepartment', null);
|
||||||
if (supplierId) {
|
if (supplierId) {
|
||||||
const supplier = calculationStore.options.selectSupplier?.find(
|
const supplier = calculationStore.getOption('selectSupplier', {
|
||||||
x => x.accountid === supplierId,
|
accountid: supplierId,
|
||||||
);
|
});
|
||||||
if (supplier && supplier.evo_fin_department_accountid)
|
if (supplier && supplier.evo_fin_department_accountid)
|
||||||
CrmService.crmgqlquery({
|
CrmService.crmgqlquery({
|
||||||
query: gql`
|
query: gql`
|
||||||
@ -1031,9 +1027,9 @@ export default [
|
|||||||
calculationStore.setValue('GPSModel', null);
|
calculationStore.setValue('GPSModel', null);
|
||||||
|
|
||||||
if (GPSBrandId) {
|
if (GPSBrandId) {
|
||||||
const gpsBrand = calculationStore.options.selectGPSBrand?.find(
|
const gpsBrand = calculationStore.getOption('selectGPSBrand', {
|
||||||
x => x.evo_gps_brandid === GPSBrandId,
|
evo_gps_brandid: GPSBrandId,
|
||||||
);
|
});
|
||||||
if (gpsBrand) {
|
if (gpsBrand) {
|
||||||
CrmService.crmgqlquery({
|
CrmService.crmgqlquery({
|
||||||
query: gql`
|
query: gql`
|
||||||
@ -1092,8 +1088,11 @@ export default [
|
|||||||
calculationStore.setValue('townRegistration', null);
|
calculationStore.setValue('townRegistration', null);
|
||||||
|
|
||||||
if (regionRegistrationId) {
|
if (regionRegistrationId) {
|
||||||
const regionRegistration = calculationStore.options.selectRegionRegistration?.find(
|
const regionRegistration = calculationStore.getOption(
|
||||||
x => x.evo_regionid === regionRegistrationId,
|
'selectRegionRegistration',
|
||||||
|
{
|
||||||
|
evo_regionid: regionRegistrationId,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (regionRegistration) {
|
if (regionRegistration) {
|
||||||
CrmService.crmgqlquery({
|
CrmService.crmgqlquery({
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { ElementsNames } from './../../../../../core/types/Calculation/Store/elements';
|
import { ElementsNames } from 'core/types/Calculation/Store/elements';
|
||||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||||
import { ElementStatus } from 'core/types/statuses';
|
import { ElementStatus } from 'core/types/statuses';
|
||||||
|
|
||||||
@ -12,15 +12,14 @@ const elementsNames: ElementsNames[] = [
|
|||||||
|
|
||||||
export default elementsNames.map(elementName => calculationStore => ({
|
export default elementsNames.map(elementName => calculationStore => ({
|
||||||
expression: () => {
|
expression: () => {
|
||||||
const { [elementName]: elementOptions } = calculationStore.options;
|
const elementOptions = calculationStore.getOptions(elementName);
|
||||||
return elementOptions?.length;
|
return elementOptions?.length;
|
||||||
},
|
},
|
||||||
effect: length => {
|
effect: length => {
|
||||||
if (length === 0) {
|
calculationStore.setStatus(
|
||||||
calculationStore.setStatus(elementName, ElementStatus.Disabled);
|
elementName,
|
||||||
} else {
|
length ? ElementStatus.Default : ElementStatus.Disabled,
|
||||||
calculationStore.setStatus(elementName, ElementStatus.Default);
|
);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
fireImmediately: true,
|
fireImmediately: true,
|
||||||
|
|||||||
@ -460,11 +460,10 @@ export default [
|
|||||||
graphType,
|
graphType,
|
||||||
parmentsDecreasePercent,
|
parmentsDecreasePercent,
|
||||||
seasonType,
|
seasonType,
|
||||||
highSeasonStart: highSeasonStartId,
|
|
||||||
} = calculationStore.values;
|
} = calculationStore.values;
|
||||||
|
|
||||||
const highSeasonStart = calculationStore.options.selectHighSeasonStart?.find(
|
const highSeasonStart = calculationStore.getOption(
|
||||||
x => x.value === highSeasonStartId,
|
'selectHighSeasonStart',
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -519,8 +518,11 @@ export default [
|
|||||||
case 100000001: {
|
case 100000001: {
|
||||||
if (seasonType) {
|
if (seasonType) {
|
||||||
const paymentsInStep = Math.ceil((leasingPeriod - 2) / 3);
|
const paymentsInStep = Math.ceil((leasingPeriod - 2) / 3);
|
||||||
const targetSeasonType = calculationStore.options?.selectSeasonType?.find(
|
const targetSeasonType = calculationStore.getOption(
|
||||||
x => x?.value === seasonType,
|
'selectSeasonType',
|
||||||
|
{
|
||||||
|
value: seasonType,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
const stepsValues: number[] =
|
const stepsValues: number[] =
|
||||||
targetSeasonType && targetSeasonType.stepsValues;
|
targetSeasonType && targetSeasonType.stepsValues;
|
||||||
@ -612,8 +614,11 @@ export default [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const next_seasonType_option = calculationStore.options.selectSeasonType?.find(
|
const next_seasonType_option = calculationStore.getOption(
|
||||||
x => x.value === seasonType,
|
'selectSeasonType',
|
||||||
|
{
|
||||||
|
value: seasonType,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -649,8 +654,11 @@ export default [
|
|||||||
if (prevShiftNumber > 0)
|
if (prevShiftNumber > 0)
|
||||||
middleRows = shiftRight(middleRows, prevShiftNumber);
|
middleRows = shiftRight(middleRows, prevShiftNumber);
|
||||||
|
|
||||||
const prev_seasonType_option = calculationStore.options.selectSeasonType?.find(
|
const prev_seasonType_option = calculationStore.getOption(
|
||||||
x => x.value === prevSeasonType,
|
'selectSeasonType',
|
||||||
|
{
|
||||||
|
value: prevSeasonType,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
const prevStartPositions =
|
const prevStartPositions =
|
||||||
prev_seasonType_option && prev_seasonType_option.startPositions;
|
prev_seasonType_option && prev_seasonType_option.startPositions;
|
||||||
|
|||||||
@ -45,16 +45,13 @@ const tablePayments: ITable = {
|
|||||||
if (graphType === 100000003) {
|
if (graphType === 100000003) {
|
||||||
const { leasingPeriod } = calculationStore.values;
|
const { leasingPeriod } = calculationStore.values;
|
||||||
if (rowIndex >= 1 && rowIndex <= PERIODS_NUMBER) {
|
if (rowIndex >= 1 && rowIndex <= PERIODS_NUMBER) {
|
||||||
const { highSeasonStart } = calculationStore.values;
|
|
||||||
const highSeasonStartValue = parseInt(
|
const highSeasonStartValue = parseInt(
|
||||||
calculationStore.options.selectHighSeasonStart?.find(
|
calculationStore.getOption('selectHighSeasonStart')?.name || '2',
|
||||||
x => x.value === highSeasonStart,
|
|
||||||
)?.name || '2',
|
|
||||||
),
|
),
|
||||||
shiftNumber = highSeasonStartValue - 2;
|
shiftNumber = highSeasonStartValue - 2;
|
||||||
|
|
||||||
const seasonTypeOptions = calculationStore.options.selectSeasonType?.find(
|
const seasonTypeOptions = calculationStore.getOption(
|
||||||
x => x.value === seasonType,
|
'selectSeasonType',
|
||||||
);
|
);
|
||||||
const startPositions =
|
const startPositions =
|
||||||
seasonTypeOptions && seasonTypeOptions.startPositions,
|
seasonTypeOptions && seasonTypeOptions.startPositions,
|
||||||
|
|||||||
@ -28,7 +28,14 @@ interface ICalculationValues {
|
|||||||
applyStaticData: (data: TStaticData) => void;
|
applyStaticData: (data: TStaticData) => void;
|
||||||
|
|
||||||
options: TElements<(IBaseOption & TCRMEntity)[]>;
|
options: TElements<(IBaseOption & TCRMEntity)[]>;
|
||||||
getOptions: (elementName: ElementsNames) => (IBaseOption & TCRMEntity)[];
|
getOption: (
|
||||||
|
elementName: ElementsNames,
|
||||||
|
fields?: { [field in keyof (IBaseOption & TCRMEntity)]: any },
|
||||||
|
) => (IBaseOption & TCRMEntity) | undefined;
|
||||||
|
getOptions: (
|
||||||
|
elementName: ElementsNames,
|
||||||
|
fields?: { [field in keyof (IBaseOption & TCRMEntity)]: any },
|
||||||
|
) => (IBaseOption & TCRMEntity)[] | undefined;
|
||||||
setOptions: (
|
setOptions: (
|
||||||
elementName: ElementsNames,
|
elementName: ElementsNames,
|
||||||
options: (IBaseOption & TCRMEntity)[],
|
options: (IBaseOption & TCRMEntity)[],
|
||||||
|
|||||||
Reference in New Issue
Block a user