trailer osago reaction
This commit is contained in:
parent
2c6cb3942d
commit
350493fb4f
@ -1,5 +1,5 @@
|
||||
import initialTables from 'client/stores/CalculationStore/config/initialTables';
|
||||
import { merge } from 'lodash';
|
||||
import { merge, mergeWith } from 'lodash';
|
||||
|
||||
const tablesData = {
|
||||
tables: initialTables,
|
||||
@ -29,21 +29,29 @@ const tablesActions = {
|
||||
return values;
|
||||
},
|
||||
|
||||
replaceTableRows(tableName) {
|
||||
return rows => {
|
||||
this.tables[tableName].rows.replace(rows);
|
||||
};
|
||||
},
|
||||
|
||||
setTableRows(tableName, startIndex, override) {
|
||||
return rows => {
|
||||
if (override) {
|
||||
this.tables[tableName].rows.replace(rows);
|
||||
return;
|
||||
}
|
||||
if (this.tables[tableName] && this.tables[tableName].rows)
|
||||
for (
|
||||
let i = startIndex, j = 0;
|
||||
i < startIndex + rows.length;
|
||||
i++, j++
|
||||
) {
|
||||
this.tables[tableName].rows[i] = merge(
|
||||
this.tables[tableName].rows[i] = mergeWith(
|
||||
this.tables[tableName].rows[i],
|
||||
rows[j],
|
||||
(obj, src, key) => {
|
||||
if (override) {
|
||||
return src;
|
||||
}
|
||||
return merge(obj, src);
|
||||
},
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -221,11 +221,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
|
||||
: ElementStatus.Disabled,
|
||||
},
|
||||
}));
|
||||
calculationStore.setTableRows(
|
||||
'tablePayments',
|
||||
0,
|
||||
true,
|
||||
)([
|
||||
calculationStore.replaceTableRows('tablePayments')([
|
||||
{
|
||||
paymentRelation: {
|
||||
value: quote.evo_first_payment_perc,
|
||||
|
||||
@ -741,11 +741,7 @@ export default [
|
||||
}
|
||||
}
|
||||
|
||||
calculationStore.setTableRows(
|
||||
'tablePayments',
|
||||
0,
|
||||
true,
|
||||
)([
|
||||
calculationStore.replaceTableRows('tablePayments')([
|
||||
...payments,
|
||||
{
|
||||
paymentRelation: {
|
||||
@ -780,4 +776,59 @@ export default [
|
||||
fireImmediately: true,
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { leaseObjectCategory } = calculationStore.values;
|
||||
return leaseObjectCategory;
|
||||
},
|
||||
effect: leaseObjectCategory => {
|
||||
const isTrailer = leaseObjectCategory === 100000004;
|
||||
|
||||
if (isTrailer) {
|
||||
const otherInsuranceCompany = calculationStore.tables.tableInsurance.options?.insuranceCompany?.find(
|
||||
x => x.name?.includes('ПРОЧИЕ'),
|
||||
);
|
||||
if (otherInsuranceCompany)
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
0,
|
||||
true,
|
||||
)({
|
||||
insuranceCompany: {
|
||||
filter: options =>
|
||||
options.filter(x => x.value === otherInsuranceCompany.value),
|
||||
value: otherInsuranceCompany.value,
|
||||
status: ElementStatus.Disabled,
|
||||
},
|
||||
insCost: {
|
||||
value: 0,
|
||||
status: ElementStatus.Disabled,
|
||||
},
|
||||
insured: {
|
||||
value: 100000000,
|
||||
status: ElementStatus.Disabled,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
calculationStore.setTableRow(
|
||||
'tableInsurance',
|
||||
0,
|
||||
true,
|
||||
)({
|
||||
insuranceCompany: {
|
||||
filter: undefined,
|
||||
value: null,
|
||||
status: ElementStatus.Default,
|
||||
},
|
||||
insCost: {
|
||||
status: ElementStatus.Default,
|
||||
},
|
||||
insured: {
|
||||
status: ElementStatus.Default,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
] as IReactionEffect[];
|
||||
|
||||
@ -15,7 +15,12 @@ import {
|
||||
} from './tables';
|
||||
import { TValue, TValues, ValuesNames, ResultValuesNames } from './values';
|
||||
|
||||
export type ElementParam = 'value' | 'status' | 'options' | 'filter' | 'validation';
|
||||
export type ElementParam =
|
||||
| 'value'
|
||||
| 'status'
|
||||
| 'options'
|
||||
| 'filter'
|
||||
| 'validation';
|
||||
|
||||
interface ICalculationValues {
|
||||
staticData: TStaticData;
|
||||
@ -72,6 +77,10 @@ interface ICalculationTables {
|
||||
paramName: ElementParam,
|
||||
) => { values: TableProps<any> };
|
||||
|
||||
replaceTableRows: (
|
||||
tableName: TableNames,
|
||||
) => (rows: TableProps<ITableCell>[]) => void;
|
||||
|
||||
setTableRows: (
|
||||
tableName: TableNames,
|
||||
startIndex: number,
|
||||
|
||||
Reference in New Issue
Block a user