load-kp: pass elt data
This commit is contained in:
parent
d153182546
commit
d1665d3995
@ -511,6 +511,13 @@ export type GetQuoteCreateKpDataQueryVariables = Exact<{
|
||||
|
||||
export type GetQuoteCreateKpDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_price_with_discount: boolean | null, evo_price_without_discount_quote: boolean | null, evo_cost_increace: boolean | null, evo_insurance: boolean | null, evo_registration_quote: boolean | null, evo_card_quote: boolean | null, evo_nsib_quote: boolean | null, evo_redemption_graph: boolean | null, evo_fingap_quote: boolean | null, evo_contact_name: string | null, evo_gender: number | null, evo_last_payment_redemption: boolean | null } | null };
|
||||
|
||||
export type GetQuoteEltDataQueryVariables = Exact<{
|
||||
quoteId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetQuoteEltDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_kasko_accountid: string | null, evo_kasko_price: number | null, evo_id_elt_kasko: string | null, evo_id_kasko_calc: string | null, evo_franchise: number | null, evo_osago_accountid: string | null, evo_id_elt_osago: string | null, evo_osago_price: number | null, evo_leasingobject_typeid: string | null } | null };
|
||||
|
||||
export type GetQuoteFingapDataQueryVariables = Exact<{
|
||||
quoteId: Scalars['Uuid'];
|
||||
}>;
|
||||
@ -661,6 +668,7 @@ export const GetQuoteAddProductDataDocument = {"kind":"Document","definitions":[
|
||||
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"}}]}}]}}]} 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>;
|
||||
export const GetFinGapAddProductTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetFinGAPAddProductTypes"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"DateTime"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_datefrom_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"lte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_dateto_param"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"gte"},"value":{"kind":"Variable","name":{"kind":"Name","value":"currentDate"}}}]}},{"kind":"Argument","name":{"kind":"Name","value":"evo_product_type"},"value":{"kind":"IntValue","value":"100000006"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","name":{"kind":"Name","value":"evo_type_calc_cerebellum"}},{"kind":"Field","name":{"kind":"Name","value":"evo_cost_service_provider_withoutnds"}},{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_types"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_addproduct_typeid"}}]}}]}}]}}]} as unknown as DocumentNode<GetFinGapAddProductTypesQuery, GetFinGapAddProductTypesQueryVariables>;
|
||||
export const GetQuoteGibddDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetQuoteGibddData"},"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_db_accept_registration"}},{"kind":"Field","name":{"kind":"Name","value":"evo_object_registration"}},{"kind":"Field","name":{"kind":"Name","value":"evo_pts_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_tax_year"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_tax_approved"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category_tr"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type_tax"}},{"kind":"Field","name":{"kind":"Name","value":"evo_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_legal_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_registration_regionid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_req_telematic"}},{"kind":"Field","name":{"kind":"Name","value":"evo_req_telematic_accept"}}]}}]}}]} as unknown as DocumentNode<GetQuoteGibddDataQuery, GetQuoteGibddDataQueryVariables>;
|
||||
|
||||
66
apps/web/process/elt/get-kp-data.ts
Normal file
66
apps/web/process/elt/get-kp-data.ts
Normal file
@ -0,0 +1,66 @@
|
||||
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
||||
import initializeApollo from '@/apollo/client';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const QUERY_GET_QUOTE_ELT_DATA = gql`
|
||||
query GetQuoteEltData($quoteId: Uuid!) {
|
||||
quote(quoteId: $quoteId) {
|
||||
evo_kasko_accountid
|
||||
evo_kasko_price
|
||||
evo_id_elt_kasko
|
||||
evo_id_kasko_calc
|
||||
evo_franchise
|
||||
evo_osago_accountid
|
||||
evo_id_elt_osago
|
||||
evo_osago_price
|
||||
evo_leasingobject_typeid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export async function getKPData({
|
||||
values: { quote: quoteId },
|
||||
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
||||
const apolloClient = initializeApollo();
|
||||
|
||||
const {
|
||||
data: { quote },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetQuoteEltDataDocument,
|
||||
variables: {
|
||||
quoteId,
|
||||
},
|
||||
});
|
||||
|
||||
const elt: NonNullable<GetQuoteProcessData['elt']> = { kasko: undefined, osago: undefined };
|
||||
|
||||
if (
|
||||
quote?.evo_kasko_accountid &&
|
||||
quote?.evo_id_elt_kasko &&
|
||||
quote?.evo_id_kasko_calc &&
|
||||
quote?.evo_kasko_price &&
|
||||
quote?.evo_franchise
|
||||
) {
|
||||
elt.kasko = {
|
||||
key: quote?.evo_kasko_accountid,
|
||||
requestId: quote?.evo_id_elt_kasko,
|
||||
skCalcId: quote?.evo_id_kasko_calc,
|
||||
sum: quote?.evo_kasko_price,
|
||||
totalFranchise: quote?.evo_franchise,
|
||||
};
|
||||
}
|
||||
|
||||
if (quote?.evo_osago_accountid && quote?.evo_id_elt_osago && quote?.evo_osago_price) {
|
||||
elt.osago = {
|
||||
key: quote?.evo_osago_accountid,
|
||||
numCalc: Number.parseInt(quote?.evo_id_elt_osago, 10),
|
||||
sum: quote?.evo_osago_price,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
elt,
|
||||
};
|
||||
}
|
||||
@ -1 +1,2 @@
|
||||
export * from './get-kp-data';
|
||||
export * as reactions from './reactions';
|
||||
|
||||
@ -2,7 +2,10 @@ import type { ProcessContext } from '../../types';
|
||||
import type { Row } from '@/Components/Calculation/Form/ELT/types';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
|
||||
export default function helper({ apolloClient, store }: ProcessContext) {
|
||||
export default function helper({
|
||||
apolloClient,
|
||||
store,
|
||||
}: Pick<ProcessContext, 'apolloClient' | 'store'>) {
|
||||
const { $calculation } = store;
|
||||
|
||||
return {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import type { ProcessContext } from '../../types';
|
||||
import helper from '../lib/helper';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import { toJS } from 'mobx';
|
||||
import { comparer, toJS } from 'mobx';
|
||||
|
||||
export default function reactions(context: ProcessContext) {
|
||||
const { store } = context;
|
||||
@ -12,8 +12,6 @@ export default function reactions(context: ProcessContext) {
|
||||
disposableReaction(
|
||||
() => $process.has('ELT') || $process.has('LoadKP'),
|
||||
() => ({
|
||||
kasko: toJS($tables.insurance.row('kasko').getValues()),
|
||||
osago: toJS($tables.insurance.row('osago').getValues()),
|
||||
values: $calculation.$values.getValues([
|
||||
'leaseObjectType',
|
||||
// osago
|
||||
@ -43,7 +41,41 @@ export default function reactions(context: ProcessContext) {
|
||||
}
|
||||
},
|
||||
{
|
||||
delay: 10,
|
||||
equals: comparer.shallow,
|
||||
fireImmediately: true,
|
||||
}
|
||||
);
|
||||
|
||||
disposableReaction(
|
||||
() => $process.has('ELT') || $process.has('LoadKP'),
|
||||
() => {
|
||||
const { insCost, insuranceCompany } = toJS($tables.insurance.row('kasko').getValues());
|
||||
|
||||
return { insCost, insuranceCompany };
|
||||
},
|
||||
() => {
|
||||
$tables.elt.kasko.resetSelectedKey();
|
||||
},
|
||||
{
|
||||
delay: 10,
|
||||
equals: comparer.shallow,
|
||||
}
|
||||
);
|
||||
|
||||
disposableReaction(
|
||||
() => $process.has('ELT') || $process.has('LoadKP'),
|
||||
() => {
|
||||
const { insCost, insuranceCompany } = toJS($tables.insurance.row('osago').getValues());
|
||||
|
||||
return { insCost, insuranceCompany };
|
||||
},
|
||||
() => {
|
||||
$tables.elt.osago.resetSelectedKey();
|
||||
},
|
||||
{
|
||||
delay: 10,
|
||||
equals: comparer.shallow,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/* eslint-disable sonarjs/cognitive-complexity */
|
||||
import eltHelper from '../elt/lib/helper';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { reaction } from 'mobx';
|
||||
import { omit } from 'radash';
|
||||
@ -5,9 +7,11 @@ import { message } from 'ui/elements';
|
||||
|
||||
const key = 'KP_LOADING_INFO';
|
||||
|
||||
export function common({ store, trpcClient }: ProcessContext) {
|
||||
export function common({ store, trpcClient, apolloClient }: ProcessContext) {
|
||||
const { $calculation, $process, $tables } = store;
|
||||
|
||||
const { init: initElt } = eltHelper({ apolloClient, store });
|
||||
|
||||
reaction(
|
||||
() => $calculation.$values.getValue('quote'),
|
||||
() => {
|
||||
@ -29,7 +33,7 @@ export function common({ store, trpcClient }: ProcessContext) {
|
||||
...$calculation.$values.getValues(['lead', 'opportunity', 'recalcWithRevision']),
|
||||
},
|
||||
})
|
||||
.then(({ values, payments, insurance, fingap }) => {
|
||||
.then(({ values, payments, insurance, fingap, elt }) => {
|
||||
$calculation.$values.setValues(
|
||||
omit(values, [
|
||||
'lead',
|
||||
@ -59,6 +63,17 @@ export function common({ store, trpcClient }: ProcessContext) {
|
||||
|
||||
if (fingap) $tables.fingap.setSelectedKeys(fingap.keys);
|
||||
|
||||
initElt().then(() => {
|
||||
if (elt?.kasko) {
|
||||
$tables.elt.kasko.setRow(elt.kasko);
|
||||
$tables.elt.kasko.setSelectedKey(elt.kasko.key);
|
||||
}
|
||||
if (elt?.osago) {
|
||||
$tables.elt.osago.setRow(elt.osago);
|
||||
$tables.elt.osago.setSelectedKey(elt.osago.key);
|
||||
}
|
||||
});
|
||||
|
||||
message.success({
|
||||
content: `КП ${quote.label} загружено`,
|
||||
key,
|
||||
|
||||
@ -24,6 +24,7 @@ import * as addProduct from '@/process/add-product';
|
||||
import * as bonuses from '@/process/bonuses';
|
||||
import * as configurator from '@/process/configurator';
|
||||
import * as createKpProcess from '@/process/create-kp';
|
||||
import * as eltProcess from '@/process/elt';
|
||||
import * as fingapProcess from '@/process/fingap';
|
||||
import * as gibdd from '@/process/gibdd';
|
||||
import * as insuranceProcess from '@/process/insurance';
|
||||
@ -69,6 +70,7 @@ export const quoteRouter = router({
|
||||
insuranceProcess,
|
||||
addProduct,
|
||||
createKpProcess,
|
||||
eltProcess,
|
||||
].map(({ getKPData }) => getKPData(input))
|
||||
);
|
||||
|
||||
@ -76,12 +78,14 @@ export const quoteRouter = router({
|
||||
const payments = processData.find((x) => x.payments)?.payments ?? defaultPayments;
|
||||
const insurance = processData.find((x) => x.insurance)?.insurance ?? defaultInsurance;
|
||||
const fingap = processData.find((x) => x.fingap)?.fingap ?? defaultFingap;
|
||||
const elt = processData.find((x) => x.elt)?.elt;
|
||||
|
||||
return {
|
||||
values,
|
||||
payments,
|
||||
insurance,
|
||||
fingap,
|
||||
elt,
|
||||
};
|
||||
}),
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/* eslint-disable zod/require-strict */
|
||||
import { CalculateInputSchema } from '../calculate/types';
|
||||
import { RowSchema as EltRowSchema } from '@/config/schema/elt';
|
||||
import { RiskSchema } from '@/config/schema/fingap';
|
||||
import { KeysSchema, RowSchema } from '@/config/schema/insurance';
|
||||
import PaymentsSchema from '@/config/schema/payments';
|
||||
@ -33,6 +34,22 @@ const InsuranceSchema = z.object({
|
||||
|
||||
export const GetQuoteOutputDataSchema = z
|
||||
.object({
|
||||
elt: z
|
||||
.object({
|
||||
kasko: EltRowSchema.pick({
|
||||
key: true,
|
||||
requestId: true,
|
||||
skCalcId: true,
|
||||
sum: true,
|
||||
totalFranchise: true,
|
||||
}).optional(),
|
||||
osago: EltRowSchema.pick({
|
||||
key: true,
|
||||
numCalc: true,
|
||||
sum: true,
|
||||
}).optional(),
|
||||
})
|
||||
.optional(),
|
||||
fingap: FinGAPSchema,
|
||||
insurance: InsuranceSchema,
|
||||
payments: PaymentsSchema,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user