diff --git a/src/client/Containers/Calculation/Components/Results/resultsList.ts b/src/client/Containers/Calculation/Components/Results/resultsList.ts index 8d02712..dd362a2 100644 --- a/src/client/Containers/Calculation/Components/Results/resultsList.ts +++ b/src/client/Containers/Calculation/Components/Results/resultsList.ts @@ -46,6 +46,7 @@ export const calculationResults: ISection[] = [ 'labelResultDopMPLLeasing', 'labelResultBonusDopProd', 'labelResultBonusSafeFinance', + 'labelResultParticipationAmount', ], }, ], diff --git a/src/client/Containers/Calculation/Elements/components.ts b/src/client/Containers/Calculation/Elements/components.ts index 0281b49..27da392 100644 --- a/src/client/Containers/Calculation/Elements/components.ts +++ b/src/client/Containers/Calculation/Elements/components.ts @@ -164,6 +164,7 @@ export default { labelResultBonusDopProd: Label, labelResultBonusSafeFinance: Label, labelResultFirstPaymentRiskPolicy: Label, + labelResultParticipationAmount: Label, /** Button Elements */ btnCreateKP: Button, diff --git a/src/client/Containers/Calculation/Elements/props/common.ts b/src/client/Containers/Calculation/Elements/props/common.ts index c19a24b..b60da25 100644 --- a/src/client/Containers/Calculation/Elements/props/common.ts +++ b/src/client/Containers/Calculation/Elements/props/common.ts @@ -399,6 +399,7 @@ const moneyResultElementsProps = ( 'labelResultBonusDopProd', 'labelSubsidySum', 'labelResultBonusSafeFinance', + 'labelResultParticipationAmount', ] as ElementsNames[] ).reduce( (ac, a) => ({ diff --git a/src/client/Containers/Calculation/Elements/titles.ts b/src/client/Containers/Calculation/Elements/titles.ts index 2c76640..6e0a107 100644 --- a/src/client/Containers/Calculation/Elements/titles.ts +++ b/src/client/Containers/Calculation/Elements/titles.ts @@ -150,6 +150,7 @@ export const elementsTitles: Partial> = { labelResultBonusDopProd: 'Бонус МПЛ за доп.продукты, без НДФЛ', labelResultBonusSafeFinance: 'Бонус за Safe Finance без НДФЛ', labelResultFirstPaymentRiskPolicy: 'Первый платеж по риск политике, %', + labelResultParticipationAmount: 'Сумма участия (для принятия решения)', }; export const tablesTitles: Record = { diff --git a/src/client/Containers/Calculation/Elements/values.ts b/src/client/Containers/Calculation/Elements/values.ts index 54d2ba6..d1a63f0 100644 --- a/src/client/Containers/Calculation/Elements/values.ts +++ b/src/client/Containers/Calculation/Elements/values.ts @@ -156,6 +156,7 @@ const elementsValues: Record = { labelResultBonusDopProd: 'resultBonusDopProd', labelResultBonusSafeFinance: 'resultBonusSafeFinance', labelResultFirstPaymentRiskPolicy: 'resultFirstPaymentRiskPolicy', + labelResultParticipationAmount: 'resultParticipationAmount', }; const elementsComputedValues: Record< diff --git a/src/client/Containers/Calculation/types/elements.ts b/src/client/Containers/Calculation/types/elements.ts index af99b4c..598a760 100644 --- a/src/client/Containers/Calculation/types/elements.ts +++ b/src/client/Containers/Calculation/types/elements.ts @@ -141,7 +141,8 @@ export type ElementsNames = | 'labelResultDopMPLLeasing' | 'labelResultBonusDopProd' | 'labelResultBonusSafeFinance' - | 'labelResultFirstPaymentRiskPolicy'; + | 'labelResultFirstPaymentRiskPolicy' + | 'labelResultParticipationAmount'; export type ButtonElementsNames = 'btnCreateKP' | 'btnCalculate'; export type LinkElementsNames = 'linkDownloadKp'; diff --git a/src/client/process/bonuses/reactions.ts b/src/client/process/bonuses/reactions.ts index 11dbccb..dbffe4d 100644 --- a/src/client/process/bonuses/reactions.ts +++ b/src/client/process/bonuses/reactions.ts @@ -12,12 +12,52 @@ export default function ($calculation: ICalculationStore) { * из поля Продукт selectProduct evo_evo_coefficient_evo_baseproduct * Если продукта нет или нет коэффициента по условиям, то поле tbxSaleBonus = 0 и закрыто для редактирования */ + reaction( - () => $calculation.getValues(['saleBonus', 'product']), - ({ saleBonus, product }) => { + () => { + return $calculation.getValue('product'); + }, + product => { $calculation.setStatus('tbxSaleBonus', ElementStatus.Default); const systemuser = $calculation.getStaticData('systemuser'); + if (systemuser && product) { + const evo_sot_coefficient_type = $calculation + .getStaticData('evo_sot_coefficient_type') + .find(x => x.evo_id === 'BONUS_LEASING'); + const evo_coefficient_bonus = $calculation + .getStaticData('evo_coefficient') + .find( + x => + x.evo_job_titleid === systemuser[0].evo_job_titleid && + x.evo_sot_coefficient_typeid === + evo_sot_coefficient_type?.evo_sot_coefficient_typeid && + x.evo_baseproducts?.map(x => x.evo_id).includes(product), + ); + + if (evo_coefficient_bonus?.evo_sot_coefficient) { + $calculation.setValue( + 'saleBonus', + evo_coefficient_bonus?.evo_sot_coefficient * 100, + ); + + $calculation.setStatus('tbxSaleBonus', ElementStatus.Default); + } else { + $calculation.setValue('saleBonus', 0); + $calculation.setStatus('tbxSaleBonus', ElementStatus.Disabled); + } + } + }, + ); + + reaction( + () => { + return $calculation.getValues(['saleBonus', 'product']); + }, + ({ saleBonus, product }) => { + $calculation.setValidation('tbxSaleBonus', undefined); + const systemuser = $calculation.getStaticData('systemuser'); + if (systemuser && product) { const evo_sot_coefficient_type = $calculation .getStaticData('evo_sot_coefficient_type') @@ -47,9 +87,6 @@ export default function ($calculation: ICalculationStore) { } else { $calculation.setValidation('tbxSaleBonus', undefined); } - } else { - $calculation.setValue('saleBonus', 0); - $calculation.setStatus('tbxSaleBonus', ElementStatus.Disabled); } } }, diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/index.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/index.ts index 7fcba7c..ed30e0d 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/index.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/index.ts @@ -28,6 +28,7 @@ export const RESULT_VALUES: ValuesNames[] = [ 'resultBonusMPL', 'resultDopMPLLeasing', 'resultBonusDopProd', + 'resultParticipationAmount', ]; export default function (this: ICalculationStore) { diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts index 8de78cb..0e13dc8 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts @@ -149,6 +149,25 @@ export default { 'resultFirstPaymentRiskPolicy', (preparedData?.preparedValues?.firstPayment || 0) * 100, ); + const { preparedValues, columns } = res; + this.setValue( + 'resultParticipationAmount', + (preparedValues.niAtInception || 0) + + ((preparedValues.ratBonus || 0) + + (preparedValues.nsBonus || 0) + + (preparedValues.nsibBonus || 0)) * + (preparedValues.marketRate || 0) * + (preparedValues.districtRate || 0) + + Math.abs(columns.npvBonusExpensesColumn.values.at(0)) + + Math.abs(columns.extraBonusSumColumn.values.at(0)) + + (preparedValues.importerSum || 0) + + (preparedValues.agentsSum || 0) + + (preparedValues.extraBonusSumColumn || 0) + + (preparedValues.deliverySum || 0) + + (preparedValues.brokerSum || 0) + + (preparedValues.brokerOfDeliverySum || 0) + + (preparedValues.financialDeptOfDeliverySum || 0), + ); }, setResValues: function ( this: ICalculationStore, diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/tables.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/tables.ts index 3c63860..4dba0dd 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/tables.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/tables.ts @@ -81,6 +81,47 @@ function validateInsuranceTable(this: ICalculationStore) { validation: !isNil(kaskoRow.insured), }, }); + + /** + * Если в таблице страхования в строке КАСКО Плательщик = ЛД и в поле "Стоимость за первый период" значение меньше 1000, то выводить ошибку + * Если в таблице страхования в строке ОСАГО Плательщик = ЛД и в поле "Стоимость за первый период" значение меньше 1000, то выводить ошибку + */ + + if (osagoRow.insured === 100_000_001 && osagoRow.insCost < 1000) { + this.setTableRow('tableInsurance', rows => + rows.findIndex(x => x?.key === 'osago'), + )({ + insCost: { + validation: false, + }, + }); + } else { + this.setTableRow('tableInsurance', rows => + rows.findIndex(x => x?.key === 'osago'), + )({ + insCost: { + validation: undefined, + }, + }); + } + + if (kaskoRow.insured === 100_000_001 && kaskoRow.insCost < 1000) { + this.setTableRow('tableInsurance', rows => + rows.findIndex(x => x?.key === 'kasko'), + )({ + insCost: { + validation: false, + }, + }); + } else { + this.setTableRow('tableInsurance', rows => + rows.findIndex(x => x?.key === 'kasko'), + )({ + insCost: { + validation: undefined, + }, + }); + } } function validatePaymentsTable(this: ICalculationStore) { diff --git a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts index 4360187..a1529e7 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts @@ -1173,7 +1173,7 @@ const reactionEffects: IReactionEffect[] = [ effect: ({ evo_base_rate }) => { calculationStore.setValue( 'creditRate', - evo_base_rate || valuesConstants.RATE, + evo_base_rate !== undefined ? evo_base_rate : valuesConstants.RATE, ); }, }), diff --git a/src/core/services/CoreService/types/Calculation/prepared.ts b/src/core/services/CoreService/types/Calculation/prepared.ts index a395917..c2cadaa 100644 --- a/src/core/services/CoreService/types/Calculation/prepared.ts +++ b/src/core/services/CoreService/types/Calculation/prepared.ts @@ -1,4 +1,5 @@ export interface PreparedValues { + extraBonusSumColumn?: number; importProgramSum?: number; calcDate?: Date; calcType?: number; diff --git a/src/core/types/Calculation/Store/values.ts b/src/core/types/Calculation/Store/values.ts index 0c5a5c1..a330754 100644 --- a/src/core/types/Calculation/Store/values.ts +++ b/src/core/types/Calculation/Store/values.ts @@ -137,6 +137,7 @@ export type ValuesNames = | 'resultBonusDopProd' | 'resultBonusSafeFinance' | 'resultFirstPaymentRiskPolicy' + | 'resultParticipationAmount' | 'leaseObjectPriceWthtVAT' | 'VATInLeaseObjectPrice' | 'engineHours'