tables/payments: Равноубывающий

This commit is contained in:
Chika 2022-10-03 14:34:01 +03:00
parent eb7dc997e4
commit 048da7947a

View File

@ -71,4 +71,53 @@ export default function paymentsReactions(
fireImmediately: true,
}
);
/**
* Равноубывающий
*/
reaction(
() => {
const graphType = $calculation.getElementValue('radioGraphType');
const leasingPeriod = $calculation.getElementValue('tbxLeasingPeriod');
const parmentsDecreasePercent = $calculation.getElementValue('tbxParmentsDecreasePercent');
return {
graphType,
leasingPeriod,
parmentsDecreasePercent,
};
},
({ graphType, leasingPeriod, parmentsDecreasePercent }) => {
if (graphType === 100_000_002) {
const middleValues: Row[] = Array.from(
{
length: leasingPeriod - 2,
},
(_, k) => {
const payment = 100 * (parmentsDecreasePercent / 100) ** k;
return {
value: Number(payment.toFixed(2)),
status: 'Disabled',
};
}
);
const firstPaymentPerc = $calculation.getElementValue('tbxFirstPaymentPerc');
const lastPaymentPerc = $calculation.getElementValue('tbxLastPaymentPerc');
$tables.payments.setRows([
{
value: firstPaymentPerc,
status: 'Disabled',
},
...middleValues,
{
value: lastPaymentPerc,
status: 'Disabled',
},
]);
}
}
);
}