diff --git a/src/client/Containers/Calculation/Components/Sections/sectionsList.ts b/src/client/Containers/Calculation/Components/Sections/sectionsList.ts index 834d453..4b6bacc 100644 --- a/src/client/Containers/Calculation/Components/Sections/sectionsList.ts +++ b/src/client/Containers/Calculation/Components/Sections/sectionsList.ts @@ -35,6 +35,7 @@ const sections: ISection[] = [ blocks: [ { elements: ['tbxFirstPaymentPerc'] }, { elements: ['tbxFirstPaymentRub'] }, + { elements: ['cbxSupplierFinancing'] }, ], }, diff --git a/src/client/Containers/Calculation/Elements/components.ts b/src/client/Containers/Calculation/Elements/components.ts index 27e9f9e..21004b1 100644 --- a/src/client/Containers/Calculation/Elements/components.ts +++ b/src/client/Containers/Calculation/Elements/components.ts @@ -137,6 +137,7 @@ export default { selectImportProgram: Select, tbxAddEquipmentPrice: InputNumber, tbxVIN: Input, + cbxSupplierFinancing: Switch, /** Computed Elements */ labelLeaseObjectRisk: Label, diff --git a/src/client/Containers/Calculation/Elements/titles.ts b/src/client/Containers/Calculation/Elements/titles.ts index 8367d67..efaf76a 100644 --- a/src/client/Containers/Calculation/Elements/titles.ts +++ b/src/client/Containers/Calculation/Elements/titles.ts @@ -131,6 +131,7 @@ export const elementsTitles: Partial> = { tbxAddEquipmentPrice: 'Стоимость доп.оборудования', tbxVIN: 'VIN', selectLeasingWithoutKasko: 'Лизинг без КАСКО', + cbxSupplierFinancing: 'Финансирование поставщика', /** Result Elements */ labelResultTotalGraphwithNDS: 'Итого по графику, с НДС', diff --git a/src/client/Containers/Calculation/Elements/values.ts b/src/client/Containers/Calculation/Elements/values.ts index 3eda07c..b181177 100644 --- a/src/client/Containers/Calculation/Elements/values.ts +++ b/src/client/Containers/Calculation/Elements/values.ts @@ -137,6 +137,7 @@ const elementsValues: Record = { tbxAddEquipmentPrice: 'addEquipmentPrice', tbxVIN: 'vin', selectLeasingWithoutKasko: 'leasingWithoutKasko', + cbxSupplierFinancing: 'supplierFinancing', /** Result Elements */ labelResultTotalGraphwithNDS: 'resultTotalGraphwithNDS', diff --git a/src/client/Containers/Calculation/types/elements.ts b/src/client/Containers/Calculation/types/elements.ts index 7259059..b182333 100644 --- a/src/client/Containers/Calculation/types/elements.ts +++ b/src/client/Containers/Calculation/types/elements.ts @@ -124,6 +124,7 @@ export type ElementsNames = | 'tbxAddEquipmentPrice' | 'tbxVIN' | 'selectLeasingWithoutKasko' + | 'cbxSupplierFinancing' /** Result Elements */ | 'labelResultTotalGraphwithNDS' | 'labelResultPlPrice' diff --git a/src/client/process/configurator/reactions/filters.ts b/src/client/process/configurator/reactions/filters.ts index e325209..ec27732 100644 --- a/src/client/process/configurator/reactions/filters.ts +++ b/src/client/process/configurator/reactions/filters.ts @@ -81,11 +81,20 @@ export default function ($calculation: ICalculationStore) { dealer, dealer => //@ts-ignore - !importProgram?.accounts?.length || - importProgram.accounts.filter( + (!importProgram?.accounts?.length || + importProgram.accounts.filter( + //@ts-ignore + x => x.accountid === dealer.accountid, + )?.length) && + dealer, + dealer => { + if (product?.evo_supplier_financing_accept) { //@ts-ignore - x => x.accountid === dealer.accountid, - )?.length, + return dealer.evo_supplier_financing_accept; + } else { + return dealer; + } + }, ), ), ); @@ -101,11 +110,20 @@ export default function ($calculation: ICalculationStore) { dealerPerson, dealerPerson => //@ts-ignore - !importProgram?.accounts?.length || - importProgram.accounts.filter( + (!importProgram?.accounts?.length || + importProgram.accounts.filter( + //@ts-ignore + x => x.accountid === dealerPerson.accountid, + )?.length) && + dealerPerson, + dealerPerson => { + if (product?.evo_supplier_financing_accept) { //@ts-ignore - x => x.accountid === dealerPerson.accountid, - )?.length, + return dealerPerson.evo_supplier_financing_accept; + } else { + return dealerPerson; + } + }, ), ), ); diff --git a/src/client/process/used-pl/reactions.ts b/src/client/process/used-pl/reactions.ts index 834cc53..1b2c6c9 100644 --- a/src/client/process/used-pl/reactions.ts +++ b/src/client/process/used-pl/reactions.ts @@ -290,7 +290,7 @@ export default function ($calculation: ICalculationStore) { */ reaction( () => { - const { leaseObjectUsed } = $calculation.values; + const { leaseObjectUsed, supplierFinancing } = $calculation.values; const sudsidy = $calculation.getOption('selectSubsidy'); const product = $calculation.getOption('selectProduct'); const dealer = $calculation.getOption('selectDealer'); @@ -300,17 +300,27 @@ export default function ($calculation: ICalculationStore) { sudsidy, product, dealer, + supplierFinancing, }; }, - ({ leaseObjectUsed, sudsidy, product, dealer }) => { + ({ leaseObjectUsed, sudsidy, product, dealer, supplierFinancing }) => { + const evo_delivery_time = sudsidy?.evo_delivery_time?.filter(x => x > 0); if ( leaseObjectUsed || - sudsidy || + (evo_delivery_time?.length === 1 && + evo_delivery_time.includes(100_000_000)) || product?.evo_sale_without_nds || dealer?.evo_return_leasing_dealer ) { $calculation.setValue('deliveryTime', 100_000_000); $calculation.setStatus('radioDeliveryTime', ElementStatus.Disabled); + } else if ( + (evo_delivery_time?.length === 1 && + evo_delivery_time.includes(100_000_001)) || + supplierFinancing + ) { + $calculation.setValue('deliveryTime', 100_000_001); + $calculation.setStatus('radioDeliveryTime', ElementStatus.Disabled); } else { $calculation.setStatus('radioDeliveryTime', ElementStatus.Default); } @@ -325,20 +335,32 @@ export default function ($calculation: ICalculationStore) { if (subsidy) { $calculation.setValues({ leaseObjectCount: 1, - leaseObjectUsed: false, }); + $calculation.setStatus('tbxLeaseObjectCount', ElementStatus.Disabled); + } else { + $calculation.setStatus('tbxLeaseObjectCount', ElementStatus.Default); } - $calculation.setStatuses({ - tbxLeaseObjectCount: subsidy - ? ElementStatus.Disabled - : ElementStatus.Default, - cbxLeaseObjectUsed: subsidy - ? ElementStatus.Disabled - : ElementStatus.Default, - }); }, ); + reaction( + () => { + return [ + $calculation.getOption('selectSubsidy'), + $calculation.getValue('supplierFinancing'), + ]; + }, + ([subsidy, supplierFinancing]) => { + if (subsidy || supplierFinancing) { + $calculation.setValues({ + leaseObjectUsed: false, + }); + $calculation.setStatus('cbxLeaseObjectUsed', ElementStatus.Disabled); + } else { + $calculation.setStatus('cbxLeaseObjectUsed', ElementStatus.Default); + } + }, + ); /** VIN */ const vinRegex = /^[A-HJ-NPR-Za-hj-npr-z0-9]+$/; diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts index 85452fe..2c92a19 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts @@ -140,6 +140,7 @@ export default function (this: ICalculationStore): PreparedData { preparedValues.transIncludeGr = values.vehicleTaxInYear > 0; preparedValues.transportTaxGrYear = values.vehicleTaxInYear; preparedValues.transportTaxGr = values.vehicleTaxInLeasingPeriod; + preparedValues.supplierFinancing = values.supplierFinancing; const insuranceKaskoRow = tables.tableInsurance.rows.find( x => x?.key === 'kasko', diff --git a/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts index 5a0c5dc..7141111 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts @@ -24,10 +24,16 @@ const v = { const gibddReactions: IReactionEffect[] = [ calculationStore => ({ expression: () => { - return calculationStore.getOption('selectLeaseObjectType'); + return [ + calculationStore.getOption('selectLeaseObjectType'), + calculationStore.getValue('supplierFinancing'), + ]; }, - effect: leaseObjectType => { - if (['6', '9', '10', '11'].includes(leaseObjectType.evo_id)) { + effect: ([leaseObjectType, supplierFinancing]) => { + if ( + ['6', '9', '10', '11'].includes(leaseObjectType?.evo_id) || + supplierFinancing + ) { calculationStore.setStatus( 'radioObjectRegistration', ElementStatus.Disabled, diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts index 5dab95b..304d34a 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts @@ -4,7 +4,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'; @@ -14,7 +14,7 @@ import { mainOptionsForQuoteQuery, quoteQuery, secondaryOptionsForQuoteQuery, - singleOptionsForQuoteQuery + singleOptionsForQuoteQuery, } from 'core/services/CrmService/graphql/query/quote'; import { TOptionizedEntity } from 'core/services/CrmService/types/common'; import { @@ -23,7 +23,7 @@ import { IEvoGraph, IEvoRewardCondition, IEvoTown, - IQuote + IQuote, } from 'core/services/CrmService/types/entities'; import { currentISODate } from 'core/tools/date'; import { NIL } from 'core/tools/uuid'; @@ -318,6 +318,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({ evo_kpp evo_inn evo_supplier_type + evo_supplier_financing_accept } } `, diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts index cd40e60..2289e12 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts @@ -99,6 +99,7 @@ const mapKPtoValues: Partial> = { evo_program_import_subsidyid: 'importProgram', evo_equip_price: 'addEquipmentPrice', evo_vin: 'vin', + evo_supplier_financing: 'supplierFinancing', }; export function getValuesFromKP(quote: IQuote) { diff --git a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts index d15789d..bdd110e 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts @@ -1333,6 +1333,35 @@ const reactionEffects: IReactionEffect[] = [ } }, }), + + calculationStore => ({ + expression: () => { + return { + selectProduct: calculationStore.getOption('selectProduct'), + selectDealerPerson: calculationStore.getOption('selectDealerPerson'), + }; + }, + effect: ({ selectProduct, selectDealerPerson }) => { + if ( + selectProduct?.evo_supplier_financing_accept && + selectDealerPerson?.evo_supplier_financing_accept + ) { + calculationStore.setStatus( + 'cbxSupplierFinancing', + ElementStatus.Default, + ); + } else { + calculationStore.setStatus( + 'cbxSupplierFinancing', + ElementStatus.Disabled, + ); + calculationStore.setValue('supplierFinancing', false); + } + }, + options: { + fireImmediately: true, + }, + }), ]; export default reactionEffects; diff --git a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts index 224c37d..01372c3 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts @@ -465,6 +465,7 @@ export default [ evo_broker_accountid evo_kpp evo_inn + evo_supplier_financing_accept } } `, @@ -478,10 +479,13 @@ export default [ 'selectDealerPerson', salon_providers, ); - calculationStore.setValue( - 'dealerPerson', - salon_providers[0].accountid, - ); + + if (!dealer.evo_supplier_financing_accept) + calculationStore.setValue( + 'dealerPerson', + salon_providers[0].accountid, + ); + calculationStore.setStatus( 'selectDealerPerson', ElementStatus.Default, diff --git a/src/client/stores/CalculationStore/config/initialStatuses.ts b/src/client/stores/CalculationStore/config/initialStatuses.ts index c36d2ce..3a4bb55 100644 --- a/src/client/stores/CalculationStore/config/initialStatuses.ts +++ b/src/client/stores/CalculationStore/config/initialStatuses.ts @@ -28,6 +28,7 @@ const initialStatuses: Partial< tbxRedemptionPaymentSum: ElementStatus.Disabled, tbxLeaseObjectPriceWthtVAT: ElementStatus.Disabled, + cbxSupplierFinancing: ElementStatus.Disabled, }; export default initialStatuses; diff --git a/src/client/stores/CalculationStore/config/initialValues.ts b/src/client/stores/CalculationStore/config/initialValues.ts index 7085736..dfdc570 100644 --- a/src/client/stores/CalculationStore/config/initialValues.ts +++ b/src/client/stores/CalculationStore/config/initialValues.ts @@ -95,5 +95,6 @@ const initialValues: Partial> = { infuranceOPF: null, addEquipmentPrice: 0, leasingWithoutKasko: null, + supplierFinancing: false, }; export default initialValues; diff --git a/src/core/services/CoreService/types/Calculation/prepared.ts b/src/core/services/CoreService/types/Calculation/prepared.ts index fcbea32..fef2413 100644 --- a/src/core/services/CoreService/types/Calculation/prepared.ts +++ b/src/core/services/CoreService/types/Calculation/prepared.ts @@ -118,6 +118,7 @@ export interface PreparedValues { regionalDirectorBonusFix?: number; profitExpected?: number; bonusCoefficient?: number; + supplierFinancing?: boolean; } export interface PaymentRow { diff --git a/src/core/services/CrmService/graphql/query/options/main_options.graphql b/src/core/services/CrmService/graphql/query/options/main_options.graphql index 24bae7d..f5df37c 100644 --- a/src/core/services/CrmService/graphql/query/options/main_options.graphql +++ b/src/core/services/CrmService/graphql/query/options/main_options.graphql @@ -36,6 +36,7 @@ query GetMainOptions( name accountid evo_return_leasing_dealer + evo_supplier_financing_accept } selectGPSBrand: evo_gps_brands(statecode: $statecode) { evo_name @@ -86,6 +87,7 @@ query GetMainOptions( evo_name evo_baseproductid } + evo_supplier_financing_accept } selectRegistration: evo_addproduct_types( statecode: $statecode @@ -259,6 +261,7 @@ query GetMainOptions( accountid } evo_subsidy_type + evo_delivery_time } selectFuelCard: evo_addproduct_types( statecode: $statecode diff --git a/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql b/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql index 27f90f3..feaf49b 100644 --- a/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql +++ b/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql @@ -143,4 +143,5 @@ fragment quoteFields on quote { evo_accept_period evo_db_accept_registration evo_vin + evo_supplier_financing } diff --git a/src/core/services/CrmService/graphql/query/quote/options/main_options.graphql b/src/core/services/CrmService/graphql/query/quote/options/main_options.graphql index b6992f2..a4e2e25 100644 --- a/src/core/services/CrmService/graphql/query/quote/options/main_options.graphql +++ b/src/core/services/CrmService/graphql/query/quote/options/main_options.graphql @@ -48,6 +48,7 @@ query GetMainOptionsForKP( evo_kpp evo_inn evo_supplier_type + evo_supplier_financing_accept } selectDealerRewardCondition: evo_reward_conditions( evo_agent_accountid: $dealer_person_accountid diff --git a/src/core/services/CrmService/types/entities.ts b/src/core/services/CrmService/types/entities.ts index 186b93d..9184485 100644 --- a/src/core/services/CrmService/types/entities.ts +++ b/src/core/services/CrmService/types/entities.ts @@ -222,6 +222,7 @@ export interface IEvoBaseproduct extends BaseEntity { evo_cut_irr_with_bonus?: boolean; evo_calculation_method?: number[]; evo_baseproducts?: IEvoBaseproduct[]; + evo_supplier_financing_accept?: boolean; } export interface IEvoLeasingObjectType extends BaseEntity { @@ -499,6 +500,7 @@ export interface IEvoSubsidy extends BaseEntity { evo_models?: IEvoModel[]; accounts?: IAccount[]; evo_subsidy_type?: number; + evo_delivery_time?: number[]; } export type CRMEntity = IAccount & diff --git a/src/core/types/Calculation/Store/values.ts b/src/core/types/Calculation/Store/values.ts index d9f967e..adb3c01 100644 --- a/src/core/types/Calculation/Store/values.ts +++ b/src/core/types/Calculation/Store/values.ts @@ -144,7 +144,8 @@ export type ValuesNames = | 'engineHours' | 'importProgram' | 'addEquipmentPrice' - | 'bonusCoefficient'; + | 'bonusCoefficient' + | 'supplierFinancing'; export type ComputedValuesNames = | 'leaseObjectRiskName'