merge release/rush-redemption-payment
This commit is contained in:
parent
42222fef40
commit
318a0d64b8
@ -80,7 +80,8 @@ const sections: ISection[] = [
|
||||
'tbxLeaseObjectPrice',
|
||||
'tbxSupplierDiscountRub',
|
||||
'tbxSupplierDiscountPerc',
|
||||
'radioBalanceHolder',
|
||||
// 'radioBalanceHolder',
|
||||
'tbxRedemptionPaymentSum',
|
||||
'tbxSaleBonus',
|
||||
'selectSubsidy',
|
||||
],
|
||||
@ -407,7 +408,7 @@ const sections: ISection[] = [
|
||||
},
|
||||
},
|
||||
elements: [
|
||||
'cbxLastPaymentRedemption',
|
||||
// 'cbxLastPaymentRedemption',
|
||||
'cbxPriceWithDiscount',
|
||||
'cbxFullPriceWithDiscount',
|
||||
'cbxCostIncrease',
|
||||
|
||||
@ -46,6 +46,7 @@ const elementsComponents: TElements<Component> = {
|
||||
radioLastPaymentRule: Radio,
|
||||
tbxLastPaymentPerc: InputNumber,
|
||||
tbxLastPaymentRub: InputNumber,
|
||||
tbxRedemptionPaymentSum: InputNumber,
|
||||
tbxLeasingPeriod: InputNumber,
|
||||
radioGraphType: Radio,
|
||||
tbxParmentsDecreasePercent: InputNumber,
|
||||
|
||||
@ -137,9 +137,16 @@ const elementsProps: TElements<ElementProps> = {
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxRedemptionPaymentSum: {
|
||||
min: '1000',
|
||||
max: '2000',
|
||||
step: '1000.00',
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
},
|
||||
tbxLeasingPeriod: {
|
||||
min: '7',
|
||||
max: '90',
|
||||
min: '13',
|
||||
max: '60',
|
||||
},
|
||||
tbxParmentsDecreasePercent: {
|
||||
min: '50',
|
||||
@ -180,7 +187,7 @@ const elementsProps: TElements<ElementProps> = {
|
||||
},
|
||||
tbxLeaseObjectYear: {
|
||||
min: '1994',
|
||||
max: currentYear + 1,
|
||||
max: (currentYear + 1).toString(),
|
||||
},
|
||||
selectLeaseObjectCategory: {
|
||||
showSearch: false,
|
||||
@ -266,7 +273,7 @@ const elementsProps: TElements<ElementProps> = {
|
||||
},
|
||||
tbxInsFranchise: {
|
||||
min: '0',
|
||||
max: MAX_FRANCHISE,
|
||||
max: MAX_FRANCHISE.toString(),
|
||||
step: '10000.00',
|
||||
precision: 2,
|
||||
formatter: formatNumber,
|
||||
@ -405,9 +412,9 @@ const elementsProps: TElements<ElementProps> = {
|
||||
style: 'button',
|
||||
},
|
||||
tbxVehicleTaxInYear: {
|
||||
min: 0,
|
||||
step: 100,
|
||||
max: 9999999,
|
||||
min: '0',
|
||||
step: '100',
|
||||
max: '9999999',
|
||||
precision: 2,
|
||||
tooltip: {
|
||||
Component: buildTooltip({
|
||||
@ -417,9 +424,9 @@ const elementsProps: TElements<ElementProps> = {
|
||||
},
|
||||
},
|
||||
tbxVehicleTaxInLeasingPeriod: {
|
||||
min: 0,
|
||||
step: 100,
|
||||
max: 9999999,
|
||||
min: '0',
|
||||
step: '100',
|
||||
max: '9999999',
|
||||
precision: 2,
|
||||
},
|
||||
selectObjectRegionRegistration: {
|
||||
@ -452,6 +459,19 @@ const elementsProps: TElements<ElementProps> = {
|
||||
},
|
||||
};
|
||||
|
||||
export const numberElementsProps: TElements<ElementProps> = Object.keys(
|
||||
elementsProps,
|
||||
).reduce((acc, a) => {
|
||||
const min = elementsProps[a]?.min,
|
||||
max = elementsProps[a]?.max;
|
||||
if (min || max)
|
||||
return {
|
||||
...acc,
|
||||
[a]: { min, max },
|
||||
};
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const labelElementsProps: TElements<ElementProps> = Object.assign(
|
||||
{},
|
||||
[
|
||||
|
||||
@ -35,6 +35,7 @@ export const elementsTitles: TElements<string> = {
|
||||
tbxLastPaymentPerc: 'Последний платеж, %',
|
||||
tbxLastPaymentRub: 'Последний платеж, руб.',
|
||||
radioLastPaymentRule: 'Последний платеж считается от ',
|
||||
tbxRedemptionPaymentSum: 'Сумма выкупного платежа, руб',
|
||||
radioBalanceHolder: 'Балансодержатель',
|
||||
radioGraphType: 'Вид графика',
|
||||
tbxParmentsDecreasePercent: 'Процент убывания платежей',
|
||||
|
||||
@ -39,6 +39,7 @@ export const elementsValues: TElements<ValuesNames> = {
|
||||
tbxLastPaymentPerc: 'lastPaymentPerc',
|
||||
tbxLastPaymentRub: 'lastPaymentRub',
|
||||
radioLastPaymentRule: 'lastPaymentRule',
|
||||
tbxRedemptionPaymentSum: 'redemptionPaymentSum',
|
||||
radioBalanceHolder: 'balanceHolder',
|
||||
radioGraphType: 'graphType',
|
||||
tbxParmentsDecreasePercent: 'parmentsDecreasePercent',
|
||||
|
||||
@ -11,8 +11,13 @@ const tablesActions = {
|
||||
},
|
||||
|
||||
getTableRowValues(tableName, rowIndex, paramName) {
|
||||
let targetIndex = rowIndex;
|
||||
if (typeof rowIndex === 'function') {
|
||||
const rows = this.tables[tableName]?.rows;
|
||||
targetIndex = rowIndex(rows);
|
||||
}
|
||||
let values = {};
|
||||
const row = this?.tables?.[tableName]?.rows?.[rowIndex];
|
||||
const row = this?.tables?.[tableName]?.rows?.[targetIndex];
|
||||
if (!row) {
|
||||
return values;
|
||||
}
|
||||
@ -32,6 +37,11 @@ const tablesActions = {
|
||||
return values;
|
||||
},
|
||||
|
||||
getTableRowValue(tableName, rowIndex, propName, paramName) {
|
||||
const values = this.getTableRowValues(tableName, rowIndex, paramName);
|
||||
return values[propName];
|
||||
},
|
||||
|
||||
getTableOptions(tableName, propName) {
|
||||
return this.tables[tableName].options[propName];
|
||||
},
|
||||
@ -65,8 +75,13 @@ const tablesActions = {
|
||||
},
|
||||
|
||||
setTableRow(tableName, rowIndex, override) {
|
||||
let targetIndex = rowIndex;
|
||||
if (typeof rowIndex === 'function') {
|
||||
const rows = this.tables[tableName]?.rows;
|
||||
targetIndex = rowIndex(rows);
|
||||
}
|
||||
return row => {
|
||||
this.setTableRows(tableName, rowIndex, override)([row]);
|
||||
this.setTableRows(tableName, targetIndex, override)([row]);
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@ -132,18 +132,14 @@ const customConditions: TElements<ValidationCondition> = {
|
||||
tbxLeasingPeriod: calculationStore => {
|
||||
const { recalcWithRevision, leasingPeriod } = calculationStore.values;
|
||||
const quote = calculationStore.getOption('selectQuote');
|
||||
const kaskoRowIndex = calculationStore.tables.tableInsurance.rows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
|
||||
const kaskoValues = calculationStore.getTableRowValues(
|
||||
const kaskoInsTerm = calculationStore.getTableRowValue(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
rows => rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
'insTerm',
|
||||
'value',
|
||||
);
|
||||
|
||||
const kaskoInsTerm = kaskoValues.insTerm;
|
||||
|
||||
if (
|
||||
recalcWithRevision &&
|
||||
quote?.evo_one_year_insurance &&
|
||||
@ -152,7 +148,7 @@ const customConditions: TElements<ValidationCondition> = {
|
||||
) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
rows => rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
false,
|
||||
)({
|
||||
insTerm: {
|
||||
@ -167,7 +163,7 @@ const customConditions: TElements<ValidationCondition> = {
|
||||
} else {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
rows => rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
false,
|
||||
)({
|
||||
insTerm: {
|
||||
|
||||
@ -5,40 +5,37 @@ import { isEqual, isNil } from 'lodash';
|
||||
const { PERIODS_NUMBER } = valuesConstants;
|
||||
|
||||
function validateInsuranceTable(this: ICalculationStore) {
|
||||
const tableInsurance = this.tables.tableInsurance;
|
||||
|
||||
const kaskoRowIndex = tableInsurance.rows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
const osagoRowIndex = tableInsurance.rows.findIndex(
|
||||
x => x.policyType?.value === 'ОСАГО',
|
||||
);
|
||||
|
||||
this.setTableRows(
|
||||
const osagoRow = this.getTableRowValues(
|
||||
'tableInsurance',
|
||||
0,
|
||||
)([
|
||||
{
|
||||
insuranceCompany: {
|
||||
validation: !isNil(
|
||||
tableInsurance.rows[osagoRowIndex].insuranceCompany?.value,
|
||||
),
|
||||
},
|
||||
insured: {
|
||||
validation: !isNil(tableInsurance.rows[osagoRowIndex].insured?.value),
|
||||
},
|
||||
rows => rows.findIndex(x => x.policyType?.value === 'ОСАГО'),
|
||||
'value',
|
||||
);
|
||||
this.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'ОСАГО'),
|
||||
)({
|
||||
insuranceCompany: {
|
||||
validation: !isNil(osagoRow.insuranceCompany),
|
||||
},
|
||||
{
|
||||
insuranceCompany: {
|
||||
validation: !isNil(
|
||||
tableInsurance.rows[kaskoRowIndex].insuranceCompany?.value,
|
||||
),
|
||||
},
|
||||
insured: {
|
||||
validation: !isNil(tableInsurance.rows[kaskoRowIndex].insured?.value),
|
||||
},
|
||||
insured: {
|
||||
validation: !isNil(osagoRow.insured),
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
const kaskoRow = this.getTableRowValues(
|
||||
'tableInsurance',
|
||||
rows => rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
'value',
|
||||
);
|
||||
this.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
)({
|
||||
insuranceCompany: {
|
||||
validation: !isNil(kaskoRow.insuranceCompany),
|
||||
},
|
||||
insured: {
|
||||
validation: !isNil(kaskoRow.insured),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function validatePaymentsTable(this: ICalculationStore) {
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
import { message } from 'antd';
|
||||
import { resetIns } from 'client/Components/Calculation/ELT/Content/lib/resetIns';
|
||||
import { numberElementsProps } from 'client/Containers/Calculation/lib/elements/elementsProps';
|
||||
import {
|
||||
getTitle,
|
||||
getValueName
|
||||
} from 'client/Containers/Calculation/lib/elements/tools';
|
||||
import { elementsValues } from 'client/Containers/Calculation/lib/elements/values';
|
||||
import { openNotification } from 'client/Elements/Notification';
|
||||
import initialValues from 'client/stores/CalculationStore/config/initialValues';
|
||||
@ -8,7 +13,10 @@ import CrmService from 'core/services/CrmService';
|
||||
import { currentISODate } from 'core/tools/date';
|
||||
import { IGetCRMEntitiesResponse } from 'core/types/Calculation/Responses';
|
||||
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
|
||||
import { TElements } from 'core/types/Calculation/Store/elements';
|
||||
import {
|
||||
ElementsNames,
|
||||
TElements
|
||||
} from 'core/types/Calculation/Store/elements';
|
||||
import { Process } from 'core/types/Calculation/Store/process';
|
||||
import { ValuesNames } from 'core/types/Calculation/Store/values';
|
||||
import { IEvoGraph } from 'core/types/Entities/crmEntities';
|
||||
@ -66,6 +74,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
||||
infuranceOPF,
|
||||
calcBroker,
|
||||
calcFinDepartment,
|
||||
balanceHolder,
|
||||
} = calculationStore.values;
|
||||
|
||||
calculationStore.setStatus('selectQuote', ElementStatus.Disabled);
|
||||
@ -257,10 +266,8 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
||||
);
|
||||
|
||||
if (current_opportunity) {
|
||||
const {
|
||||
evo_programsolution,
|
||||
evo_client_riskid,
|
||||
} = current_opportunity;
|
||||
const { evo_programsolution, evo_client_riskid } =
|
||||
current_opportunity;
|
||||
|
||||
if (evo_programsolution === 100000000) {
|
||||
const midClientRisk = calculationStore.getOption(
|
||||
@ -482,36 +489,77 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
||||
//townRegistration
|
||||
}
|
||||
|
||||
calculationStore.setValues(
|
||||
{
|
||||
...initialValues,
|
||||
...newValues,
|
||||
product,
|
||||
...addProducts,
|
||||
rate,
|
||||
lead,
|
||||
opportunity,
|
||||
quote: quoteId,
|
||||
recalcWithRevision,
|
||||
leaseObjectCount,
|
||||
clientRisk,
|
||||
calcType,
|
||||
totalPayments: evo_graph.evo_sumpay_withnds,
|
||||
indAgent,
|
||||
vehicleTaxInYear,
|
||||
INNForCalc,
|
||||
creditRate,
|
||||
infuranceOPF,
|
||||
legalClientRegion,
|
||||
regionRegistration,
|
||||
legalClientTown,
|
||||
townRegistration,
|
||||
calcBroker,
|
||||
calcFinDepartment,
|
||||
requirementTelematic,
|
||||
// redemptionPayment
|
||||
let redemptionPaymentSum =
|
||||
quote.evo_payment_redemption_sum ||
|
||||
initialValues.redemptionPaymentSum;
|
||||
// redemptionPayment
|
||||
|
||||
const finalValues = {
|
||||
...initialValues,
|
||||
...newValues,
|
||||
product,
|
||||
...addProducts,
|
||||
rate,
|
||||
lead,
|
||||
opportunity,
|
||||
quote: quoteId,
|
||||
recalcWithRevision,
|
||||
leaseObjectCount,
|
||||
clientRisk,
|
||||
calcType,
|
||||
totalPayments: evo_graph.evo_sumpay_withnds,
|
||||
indAgent,
|
||||
vehicleTaxInYear,
|
||||
INNForCalc,
|
||||
creditRate,
|
||||
infuranceOPF,
|
||||
legalClientRegion,
|
||||
regionRegistration,
|
||||
legalClientTown,
|
||||
townRegistration,
|
||||
calcBroker,
|
||||
calcFinDepartment,
|
||||
requirementTelematic,
|
||||
balanceHolder,
|
||||
redemptionPaymentSum,
|
||||
};
|
||||
|
||||
// check min max number values
|
||||
let fixedElementsNames: ElementsNames[] = [];
|
||||
(Object.keys(numberElementsProps) as ElementsNames[]).forEach(
|
||||
elementName => {
|
||||
if (elementName in numberElementsProps) {
|
||||
const elementProps = numberElementsProps[elementName];
|
||||
|
||||
const valueName = getValueName(elementName);
|
||||
if (
|
||||
finalValues[valueName] &&
|
||||
((elementProps?.min &&
|
||||
finalValues[valueName] < parseFloat(elementProps?.min)) ||
|
||||
(elementProps?.max &&
|
||||
finalValues[valueName] > parseFloat(elementProps?.max)))
|
||||
) {
|
||||
finalValues[valueName] = initialValues[valueName];
|
||||
fixedElementsNames.push(elementName);
|
||||
}
|
||||
}
|
||||
},
|
||||
true,
|
||||
);
|
||||
if (fixedElementsNames.length > 0) {
|
||||
const fieldsTitles = fixedElementsNames
|
||||
.map(x => getTitle(x))
|
||||
.join(', ');
|
||||
openNotification({
|
||||
type: 'warning',
|
||||
title: 'Внимание',
|
||||
description:
|
||||
'При подгрузке КП были сброшены поля: ' + fieldsTitles,
|
||||
})();
|
||||
}
|
||||
// check min max number values
|
||||
|
||||
calculationStore.setValues(finalValues, true);
|
||||
|
||||
message.success({
|
||||
content: `КП ${quote?.evo_quotename || ''} загружено!`,
|
||||
|
||||
@ -12,7 +12,7 @@ const mapKPtoValues: TValues<keyof IQuote | string> = {
|
||||
lastPaymentRule: 'evo_last_payment_calc',
|
||||
lastPaymentPerc: 'evo_last_payment_perc',
|
||||
lastPaymentRub: 'evo_last_payment_rub',
|
||||
balanceHolder: 'evo_balance_holder',
|
||||
// balanceHolder: 'evo_balance_holder',
|
||||
graphType: 'evo_graph_type',
|
||||
parmentsDecreasePercent: 'evo_payments_decrease_perc',
|
||||
seasonType: 'evo_seasons_type',
|
||||
|
||||
@ -58,6 +58,7 @@ export default gql`
|
||||
evo_req_telematic
|
||||
evo_req_telematic_accept
|
||||
evo_accept_control_addproduct_typeid
|
||||
evo_payment_redemption_sum
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@ -877,31 +877,31 @@ const reactionEffects: IReactionEffect[] = [
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { leasingPeriod } = calculationStore.values;
|
||||
return leasingPeriod;
|
||||
},
|
||||
effect: leasingPeriod => {
|
||||
if (leasingPeriod) {
|
||||
if (parseInt(leasingPeriod) < 13) {
|
||||
calculationStore.setStatus(
|
||||
'radioBalanceHolder',
|
||||
ElementStatus.Disabled,
|
||||
);
|
||||
calculationStore.setValue('balanceHolder', 100000000);
|
||||
} else {
|
||||
calculationStore.setStatus(
|
||||
'radioBalanceHolder',
|
||||
ElementStatus.Default,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
options: {
|
||||
fireImmediately: true,
|
||||
},
|
||||
}),
|
||||
// calculationStore => ({
|
||||
// expression: () => {
|
||||
// const { leasingPeriod } = calculationStore.values;
|
||||
// return leasingPeriod;
|
||||
// },
|
||||
// effect: leasingPeriod => {
|
||||
// if (leasingPeriod) {
|
||||
// if (parseInt(leasingPeriod) < 13) {
|
||||
// calculationStore.setStatus(
|
||||
// 'radioBalanceHolder',
|
||||
// ElementStatus.Disabled,
|
||||
// );
|
||||
// calculationStore.setValue('balanceHolder', 100000000);
|
||||
// } else {
|
||||
// calculationStore.setStatus(
|
||||
// 'radioBalanceHolder',
|
||||
// ElementStatus.Default,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// options: {
|
||||
// fireImmediately: true,
|
||||
// },
|
||||
// }),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
|
||||
@ -16,14 +16,9 @@ const { PERIODS_NUMBER } = valuesConstants;
|
||||
export default [
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
|
||||
const kaskoValues = calculationStore.getTableRowValues(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
rows => rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
'value',
|
||||
);
|
||||
|
||||
@ -72,47 +67,41 @@ export default [
|
||||
},
|
||||
}),
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
const kaskoRow = tableRows[kaskoRowIndex];
|
||||
const { leasingPeriod } = calculationStore.values;
|
||||
// (calculationStore, calculationProcess) => ({
|
||||
// expression: () => {
|
||||
// const { leasingPeriod } = calculationStore.values;
|
||||
|
||||
return {
|
||||
insTerm: kaskoRow.insTerm?.value,
|
||||
leasingPeriod,
|
||||
};
|
||||
},
|
||||
effect: ({ insTerm, leasingPeriod }) => {
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
if (insTerm === 100000001 && leasingPeriod > 15 && kaskoRowIndex) {
|
||||
if (kaskoRowIndex >= 0)
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insured: { value: 100000001, status: ElementStatus.Disabled },
|
||||
});
|
||||
} else {
|
||||
if (kaskoRowIndex >= 0)
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
)({
|
||||
insured: { status: ElementStatus.Default },
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
// const insTermValue = calculationStore.getTableRowValue(
|
||||
// 'tableInsurance',
|
||||
// rows => rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
// 'insTerm',
|
||||
// 'value',
|
||||
// );
|
||||
|
||||
// return {
|
||||
// insTerm: insTermValue,
|
||||
// leasingPeriod,
|
||||
// };
|
||||
// },
|
||||
// effect: ({ insTerm, leasingPeriod }) => {
|
||||
// if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
// return;
|
||||
// }
|
||||
// if (insTerm === 100000001 && leasingPeriod > 15) {
|
||||
// calculationStore.setTableRow('tableInsurance', rows =>
|
||||
// rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
// )({
|
||||
// insured: { value: 100000001, status: ElementStatus.Disabled },
|
||||
// });
|
||||
// } else {
|
||||
// calculationStore.setTableRow('tableInsurance', rows =>
|
||||
// rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
// )({
|
||||
// insured: { status: ElementStatus.Default },
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// }),
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
@ -121,87 +110,74 @@ export default [
|
||||
},
|
||||
effect: leasingPeriod => {
|
||||
if (leasingPeriod) {
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
const osagoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'ОСАГО',
|
||||
);
|
||||
|
||||
if (leasingPeriod < 12) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
osagoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'ОСАГО'),
|
||||
)({
|
||||
insured: { value: 100000000, status: ElementStatus.Disabled },
|
||||
});
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
)({
|
||||
insured: { value: 100000000, status: ElementStatus.Disabled },
|
||||
insTerm: { value: 100000000, status: ElementStatus.Disabled },
|
||||
});
|
||||
} else if (leasingPeriod === 12) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
osagoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'ОСАГО'),
|
||||
)({
|
||||
insured: { status: ElementStatus.Default },
|
||||
});
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
)({
|
||||
insured: { status: ElementStatus.Default },
|
||||
insTerm: { value: 100000000, status: ElementStatus.Disabled },
|
||||
});
|
||||
} else if (leasingPeriod > 12 && leasingPeriod < 16) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
osagoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'ОСАГО'),
|
||||
)({
|
||||
insured: { status: ElementStatus.Default },
|
||||
});
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
)({
|
||||
insured: { status: ElementStatus.Default },
|
||||
insTerm: { value: 100000001, status: ElementStatus.Disabled },
|
||||
});
|
||||
} else if (
|
||||
leasingPeriod > 16 &&
|
||||
calculationStore?.tables?.tableInsurance?.rows[kaskoRowIndex]?.insTerm
|
||||
?.value === 100000001
|
||||
leasingPeriod > 16
|
||||
// &&
|
||||
// calculationStore.getTableRowValue(
|
||||
// 'tableInsurance',
|
||||
// rows => rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
// 'insTerm',
|
||||
// 'value',
|
||||
// ) === 100000001
|
||||
) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
osagoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'ОСАГО'),
|
||||
)({
|
||||
insured: { status: ElementStatus.Default },
|
||||
});
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
)({
|
||||
insured: { value: 100000001, status: ElementStatus.Disabled },
|
||||
insTerm: { status: ElementStatus.Default },
|
||||
insured: { status: ElementStatus.Default },
|
||||
insTerm: { value: 100000000, status: ElementStatus.Disabled },
|
||||
});
|
||||
} else {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
osagoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'ОСАГО'),
|
||||
)({
|
||||
insured: { status: ElementStatus.Default },
|
||||
});
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
)({
|
||||
insured: { status: ElementStatus.Default },
|
||||
insTerm: { status: ElementStatus.Default },
|
||||
insTerm: { status: ElementStatus.Disabled },
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -213,28 +189,19 @@ export default [
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
const dgoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'ДГО',
|
||||
);
|
||||
const nsRowIndex = tableRows.findIndex(x => x.policyType?.value === 'НС');
|
||||
|
||||
const kaskoValues = calculationStore.getTableRowValues(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
rows => rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
'value',
|
||||
);
|
||||
const dgoValues = calculationStore.getTableRowValues(
|
||||
'tableInsurance',
|
||||
dgoRowIndex,
|
||||
rows => rows.findIndex(x => x.policyType?.value === 'ДГО'),
|
||||
'value',
|
||||
);
|
||||
const nsValues = calculationStore.getTableRowValues(
|
||||
'tableInsurance',
|
||||
nsRowIndex,
|
||||
rows => rows.findIndex(x => x.policyType?.value === 'НС'),
|
||||
'value',
|
||||
);
|
||||
|
||||
@ -248,19 +215,14 @@ export default [
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
|
||||
if (
|
||||
kaskoRow &&
|
||||
kaskoRow.insCost === 0 &&
|
||||
((dgoRow && dgoRow.insCost > 0) || (nsRow && nsRow.insCost > 0))
|
||||
) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
1,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
)({
|
||||
insCost: {
|
||||
validation: false,
|
||||
@ -273,9 +235,8 @@ export default [
|
||||
description: 'Укажите стоимость КАСКО',
|
||||
})();
|
||||
} else {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
)({
|
||||
insCost: {
|
||||
validation: true,
|
||||
@ -287,13 +248,9 @@ export default [
|
||||
|
||||
(calculationStore, calculationProcess) => ({
|
||||
expression: () => {
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
const kaskoValues = calculationStore.getTableRowValues(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
rows => rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
'value',
|
||||
);
|
||||
return {
|
||||
@ -304,19 +261,14 @@ export default [
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const kaskoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
|
||||
if (
|
||||
kaskoRow &&
|
||||
kaskoRow.insured === 100000001 &&
|
||||
kaskoRow.insCost === 0
|
||||
) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
)({
|
||||
insCost: {
|
||||
validation: false,
|
||||
@ -328,9 +280,8 @@ export default [
|
||||
description: 'Укажите стоимость КАСКО, включаемую в график',
|
||||
})();
|
||||
} else {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
kaskoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'КАСКО'),
|
||||
)({
|
||||
insCost: {
|
||||
validation: true,
|
||||
@ -359,19 +310,14 @@ export default [
|
||||
if (calculationProcess.hasProcess(Process.LoadKp)) {
|
||||
return;
|
||||
}
|
||||
const { rows: tableRows } = calculationStore.tables.tableInsurance;
|
||||
const osagoRowIndex = tableRows.findIndex(
|
||||
x => x.policyType?.value === 'ОСАГО',
|
||||
);
|
||||
|
||||
if (
|
||||
osagoRow &&
|
||||
osagoRow.insured === 100000001 &&
|
||||
osagoRow.insCost === 0
|
||||
) {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
osagoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'ОСАГО'),
|
||||
)({
|
||||
insCost: {
|
||||
validation: false,
|
||||
@ -383,9 +329,8 @@ export default [
|
||||
description: 'Укажите стоимость ОСАГО, включаемую в график',
|
||||
})();
|
||||
} else {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
osagoRowIndex,
|
||||
calculationStore.setTableRow('tableInsurance', rows =>
|
||||
rows.findIndex(x => x.policyType?.value === 'ОСАГО'),
|
||||
)({
|
||||
insCost: {
|
||||
validation: true,
|
||||
@ -762,15 +707,15 @@ export default [
|
||||
|
||||
if (nextIsTrailer) {
|
||||
const otherInsuranceCompany = calculationStore.tables.tableInsurance.options?.insuranceCompany?.find(
|
||||
x => x.name?.includes('ПРОЧИЕ'),
|
||||
);
|
||||
x => x.name?.includes('ПРОЧИЕ'),
|
||||
);
|
||||
if (otherInsuranceCompany) {
|
||||
const insuranceOtherFilter = singleValueFilter(
|
||||
otherInsuranceCompany.value,
|
||||
);
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
0,
|
||||
rows => rows.findIndex(x => x.policyType?.value === 'ОСАГО'),
|
||||
true,
|
||||
)({
|
||||
insuranceCompany: {
|
||||
@ -791,7 +736,7 @@ export default [
|
||||
} else {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
0,
|
||||
rows => rows.findIndex(x => x.policyType?.value === 'ОСАГО'),
|
||||
true,
|
||||
)({
|
||||
insuranceCompany: {
|
||||
|
||||
@ -41,6 +41,8 @@ const initialStatuses: TElements<ElementStatus> = {
|
||||
selectLeaseObjectCategory: ElementStatus.Disabled,
|
||||
tbxINNForCalc: ElementStatus.Disabled,
|
||||
radioInfuranceOPF: ElementStatus.Disabled,
|
||||
|
||||
tbxRedemptionPaymentSum: ElementStatus.Disabled,
|
||||
};
|
||||
|
||||
export default initialStatuses;
|
||||
|
||||
@ -15,12 +15,13 @@ const initialValues: TValues<TValue> = {
|
||||
supplierCurrency: 'RUB',
|
||||
supplierDiscountRub: 0,
|
||||
supplierDiscountPerc: 0,
|
||||
leasingPeriod: 12,
|
||||
leasingPeriod: 13,
|
||||
firstPaymentPerc: 25,
|
||||
firstPaymentRub: 0,
|
||||
lastPaymentPerc: 1,
|
||||
lastPaymentRule: 100000001,
|
||||
balanceHolder: 100000000,
|
||||
redemptionPaymentSum: 1000,
|
||||
balanceHolder: 100000001,
|
||||
graphType: 100000000,
|
||||
parmentsDecreasePercent: 94,
|
||||
seasonType: 100000000,
|
||||
|
||||
@ -36,6 +36,7 @@ export type ElementsNames =
|
||||
| 'tbxLastPaymentPerc'
|
||||
| 'tbxLastPaymentRub'
|
||||
| 'radioLastPaymentRule'
|
||||
| 'tbxRedemptionPaymentSum'
|
||||
| 'radioBalanceHolder'
|
||||
| 'radioGraphType'
|
||||
| 'tbxParmentsDecreasePercent'
|
||||
|
||||
@ -81,10 +81,17 @@ interface ICalculationTables {
|
||||
cleanTable: (tableName: TableNames) => void;
|
||||
getTableRowValues: (
|
||||
tableName: TableNames,
|
||||
rowIndex: number,
|
||||
rowIndex: number | ((rows: TableProps<ITableCell>[]) => number),
|
||||
paramName: ElementParam,
|
||||
) => TableProps<any>;
|
||||
|
||||
getTableRowValue: (
|
||||
tableName: TableNames,
|
||||
rowIndex: number | ((rows: TableProps<ITableCell>[]) => number),
|
||||
propName: TableValuesNames,
|
||||
paramName: ElementParam,
|
||||
) => any;
|
||||
|
||||
getTableOptions: (
|
||||
tableName: TableNames,
|
||||
propName: TableValuesNames,
|
||||
@ -102,7 +109,7 @@ interface ICalculationTables {
|
||||
|
||||
setTableRow: (
|
||||
tableName: TableNames,
|
||||
rowIndex: number,
|
||||
rowIndex: number | ((rows: TableProps<ITableCell>[]) => number),
|
||||
override?: boolean,
|
||||
) => (row: TableProps<ITableCell>) => void;
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ export type ValuesNames =
|
||||
| 'lastPaymentPerc'
|
||||
| 'lastPaymentRub'
|
||||
| 'lastPaymentRule'
|
||||
| 'redemptionPaymentSum'
|
||||
| 'balanceHolder'
|
||||
| 'graphType'
|
||||
| 'parmentsDecreasePercent'
|
||||
|
||||
@ -102,6 +102,7 @@ export interface IQuote {
|
||||
evo_req_telematic?: number;
|
||||
evo_req_telematic_accept?: number;
|
||||
evo_one_year_insurance?: boolean;
|
||||
evo_payment_redemption_sum?: number;
|
||||
}
|
||||
|
||||
export interface IEvoGraph {
|
||||
|
||||
Reference in New Issue
Block a user