tbxFirstPaymentRub, tbxFirstPaymentPerc
This commit is contained in:
parent
b61bca1947
commit
13fc2b4c78
@ -40,7 +40,7 @@ const defaultValues: CalculationValues = {
|
||||
engineVolume: 0,
|
||||
finDepartmentRewardCondtion: null,
|
||||
finDepartmentRewardSumm: 0,
|
||||
firstPaymentPerc: 25,
|
||||
firstPaymentPerc: 0,
|
||||
firstPaymentRub: 0,
|
||||
fuelCard: null,
|
||||
fullPriceWithDiscount: false,
|
||||
@ -113,7 +113,7 @@ const defaultValues: CalculationValues = {
|
||||
quoteUrl: null,
|
||||
rate: null,
|
||||
recalcWithRevision: false,
|
||||
redemptionPaymentSum: 1_000,
|
||||
redemptionPaymentSum: 1000,
|
||||
regionRegistration: null,
|
||||
registration: null,
|
||||
registrationDescription: '-',
|
||||
|
||||
@ -3,9 +3,11 @@ import { VAT } from '@/constants/values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ReactionsContext } from '@/process/types';
|
||||
import { autorun, reaction } from 'mobx';
|
||||
import { pick } from 'radash';
|
||||
import { makeDisposable } from 'tools';
|
||||
|
||||
export default function commonReactions({ store, apolloClient }: ReactionsContext) {
|
||||
const { $calculation } = store;
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
reaction(
|
||||
() => $calculation.element('radioLastPaymentRule').getValue(),
|
||||
@ -88,4 +90,32 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex
|
||||
$calculation.element('tbxVATInLeaseObjectPrice').setValue(priceVAT);
|
||||
}
|
||||
});
|
||||
|
||||
reaction(
|
||||
() =>
|
||||
pick($calculation.$values.values, [
|
||||
'firstPaymentPerc',
|
||||
'addEquipmentPrice',
|
||||
'importProgramSum',
|
||||
'plPriceRub',
|
||||
]),
|
||||
({ firstPaymentPerc, addEquipmentPrice, importProgramSum, plPriceRub }) => {
|
||||
const rub = (firstPaymentPerc * (plPriceRub + addEquipmentPrice - importProgramSum)) / 100;
|
||||
$calculation.element('tbxFirstPaymentRub').setValue(rub);
|
||||
}
|
||||
);
|
||||
|
||||
makeDisposable(
|
||||
() =>
|
||||
reaction(
|
||||
() => pick($calculation.$values.values, ['firstPaymentRub']),
|
||||
({ firstPaymentRub }) => {
|
||||
const { plPriceRub, addEquipmentPrice, importProgramSum } = $calculation.$values.values;
|
||||
const perc =
|
||||
(firstPaymentRub / (plPriceRub + addEquipmentPrice - importProgramSum)) * 100;
|
||||
$calculation.element('tbxFirstPaymentPerc').setValue(perc);
|
||||
}
|
||||
),
|
||||
() => $process.has('LoadKP')
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user