fix tbxLastPaymentRub & tbxLastPaymentPerc

This commit is contained in:
vchikalkin 2023-04-06 17:23:58 +03:00
parent 09c9028a93
commit 445d527c5a

View File

@ -169,28 +169,40 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
'lastPaymentPerc',
'addEquipmentPrice',
'importProgramSum',
'lastPaymentRule',
]),
({ addEquipmentPrice, lastPaymentPerc, plPriceRub, importProgramSum }) => {
({ addEquipmentPrice, lastPaymentPerc, plPriceRub, importProgramSum, lastPaymentRule }) => {
if (lastPaymentRule === 100_000_000) {
return;
}
const rub = (lastPaymentPerc * (plPriceRub + addEquipmentPrice - importProgramSum)) / 100;
$calculation.element('tbxLastPaymentRub').setValue(rub);
}
),
() => $calculation.element('radioLastPaymentRule').getValue() === 100_000_000
() => $process.has('LoadKP')
);
makeDisposable(
() =>
reaction(
() => $calculation.element('tbxLastPaymentRub').getValue(),
(lastPaymentRub) => {
const { plPriceRub, addEquipmentPrice, importProgramSum } =
$calculation.$values.getValues();
() =>
$calculation.$values.getValues([
'plPriceRub',
'lastPaymentRub',
'addEquipmentPrice',
'importProgramSum',
'lastPaymentRule',
]),
({ lastPaymentRub, plPriceRub, addEquipmentPrice, importProgramSum, lastPaymentRule }) => {
if (lastPaymentRule === 100_000_001) {
return;
}
const perc = (lastPaymentRub / (plPriceRub + addEquipmentPrice - importProgramSum)) * 100;
$calculation.element('tbxLastPaymentPerc').setValue(perc);
}
),
() =>
$process.has('LoadKP') ||
$calculation.element('radioLastPaymentRule').getValue() === 100_000_001
() => $process.has('LoadKP')
);
}