fix: платежи - загружаем КП Севертранс 380 с дегрессией, потом выбираем гибкую и платежи заполняются пустыми значениями

This commit is contained in:
vchikalkin 2023-02-08 09:49:15 +03:00
parent 5b35d4faf8
commit f6879220cb

View File

@ -339,7 +339,7 @@ export default function paymentsReactions({ store }: ReactionsContext) {
},
];
if (!$process.has('LoadKP')) {
if (!$process.has('LoadKP') && degressionType !== 100_000_007) {
$tables.payments.setValues(rows.map((row) => row.value));
}
@ -348,48 +348,6 @@ 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')
);
/**
* Сезонный
*/