Compare commits
5 Commits
dev
...
migration/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ae502c262 | ||
|
|
9c3fa098b8 | ||
|
|
8550020e7e | ||
|
|
d3b8e9f099 | ||
|
|
518d766015 |
@ -498,6 +498,13 @@ 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 } | null };
|
export type GetQuoteConfiguratorDataQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_baseproductid: string | null, evo_client_typeid: string | null, evo_msfo_irr: number | null } | null };
|
||||||
|
|
||||||
|
export type GetQuoteCreateKpDataQueryVariables = Exact<{
|
||||||
|
quoteId: Scalars['Uuid'];
|
||||||
|
}>;
|
||||||
|
|
||||||
|
|
||||||
|
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 } | null };
|
||||||
|
|
||||||
export type GetQuoteFingapDataQueryVariables = Exact<{
|
export type GetQuoteFingapDataQueryVariables = Exact<{
|
||||||
quoteId: Scalars['Uuid'];
|
quoteId: Scalars['Uuid'];
|
||||||
}>;
|
}>;
|
||||||
@ -653,6 +660,7 @@ export const GetRolesDocument = {"kind":"Document","definitions":[{"kind":"Opera
|
|||||||
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"}}]}}]}}]}}]} as unknown as DocumentNode<GetQuoteAddProductDataQuery, GetQuoteAddProductDataQueryVariables>;
|
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"}}]}}]}}]}}]} 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 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 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"}}]}}]}}]} as unknown as DocumentNode<GetQuoteCreateKpDataQuery, GetQuoteCreateKpDataQueryVariables>;
|
||||||
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 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 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>;
|
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>;
|
||||||
|
|||||||
55
apps/web/process/create-kp/get-kp-data.ts
Normal file
55
apps/web/process/create-kp/get-kp-data.ts
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import type { GetQuoteInputData, GetQuoteProcessData } from '../load-kp/types';
|
||||||
|
import initializeApollo from '@/apollo/client';
|
||||||
|
import defaultValues from '@/config/default-values';
|
||||||
|
import * as CRMTypes from '@/graphql/crm.types';
|
||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
const QUERY_GET_CREATEKP_DATA = gql`
|
||||||
|
query GetQuoteCreateKPData($quoteId: Uuid!) {
|
||||||
|
quote(quoteId: $quoteId) {
|
||||||
|
evo_price_with_discount
|
||||||
|
evo_price_without_discount_quote
|
||||||
|
evo_cost_increace
|
||||||
|
evo_insurance
|
||||||
|
evo_registration_quote
|
||||||
|
evo_card_quote
|
||||||
|
evo_nsib_quote
|
||||||
|
evo_redemption_graph
|
||||||
|
evo_fingap_quote
|
||||||
|
evo_contact_name
|
||||||
|
evo_gender
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export async function getKPData({
|
||||||
|
values: { quote: quoteId },
|
||||||
|
}: GetQuoteInputData): Promise<GetQuoteProcessData> {
|
||||||
|
const apolloClient = initializeApollo();
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: { quote },
|
||||||
|
} = await apolloClient.query({
|
||||||
|
query: CRMTypes.GetQuoteCreateKpDataDocument,
|
||||||
|
variables: {
|
||||||
|
quoteId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
values: {
|
||||||
|
NSIB: quote?.evo_nsib_quote ?? defaultValues.NSIB,
|
||||||
|
costIncrease: quote?.evo_cost_increace ?? defaultValues.costIncrease,
|
||||||
|
fullPriceWithDiscount:
|
||||||
|
quote?.evo_price_without_discount_quote ?? defaultValues.fullPriceWithDiscount,
|
||||||
|
insurance: quote?.evo_insurance ?? defaultValues.insurance,
|
||||||
|
priceWithDiscount: quote?.evo_price_with_discount ?? defaultValues.priceWithDiscount,
|
||||||
|
quoteContactGender: quote?.evo_gender ?? defaultValues.quoteContactGender,
|
||||||
|
quoteName: quote?.evo_contact_name ?? defaultValues.quoteName,
|
||||||
|
quoteRedemptionGraph: quote?.evo_redemption_graph ?? defaultValues.quoteRedemptionGraph,
|
||||||
|
registrationQuote: quote?.evo_registration_quote ?? defaultValues.registrationQuote,
|
||||||
|
showFinGAP: quote?.evo_fingap_quote ?? defaultValues.showFinGAP,
|
||||||
|
technicalCardQuote: quote?.evo_card_quote ?? defaultValues.technicalCardQuote,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -1,2 +1,3 @@
|
|||||||
export * from './action';
|
export * from './action';
|
||||||
|
export * from './get-kp-data';
|
||||||
export * as reactions from './reactions';
|
export * as reactions from './reactions';
|
||||||
|
|||||||
@ -332,6 +332,9 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let evo_importer_reward_perc = 0;
|
||||||
|
let evo_importer_reward_rub = 0;
|
||||||
|
|
||||||
if (modelId) {
|
if (modelId) {
|
||||||
const {
|
const {
|
||||||
data: { evo_model },
|
data: { evo_model },
|
||||||
@ -341,17 +344,15 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (evo_model?.evo_importer_reward_perc) {
|
if (evo_model?.evo_importer_reward_perc) {
|
||||||
tbxImporterRewardPerc.setValue(evo_model?.evo_importer_reward_perc);
|
evo_importer_reward_perc = evo_model?.evo_importer_reward_perc;
|
||||||
} else {
|
|
||||||
tbxImporterRewardPerc.resetValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evo_model?.evo_importer_reward_rub) {
|
if (evo_model?.evo_importer_reward_rub) {
|
||||||
tbxImporterRewardRub.setValue(evo_model?.evo_importer_reward_rub);
|
evo_importer_reward_rub = evo_model?.evo_importer_reward_rub;
|
||||||
} else {
|
|
||||||
tbxImporterRewardRub.resetValue();
|
|
||||||
}
|
}
|
||||||
} else if (brandId) {
|
}
|
||||||
|
|
||||||
|
if (brandId && evo_importer_reward_perc === 0 && evo_importer_reward_rub === 0) {
|
||||||
const {
|
const {
|
||||||
data: { evo_brand },
|
data: { evo_brand },
|
||||||
} = await apolloClient.query({
|
} = await apolloClient.query({
|
||||||
@ -360,20 +361,16 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (evo_brand?.evo_importer_reward_perc) {
|
if (evo_brand?.evo_importer_reward_perc) {
|
||||||
tbxImporterRewardPerc.setValue(evo_brand?.evo_importer_reward_perc);
|
evo_importer_reward_perc = evo_brand?.evo_importer_reward_perc;
|
||||||
} else {
|
|
||||||
tbxImporterRewardPerc.resetValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evo_brand?.evo_importer_reward_rub) {
|
if (evo_brand?.evo_importer_reward_rub) {
|
||||||
tbxImporterRewardRub.setValue(evo_brand?.evo_importer_reward_rub);
|
evo_importer_reward_rub = evo_brand?.evo_importer_reward_rub;
|
||||||
} else {
|
|
||||||
tbxImporterRewardRub.resetValue();
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
tbxImporterRewardPerc.resetValue();
|
|
||||||
tbxImporterRewardRub.resetValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tbxImporterRewardPerc.setValue(evo_importer_reward_perc);
|
||||||
|
tbxImporterRewardRub.setValue(evo_importer_reward_rub);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -57,6 +57,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
delay: 100,
|
delay: 100,
|
||||||
|
fireImmediately: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,6 +109,36 @@ function helper({ apolloClient, ctx }: ValidationContext & { ctx: RefinementCtx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async validateRewardWithoutOtherAgent({
|
||||||
|
conditionId,
|
||||||
|
fieldName,
|
||||||
|
}: {
|
||||||
|
conditionId: string | null;
|
||||||
|
fieldName: string;
|
||||||
|
}) {
|
||||||
|
if (conditionId) {
|
||||||
|
const {
|
||||||
|
data: { evo_reward_condition },
|
||||||
|
} = await apolloClient.query<
|
||||||
|
CRMTypes.GetRewardConditionQuery,
|
||||||
|
CRMTypes.GetRewardConditionQueryVariables
|
||||||
|
>({
|
||||||
|
query: CRMTypes.GetRewardConditionDocument,
|
||||||
|
variables: {
|
||||||
|
conditionId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (evo_reward_condition?.evo_agency_agreementidData?.evo_reward_without_other_agent) {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
message: 'Согласно условиям АД выплата допустима только этому агенту',
|
||||||
|
path: [fieldName],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,13 +182,15 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
.merge(SumsSchema)
|
.merge(SumsSchema)
|
||||||
.superRefine(async (values, ctx) => {
|
.superRefine(async (values, ctx) => {
|
||||||
const {
|
const {
|
||||||
|
calcBroker,
|
||||||
calcBrokerRewardCondition,
|
calcBrokerRewardCondition,
|
||||||
calcBrokerRewardSum,
|
calcBrokerRewardSum,
|
||||||
|
calcDoubleAgent,
|
||||||
calcDoubleAgentRewardCondition,
|
calcDoubleAgentRewardCondition,
|
||||||
calcDoubleAgentRewardSumm,
|
calcDoubleAgentRewardSumm,
|
||||||
|
calcFinDepartment,
|
||||||
dealer: dealerId,
|
dealer: dealerId,
|
||||||
dealerBroker,
|
dealerBroker,
|
||||||
calcFinDepartment,
|
|
||||||
dealerBrokerRewardCondition,
|
dealerBrokerRewardCondition,
|
||||||
dealerBrokerRewardSumm,
|
dealerBrokerRewardSumm,
|
||||||
dealerPerson,
|
dealerPerson,
|
||||||
@ -169,9 +201,8 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
indAgent,
|
indAgent,
|
||||||
indAgentRewardCondition,
|
indAgentRewardCondition,
|
||||||
indAgentRewardSumm,
|
indAgentRewardSumm,
|
||||||
calcDoubleAgent,
|
|
||||||
calcBroker,
|
|
||||||
} = values;
|
} = values;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Добавить валидацию на кнопку Рассчитать:
|
* Добавить валидацию на кнопку Рассчитать:
|
||||||
* если tbxDealerRewardSumm > 0 и
|
* если tbxDealerRewardSumm > 0 и
|
||||||
@ -339,7 +370,7 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const { validateRewardSum } = helper({ ...context, ctx });
|
const { validateRewardSum, validateRewardWithoutOtherAgent } = helper({ ...context, ctx });
|
||||||
|
|
||||||
await validateRewardSum({
|
await validateRewardSum({
|
||||||
agentid: dealerPerson,
|
agentid: dealerPerson,
|
||||||
@ -382,5 +413,54 @@ export function createValidationSchema(context: ValidationContext) {
|
|||||||
sum: finDepartmentRewardSumm,
|
sum: finDepartmentRewardSumm,
|
||||||
sumFieldName: 'tbxFinDepartmentRewardSumm',
|
sumFieldName: 'tbxFinDepartmentRewardSumm',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Если в 2х и более полях RewardSumm значения больше 0 И в полях RewardCondtion есть хотя бы одна запись,
|
||||||
|
* у которой evo_reward_condition.evo_agency_agreementid. Выплата без других агентов
|
||||||
|
* (evo_reward_without_other_agent) = True,
|
||||||
|
* то выводить ошибку "Согласно условиям АД выплата допустима только этому агенту" на то RewardCondtion,
|
||||||
|
* у которого evo_reward_condition.evo_agency_agreementid равно True
|
||||||
|
* иначе все ок
|
||||||
|
*/
|
||||||
|
if (
|
||||||
|
[
|
||||||
|
calcBrokerRewardSum,
|
||||||
|
calcDoubleAgentRewardSumm,
|
||||||
|
dealerBrokerRewardSumm,
|
||||||
|
dealerRewardSumm,
|
||||||
|
finDepartmentRewardSumm,
|
||||||
|
indAgentRewardSumm,
|
||||||
|
].filter((x) => x > 0).length > 1
|
||||||
|
) {
|
||||||
|
await validateRewardWithoutOtherAgent({
|
||||||
|
conditionId: calcBrokerRewardCondition,
|
||||||
|
fieldName: 'selectCalcBrokerRewardCondition',
|
||||||
|
});
|
||||||
|
|
||||||
|
await validateRewardWithoutOtherAgent({
|
||||||
|
conditionId: calcDoubleAgentRewardCondition,
|
||||||
|
fieldName: 'selectCalcDoubleAgentRewardCondition',
|
||||||
|
});
|
||||||
|
|
||||||
|
await validateRewardWithoutOtherAgent({
|
||||||
|
conditionId: dealerBrokerRewardCondition,
|
||||||
|
fieldName: 'selectDealerBrokerRewardCondition',
|
||||||
|
});
|
||||||
|
|
||||||
|
await validateRewardWithoutOtherAgent({
|
||||||
|
conditionId: dealerRewardCondition,
|
||||||
|
fieldName: 'selectDealerRewardCondition',
|
||||||
|
});
|
||||||
|
|
||||||
|
await validateRewardWithoutOtherAgent({
|
||||||
|
conditionId: finDepartmentRewardCondtion,
|
||||||
|
fieldName: 'selectFinDepartmentRewardCondtion',
|
||||||
|
});
|
||||||
|
|
||||||
|
await validateRewardWithoutOtherAgent({
|
||||||
|
conditionId: indAgentRewardCondition,
|
||||||
|
fieldName: 'selectIndAgentRewardCondition',
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,12 +27,6 @@ export const userMiddleware = t.middleware(async ({ ctx, next }) => {
|
|||||||
|
|
||||||
const unlimited = systemuser?.roles?.some((x) => x?.name && unlimitedRoles.includes(x.name));
|
const unlimited = systemuser?.roles?.some((x) => x?.name && unlimitedRoles.includes(x.name));
|
||||||
|
|
||||||
if (!unlimited) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: 'UNAUTHORIZED',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return next({
|
return next({
|
||||||
ctx: {
|
ctx: {
|
||||||
unlimited,
|
unlimited,
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export const calculateRouter = router({
|
|||||||
const apolloClient = initializeApollo();
|
const apolloClient = initializeApollo();
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
|
|
||||||
if (ctx.unlimited === false) {
|
if (!ctx.unlimited) {
|
||||||
const validationResult = await validate({
|
const validationResult = await validate({
|
||||||
context: {
|
context: {
|
||||||
apolloClient,
|
apolloClient,
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import * as CRMTypes from '@/graphql/crm.types';
|
|||||||
import * as addProduct from '@/process/add-product';
|
import * as addProduct from '@/process/add-product';
|
||||||
import * as bonuses from '@/process/bonuses';
|
import * as bonuses from '@/process/bonuses';
|
||||||
import * as configurator from '@/process/configurator';
|
import * as configurator from '@/process/configurator';
|
||||||
|
import * as createKpProcess from '@/process/create-kp';
|
||||||
import * as fingapProcess from '@/process/fingap';
|
import * as fingapProcess from '@/process/fingap';
|
||||||
import * as gibdd from '@/process/gibdd';
|
import * as gibdd from '@/process/gibdd';
|
||||||
import * as insuranceProcess from '@/process/insurance';
|
import * as insuranceProcess from '@/process/insurance';
|
||||||
@ -63,6 +64,7 @@ export const quoteRouter = router({
|
|||||||
subsidy,
|
subsidy,
|
||||||
insuranceProcess,
|
insuranceProcess,
|
||||||
addProduct,
|
addProduct,
|
||||||
|
createKpProcess,
|
||||||
].map(({ getKPData }) => getKPData(input))
|
].map(({ getKPData }) => getKPData(input))
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -89,7 +91,7 @@ export const quoteRouter = router({
|
|||||||
const apolloClient = initializeApollo();
|
const apolloClient = initializeApollo();
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
|
|
||||||
if (ctx.unlimited === false) {
|
if (!ctx.unlimited) {
|
||||||
const validationResult = await validate({
|
const validationResult = await validate({
|
||||||
context: {
|
context: {
|
||||||
apolloClient,
|
apolloClient,
|
||||||
|
|||||||
@ -26,7 +26,9 @@ export default class ValuesStore {
|
|||||||
public setValues = (values: Partial<CalculationValues>) => {
|
public setValues = (values: Partial<CalculationValues>) => {
|
||||||
(Object.keys(values) as Array<keyof CalculationValues>).forEach((valueName) => {
|
(Object.keys(values) as Array<keyof CalculationValues>).forEach((valueName) => {
|
||||||
const value = values[valueName];
|
const value = values[valueName];
|
||||||
if (value) this.setValue(valueName, value);
|
if (value !== null && value !== undefined) {
|
||||||
|
this.setValue(valueName, value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user