fix prepareData

This commit is contained in:
Chika 2020-11-13 13:55:04 +03:00
parent 38793c28d2
commit 19e592de67
4 changed files with 54 additions and 24 deletions

View File

@ -29,9 +29,11 @@ export const prepareCalculationData = ({
}),
);
const tracker = options.selectTracker?.find(x => x.evo_id === values.tracker);
const tracker = options.selectTracker?.find(
x => x.evo_addproduct_typeid === values.tracker,
);
const telematic = options.selectTelematic?.find(
x => x.evo_id === values.telematic,
x => x.evo_addproduct_typeid === values.telematic,
);
for (let i = 0; i < values.leasingPeriod; i++) {
@ -412,7 +414,7 @@ export const prepareCalculationData = ({
}
const technicalCard = options.selectTechnicalCard?.find(
x => x.evo_id === values.technicalCard,
x => x.evo_addproduct_typeid === values.technicalCard,
);
if (technicalCard) {
@ -423,7 +425,7 @@ export const prepareCalculationData = ({
}
const selectedRegistration = options.selectRegistration?.find(
x => x.evo_id === values.registration,
x => x.evo_addproduct_typeid === values.registration,
);
if (selectedRegistration) {
@ -443,7 +445,8 @@ export const prepareCalculationData = ({
const nsibBaseValue =
((preparedValues.plPrice || 0) +
(preparedValues.insuranceContract * (preparedValues.rats || 0) +
(preparedValues.insuranceContract +
(preparedValues.rats || 0) +
(preparedValues.registration || 0) +
(preparedValues.trackerCost || 0) +
(preparedValues.tLMCost || 0) +
@ -466,18 +469,19 @@ export const prepareCalculationData = ({
}
const selectedInsNSIB = options.selectInsNSIB?.find(
x => x.evo_id === values.insNSIB,
x => x.evo_addproduct_typeid === values.insNSIB,
);
if (selectedInsNSIB) {
preparedValues.nsibBrutto =
(((selectedInsNSIB.evo_graph_price || 0 / 100) *
((((selectedInsNSIB.evo_graph_price || 0) / 100) *
preparedValues.nsibBase) /
12) *
(preparedValues.nmper || 0);
preparedValues.nsibNetto =
(((selectedInsNSIB.evo_prime_cost || 0 / 100) * preparedValues.nsibBase) /
((((selectedInsNSIB.evo_prime_cost || 0) / 100) *
preparedValues.nsibBase) /
12) *
(preparedValues.nmper || 0);
}

View File

@ -181,7 +181,20 @@ const initialOptions: TEntityQuery[] = [
gte: currentDate,
},
},
fields: ['evo_addproduct_typeid', 'evo_name'],
fields: [
'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',
],
many: true,
toOption: true,
},
@ -200,7 +213,20 @@ const initialOptions: TEntityQuery[] = [
gte: currentDate,
},
},
fields: ['evo_addproduct_typeid', 'evo_name'],
fields: [
'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',
],
many: true,
toOption: true,
},
@ -221,17 +247,17 @@ const initialOptions: TEntityQuery[] = [
},
fields: [
'evo_id',
'evo_addproduct_typeid',
'evo_name',
'evo_min_period',
'evo_max_period',
'evo_controls_program',
'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',
],
relatedEntities: [
{
@ -265,17 +291,17 @@ const initialOptions: TEntityQuery[] = [
},
fields: [
'evo_id',
'evo_addproduct_typeid',
'evo_name',
'evo_min_period',
'evo_max_period',
'evo_controls_program',
'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',
],
relatedEntities: [
{
@ -309,17 +335,17 @@ const initialOptions: TEntityQuery[] = [
},
fields: [
'evo_id',
'evo_addproduct_typeid',
'evo_name',
'evo_min_period',
'evo_max_period',
'evo_controls_program',
'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',
],
many: true,
toOption: true,

View File

@ -95,7 +95,7 @@ const propsMap: TEntities<{
},
evo_addproduct_type: {
name: 'evo_name',
value: 'evo_id',
value: 'evo_addproduct_typeid',
},
evo_planpayment: {
name: 'evo_name',

View File

@ -3,5 +3,5 @@ export default {
ESN: 1.271,
KASKO_PR: 0.3,
KASKO_BONUS_PR: 0.35,
NSIB_MAX: 1.2,
NSIB_MAX: 5000000,
};