fix get value from nextPeriods

This commit is contained in:
Chika 2020-10-08 10:12:26 +03:00
parent a7e794486c
commit 1a6e28614c
2 changed files with 13 additions and 9 deletions

View File

@ -2414,26 +2414,26 @@ const reactionEffects: IReactionEffect[] = [
nextLeasingPeriod <= 14 ? nextLeasingPeriod - 2 : 12;
const nextShiftNumber = nextHighSeasonStart - 2;
let nextMiddleValues: number[] = [];
let nextPeriods: number[] = [];
switch (nextSeasonType) {
// 6/6
case 100000000: {
nextMiddleValues = Array.from({ length: 12 }, (v, i) =>
nextPeriods = Array.from({ length: 12 }, (v, i) =>
i < 6 ? HIGH : LOW,
);
break;
}
// 8/4
case 100000001: {
nextMiddleValues = Array.from({ length: 12 }, (v, i) =>
nextPeriods = Array.from({ length: 12 }, (v, i) =>
i < 8 ? HIGH : LOW,
);
break;
}
// 4/4/4
case 100000002: {
nextMiddleValues = Array.from(
nextPeriods = Array.from(
{ length: 12 },
(v, i) => (i < 4 && HIGH) || (i < 8 && MIDDLE) || LOW,
);
@ -2441,16 +2441,19 @@ const reactionEffects: IReactionEffect[] = [
}
}
if (nextShiftNumber > 0) {
nextMiddleValues = shift(nextMiddleValues, nextShiftNumber);
nextPeriods = shift(nextPeriods, nextShiftNumber);
}
nextMiddleValues.length = nextPeriodsNumber;
nextPeriods.length = nextPeriodsNumber;
const middleRows = Array.from(
{ length: nextLeasingPeriod - 2 },
(v, i) => {
return {
paymentRelation: {
value: nextMiddleValues[i] || nextMiddleValues[i - 12],
value:
nextPeriods[
i - nextPeriodsNumber * Math.floor(i / nextPeriodsNumber)
],
status:
i < nextPeriodsNumber ? Status.Default : Status.Disabled,
},

View File

@ -88,8 +88,9 @@ const tablePayments: ITable = {
if (graphType === 100000003) {
const { leasingPeriod } = calculationStore.values;
if (rowIndex >= 1 && rowIndex <= 12) {
for (let i = rowIndex; i < leasingPeriod - 1; i += 12) {
const periodsNumber = leasingPeriod <= 14 ? leasingPeriod - 2 : 12;
if (rowIndex >= 1 && rowIndex <= periodsNumber) {
for (let i = rowIndex; i < leasingPeriod - 1; i += periodsNumber) {
calculationStore.setTableRow(
tableName,
i,