process: add gibdd

This commit is contained in:
vchikalkin 2023-02-22 12:47:58 +03:00
parent ac63898c4e
commit 21b01d9e18
7 changed files with 281 additions and 29 deletions

View File

@ -70,6 +70,33 @@ export const radioGraphType = [
},
];
export const selectObjectCategoryTax = [
'M1',
'M2',
'M3',
'M1G',
'M2G',
'M3G',
'N1',
'N2',
'N3',
'N1G',
'N2G',
'N3G',
'O1',
'O2',
'O3',
'O4',
'L1',
'L2',
'L3',
'L4',
'L5',
].map((label, i) => ({
label,
value: 100_000_000 + i,
}));
const defaultOptions: CalculationOptions = {
radioLastPaymentRule: [
{
@ -344,32 +371,7 @@ const defaultOptions: CalculationOptions = {
value: 100_000_001,
},
],
selectObjectCategoryTax: [
'M1',
'M2',
'M3',
'M1G',
'M2G',
'M3G',
'N1',
'N2',
'N3',
'N1G',
'N2G',
'N3G',
'O1',
'O2',
'O3',
'O4',
'L1',
'L2',
'L3',
'L4',
'L5',
].map((label, i) => ({
label,
value: 100_000_000 + i,
})),
selectObjectCategoryTax,
selectObjectTypeTax: [
{
label: 'Автобус',

View File

@ -134,7 +134,7 @@ const defaultValues: CalculationValues = {
totalPayments: 0,
townRegistration: null,
tracker: null,
typePTS: 100_000_001,
typePTS: null,
VATInLeaseObjectPrice: 0,
vehicleTaxInLeasingPeriod: 0,
vehicleTaxInYear: 0,

View File

@ -3,6 +3,7 @@ import * as calculate from '@/process/calculate';
import * as configurator from '@/process/configurator';
import * as createKP from '@/process/create-kp';
import * as fingap from '@/process/fingap';
import * as gibdd from '@/process/gibdd';
import { useProcess } from '@/process/hooks';
import * as leadOpportunity from '@/process/lead-opportunity';
import * as leasingObject from '@/process/leasing-object';
@ -32,4 +33,5 @@ export default function useReactions() {
useProcess(usedPl);
useProcess(subsidyImportProgram);
useProcess(payments);
useProcess(gibdd);
}

View File

@ -230,6 +230,8 @@ query GetLeaseObjectType($leaseObjectTypeId: Uuid!) {
evo_vehicle_type
evo_id
evo_category
evo_vehicle_type_tax
evo_category_tr
}
}

View File

@ -260,7 +260,7 @@ export type GetLeaseObjectTypeQueryVariables = Exact<{
}>;
export type GetLeaseObjectTypeQuery = { __typename?: 'Query', evo_leasingobject_type: { __typename?: 'evo_leasingobject_type', evo_vehicle_type: Array<number> | null, evo_id: string | null, evo_category: number | null } | null };
export type GetLeaseObjectTypeQuery = { __typename?: 'Query', evo_leasingobject_type: { __typename?: 'evo_leasingobject_type', evo_vehicle_type: Array<number> | null, evo_id: string | null, evo_category: number | null, evo_vehicle_type_tax: number | null, evo_category_tr: Array<number> | null } | null };
export type GetBrandsQueryVariables = Exact<{ [key: string]: never; }>;
@ -492,7 +492,7 @@ export const GetImportProgramDocument = {"kind":"Document","definitions":[{"kind
export const GetRegionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRegions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_regions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_regionid"}}]}}]}}]} as unknown as DocumentNode<GetRegionsQuery, GetRegionsQueryVariables>;
export const GetGpsBrandsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGPSBrands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_gps_brands"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_gps_brandid"}}]}}]}}]} as unknown as DocumentNode<GetGpsBrandsQuery, GetGpsBrandsQueryVariables>;
export const GetLeaseObjectTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectTypes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_leasingobject_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}}]}}]} as unknown as DocumentNode<GetLeaseObjectTypesQuery, GetLeaseObjectTypesQueryVariables>;
export const GetLeaseObjectTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_leasingobject_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category"}}]}}]}}]} as unknown as DocumentNode<GetLeaseObjectTypeQuery, GetLeaseObjectTypeQueryVariables>;
export const GetLeaseObjectTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_leasingobject_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type_tax"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category_tr"}}]}}]}}]} as unknown as DocumentNode<GetLeaseObjectTypeQuery, GetLeaseObjectTypeQueryVariables>;
export const GetBrandsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetBrands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}}]}}]}}]} as unknown as DocumentNode<GetBrandsQuery, GetBrandsQueryVariables>;
export const GetBrandDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetBrand"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brand"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_perc"}},{"kind":"Field","name":{"kind":"Name","value":"evo_importer_reward_rub"}}]}}]}}]} as unknown as DocumentNode<GetBrandQuery, GetBrandQueryVariables>;
export const GetModelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetModels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_models"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}},{"kind":"Argument","name":{"kind":"Name","value":"evo_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"brandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_modelid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}}]}}]}}]} as unknown as DocumentNode<GetModelsQuery, GetModelsQueryVariables>;

View File

@ -0,0 +1 @@
export * as reactions from './reactions';

View File

@ -0,0 +1,245 @@
/* eslint-disable @typescript-eslint/naming-convention */
import type { ProcessContext } from '../types';
import { selectObjectCategoryTax } from '@/config/default-options';
import * as CRMTypes from '@/graphql/crm.types';
import ValidationHelper from '@/stores/validation/helper';
import { reaction } from 'mobx';
import { makeDisposable } from 'tools';
export function common({ store, apolloClient }: ProcessContext) {
const { $calculation, $process } = store;
reaction(
() => $calculation.element('selectLeaseObjectType').getValue(),
async (leaseObjectTypeId) => {
if (!leaseObjectTypeId) {
$calculation.element('radioObjectRegistration').resetValue().unblock();
return;
}
const {
data: { evo_leasingobject_type },
} = await apolloClient.query({
query: CRMTypes.GetLeaseObjectTypeDocument,
variables: { leaseObjectTypeId },
});
if (
evo_leasingobject_type?.evo_id &&
['6', '9', '10', '11'].includes(evo_leasingobject_type.evo_id)
) {
$calculation.element('radioObjectRegistration').setValue(100_000_000).block();
} else {
$calculation.element('radioObjectRegistration').unblock();
}
}
);
reaction(
() => $calculation.$values.getValues(['objectRegistration', 'vehicleTaxInYear']),
({ objectRegistration, vehicleTaxInYear }) => {
if (objectRegistration === 100_000_001) {
$calculation.element('tbxVehicleTaxInYear').unblock();
} else {
$calculation.element('tbxVehicleTaxInYear').resetValue().block();
}
$calculation.element('tbxVehicleTaxInYear').validate({
invalid: objectRegistration === 100_000_001 && !(vehicleTaxInYear > 0),
message: 'Значение должно быть больше 0',
});
}
);
reaction(
() => $calculation.$values.getValues(['objectRegistration', 'typePTS']),
({ objectRegistration, typePTS }) => {
if (objectRegistration === 100_000_001) {
$calculation.element('radioTypePTS').unblock();
} else {
$calculation.element('radioTypePTS').resetValue().block();
}
$calculation.element('radioTypePTS').validate({
invalid: objectRegistration === 100_000_001 && !typePTS,
message: 'Не заполнено поле',
});
}
);
reaction(
() => $calculation.$values.getValues(['leasingPeriod', 'vehicleTaxInYear']),
({ leasingPeriod, vehicleTaxInYear }) => {
if (vehicleTaxInYear > 0) {
$calculation
.element('tbxVehicleTaxInLeasingPeriod')
.setValue((vehicleTaxInYear / 12) * leasingPeriod);
} else {
$calculation.element('tbxVehicleTaxInLeasingPeriod').resetValue();
}
}
);
makeDisposable(
() =>
reaction(
() =>
$calculation.$values.getValues([
'leaseObjectType',
'objectCategoryTax',
'objectRegistration',
]),
async ({ leaseObjectType: leaseObjectTypeId, objectRegistration, objectCategoryTax }) => {
if (objectRegistration === 100_000_001) {
if (objectCategoryTax && [100_000_006, 100_000_009].includes(objectCategoryTax)) {
$calculation.element('selectObjectTypeTax').setValue(100_000_002);
} else if (leaseObjectTypeId) {
const {
data: { evo_leasingobject_type },
} = await apolloClient.query({
query: CRMTypes.GetLeaseObjectTypeDocument,
variables: { leaseObjectTypeId },
});
if (evo_leasingobject_type?.evo_vehicle_type_tax) {
$calculation
.element('selectObjectTypeTax')
.setValue(evo_leasingobject_type?.evo_vehicle_type_tax);
} else {
$calculation.element('selectObjectTypeTax').resetValue();
}
}
} else {
$calculation.element('selectObjectTypeTax').resetValue();
}
}
),
() => $process.has('LoadKP')
);
reaction(
() =>
$calculation.$values.getValues([
'leaseObjectType',
'leaseObjectCategory',
'typePTS',
'objectRegistration',
]),
async ({
leaseObjectType: leaseObjectTypeId,
leaseObjectCategory,
typePTS,
objectRegistration,
}) => {
if (objectRegistration === 100_000_001 && typePTS === 100_000_001) {
$calculation.element('selectObjectCategoryTax').unblock();
if (leaseObjectTypeId) {
const {
data: { evo_leasingobject_type },
} = await apolloClient.query({
query: CRMTypes.GetLeaseObjectTypeDocument,
variables: { leaseObjectTypeId },
});
if (leaseObjectCategory && leaseObjectCategory === evo_leasingobject_type?.evo_category) {
$calculation
.element('selectObjectCategoryTax')
.setOptions(
selectObjectCategoryTax.filter((option) =>
evo_leasingobject_type?.evo_category_tr?.includes(option.value)
)
);
} else {
$calculation.element('selectObjectCategoryTax').resetOptions();
}
}
} else {
$calculation.element('selectObjectCategoryTax').resetValue().block();
}
}
);
}
export function validation({ store, apolloClient }: ProcessContext) {
const { $calculation } = store;
reaction(
() => $calculation.$values.getValues(['leaseObjectCategory', 'maxMass']),
({ leaseObjectCategory, maxMass }) => {
$calculation.element('tbxMaxMass').validate({
invalid: leaseObjectCategory === 100_000_001 && maxMass > 3500,
message: 'При категории ТС = В Разрешенная макс.масса не может быть больше 3500 кг',
});
$calculation.element('tbxMaxMass').validate({
invalid: leaseObjectCategory === 100_000_002 && maxMass <= 3500,
message: 'При категории ТС = С Разрешенная макс.масса не может быть меньше 3500 кг',
});
}
);
{
const validationHelper = new ValidationHelper();
reaction(
() =>
$calculation.$values.getValues([
'typePTS',
'objectRegistration',
'objectCategoryTax',
'leaseObjectType',
]),
async ({
leaseObjectType: leaseObjectTypeId,
typePTS,
objectRegistration,
objectCategoryTax,
}) => {
if (!leaseObjectTypeId) {
validationHelper.removeErrors();
return;
}
const {
data: { evo_leasingobject_type },
} = await apolloClient.query({
query: CRMTypes.GetLeaseObjectTypeDocument,
variables: { leaseObjectTypeId },
});
$calculation.element('selectObjectCategoryTax').validate({
helper: validationHelper,
invalid:
objectRegistration === 100_000_001 &&
typePTS === 100_000_001 &&
objectCategoryTax === null &&
Boolean(evo_leasingobject_type?.evo_category_tr?.length),
message: 'Необходимо из ЭПТС указать Категорию в соответствии с ТР ТС 018/2011',
});
}
);
}
{
const validationHelper = new ValidationHelper();
reaction(
() => $calculation.$values.getValues(['leaseObjectType', 'insNSIB']),
async ({ insNSIB, leaseObjectType: leaseObjectTypeId }) => {
if (!leaseObjectTypeId) {
validationHelper.removeErrors();
return;
}
const {
data: { evo_leasingobject_type },
} = await apolloClient.query({
query: CRMTypes.GetLeaseObjectTypeDocument,
variables: { leaseObjectTypeId },
});
$calculation.element('selectInsNSIB').validate({
helper: validationHelper,
invalid: evo_leasingobject_type?.evo_id === '11' && !insNSIB,
message: 'Страхование НСИБ обязательно для мотоциклистов',
});
}
);
}
}