merge release/dyn-829_last-payment-calculation

This commit is contained in:
Chika 2022-02-09 12:09:39 +03:00
parent 1e1422f723
commit c0dcaaf8fd
9 changed files with 44 additions and 27 deletions

View File

@ -209,12 +209,12 @@ const elementsProps: Partial<Record<AllElementsNames, ElementProps>> = {
formatter: formatNumber,
},
tbxInsAgeDrivers: {
min: '18',
max: '99',
// min: '18',
// max: '99',
},
tbxInsExpDrivers: {
min: '0',
max: '99',
// min: '0',
// max: '99',
},
selectRegionRegistration: {
showSearch: true,

View File

@ -17,7 +17,7 @@ export const elementsTitles: Partial<Record<AllElementsNames, string>> = {
tbxFirstPaymentRub: 'Первый платеж, руб.',
tbxLastPaymentPerc: 'Последний платеж, %',
tbxLastPaymentRub: 'Последний платеж, руб.',
radioLastPaymentRule: 'Последний платеж считается от ',
radioLastPaymentRule: 'Последний платеж',
tbxRedemptionPaymentSum: 'Сумма выкупного платежа, руб',
radioBalanceHolder: 'Балансодержатель',
radioGraphType: 'Вид графика',

View File

@ -109,6 +109,7 @@ export default function (this: ICalculationStore): PreparedData {
preparedValues.firstPaymentAbs = undefined;
preparedValues.firstPaymentNdsAbs = undefined;
preparedValues.firstPaymentWithNdsAbs = undefined;
preparedValues.lastPaymentFix = values.lastPaymentRule !== 100_000_002;
preparedValues.lastPayment = (values.lastPaymentPerc as number) / 100;
preparedValues.lastPaymentSum =
(values.lastPaymentRub as number) / (1 + valuesConstants.VAT);

View File

@ -157,5 +157,10 @@ export default {
(res?.columns?.sumWithVatColumn?.values[0] || 0) -
(this.getValue('subsidySum') || 0),
);
if (this.getValue('lastPaymentRule') === 100_000_002)
this.setValue(
'lastPaymentRub',
res?.columns?.sumWithVatColumn?.values.pop(),
);
},
};

View File

@ -445,8 +445,8 @@ const reactionEffects: IReactionEffect[] = [
return lastPaymentRule;
},
effect: lastPaymentRule => {
if (lastPaymentRule) {
if (lastPaymentRule === 100000000) {
switch (lastPaymentRule) {
case 100_000_000: {
calculationStore.setStatus(
'tbxLastPaymentPerc',
ElementStatus.Disabled,
@ -455,7 +455,9 @@ const reactionEffects: IReactionEffect[] = [
'tbxLastPaymentRub',
ElementStatus.Default,
);
} else {
break;
}
case 100_000_001: {
calculationStore.setStatus(
'tbxLastPaymentPerc',
ElementStatus.Default,
@ -464,6 +466,17 @@ const reactionEffects: IReactionEffect[] = [
'tbxLastPaymentRub',
ElementStatus.Disabled,
);
break;
}
default: {
calculationStore.setStatus(
'tbxLastPaymentPerc',
ElementStatus.Disabled,
);
calculationStore.setStatus(
'tbxLastPaymentRub',
ElementStatus.Disabled,
);
}
}
},
@ -474,9 +487,7 @@ const reactionEffects: IReactionEffect[] = [
calculationStore => ({
expression: () => {
const { lastPaymentRub, lastPaymentPerc, insNSIB } =
calculationStore.values;
return { lastPaymentRub, lastPaymentPerc, insNSIB };
return calculationStore.getValues(['lastPaymentRub', 'insNSIB']);
},
effect: ({ lastPaymentRub, insNSIB }) => {
if (insNSIB && lastPaymentRub && lastPaymentRub < 3500) {
@ -487,18 +498,9 @@ const reactionEffects: IReactionEffect[] = [
description:
'Последний платеж меньше 3500 руб. не может быть при наличии НСИБ, укажите большее значение',
})();
return;
} else if (lastPaymentRub && lastPaymentRub < 1000) {
calculationStore.setValidation('tbxLastPaymentRub', false);
openNotification({
type: 'error',
title: 'Ошибка',
description:
'Последний платеж меньше 1000 руб. не может быть, укажите большее значение',
})();
return;
} else {
calculationStore.setValidation('tbxLastPaymentRub', true);
}
calculationStore.setValidation('tbxLastPaymentRub', true);
},
}),

View File

@ -173,7 +173,7 @@ export default [
lastPaymentRule,
]) => {
if (
lastPaymentRule !== 100000001 ||
lastPaymentRule === 100000000 ||
calculationProcess.hasProcess(Process.LoadKp)
) {
return;
@ -212,7 +212,7 @@ export default [
lastPaymentRule,
]) => {
if (
lastPaymentRule !== 100000000 ||
lastPaymentRule === 100000001 ||
calculationProcess.hasProcess(Process.LoadKp)
) {
return;

View File

@ -540,7 +540,11 @@ const reactionEffects: IReactionEffect[] = [
calculationStore => ({
expression: () =>
calculationStore.getValues(['lastPaymentPerc', 'balanceHolder']),
calculationStore.getValues([
'lastPaymentPerc',
'balanceHolder',
'lastPaymentRule',
]),
effect: ({ lastPaymentPerc, balanceHolder }) => {
if (balanceHolder && balanceHolder === 100000001) {
if (!lastPaymentPerc || parseFloat(lastPaymentPerc) < 1) {

View File

@ -5,11 +5,15 @@ import { orderBy } from 'lodash';
const initialOptions: Partial<Record<ElementsNames, IBaseOption[]>> = {
radioLastPaymentRule: [
{
name: 'рублей',
name: 'равен платежу',
value: 100000002,
},
{
name: 'в рублях',
value: 100000000,
},
{
name: '%',
name: 'в %',
value: 100000001,
},
],

View File

@ -17,6 +17,7 @@ export interface PreparedValues {
firstPaymentAbs?: number;
firstPaymentNdsAbs?: number;
firstPaymentWithNdsAbs?: number;
lastPaymentFix?: boolean;
lastPayment?: number;
lastPaymentSum?: number;
scheduleOfPayments?: number;