From 2a98c6c1a31def9a3f521889622d85d8ce1b624e Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 8 Feb 2023 10:12:23 +0300 Subject: [PATCH] =?UTF-8?q?Revert=20"fix:=20=D0=BF=D0=BB=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=B6=D0=B8=20-=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B6=D0=B0?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=9A=D0=9F=20=D0=A1=D0=B5=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D0=BD=D1=81=20380=20=D1=81=20=D0=B4=D0=B5?= =?UTF-8?q?=D0=B3=D1=80=D0=B5=D1=81=D1=81=D0=B8=D0=B5=D0=B9,=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=BC=20=D0=B2=D1=8B=D0=B1=D0=B8=D1=80=D0=B0?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=B3=D0=B8=D0=B1=D0=BA=D1=83=D1=8E=20=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BB=D0=B0=D1=82=D0=B5=D0=B6=D0=B8=20=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=BD=D1=8F=D1=8E=D1=82=D1=81=D1=8F=20=D0=BF=D1=83?= =?UTF-8?q?=D1=81=D1=82=D1=8B=D0=BC=D0=B8=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=D0=BC=D0=B8"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f6879220cb5e1abb8d6fa755d16e7e3482979c7c. --- apps/web/process/payments/reactions.ts | 44 +++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/apps/web/process/payments/reactions.ts b/apps/web/process/payments/reactions.ts index 68d749a..c215858 100644 --- a/apps/web/process/payments/reactions.ts +++ b/apps/web/process/payments/reactions.ts @@ -341,7 +341,7 @@ export default function paymentsReactions({ store }: ReactionsContext) { }, ]; - if (!$process.has('LoadKP') && degressionType !== 100_000_007) { + if (!$process.has('LoadKP')) { $tables.payments.setValues(rows.map((row) => row.value)); } @@ -350,6 +350,48 @@ export default function paymentsReactions({ store }: ReactionsContext) { } ); + makeDisposable( + () => + reaction( + () => { + const graphType = $calculation.element('radioGraphType').getValue(); + const payments = toJS($tables.payments.values); + const degressionType = $calculation.element('selectSeasonType').getValue(); + + return { + degressionType, + graphType, + payments, + }; + }, + (nextParams, prevParams) => { + if (nextParams.graphType === 100_000_001 && nextParams.degressionType === 100_000_007) { + const changes = difference(nextParams.payments, prevParams.payments); + + if (changes === null || changes.length > 1) return; + + const [changeIndex] = changes; + const value = nextParams.payments[changeIndex]; + const payments = nextParams.payments.slice(1, -1).map((payment, i) => { + if (i <= changeIndex - 2) return payment; + + return value; + }); + + const firstPaymentPerc = $calculation.element('tbxFirstPaymentPerc').getValue(); + const lastPaymentPerc = $calculation.element('tbxLastPaymentPerc').getValue(); + + $tables.payments.setValues([firstPaymentPerc, ...payments, lastPaymentPerc]); + } + }, + { + delay: 50, + equals: comparer.structural, + } + ), + () => $process.has('LoadKP') + ); + /** * Сезонный */