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, formatter: formatNumber,
}, },
tbxInsAgeDrivers: { tbxInsAgeDrivers: {
min: '18', // min: '18',
max: '99', // max: '99',
}, },
tbxInsExpDrivers: { tbxInsExpDrivers: {
min: '0', // min: '0',
max: '99', // max: '99',
}, },
selectRegionRegistration: { selectRegionRegistration: {
showSearch: true, showSearch: true,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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