From f725d48fb90e01bca6106d0d1a752bab01882363 Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 21 Apr 2022 11:49:45 +0300 Subject: [PATCH 1/3] =?UTF-8?q?loadKP:=20=D1=81=D1=82=D0=B0=D1=82=D1=83?= =?UTF-8?q?=D1=81=D1=8B=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=81=20=D0=B3=D0=B8=D0=B1=D0=BA=D0=BE=D0=B9=20=D0=B4=D0=B5?= =?UTF-8?q?=D0=B3=D1=80=D0=B5=D1=81=D1=81=D0=B8=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Effects/reactions/loadKpReaction/index.ts | 22 +++++++++++-------- .../services/CrmService/types/entities.ts | 1 + 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts index b833910..6502f48 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts @@ -3,7 +3,7 @@ import { resetIns } from 'client/Containers/Calculation/Components/ELT/lib/reset import { numberElementsProps } from 'client/Containers/Calculation/Elements/props/common'; import { getTitle, - getValueName, + getValueName } from 'client/Containers/Calculation/Elements/tools'; import { ElementsNames } from 'client/Containers/Calculation/types/elements'; import { openNotification } from 'client/Elements/Notification'; @@ -13,7 +13,7 @@ import { mainOptionsForQuoteQuery, quoteQuery, secondaryOptionsForQuoteQuery, - singleOptionsForQuoteQuery, + singleOptionsForQuoteQuery } from 'core/services/CrmService/graphql/query/quote'; import { TOptionizedEntity } from 'core/services/CrmService/types/common'; import { @@ -21,7 +21,7 @@ import { IAccount, IEvoGraph, IEvoTown, - IQuote, + IQuote } from 'core/services/CrmService/types/entities'; import { currentISODate } from 'core/tools/date'; import { NIL } from 'core/tools/uuid'; @@ -40,10 +40,12 @@ const map_add_product_types_to_values = { fuelCard: 100000005, }; -const tablePaymentsStatuses = (graphType, leasingPeriod) => { +const tablePaymentsStatuses = (graphType, seasonType, leasingPeriod) => { switch (graphType) { case 100000001: { - return Array.from({ length: leasingPeriod - 3 }, (_, i) => i + 2); + if (seasonType === 100_000_007) + return Array.from({ length: leasingPeriod - 3 }, (_, i) => i + 2); + break; } case 100000003: { return Array.from({ length: 12 }, (_, i) => i + 1); @@ -248,16 +250,18 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ (a, b) => b.createdon - a.createdon, )[0]; if (evo_graph.evo_planpayments) { + const statuses = tablePaymentsStatuses( + quote.evo_graph_type, + quote.evo_seasons_type, + quote.evo_period, + ); const payments = evo_graph.evo_planpayments .slice(1, evo_graph.evo_planpayments.length - 1) .map((evo_planpayment, i) => ({ paymentRelation: { validation: undefined, value: evo_planpayment.evo_payment_ratio, - status: tablePaymentsStatuses( - quote.evo_graph_type, - quote.evo_period, - )?.includes(i + 1) + status: statuses?.includes(i + 1) ? ElementStatus.Default : ElementStatus.Disabled, }, diff --git a/src/core/services/CrmService/types/entities.ts b/src/core/services/CrmService/types/entities.ts index 1296bda..a630834 100644 --- a/src/core/services/CrmService/types/entities.ts +++ b/src/core/services/CrmService/types/entities.ts @@ -102,6 +102,7 @@ export interface IOpportunity extends BaseEntity { } export interface IQuote extends BaseEntity { + evo_seasons_type?: number; evo_engine_hours?: number; evo_client_riskid?: string; evo_addproduct_types?: IEvoAddproductType[]; From 6f804f15ccd56b3e16c0a09711a4fb2a03df677d Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 21 Apr 2022 12:17:24 +0300 Subject: [PATCH 2/3] =?UTF-8?q?reactions:=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BC=D0=B8=D0=BD=20=D0=B8=20=D0=BC=D0=B0=D0=BA=D1=81=20=D1=81?= =?UTF-8?q?=D1=82=D0=BE=D0=B8=D0=BC=D0=BE=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reactions/recalcWoRevisionReactions.ts | 66 +++++++++++-------- .../services/CrmService/types/entities.ts | 1 + 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts index ed38c34..eb9a8b4 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts @@ -8,7 +8,6 @@ import { IReactionEffect } from 'core/types/Calculation/Store/effect'; import { Process } from 'core/types/Calculation/Store/process'; import { ValuesNames } from 'core/types/Calculation/Store/values'; import { ElementStatus } from 'types/elements'; -import { convertPrice } from '../lib/tools'; import { getPrice } from './priceReactions/calculate'; const reactionEffects: IReactionEffect[] = [ @@ -91,21 +90,23 @@ const reactionEffects: IReactionEffect[] = [ expression: () => { const { supplierDiscountRub, - leaseObjectPrice, - supplierCurrency, + leaseObjectPriceWthtVAT, recalcWithRevision, } = calculationStore.values; + + //@ts-ignore + const price = calculationStore.plPriceRub(); return [ supplierDiscountRub, - leaseObjectPrice, - supplierCurrency, + price, + leaseObjectPriceWthtVAT, recalcWithRevision, ]; }, effect: ([ supplierDiscountRub, - leaseObjectPrice, - supplierCurrencyId, + price, + leaseObjectPriceWthtVAT, recalcWithRevision, ]) => { if (!recalcWithRevision) { @@ -113,43 +114,50 @@ const reactionEffects: IReactionEffect[] = [ return; } - const supplierCurrency = calculationStore - .getOptions('selectSupplierCurrency') - ?.find(x => x.transactioncurrencyid === supplierCurrencyId); - const evo_currencychange = calculationStore - .getStaticData('evo_currencychange') - ?.find(x => x.evo_ref_transactioncurrency === supplierCurrencyId); - const evo_currencychangeValue = - (evo_currencychange && evo_currencychange.evo_currencychange) || 0; - const price = convertPrice( - supplierCurrency?.isocurrencycode, - leaseObjectPrice, - evo_currencychangeValue, - ); + const product = calculationStore.getOption('selectProduct'); const quote = calculationStore.getOption('selectQuote'); - if ( + + const maxCondition1 = quote?.evo_max_price_change && - price - supplierDiscountRub > quote.evo_max_price_change - ) { + !product?.evo_sale_without_nds && + price - supplierDiscountRub > quote.evo_max_price_change; + + const maxCondition2 = + quote?.evo_max_price_change && + product?.evo_sale_without_nds && + leaseObjectPriceWthtVAT > + quote.evo_max_price_change - + (quote.evo_nds_in_price_supplier_currency || 0); + + const minCondition1 = + quote?.evo_min_change_price && + !product?.evo_sale_without_nds && + price - supplierDiscountRub < quote.evo_min_change_price; + + const minCondition2 = + quote?.evo_min_change_price && + product?.evo_sale_without_nds && + leaseObjectPriceWthtVAT < + quote.evo_min_change_price - + (quote.evo_nds_in_price_supplier_currency || 0); + + if (maxCondition1 || maxCondition2) { calculationStore.setValidation('tbxLeaseObjectPrice', false); openNotification({ type: 'error', message: 'Ошибка', description: - 'Указанная стоимость предмета лизинга больше возмножного изменения стоимости предмета лизинга при пересчете без пересмотра. ' + + 'Указанная стоимость предмета лизинга больше возможного изменения стоимости предмета лизинга при пересчете без пересмотра. ' + 'Уменьшите стоимость предмета лизинга', }); - } else if ( - quote?.evo_min_change_price && - price - supplierDiscountRub < quote.evo_min_change_price - ) { + } else if (minCondition1 || minCondition2) { calculationStore.setValidation('tbxLeaseObjectPrice', false); openNotification({ type: 'error', message: 'Ошибка', description: - 'Указанная стоимость предмета лизинга меньше возмножного изменения стоимости предмета лизинга при пересчете без пересмотра. ' + + 'Указанная стоимость предмета лизинга меньше возможного изменения стоимости предмета лизинга при пересчете без пересмотра. ' + 'Увеличьте стоимость предмета лизинга', }); } else { diff --git a/src/core/services/CrmService/types/entities.ts b/src/core/services/CrmService/types/entities.ts index a630834..cf8ebcc 100644 --- a/src/core/services/CrmService/types/entities.ts +++ b/src/core/services/CrmService/types/entities.ts @@ -141,6 +141,7 @@ export interface IQuote extends BaseEntity { evo_last_payment_perc?: number; evo_min_change_price?: number; evo_max_price_change?: number; + evo_nds_in_price_supplier_currency?: number; evo_max_mass?: number; evo_seats?: number; evo_year?: number; From 56959e491baadd4cc86f42c4cdbb9e9ebf0a9ea7 Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 21 Apr 2022 17:04:31 +0300 Subject: [PATCH 3/3] =?UTF-8?q?=D0=B5=D1=81=D0=BB=D0=B8=20=D0=B2=20=D0=A1?= =?UTF-8?q?=D0=9A=20=D0=9E=D0=A1=D0=90=D0=93=D0=9E=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=20evo=5Fosago=5Fwith=5Fkasko=3DTrue=20=D0=98=20=D0=A1?= =?UTF-8?q?=D0=9A=20=D0=9E=D0=A1=D0=90=D0=93=D0=9E=20!=3D=20=D0=A1=D0=9A?= =?UTF-8?q?=20=D0=9A=D0=90=D0=A1=D0=9A=D0=9E,=20=D1=82=D0=BE=20=D0=B2?= =?UTF-8?q?=D1=8B=D0=B2=D0=B5=D1=81=D1=82=D0=B8=20=D0=B8=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BA=D1=83:=20"=D0=9D=D0=B5=D0=B2=D0=BE=D0=B7?= =?UTF-8?q?=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=20=D1=81=D1=82=D1=80=D0=B0=D1=85?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=9E=D0=A1=D0=90=D0=93?= =?UTF-8?q?=D0=9E=20=D0=BE=D1=82=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=BE=D1=82=20=D0=9A=D0=90=D0=A1=D0=9A=D0=9E=20-=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D1=85=D0=BE=D0=B2=D0=B0=D1=8F=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=D0=BF=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BE=D0=BB=D0=B6?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B1=D1=8B=D1=82=D1=8C=20=D0=BE=D0=B4=D0=BD?= =?UTF-8?q?=D0=B0!",=20=D0=B8=D0=BD=D0=B0=D1=87=D0=B5=20=D0=B2=D1=81=D0=B5?= =?UTF-8?q?=20=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/calculate/validate/tables.ts | 35 +++++++++++++++++++ .../query/options/insurance_options.graphql | 1 + .../services/CrmService/types/entities.ts | 1 + 3 files changed, 37 insertions(+) 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 3255687..182458b 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/tables.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/tables.ts @@ -1,3 +1,4 @@ +import { openNotification } from 'client/Elements/Notification'; import valuesConstants from 'core/constants/values'; import { shiftRight } from 'core/tools/array'; import { ICalculationStore } from 'core/types/Calculation/Store'; @@ -36,6 +37,40 @@ function validateInsuranceTable(this: ICalculationStore) { validation: !isNil(kaskoRow.insured), }, }); + + /** + * если в СК ОСАГО поле evo_osago_with_kasko=True И СК ОСАГО != СК КАСКО, + * то вывести и ошибку: "Невозможно страхование ОСАГО отдельно от КАСКО - + * страховая компания должна быть одна!", иначе все ок + */ + const osagoInsuranceCompanyOption = + this.tables?.tableInsurance?.options?.insuranceCompany?.find( + x => x.accountid === osagoRow.insuranceCompany, + ); + const invalid = + osagoInsuranceCompanyOption?.evo_osago_with_kasko && + osagoRow.insuranceCompany !== kaskoRow.insuranceCompany; + if (invalid) + openNotification({ + type: 'error', + message: 'Ошибка', + description: + 'Невозможно страхование ОСАГО отдельно от КАСКО - страховая компания должна быть одна!', + }); + this.setTableRow('tableInsurance', rows => + rows.findIndex(x => x?.key === 'osago'), + )({ + insuranceCompany: { + validation: !invalid, + }, + }); + this.setTableRow('tableInsurance', rows => + rows.findIndex(x => x?.key === 'kasko'), + )({ + insuranceCompany: { + validation: !invalid, + }, + }); } function validatePaymentsTable(this: ICalculationStore) { diff --git a/src/core/services/CrmService/graphql/query/options/insurance_options.graphql b/src/core/services/CrmService/graphql/query/options/insurance_options.graphql index a671cff..7058f20 100644 --- a/src/core/services/CrmService/graphql/query/options/insurance_options.graphql +++ b/src/core/services/CrmService/graphql/query/options/insurance_options.graphql @@ -11,5 +11,6 @@ query GetInsuranceOptions($evo_account_type: [Int!], $statecode: Int) { evo_id_elt_osago evo_legal_region_calc evo_inn + evo_osago_with_kasko } } diff --git a/src/core/services/CrmService/types/entities.ts b/src/core/services/CrmService/types/entities.ts index cf8ebcc..0088a43 100644 --- a/src/core/services/CrmService/types/entities.ts +++ b/src/core/services/CrmService/types/entities.ts @@ -60,6 +60,7 @@ export interface IAccount extends BaseEntity { evo_id_elt?: string; evo_id_elt_osago?: string; evo_legal_region_calc?: boolean; + evo_osago_with_kasko?: boolean; } export interface ISalonProvider extends IAccount {