Compare commits
3 Commits
dev
...
fix/kp-dat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fb5bce959 | ||
|
|
f2c8f183df | ||
|
|
5b847ffa07 |
@ -1033,7 +1033,7 @@ export type GetQuoteConfiguratorDataQueryVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type GetQuoteConfiguratorDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_baseproductid: string | null, evo_client_typeid: string | null, evo_msfo_irr: number | null, evo_delivery_time: number | null, evo_first_payment_perc: number | null, evo_last_payment_perc: number | null, evo_leasingobject_typeid: string | null, evo_leasingobject_used: boolean | null, evo_period: number | null, evo_accept_period: number | null, evo_rateid: string | null } | null };
|
||||
export type GetQuoteConfiguratorDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_baseproductid: string | null, evo_client_typeid: string | null, evo_msfo_irr: number | null, evo_delivery_time: number | null, evo_first_payment_perc: number | null, evo_last_payment_perc: number | null, evo_leasingobject_typeid: string | null, evo_leasingobject_used: boolean | null, evo_period: number | null, evo_accept_period: number | null, evo_rateid: string | null, evo_min_change_price: number | null, evo_max_price_change: number | null } | null };
|
||||
|
||||
export type GetQuoteCreateKpDataQueryVariables = Exact<{
|
||||
quoteId: Scalars['Uuid'];
|
||||
@ -1197,7 +1197,7 @@ export const GetInsuranceCompaniesDocument = {"kind":"Document","definitions":[{
|
||||
export const GetRolesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRoles"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"roleName"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"roles"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"name"},"value":{"kind":"Variable","name":{"kind":"Name","value":"roleName"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"systemusers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"fullname"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"domainname"}}]}}]}}]}}]} as unknown as DocumentNode<GetRolesQuery, GetRolesQueryVariables>;
|
||||
export const GetQuoteAddProductDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteAddProductData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_product_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evo_accept_control_addproduct_typeid"}}]}}]}}]} as unknown as DocumentNode<GetQuoteAddProductDataQuery, GetQuoteAddProductDataQueryVariables>;
|
||||
export const GetQuoteBonusDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteBonusData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_sale_bonus"}}]}}]}}]} as unknown as DocumentNode<GetQuoteBonusDataQuery, GetQuoteBonusDataQueryVariables>;
|
||||
export const GetQuoteConfiguratorDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteConfiguratorData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_client_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_msfo_irr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_delivery_time"}},{"kind":"Field","name":{"kind":"Name","value":"evo_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_used"}},{"kind":"Field","name":{"kind":"Name","value":"evo_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_accept_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_rateid"}}]}}]}}]} as unknown as DocumentNode<GetQuoteConfiguratorDataQuery, GetQuoteConfiguratorDataQueryVariables>;
|
||||
export const GetQuoteConfiguratorDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteConfiguratorData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_baseproductid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_client_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_msfo_irr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_delivery_time"}},{"kind":"Field","name":{"kind":"Name","value":"evo_first_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_used"}},{"kind":"Field","name":{"kind":"Name","value":"evo_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_accept_period"}},{"kind":"Field","name":{"kind":"Name","value":"evo_rateid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_min_change_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_max_price_change"}}]}}]}}]} as unknown as DocumentNode<GetQuoteConfiguratorDataQuery, GetQuoteConfiguratorDataQueryVariables>;
|
||||
export const GetQuoteCreateKpDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteCreateKPData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_price_with_discount"}},{"kind":"Field","name":{"kind":"Name","value":"evo_price_without_discount_quote"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cost_increace"}},{"kind":"Field","name":{"kind":"Name","value":"evo_insurance"}},{"kind":"Field","name":{"kind":"Name","value":"evo_registration_quote"}},{"kind":"Field","name":{"kind":"Name","value":"evo_card_quote"}},{"kind":"Field","name":{"kind":"Name","value":"evo_nsib_quote"}},{"kind":"Field","name":{"kind":"Name","value":"evo_redemption_graph"}},{"kind":"Field","name":{"kind":"Name","value":"evo_fingap_quote"}},{"kind":"Field","name":{"kind":"Name","value":"evo_contact_name"}},{"kind":"Field","name":{"kind":"Name","value":"evo_gender"}},{"kind":"Field","name":{"kind":"Name","value":"evo_last_payment_redemption"}}]}}]}}]} as unknown as DocumentNode<GetQuoteCreateKpDataQuery, GetQuoteCreateKpDataQueryVariables>;
|
||||
export const GetQuoteEltDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteEltData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_kasko_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id_elt_kasko"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id_kasko_calc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_franchise"}},{"kind":"Field","name":{"kind":"Name","value":"evo_osago_accountid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id_elt_osago"}},{"kind":"Field","name":{"kind":"Name","value":"evo_osago_price"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}}]}}]} as unknown as DocumentNode<GetQuoteEltDataQuery, GetQuoteEltDataQueryVariables>;
|
||||
export const GetQuoteFingapDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteFingapData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"quote"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"quoteId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"quoteId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_product_risks"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]}}]}}]} as unknown as DocumentNode<GetQuoteFingapDataQuery, GetQuoteFingapDataQueryVariables>;
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
/* eslint-disable sonarjs/cognitive-complexity */
|
||||
/* eslint-disable complexity */
|
||||
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
||||
import helper from './lib/helper';
|
||||
import initializeApollo from '@/apollo/client';
|
||||
import defaultValues from '@/config/default-values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { getKPData as getKPDataPrice } from '@/process/price/get-kp-data';
|
||||
import { getKPData as getKPDataSubsidy } from '@/process/subsidy/get-kp-data';
|
||||
import { createCurrencyUtility } from '@/utils/currency';
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@ -20,13 +25,14 @@ const QUERY_GET_QUOTE_CONFIGURATOR_DATA = gql`
|
||||
evo_period
|
||||
evo_accept_period
|
||||
evo_rateid
|
||||
evo_min_change_price
|
||||
evo_max_price_change
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export async function getKPData({
|
||||
values: { quote: quoteId, recalcWithRevision },
|
||||
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
||||
export async function getKPData({ values }: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
||||
const { quote: quoteId, recalcWithRevision } = values;
|
||||
const apolloClient = initializeApollo();
|
||||
|
||||
const {
|
||||
@ -42,7 +48,7 @@ export async function getKPData({
|
||||
? Math.min(quote?.evo_period ?? 0, quote?.evo_accept_period ?? 0)
|
||||
: quote?.evo_period ?? 0;
|
||||
|
||||
const { getTarifs, getRates } = helper({ apolloClient });
|
||||
const { getTarifs, getRates, getPriceChange } = helper({ apolloClient });
|
||||
|
||||
let tarif = defaultValues.tarif;
|
||||
if (
|
||||
@ -72,12 +78,54 @@ export async function getKPData({
|
||||
}
|
||||
}
|
||||
|
||||
let maxPriceChange = quote?.evo_max_price_change ?? defaultValues.maxPriceChange;
|
||||
let minPriceChange = quote?.evo_min_change_price ?? defaultValues.minPriceChange;
|
||||
|
||||
if (!recalcWithRevision) {
|
||||
const kpDataPrice = await getKPDataPrice({ values });
|
||||
const kpDataSubsidy = await getKPDataSubsidy({ values });
|
||||
|
||||
const supplierCurrency = kpDataPrice.values?.supplierCurrency ?? defaultValues.supplierCurrency;
|
||||
const leaseObjectPrice = kpDataPrice.values?.leaseObjectPrice ?? defaultValues.leaseObjectPrice;
|
||||
const supplierDiscountRub =
|
||||
kpDataPrice.values?.supplierDiscountRub ?? defaultValues.supplierDiscountRub;
|
||||
|
||||
const { RUB } = createCurrencyUtility({ apolloClient });
|
||||
|
||||
let plPriceRub = 0;
|
||||
if (supplierCurrency && leaseObjectPrice) {
|
||||
plPriceRub = await RUB({
|
||||
currencyid: supplierCurrency,
|
||||
value: leaseObjectPrice,
|
||||
});
|
||||
}
|
||||
|
||||
let discountRub = 0;
|
||||
if (supplierCurrency && supplierDiscountRub) {
|
||||
discountRub = await RUB({
|
||||
currencyid: supplierCurrency,
|
||||
value: supplierDiscountRub,
|
||||
});
|
||||
}
|
||||
|
||||
({ minPriceChange, maxPriceChange } = await getPriceChange({
|
||||
addEquipmentPrice: kpDataPrice.values?.addEquipmentPrice ?? defaultValues.addEquipmentPrice,
|
||||
discountRub,
|
||||
importProgramSum: kpDataSubsidy.values?.importProgramSum ?? defaultValues.importProgramSum,
|
||||
leaseObjectType: quote?.evo_leasingobject_typeid ?? defaultValues.leaseObjectType,
|
||||
plPriceRub,
|
||||
recalcWithRevision,
|
||||
}));
|
||||
}
|
||||
|
||||
const { evo_rate } = await getRates({ tarif });
|
||||
|
||||
return {
|
||||
values: {
|
||||
IRR_Perc: quote?.evo_msfo_irr ?? defaultValues.IRR_Perc,
|
||||
clientType: quote?.evo_client_typeid,
|
||||
maxPriceChange,
|
||||
minPriceChange,
|
||||
product: quote?.evo_baseproductid,
|
||||
rate: evo_rate?.evo_rateid ?? defaultValues.rate,
|
||||
tarif,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import defaultValues from '@/config/default-values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import type { CalculationValues } from '@/stores/calculation/values/types';
|
||||
@ -17,8 +18,63 @@ type GetTarifInputValues = Pick<
|
||||
|
||||
type GetRatesInputValues = Pick<CalculationValues, 'tarif'>;
|
||||
|
||||
type GetPriceChangeInputValues = Pick<
|
||||
CalculationValues,
|
||||
| 'addEquipmentPrice'
|
||||
| 'discountRub'
|
||||
| 'importProgramSum'
|
||||
| 'leaseObjectType'
|
||||
| 'plPriceRub'
|
||||
| 'recalcWithRevision'
|
||||
>;
|
||||
|
||||
export default function helper({ apolloClient }: Pick<ProcessContext, 'apolloClient'>) {
|
||||
return {
|
||||
async getPriceChange({
|
||||
discountRub,
|
||||
importProgramSum,
|
||||
addEquipmentPrice,
|
||||
plPriceRub,
|
||||
recalcWithRevision,
|
||||
leaseObjectType: leaseObjectTypeId,
|
||||
}: GetPriceChangeInputValues) {
|
||||
if (recalcWithRevision) {
|
||||
return {
|
||||
maxPriceChange: defaultValues.maxPriceChange,
|
||||
minPriceChange: defaultValues.minPriceChange,
|
||||
};
|
||||
}
|
||||
|
||||
let evo_leasingobject_type: CRMTypes.GetLeaseObjectTypeQuery['evo_leasingobject_type'] = null;
|
||||
|
||||
if (leaseObjectTypeId) {
|
||||
const { data } = await apolloClient.query({
|
||||
query: CRMTypes.GetLeaseObjectTypeDocument,
|
||||
variables: { leaseObjectTypeId },
|
||||
});
|
||||
|
||||
({ evo_leasingobject_type } = data);
|
||||
}
|
||||
|
||||
const price = plPriceRub + addEquipmentPrice - importProgramSum;
|
||||
const maxPriceChange =
|
||||
price - discountRub < 800_000
|
||||
? price - discountRub + 50_000
|
||||
: (price - discountRub) *
|
||||
(evo_leasingobject_type?.evo_vehicle_type?.includes(100_000_001) ||
|
||||
evo_leasingobject_type?.evo_vehicle_type?.includes(100_000_005)
|
||||
? 1.01
|
||||
: 1.05);
|
||||
|
||||
const minPriceChange =
|
||||
price - discountRub < 800_000 ? price - discountRub - 50_000 : (price - discountRub) * 0.95;
|
||||
|
||||
return {
|
||||
maxPriceChange,
|
||||
minPriceChange,
|
||||
};
|
||||
},
|
||||
|
||||
async getRates({ tarif: tarifId }: GetRatesInputValues) {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ dayjs.extend(utc);
|
||||
export default function valuesReactions({ store, apolloClient }: ProcessContext) {
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
const { getTarifs, getRates } = helper({ apolloClient });
|
||||
const { getTarifs, getRates, getPriceChange } = helper({ apolloClient });
|
||||
|
||||
disposableReaction(
|
||||
() => $process.has('LoadKP'),
|
||||
@ -131,6 +131,29 @@ export default function valuesReactions({ store, apolloClient }: ProcessContext)
|
||||
}
|
||||
);
|
||||
|
||||
disposableReaction(
|
||||
() => $process.has('LoadKP'),
|
||||
() =>
|
||||
$calculation.$values.getValues([
|
||||
'discountRub',
|
||||
'addEquipmentPrice',
|
||||
'importProgramSum',
|
||||
'plPriceRub',
|
||||
'leaseObjectType',
|
||||
'recalcWithRevision',
|
||||
]),
|
||||
async (values) => {
|
||||
const { maxPriceChange, minPriceChange } = await getPriceChange(values);
|
||||
|
||||
$calculation.element('tbxMaxPriceChange').setValue(maxPriceChange);
|
||||
$calculation.element('tbxMinPriceChange').setValue(minPriceChange);
|
||||
},
|
||||
{
|
||||
delay: 5,
|
||||
equals: comparer.shallow,
|
||||
}
|
||||
);
|
||||
|
||||
(
|
||||
[
|
||||
'selectProduct',
|
||||
|
||||
@ -1,16 +1,10 @@
|
||||
import type { ProcessContext } from '../types';
|
||||
import { createValidationSchema } from './validation';
|
||||
import type { Elements } from '@/Components/Calculation/config/map/values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { createValidationReaction } from '@/process/tools';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export function common({ store, apolloClient }: ProcessContext) {
|
||||
export function common({ store }: ProcessContext) {
|
||||
const { $calculation, $tables } = store;
|
||||
|
||||
reaction(
|
||||
@ -18,53 +12,6 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
() => $calculation.element('selectQuote').resetValue()
|
||||
);
|
||||
|
||||
disposableReaction(
|
||||
() => $calculation.element('cbxRecalcWithRevision').getValue() === true,
|
||||
() =>
|
||||
$calculation.$values.getValues([
|
||||
'discountRub',
|
||||
'addEquipmentPrice',
|
||||
'importProgramSum',
|
||||
'plPriceRub',
|
||||
'leaseObjectType',
|
||||
]),
|
||||
async ({
|
||||
discountRub,
|
||||
importProgramSum,
|
||||
addEquipmentPrice,
|
||||
plPriceRub,
|
||||
leaseObjectType: leaseObjectTypeId,
|
||||
}) => {
|
||||
let evo_leasingobject_type: CRMTypes.GetLeaseObjectTypeQuery['evo_leasingobject_type'] = null;
|
||||
|
||||
if (leaseObjectTypeId) {
|
||||
const { data } = await apolloClient.query({
|
||||
query: CRMTypes.GetLeaseObjectTypeDocument,
|
||||
variables: { leaseObjectTypeId },
|
||||
});
|
||||
|
||||
({ evo_leasingobject_type } = data);
|
||||
}
|
||||
|
||||
const price = plPriceRub + addEquipmentPrice - importProgramSum;
|
||||
const maxPriceChange =
|
||||
price - discountRub < 800_000
|
||||
? price - discountRub + 50_000
|
||||
: (price - discountRub) *
|
||||
(evo_leasingobject_type?.evo_vehicle_type?.includes(100_000_001) ||
|
||||
evo_leasingobject_type?.evo_vehicle_type?.includes(100_000_005)
|
||||
? 1.01
|
||||
: 1.05);
|
||||
|
||||
$calculation.element('tbxMaxPriceChange').setValue(maxPriceChange);
|
||||
|
||||
const minPriceChange =
|
||||
price - discountRub < 800_000 ? price - discountRub - 50_000 : (price - discountRub) * 0.95;
|
||||
|
||||
$calculation.element('tbxMinPriceChange').setValue(minPriceChange);
|
||||
}
|
||||
);
|
||||
|
||||
reaction(
|
||||
() => $calculation.$values.getValues(['leaseObjectUsed', 'recalcWithRevision']),
|
||||
({ leaseObjectUsed, recalcWithRevision }) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user