merge release/dyn-190_subsidy

This commit is contained in:
Chika 2021-09-09 11:23:47 +03:00
parent f665d9c477
commit b3af7b3827
27 changed files with 515 additions and 132 deletions

View File

@ -82,6 +82,7 @@ const sections: ISection[] = [
'tbxSupplierDiscountPerc',
'radioBalanceHolder',
'tbxSaleBonus',
'selectSubsidy',
],
},
{
@ -93,6 +94,7 @@ const sections: ISection[] = [
'tbxLastPaymentPerc',
'tbxLastPaymentRub',
'tbxLeasingPeriod',
'labelSubsidySum',
],
},
@ -380,6 +382,7 @@ const sections: ISection[] = [
{
elements: [
'selectTechnicalCard',
// 'selectFuelCard',
'selectInsNSIB',
'radioRequirementTelematic',
'selectTracker',

View File

@ -171,6 +171,9 @@ const elementsComponents: TElements<Component> = {
labelRegistrationDescription: Label,
selectLegalClientRegion: Select,
selectLegalClientTown: Select,
selectSubsidy: Select,
selectFuelCard: Select,
labelSubsidySum: Label,
};
const tablesComponents: StoreTables<Component> = {

View File

@ -450,7 +450,7 @@ const elementsProps: TElements<ElementProps> = {
},
};
const resultElementsProps: TElements<ElementProps> = Object.assign(
const labelElementsProps: TElements<ElementProps> = Object.assign(
{},
[
'labelResultTotalGraphwithNDS',
@ -465,6 +465,7 @@ const resultElementsProps: TElements<ElementProps> = Object.assign(
'labelResultBonusMPL',
'labelResultDopMPLLeasing',
'labelResultBonusDopProd',
'labelSubsidySum',
].reduce(
(ac, a) => ({
...ac,
@ -486,4 +487,4 @@ const resultElementsProps: TElements<ElementProps> = Object.assign(
{},
),
);
export default Object.assign(elementsProps, resultElementsProps);
export default Object.assign(elementsProps, labelElementsProps);

View File

@ -136,6 +136,9 @@ export const elementsTitles: TElements<string> = {
tbxINNForCalc: 'ИНН контрагента',
selectLegalClientRegion: 'Регион по юр.адресу клиента',
selectLegalClientTown: 'Город по юр.адресу клиента',
selectSubsidy: 'Субсидия',
labelSubsidySum: 'Сумма субсидии с НДС',
selectFuelCard: 'Топливная карта',
};
const resultsTitles: TElements<string> = {

View File

@ -135,6 +135,9 @@ export const elementsValues: TElements<ValuesNames> = {
radioTypePTS: 'typePTS',
selectLegalClientRegion: 'legalClientRegion',
selectLegalClientTown: 'legalClientTown',
selectSubsidy: 'subsidy',
labelSubsidySum: 'subsidySum',
selectFuelCard: 'fuelCard',
};
const resultElementsValues: TElements<ResultValuesNames> = {

View File

@ -16,6 +16,7 @@ const query = gql`
$nsib_product_type: Int
$tracker_product_type: Int
$telematic_product_type: Int
$fuelcard_product_type: Int
$techcard_product_type: Int
) {
selectSupplier: accounts(
@ -251,9 +252,10 @@ const query = gql`
}
selectRate: evo_rates(
statecode: $statecode
) # evo_datefrom_param: { lte: $currentDate }
# evo_dateto_param: { gte: $currentDate }
{
evo_datefrom_param: { lte: $currentDate }
evo_dateto_param: { gte: $currentDate }
) {
createdon
evo_id
evo_rateid
evo_name
@ -267,6 +269,7 @@ const query = gql`
evo_tarifid
evo_name
}
evo_credit_period
}
selectLeaseObjectType: evo_leasingobject_types(statecode: $statecode) {
evo_name
@ -292,6 +295,53 @@ const query = gql`
accountid
}
}
selectSubsidy: evo_subsidies(
statecode: $statecode
evo_datefrom_param: { lte: $currentDate }
evo_dateto_param: { gte: $currentDate }
) {
evo_name
evo_subsidyid
evo_percent_subsidy
evo_subsidy_summ
evo_max_subsidy_summ
evo_get_subsidy_payment
evo_brands {
evo_brandid
}
evo_models {
evo_modelid
}
evo_leasingobject_types {
evo_leasingobject_typeid
}
accounts {
accountid
}
}
selectFuelCard: evo_addproduct_types(
statecode: $statecode
evo_product_type: $fuelcard_product_type
evo_datefrom_param: { lte: $currentDate }
evo_dateto_param: { gte: $currentDate }
) {
evo_id
evo_name
evo_addproduct_typeid
evo_accountid
evo_graph_price_withoutnds
evo_cost_service_provider_withoutnds
evo_retro_bonus_withoutnds
evo_prime_cost
evo_graph_price
evo_max_period
evo_min_period
evo_controls_program
evo_helpcard_type
evo_leasingobject_types {
evo_leasingobject_typeid
}
}
}
`;
@ -309,6 +359,7 @@ const variables = {
tracker_product_type: 100000003,
telematic_product_type: 100000004,
techcard_product_type: 100000000,
fuelcard_product_type: 100000005,
};
const toOptions = [
@ -332,6 +383,8 @@ const toOptions = [
'selectLeaseObjectType',
'selectObjectRegionRegistration',
'selectLegalClientRegion',
'selectSubsidy',
'selectFuelCard',
];
export default {

View File

@ -1,5 +1,7 @@
import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
import initialFilters from 'client/stores/CalculationStore/config/initialFilters';
import initialFilters, {
noResetValueElements,
} from 'client/stores/CalculationStore/config/initialFilters';
import initialStatuses from 'client/stores/CalculationStore/config/initialStatuses';
import { isNil, mergeWith, pick } from 'lodash';
@ -39,6 +41,11 @@ const valuesActions = {
this.statuses[elementName] = status;
},
setStatuses(statuses, override) {
if (override) this.statuses = statuses;
this.statuses = Object.assign(this.statuses, statuses);
},
getValidation(elementName) {
return this.validations[elementName];
},
@ -101,7 +108,8 @@ const valuesActions = {
const value = this.getValue(valueName);
if (
filter &&
!filter(this.getOptions(elementName)).some(x => x.value === value)
!filter(this.getOptions(elementName)).some(x => x.value === value) &&
!noResetValueElements.includes(elementName)
) {
this.setValue(valueName, null);
}

View File

@ -89,7 +89,7 @@ export default function (this: ICalculationStore): IPreparedData {
preparedValues.calcType = values.calcType;
preparedValues.irrExpected = (values.IRR_Perc as number) / 100;
preparedValues.npvniExpected = 0;
preparedValues.totalExpected = values.totalPayments;
preparedValues.totalExpected = values.totalPayments + values.subsidySum;
preparedValues.nmper = values.leasingPeriod;
preparedValues.leasing0K =
values.product === 'LEASING0'
@ -97,6 +97,9 @@ export default function (this: ICalculationStore): IPreparedData {
(0.0234 / ((1 - 1 / 1.0234) ^ ((preparedValues.nmper as number) - 2)))
: 1;
preparedValues.loanRate = parseFloat(values.creditRate) / 100;
preparedValues.loanRatePeriod = this.getOption(
'selectRate',
)?.evo_credit_period;
preparedValues.balanceHolder = values.balanceHolder;
preparedValues.dogDate = preparedValues.calcDate;
preparedValues.paymentDateNew = undefined;
@ -107,6 +110,14 @@ export default function (this: ICalculationStore): IPreparedData {
preparedValues.lastPayment = (values.lastPaymentPerc as number) / 100;
preparedValues.lastPaymentSum =
(values.lastPaymentRub as number) / (1 + valuesConstants.VAT);
preparedValues.subsidySum =
parseInt(values.subsidySum) / (1 + valuesConstants.VAT);
preparedValues.subsidyPaymentNumber = this.getOption(
'selectSubsidy',
)?.evo_get_subsidy_payment;
preparedValues.fuelCardSum = this.getOption(
'selectFuelCard',
)?.evo_graph_price_withoutnds;
preparedValues.scheduleOfPayments = values.graphType;
preparedValues.comissionRub =
(values.comissionRub as number) / (1 + valuesConstants.VAT);
@ -426,6 +437,8 @@ export default function (this: ICalculationStore): IPreparedData {
preparedValues.tLMCost = telematic.evo_graph_price_withoutnds || 0;
}
//
const nsibBaseValue =
((preparedValues.plPrice || 0) +
(preparedValues.insuranceContract +
@ -512,6 +525,50 @@ export default function (this: ICalculationStore): IPreparedData {
}
}
if (
evo_coefficient_bonuses &&
evo_coefficient_bonuses.length > 0 &&
systemuser
) {
const evo_sot_coefficient_type = this.getStaticData(
'evo_sot_coefficient_type',
).find(x => x.evo_id === 'DIRECTOR_BONUS_NSIB');
const evo_coefficient = evo_coefficient_bonuses.find(
x =>
x.evo_sot_coefficient_typeid ===
evo_sot_coefficient_type?.evo_sot_coefficient_typeid,
);
if (evo_coefficient) {
preparedValues.directorBonusNsib =
(evo_coefficient.evo_sot_coefficient || 0) *
(preparedValues.nsibBrutto || 0);
}
}
if (
evo_coefficient_bonuses &&
evo_coefficient_bonuses.length > 0 &&
systemuser
) {
const evo_sot_coefficient_type = this.getStaticData(
'evo_sot_coefficient_type',
).find(x => x.evo_id === 'REGIONAL_DIRECTOR_BONUS_NSIB');
const evo_coefficient = evo_coefficient_bonuses.find(
x =>
x.evo_sot_coefficient_typeid ===
evo_sot_coefficient_type?.evo_sot_coefficient_typeid,
);
if (evo_coefficient) {
preparedValues.regionalDirectorBonusNsib =
(evo_coefficient.evo_sot_coefficient || 0) *
(preparedValues.nsibBrutto || 0);
}
}
if (
evo_coefficient_bonuses &&
evo_coefficient_bonuses.length > 0 &&

View File

@ -23,6 +23,14 @@ export default {
},
});
}
const subdidySum = this.getValue('subsidySum') || 0;
if (results[0]?.paymentSum?.value)
results[0].paymentSum.value -= subdidySum;
if (results[0]?.ndsCompensation?.value) {
results[0].ndsCompensation.value -= subdidySum - subdidySum / 1.2;
}
//TODO: speed up table render
this.setTableRows('tableResults', 0)(results);
}
@ -33,7 +41,10 @@ export default {
res: IGetCalculationResponse,
) {
const { sumWithVatColumn } = res.columns;
this.setValue('resultTotalGraphwithNDS', sumWithVatColumn?.values[0] || 0);
this.setValue(
'resultTotalGraphwithNDS',
(sumWithVatColumn?.values[0] || 0) - (this.getValue('subsidySum') || 0),
);
this.setValue(
'resultPlPrice',
(preparedData?.preparedValues?.acceptSum || 0) *
@ -74,7 +85,8 @@ export default {
this.setValue(
'resultFirstPayment',
(preparedData?.preparedValues?.firstPaymentSum || 0) *
(1 + valuesConstants.VAT),
(1 + valuesConstants.VAT) -
this.getValue('subsidySum') || 0,
);
this.setValue(
'resultLastPayment',
@ -133,7 +145,8 @@ export default {
);
this.setValue(
'totalPayments',
res?.columns?.sumWithVatColumn?.values[0] || 0,
(res?.columns?.sumWithVatColumn?.values[0] || 0) -
(this.getValue('subsidySum') || 0),
);
},
};

View File

@ -81,7 +81,6 @@ const customConditions: TElements<ValidationCondition> = {
}
return { isValid: true };
},
radioRequirementTelematic: calculationStore => {
const {
telematic,
@ -107,6 +106,28 @@ const customConditions: TElements<ValidationCondition> = {
}
return { isValid: true };
},
selectTownRegistration: calculationStore => {
const {
townRegistration,
objectRegistration,
} = calculationStore.getValues(['townRegistration', 'objectRegistration']);
if (objectRegistration === 100000000 && !townRegistration) {
return {
isValid: false,
};
}
return {
isValid: true,
};
},
tbxFirstPaymentRub: calculationStore => {
const { firstPaymentRub, subsidySum } = calculationStore.values;
return {
isValid: firstPaymentRub - subsidySum > 0,
message:
'Первый платеж с учетом субсидии получается отрицательный, увеличьте первый платеж',
};
},
};
const elementsValidations: TElements<any> = {
@ -120,7 +141,6 @@ const elementsValidations: TElements<any> = {
selectDealer: CONDITIONS.IS_NULL,
selectDealerPerson: CONDITIONS.IS_NULL,
selectRegionRegistration: CONDITIONS.IS_NULL,
selectTownRegistration: CONDITIONS.IS_NULL,
selectTarif: CONDITIONS.IS_NULL,
// selectRate: VALIDATIONS.IS_NULL,
selectRegistration: CONDITIONS.IS_NULL,

View File

@ -1,6 +1,7 @@
import { openNotification } from 'client/Elements/Notification';
import { IAutorunEffect } from 'core/types/Calculation/Store/effect';
import { ElementStatus } from 'core/types/statuses';
import { convertPrice } from './lib/tools';
const autorunEffects: IAutorunEffect[] = [
calculationStore => () => {
@ -186,6 +187,48 @@ const autorunEffects: IAutorunEffect[] = [
}
}
},
calculationStore => () => {
const subsidy = calculationStore.getOption('selectSubsidy');
if (subsidy?.evo_subsidy_summ && subsidy?.evo_subsidy_summ > 0) {
calculationStore.setValue('subsidySum', subsidy?.evo_subsidy_summ);
} else {
if (subsidy?.evo_max_subsidy_summ) {
const {
leaseObjectPrice,
supplierDiscountRub,
} = calculationStore.values;
const supplierCurrency = calculationStore.getOption(
'selectSupplierCurrency',
);
const evo_currencychanges = calculationStore.getStaticData(
'evo_currencychange',
);
const evo_currencychange = evo_currencychanges.find(
x =>
x.evo_ref_transactioncurrency ===
supplierCurrency?.transactioncurrencyid,
);
const plPriceRub = convertPrice(
supplierCurrency?.isocurrencycode,
leaseObjectPrice - supplierDiscountRub,
evo_currencychange?.evo_currencychange,
);
const subsidySum =
(plPriceRub * (subsidy?.evo_percent_subsidy || 0)) / 100;
const subsidySumValue =
subsidySum > subsidy?.evo_max_subsidy_summ
? subsidy?.evo_max_subsidy_summ
: subsidySum;
calculationStore.setValue('subsidySum', subsidySumValue);
} else {
calculationStore.setValue('subsidySum', 0);
}
}
},
];
export default autorunEffects;

View File

@ -1,66 +0,0 @@
import customValues from './lib/customValues';
const LEASE_OBJECT_RISK = {
100000000: 'Низкий',
100000001: 'Средний',
100000002: 'Высокий',
};
const computedEffects = {
// leadName() {
// const leadid = this.values.lead;
// if (this.options.selectLead && this.options.selectLead.length) {
// const lead = this.getOption('selectLead', { leadid });
// if (lead) {
// return lead.name;
// }
// }
// },
// opportunityName() {
// const opportunityid = this.values.opportunity;
// if (
// this.options.selectOpportunity &&
// this.options.selectOpportunity.length > 0
// ) {
// const opportunity = this.getOption('selectOpportunity', {
// opportunityid,
// });
// if (opportunity) {
// return opportunity.name;
// }
// }
// },
leaseObjectRiskName() {
const configuration = this.getOption('selectConfiguration');
if (configuration) {
if (configuration.evo_leasingobject_risk) {
const res = LEASE_OBJECT_RISK[configuration.evo_leasingobject_risk];
return res;
}
}
const model = this.getOption('selectModel');
if (model) {
const evo_leasingobject_risk = model.evo_leasingobject_risk;
return LEASE_OBJECT_RISK[evo_leasingobject_risk];
}
},
insKaskoPriceLeasePeriod() {
return customValues.insKaskoPriceLeasePeriod.call(this).toFixed(2);
},
irrInfo() {
const tarif = this.getOption('selectTarif');
if (tarif && tarif.evo_min_irr && tarif.evo_max_irr) {
return `Min: ${tarif.evo_min_irr}% - Max: ${tarif.evo_max_irr}%`;
}
return '-';
},
registrationDescription() {
const registration = this.getOption('selectRegistration');
if (registration && registration.evo_description) {
return registration.evo_description;
}
},
};
export default computedEffects;

View File

@ -0,0 +1,44 @@
import { ICalculationStore } from 'core/types/Calculation/Store';
import { TValues } from 'core/types/Calculation/Store/values';
import customValues from './lib/customValues';
const LEASE_OBJECT_RISK = {
100000000: 'Низкий',
100000001: 'Средний',
100000002: 'Высокий',
};
const computedEffects: TValues<
(this: ICalculationStore) => string | number | undefined
> = {
leaseObjectRiskName: function () {
const configuration = this.getOption('selectConfiguration');
if (configuration) {
if (configuration.evo_leasingobject_risk) {
const res = LEASE_OBJECT_RISK[configuration.evo_leasingobject_risk];
return res;
}
}
const model = this.getOption('selectModel');
const evo_leasingobject_risk = model?.evo_leasingobject_risk;
if (evo_leasingobject_risk)
return LEASE_OBJECT_RISK[evo_leasingobject_risk];
},
insKaskoPriceLeasePeriod: function () {
return customValues.insKaskoPriceLeasePeriod.call(this).toFixed(2);
},
irrInfo: function () {
const tarif = this.getOption('selectTarif');
if (tarif && tarif.evo_min_irr && tarif.evo_max_irr) {
return `Min: ${tarif.evo_min_irr}% - Max: ${tarif.evo_max_irr}%`;
}
return '-';
},
registrationDescription: function () {
const registration = this.getOption('selectRegistration');
return registration?.evo_description;
},
};
export default computedEffects;

View File

@ -1,12 +1,8 @@
export function convertPrice(
isocurrencycode,
leaseObjectPrice,
evo_currencychange,
) {
let price = leaseObjectPrice;
export function convertPrice(isocurrencycode, targetPrice, evo_currencychange) {
let price = targetPrice;
const isRUB = !isocurrencycode || isocurrencycode === 'RUB';
if (!isRUB) {
price = leaseObjectPrice * evo_currencychange;
price = targetPrice * evo_currencychange;
}
return price;
}

View File

@ -24,7 +24,8 @@ const map_add_product_types_to_values = {
registration: 100000001,
insNSIB: 100000002,
tracker: 100000003,
telematic: 100000004,
telematics: 100000004,
fuelCard: 100000005,
};
const tablePaymentsStatuses = (graphType, leasingPeriod) => {

View File

@ -1,7 +1,7 @@
import { TValues, ValuesNames } from 'core/types/Calculation/Store/values';
// import { TCRMEntity } from 'core/types/Entities/crmEntities';
import { IQuote } from 'core/types/Entities/crmEntities';
const mapKPtoValues: TValues<string> = {
const mapKPtoValues: TValues<keyof IQuote | string> = {
product: 'evo_baseproductid',
clientType: 'evo_client_typeid',
leaseObjectPrice: 'evo_supplier_currency_price',
@ -92,6 +92,8 @@ const mapKPtoValues: TValues<string> = {
objectCategoryTax: 'evo_category_tr',
objectTypeTax: 'evo_vehicle_type_tax',
typePTS: 'evo_pts_type',
subsidy: 'evo_subsidyid',
subsidySum: 'evo_subsidy_summ',
};
export function getKpPropName(valueName: ValuesNames) {

View File

@ -1231,10 +1231,19 @@ const reactionEffects: IReactionEffect[] = [
},
effect: leaseObjectUsed => {
if (leaseObjectUsed === true) {
calculationStore.setValue('deliveryTime', 100000000);
calculationStore.setStatus('radioDeliveryTime', ElementStatus.Disabled);
calculationStore.setValues({
deliveryTime: 100000000,
subsidy: null,
});
calculationStore.setStatuses({
radioDeliveryTime: ElementStatus.Disabled,
selectSubsidy: ElementStatus.Disabled,
});
} else {
calculationStore.setStatus('radioDeliveryTime', ElementStatus.Default);
calculationStore.setStatuses({
radioDeliveryTime: ElementStatus.Default,
selectSubsidy: ElementStatus.Default,
});
}
},
options: {
@ -1419,9 +1428,32 @@ const reactionEffects: IReactionEffect[] = [
calculationStore.setFilter('selectTechnicalCard', options =>
options.filter(
x =>
x &&
x.evo_max_period &&
x.evo_min_period &&
x?.evo_max_period &&
x?.evo_min_period &&
x.evo_max_period >= leasingPeriod &&
x.evo_min_period <= leasingPeriod &&
x.evo_leasingobject_types?.find(
x => x.evo_leasingobject_typeid === leaseObjectType,
),
),
);
},
options: {
fireImmediately: true,
},
}),
calculationStore => ({
expression: () => {
const { leasingPeriod, leaseObjectType } = calculationStore.values;
return { leasingPeriod, leaseObjectType };
},
effect: ({ leasingPeriod, leaseObjectType }) => {
calculationStore.setFilter('selectFuelCard', options =>
options.filter(
x =>
x?.evo_max_period &&
x?.evo_min_period &&
x.evo_max_period >= leasingPeriod &&
x.evo_min_period <= leasingPeriod &&
x.evo_leasingobject_types?.find(
@ -1487,6 +1519,37 @@ const reactionEffects: IReactionEffect[] = [
},
}),
(calculationStore, calculationProcess) => ({
expression: () => {
return calculationStore.getValue('leasingPeriod');
},
effect: () => {
if (calculationProcess.hasProcess(Process.LoadKp)) {
return;
}
const fuelCard = calculationStore.getOption('selectFuelCard');
if (fuelCard) {
const selectFuelCard_filter = calculationStore.getFilter(
'selectFuelCard',
);
const selectFueldCard_options = calculationStore.getOptions(
'selectFuelCard',
);
if (selectFuelCard_filter && selectFueldCard_options) {
const filtered_technicalCards = selectFuelCard_filter(
selectFueldCard_options,
);
calculationStore.setValue(
'fuelCard',
filtered_technicalCards?.[0]?.evo_addproduct_typeid,
);
}
}
},
}),
calculationStore => ({
expression: () => {
const {
@ -1679,38 +1742,39 @@ const reactionEffects: IReactionEffect[] = [
return {
leaseObjectType: calculationStore.getOption('selectLeaseObjectType'),
product: calculationStore.getOption('selectProduct'),
subsidy: calculationStore.getOption('selectSubsidy'),
};
},
effect: ({ leaseObjectType, product }) => {
effect: ({ leaseObjectType, product, subsidy }) => {
calculationStore.setStatus(
'selectBrand',
leaseObjectType ? ElementStatus.Default : ElementStatus.Disabled,
);
calculationStore.setFilter('selectBrand', options =>
options.filter(
calculationStore.setFilter('selectBrand', brands =>
brands.filter(
pipe(
option => {
if (
product &&
product.evo_brands &&
product.evo_brands.length > 0
) {
return (
product.evo_brands
.map(x => x.evo_brandid)
.includes(option.evo_brandid) && option
);
}
return option;
},
brand =>
(!product?.evo_brands?.length ||
product.evo_brands.filter(
x => x.evo_brandid === brand?.evo_brandid,
)?.length) &&
brand,
option =>
option.evo_vehicle_type &&
brand =>
brand?.evo_vehicle_type &&
intersection(
option.evo_vehicle_type?.filter(x => x > 0),
brand.evo_vehicle_type?.filter(x => x > 0),
leaseObjectType.evo_vehicle_type,
).length > 0,
).length > 0 &&
brand,
brand =>
brand &&
(!subsidy?.evo_brands ||
subsidy?.evo_brands?.filter(
x => x.evo_brandid === brand.evo_brandid,
)?.length),
),
),
);
@ -1725,19 +1789,64 @@ const reactionEffects: IReactionEffect[] = [
return {
selectBrandOptions: calculationStore.getOption('selectBrand'),
selectBrandFilter: calculationStore.getFilter('selectBrand'),
subsidy: calculationStore.getOption('selectSubsidy'),
};
},
effect: () => {
effect: ({ subsidy }) => {
const leaseObjectType = calculationStore.getOption(
'selectLeaseObjectType',
);
calculationStore.setFilter('selectModel', options =>
options.filter(
model =>
model.evo_vehicle_type &&
leaseObjectType &&
leaseObjectType.evo_vehicle_type &&
leaseObjectType.evo_vehicle_type.includes(model.evo_vehicle_type),
pipe(
model =>
model.evo_vehicle_type &&
leaseObjectType?.evo_vehicle_type?.includes(
model.evo_vehicle_type,
) &&
model,
model =>
model &&
(!subsidy?.evo_models?.length ||
subsidy?.evo_models?.filter(
x => x.evo_modelid === model.evo_modelid,
)?.length),
),
),
);
},
}),
calculationStore => ({
expression: () => {
return calculationStore.getOption('selectSubsidy');
},
effect: subsidy => {
calculationStore.setFilter('selectLeaseObjectType', types =>
types.filter(
type =>
!subsidy?.evo_leasingobject_types ||
subsidy.evo_leasingobject_types.filter(
x => x.evo_leasingobject_typeid === type.evo_leasingobject_typeid,
)?.length,
),
);
calculationStore.setFilter('selectDealer', dealers =>
dealers.filter(
dealer =>
!subsidy?.accounts ||
subsidy.accounts.filter(x => x.accountid === dealer.accountid)
?.length,
),
);
calculationStore.setFilter('selectDealerPerson', dealerPersons =>
dealerPersons.filter(
dealerPerson =>
!subsidy?.accounts ||
subsidy.accounts.filter(x => x.accountid === dealerPerson.accountid)
?.length,
),
);
},
@ -1767,6 +1876,57 @@ const reactionEffects: IReactionEffect[] = [
);
},
}),
calculationStore => ({
expression: () => {
return calculationStore.getOption('selectTarif');
},
effect: tarif => {
const ratesOptions = calculationStore.getOptions('selectRate');
if (!ratesOptions) {
return;
}
let rates = ratesOptions.filter(
rate =>
rate?.evo_tarifs?.filter(
evo_tarif => evo_tarif?.evo_tarifid === tarif?.evo_tarifid,
).length,
);
if (!rates?.length) {
rates = ratesOptions.filter(rate => rate.evo_id === 'BASE');
}
calculationStore.setValue('rate', rates[0].evo_id);
},
}),
calculationStore => ({
expression: () => {
return calculationStore.getOption('selectSubsidy');
},
effect: subsidy => {
if (subsidy) {
calculationStore.setValues({
leaseObjectCount: 1,
leaseObjectUsed: false,
deliveryTime: 100000000,
});
}
calculationStore.setStatuses({
tbxLeaseObjectCount: subsidy
? ElementStatus.Disabled
: ElementStatus.Default,
cbxLeaseObjectUsed: subsidy
? ElementStatus.Disabled
: ElementStatus.Default,
radioDeliveryTime: subsidy
? ElementStatus.Disabled
: ElementStatus.Default,
});
},
}),
];
export default reactionEffects;

View File

@ -504,6 +504,7 @@ const elementsToDisable: (ElementsNames | TableNames)[] = [
'selectTelematic',
'selectTracker',
'tbxMileage',
'selectSubsidy',
];
export default reactionEffects;

View File

@ -1,6 +1,14 @@
import {
ElementsNames,
TElements,
} from 'core/types/Calculation/Store/elements';
import { TElementFilter } from 'core/types/Calculation/Store/filters';
import { TElements } from 'core/types/Calculation/Store/elements';
const initialFilters: TElements<TElementFilter> = {};
export const noResetValueElements: ElementsNames[] = [
'selectTechnicalCard',
'selectFuelCard',
];
export default initialFilters;

View File

@ -13,7 +13,6 @@ export default class {
String.prototype.concat(
CORE_PROXY_URL,
'/api',
'/v1',
'/calculation',
'/calculate',
),

View File

@ -131,6 +131,10 @@ const propsMap: TEntities<{
name: 'evo_name',
value: 'evo_id',
},
evo_subsidy: {
name: 'evo_name',
value: 'evo_subsidyid',
},
};
export default propsMap;

View File

@ -91,6 +91,12 @@ export interface PreparedValues {
dogCreditLeasing?: number;
tlmCostPaymentSum?: number;
gpsCostPaymentSum?: number;
directorBonusNsib?: number;
regionalDirectorBonusNsib?: number;
loanRatePeriod?: number;
subsidySum?: number;
subsidyPaymentNumber?: number;
fuelCardSum?: number;
}
export interface PaymentRow {

View File

@ -145,7 +145,10 @@ export type ElementsNames =
| 'radioTypePTS'
| 'labelRegistrationDescription'
| 'selectLegalClientRegion'
| 'selectLegalClientTown';
| 'selectLegalClientTown'
| 'selectSubsidy'
| 'labelSubsidySum'
| 'selectFuelCard';
export type LinkElementsNames = 'linkDownloadKp';

View File

@ -46,7 +46,7 @@ interface ICalculationValues {
applyOptions: (options: TElements<(IBaseOption & TCRMEntity)[]>) => void;
filters: TElements<TElementFilter>;
getFilter: (elementName: ElementsNames) => TElementFilter;
getFilter: (elementName: ElementsNames) => TElementFilter | undefined;
setFilter: (
elementName: ElementsNames,
filter: TElementFilter | undefined,
@ -65,6 +65,7 @@ interface ICalculationValues {
statuses: TElements<ElementStatus>;
getStatus: (elementName: ElementsNames) => ElementStatus;
setStatus: (elementName: ElementsNames, status: ElementStatus) => void;
setStatuses: (statuses: TElements<ElementStatus>, override?: boolean) => void;
validations: TElements<boolean>;
getValidation: (elementName: ElementsNames) => boolean;

View File

@ -131,11 +131,12 @@ export type ValuesNames =
| 'objectTypeTax'
| 'typePTS'
| 'legalClientRegion'
| 'legalClientTown';
| 'legalClientTown'
| 'subsidy'
| 'subsidySum'
| 'fuelCard';
export type ComputedValuesNames =
| 'leadName'
| 'opportunityName'
| 'leaseObjectRiskName'
| 'insKaskoPriceLeasePeriod'
| 'irrInfo'
@ -163,7 +164,7 @@ type SuitTuple = typeof resultsValues;
export type ResultValuesNames = SuitTuple[number];
export type TValues<T> = {
[valueName in ValuesNames | ResultValuesNames]?: T;
[valueName in ValuesNames | ResultValuesNames | ComputedValuesNames]?: T;
};
export type TValue = any;

View File

@ -371,6 +371,7 @@ export interface IEvoTarif {
}
export interface IEvoRate {
createdon?: Date;
evo_id?: string;
evo_name?: string;
evo_rateid?: string;
@ -384,6 +385,8 @@ export interface IEvoRate {
evo_dateto?: Date;
statecode?: number;
evo_brands?: IEvoBrand[];
evo_credit_period?: number;
evo_tarifs?: IEvoTarif[];
}
export interface IEvoPlanPayment {
@ -420,6 +423,17 @@ export interface IEvoJobTitle {
evo_job_titleid?: string;
}
export interface IEvoSubsidy {
evo_subsidy_summ?: number;
evo_percent_subsidy?: number;
evo_max_subsidy_summ?: number;
evo_subsidyid?: string;
evo_get_subsidy_payment?: number;
evo_brands?: IEvoBrand[];
evo_models?: IEvoModel[];
accounts?: IAccount[];
}
type BaseEntity = {
__typename?: CRMEntityNames;
};
@ -456,4 +470,5 @@ export type TCRMEntity = BaseEntity &
IEvoPlanPayment &
ISystemUser &
IEvoJobTitle &
IEvoSotCoefficientType;
IEvoSotCoefficientType &
IEvoSubsidy;

View File

@ -28,7 +28,8 @@ export type CRMEntityNames =
| 'evo_rate'
| 'evo_planpayment'
| 'systemuser'
| 'evo_sot_coefficient_type';
| 'evo_sot_coefficient_type'
| 'evo_subsidy';
//TODO: or string
export type TEntities<T> = {