prelast payments table effect

This commit is contained in:
Chika 2020-10-06 17:30:03 +03:00
parent 017fa89a61
commit 37d70b1c46
2 changed files with 98 additions and 1 deletions

View File

@ -2319,6 +2319,46 @@ const reactionEffects: IReactionEffect[] = [
break;
}
case 100000004: {
calculationStore.setTableRows(
'tablePayments',
1,
)([
{
paymentRelation: {
value: 25,
status: Status.Default,
},
},
{
paymentRelation: {
value: 50,
status: Status.Default,
},
},
{
paymentRelation: {
value: 75,
status: Status.Default,
},
},
]);
calculationStore.setTableRows(
'tablePayments',
4,
)(
Array.from({ length: leasingPeriod - 5 }, () => ({
paymentRelation: {
value: 100,
status: Status.Disabled,
},
})),
);
break;
}
default: {
break;
}

View File

@ -62,7 +62,6 @@ const tablePayments: ITable = {
}
}
const middleRows = toJS(calculationStore.tables[tableName].rows);
console.log('middleRows', middleRows);
middleRows.splice(0, 1);
middleRows.splice(-1, 1);
@ -86,6 +85,64 @@ const tablePayments: ITable = {
}
}
}
if (graphType === 100000004) {
if (rowIndex > 0 && rowIndex < 4) {
for (let i in calculationStore.tables[tableName].rows) {
const currRow =
calculationStore.tables[tableName].rows[parseInt(i)];
const prevRow =
calculationStore.tables[tableName].rows[parseInt(i) - 1];
if (
parseInt(i) > 0 &&
parseInt(i) < 4 &&
currRow &&
prevRow &&
currRow.paymentRelation?.value < prevRow.paymentRelation?.value
) {
calculationStore.setTableRow(
tableName,
parseInt(i),
)({
paymentRelation: {
validation: false,
},
});
} else {
calculationStore.setTableRow(
tableName,
parseInt(i),
)({
paymentRelation: {
validation: true,
},
});
}
}
const middleRows = toJS(calculationStore.tables[tableName].rows);
middleRows.splice(0, 1);
middleRows.length = 3;
if (
middleRows.every(
x =>
x.paymentRelation?.value ===
middleRows[0].paymentRelation?.value,
)
) {
calculationStore.setTableRows(
tableName,
1,
)(
Array.from({ length: middleRows.length }, (v, i) => ({
paymentRelation: {
validation: false,
},
})),
);
}
}
}
},
},
};