From 1a6e28614ca9479f6e106e60218e88b8bf83e92e Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 8 Oct 2020 10:12:26 +0300 Subject: [PATCH] fix get value from nextPeriods --- .../stores/CalculationStore/Effects/reaction.ts | 17 ++++++++++------- src/core/config/initialTables/tablePayments.ts | 5 +++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/client/stores/CalculationStore/Effects/reaction.ts b/src/client/stores/CalculationStore/Effects/reaction.ts index 9ea33dd..7689f46 100644 --- a/src/client/stores/CalculationStore/Effects/reaction.ts +++ b/src/client/stores/CalculationStore/Effects/reaction.ts @@ -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, }, diff --git a/src/core/config/initialTables/tablePayments.ts b/src/core/config/initialTables/tablePayments.ts index 9e6a61b..4ff2069 100644 --- a/src/core/config/initialTables/tablePayments.ts +++ b/src/core/config/initialTables/tablePayments.ts @@ -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,