Merge branch 'development'

This commit is contained in:
vchikalkin 2023-02-01 09:33:37 +03:00
commit 62057f2b85
21 changed files with 129 additions and 31 deletions

View File

@ -35,6 +35,7 @@ const sections: ISection[] = [
blocks: [ blocks: [
{ elements: ['tbxFirstPaymentPerc'] }, { elements: ['tbxFirstPaymentPerc'] },
{ elements: ['tbxFirstPaymentRub'] }, { elements: ['tbxFirstPaymentRub'] },
{ elements: ['cbxSupplierFinancing'] },
], ],
}, },

View File

@ -137,6 +137,7 @@ export default {
selectImportProgram: Select, selectImportProgram: Select,
tbxAddEquipmentPrice: InputNumber, tbxAddEquipmentPrice: InputNumber,
tbxVIN: Input, tbxVIN: Input,
cbxSupplierFinancing: Switch,
/** Computed Elements */ /** Computed Elements */
labelLeaseObjectRisk: Label, labelLeaseObjectRisk: Label,

View File

@ -131,6 +131,7 @@ export const elementsTitles: Partial<Record<AllElementsNames, string>> = {
tbxAddEquipmentPrice: 'Стоимость доп.оборудования', tbxAddEquipmentPrice: 'Стоимость доп.оборудования',
tbxVIN: 'VIN', tbxVIN: 'VIN',
selectLeasingWithoutKasko: 'Лизинг без КАСКО', selectLeasingWithoutKasko: 'Лизинг без КАСКО',
cbxSupplierFinancing: 'Финансирование поставщика',
/** Result Elements */ /** Result Elements */
labelResultTotalGraphwithNDS: 'Итого по графику, с НДС', labelResultTotalGraphwithNDS: 'Итого по графику, с НДС',

View File

@ -137,6 +137,7 @@ const elementsValues: Record<ElementsNames, ValuesNames> = {
tbxAddEquipmentPrice: 'addEquipmentPrice', tbxAddEquipmentPrice: 'addEquipmentPrice',
tbxVIN: 'vin', tbxVIN: 'vin',
selectLeasingWithoutKasko: 'leasingWithoutKasko', selectLeasingWithoutKasko: 'leasingWithoutKasko',
cbxSupplierFinancing: 'supplierFinancing',
/** Result Elements */ /** Result Elements */
labelResultTotalGraphwithNDS: 'resultTotalGraphwithNDS', labelResultTotalGraphwithNDS: 'resultTotalGraphwithNDS',

View File

@ -124,6 +124,7 @@ export type ElementsNames =
| 'tbxAddEquipmentPrice' | 'tbxAddEquipmentPrice'
| 'tbxVIN' | 'tbxVIN'
| 'selectLeasingWithoutKasko' | 'selectLeasingWithoutKasko'
| 'cbxSupplierFinancing'
/** Result Elements */ /** Result Elements */
| 'labelResultTotalGraphwithNDS' | 'labelResultTotalGraphwithNDS'
| 'labelResultPlPrice' | 'labelResultPlPrice'

View File

@ -81,11 +81,20 @@ export default function ($calculation: ICalculationStore) {
dealer, dealer,
dealer => dealer =>
//@ts-ignore //@ts-ignore
!importProgram?.accounts?.length || (!importProgram?.accounts?.length ||
importProgram.accounts.filter( importProgram.accounts.filter(
//@ts-ignore
x => x.accountid === dealer.accountid,
)?.length) &&
dealer,
dealer => {
if (product?.evo_supplier_financing_accept) {
//@ts-ignore //@ts-ignore
x => x.accountid === dealer.accountid, return dealer.evo_supplier_financing_accept;
)?.length, } else {
return dealer;
}
},
), ),
), ),
); );
@ -101,11 +110,20 @@ export default function ($calculation: ICalculationStore) {
dealerPerson, dealerPerson,
dealerPerson => dealerPerson =>
//@ts-ignore //@ts-ignore
!importProgram?.accounts?.length || (!importProgram?.accounts?.length ||
importProgram.accounts.filter( importProgram.accounts.filter(
//@ts-ignore
x => x.accountid === dealerPerson.accountid,
)?.length) &&
dealerPerson,
dealerPerson => {
if (product?.evo_supplier_financing_accept) {
//@ts-ignore //@ts-ignore
x => x.accountid === dealerPerson.accountid, return dealerPerson.evo_supplier_financing_accept;
)?.length, } else {
return dealerPerson;
}
},
), ),
), ),
); );

View File

@ -290,7 +290,7 @@ export default function ($calculation: ICalculationStore) {
*/ */
reaction( reaction(
() => { () => {
const { leaseObjectUsed } = $calculation.values; const { leaseObjectUsed, supplierFinancing } = $calculation.values;
const sudsidy = $calculation.getOption('selectSubsidy'); const sudsidy = $calculation.getOption('selectSubsidy');
const product = $calculation.getOption('selectProduct'); const product = $calculation.getOption('selectProduct');
const dealer = $calculation.getOption('selectDealer'); const dealer = $calculation.getOption('selectDealer');
@ -300,17 +300,27 @@ export default function ($calculation: ICalculationStore) {
sudsidy, sudsidy,
product, product,
dealer, dealer,
supplierFinancing,
}; };
}, },
({ leaseObjectUsed, sudsidy, product, dealer }) => { ({ leaseObjectUsed, sudsidy, product, dealer, supplierFinancing }) => {
const evo_delivery_time = sudsidy?.evo_delivery_time?.filter(x => x > 0);
if ( if (
leaseObjectUsed || leaseObjectUsed ||
sudsidy || (evo_delivery_time?.length === 1 &&
evo_delivery_time.includes(100_000_000)) ||
product?.evo_sale_without_nds || product?.evo_sale_without_nds ||
dealer?.evo_return_leasing_dealer dealer?.evo_return_leasing_dealer
) { ) {
$calculation.setValue('deliveryTime', 100_000_000); $calculation.setValue('deliveryTime', 100_000_000);
$calculation.setStatus('radioDeliveryTime', ElementStatus.Disabled); $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 { } else {
$calculation.setStatus('radioDeliveryTime', ElementStatus.Default); $calculation.setStatus('radioDeliveryTime', ElementStatus.Default);
} }
@ -325,20 +335,32 @@ export default function ($calculation: ICalculationStore) {
if (subsidy) { if (subsidy) {
$calculation.setValues({ $calculation.setValues({
leaseObjectCount: 1, 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 */ /** VIN */
const vinRegex = /^[A-HJ-NPR-Za-hj-npr-z0-9]+$/; const vinRegex = /^[A-HJ-NPR-Za-hj-npr-z0-9]+$/;

View File

@ -140,6 +140,7 @@ export default function (this: ICalculationStore): PreparedData {
preparedValues.transIncludeGr = values.vehicleTaxInYear > 0; preparedValues.transIncludeGr = values.vehicleTaxInYear > 0;
preparedValues.transportTaxGrYear = values.vehicleTaxInYear; preparedValues.transportTaxGrYear = values.vehicleTaxInYear;
preparedValues.transportTaxGr = values.vehicleTaxInLeasingPeriod; preparedValues.transportTaxGr = values.vehicleTaxInLeasingPeriod;
preparedValues.supplierFinancing = values.supplierFinancing;
const insuranceKaskoRow = tables.tableInsurance.rows.find( const insuranceKaskoRow = tables.tableInsurance.rows.find(
x => x?.key === 'kasko', x => x?.key === 'kasko',

View File

@ -24,10 +24,16 @@ const v = {
const gibddReactions: IReactionEffect[] = [ const gibddReactions: IReactionEffect[] = [
calculationStore => ({ calculationStore => ({
expression: () => { expression: () => {
return calculationStore.getOption('selectLeaseObjectType'); return [
calculationStore.getOption('selectLeaseObjectType'),
calculationStore.getValue('supplierFinancing'),
];
}, },
effect: leaseObjectType => { effect: ([leaseObjectType, supplierFinancing]) => {
if (['6', '9', '10', '11'].includes(leaseObjectType.evo_id)) { if (
['6', '9', '10', '11'].includes(leaseObjectType?.evo_id) ||
supplierFinancing
) {
calculationStore.setStatus( calculationStore.setStatus(
'radioObjectRegistration', 'radioObjectRegistration',
ElementStatus.Disabled, ElementStatus.Disabled,

View File

@ -4,7 +4,7 @@ import { resetIns } from 'client/Containers/Calculation/Components/ELT/lib/reset
import { numberElementsProps } from 'client/Containers/Calculation/Elements/props/common'; import { numberElementsProps } from 'client/Containers/Calculation/Elements/props/common';
import { import {
getTitle, getTitle,
getValueName getValueName,
} from 'client/Containers/Calculation/Elements/tools'; } from 'client/Containers/Calculation/Elements/tools';
import { ElementsNames } from 'client/Containers/Calculation/types/elements'; import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { openNotification } from 'client/Elements/Notification'; import { openNotification } from 'client/Elements/Notification';
@ -14,7 +14,7 @@ import {
mainOptionsForQuoteQuery, mainOptionsForQuoteQuery,
quoteQuery, quoteQuery,
secondaryOptionsForQuoteQuery, secondaryOptionsForQuoteQuery,
singleOptionsForQuoteQuery singleOptionsForQuoteQuery,
} from 'core/services/CrmService/graphql/query/quote'; } from 'core/services/CrmService/graphql/query/quote';
import { TOptionizedEntity } from 'core/services/CrmService/types/common'; import { TOptionizedEntity } from 'core/services/CrmService/types/common';
import { import {
@ -23,7 +23,7 @@ import {
IEvoGraph, IEvoGraph,
IEvoRewardCondition, IEvoRewardCondition,
IEvoTown, IEvoTown,
IQuote IQuote,
} from 'core/services/CrmService/types/entities'; } from 'core/services/CrmService/types/entities';
import { currentISODate } from 'core/tools/date'; import { currentISODate } from 'core/tools/date';
import { NIL } from 'core/tools/uuid'; import { NIL } from 'core/tools/uuid';
@ -318,6 +318,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
evo_kpp evo_kpp
evo_inn evo_inn
evo_supplier_type evo_supplier_type
evo_supplier_financing_accept
} }
} }
`, `,

View File

@ -99,6 +99,7 @@ const mapKPtoValues: Partial<Record<keyof IQuote | string, ValuesNames>> = {
evo_program_import_subsidyid: 'importProgram', evo_program_import_subsidyid: 'importProgram',
evo_equip_price: 'addEquipmentPrice', evo_equip_price: 'addEquipmentPrice',
evo_vin: 'vin', evo_vin: 'vin',
evo_supplier_financing: 'supplierFinancing',
}; };
export function getValuesFromKP(quote: IQuote) { export function getValuesFromKP(quote: IQuote) {

View File

@ -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; export default reactionEffects;

View File

@ -465,6 +465,7 @@ export default [
evo_broker_accountid evo_broker_accountid
evo_kpp evo_kpp
evo_inn evo_inn
evo_supplier_financing_accept
} }
} }
`, `,
@ -478,10 +479,13 @@ export default [
'selectDealerPerson', 'selectDealerPerson',
salon_providers, salon_providers,
); );
calculationStore.setValue(
'dealerPerson', if (!dealer.evo_supplier_financing_accept)
salon_providers[0].accountid, calculationStore.setValue(
); 'dealerPerson',
salon_providers[0].accountid,
);
calculationStore.setStatus( calculationStore.setStatus(
'selectDealerPerson', 'selectDealerPerson',
ElementStatus.Default, ElementStatus.Default,

View File

@ -28,6 +28,7 @@ const initialStatuses: Partial<
tbxRedemptionPaymentSum: ElementStatus.Disabled, tbxRedemptionPaymentSum: ElementStatus.Disabled,
tbxLeaseObjectPriceWthtVAT: ElementStatus.Disabled, tbxLeaseObjectPriceWthtVAT: ElementStatus.Disabled,
cbxSupplierFinancing: ElementStatus.Disabled,
}; };
export default initialStatuses; export default initialStatuses;

View File

@ -95,5 +95,6 @@ const initialValues: Partial<Record<ValuesNames, any>> = {
infuranceOPF: null, infuranceOPF: null,
addEquipmentPrice: 0, addEquipmentPrice: 0,
leasingWithoutKasko: null, leasingWithoutKasko: null,
supplierFinancing: false,
}; };
export default initialValues; export default initialValues;

View File

@ -118,6 +118,7 @@ export interface PreparedValues {
regionalDirectorBonusFix?: number; regionalDirectorBonusFix?: number;
profitExpected?: number; profitExpected?: number;
bonusCoefficient?: number; bonusCoefficient?: number;
supplierFinancing?: boolean;
} }
export interface PaymentRow { export interface PaymentRow {

View File

@ -36,6 +36,7 @@ query GetMainOptions(
name name
accountid accountid
evo_return_leasing_dealer evo_return_leasing_dealer
evo_supplier_financing_accept
} }
selectGPSBrand: evo_gps_brands(statecode: $statecode) { selectGPSBrand: evo_gps_brands(statecode: $statecode) {
evo_name evo_name
@ -86,6 +87,7 @@ query GetMainOptions(
evo_name evo_name
evo_baseproductid evo_baseproductid
} }
evo_supplier_financing_accept
} }
selectRegistration: evo_addproduct_types( selectRegistration: evo_addproduct_types(
statecode: $statecode statecode: $statecode
@ -259,6 +261,7 @@ query GetMainOptions(
accountid accountid
} }
evo_subsidy_type evo_subsidy_type
evo_delivery_time
} }
selectFuelCard: evo_addproduct_types( selectFuelCard: evo_addproduct_types(
statecode: $statecode statecode: $statecode

View File

@ -143,4 +143,5 @@ fragment quoteFields on quote {
evo_accept_period evo_accept_period
evo_db_accept_registration evo_db_accept_registration
evo_vin evo_vin
evo_supplier_financing
} }

View File

@ -48,6 +48,7 @@ query GetMainOptionsForKP(
evo_kpp evo_kpp
evo_inn evo_inn
evo_supplier_type evo_supplier_type
evo_supplier_financing_accept
} }
selectDealerRewardCondition: evo_reward_conditions( selectDealerRewardCondition: evo_reward_conditions(
evo_agent_accountid: $dealer_person_accountid evo_agent_accountid: $dealer_person_accountid

View File

@ -222,6 +222,7 @@ export interface IEvoBaseproduct extends BaseEntity {
evo_cut_irr_with_bonus?: boolean; evo_cut_irr_with_bonus?: boolean;
evo_calculation_method?: number[]; evo_calculation_method?: number[];
evo_baseproducts?: IEvoBaseproduct[]; evo_baseproducts?: IEvoBaseproduct[];
evo_supplier_financing_accept?: boolean;
} }
export interface IEvoLeasingObjectType extends BaseEntity { export interface IEvoLeasingObjectType extends BaseEntity {
@ -499,6 +500,7 @@ export interface IEvoSubsidy extends BaseEntity {
evo_models?: IEvoModel[]; evo_models?: IEvoModel[];
accounts?: IAccount[]; accounts?: IAccount[];
evo_subsidy_type?: number; evo_subsidy_type?: number;
evo_delivery_time?: number[];
} }
export type CRMEntity = IAccount & export type CRMEntity = IAccount &

View File

@ -144,7 +144,8 @@ export type ValuesNames =
| 'engineHours' | 'engineHours'
| 'importProgram' | 'importProgram'
| 'addEquipmentPrice' | 'addEquipmentPrice'
| 'bonusCoefficient'; | 'bonusCoefficient'
| 'supplierFinancing';
export type ComputedValuesNames = export type ComputedValuesNames =
| 'leaseObjectRiskName' | 'leaseObjectRiskName'