upgrade for new elt backend
This commit is contained in:
parent
07c87d583f
commit
af34a55c17
@ -57,7 +57,6 @@ export const Kasko = observer(() => {
|
||||
)
|
||||
.then((res) => {
|
||||
if (res) {
|
||||
const companyRes = res?.[row.id];
|
||||
const {
|
||||
kaskoSum = 0,
|
||||
message,
|
||||
@ -65,8 +64,8 @@ export const Kasko = observer(() => {
|
||||
totalFranchise = 0,
|
||||
requestId,
|
||||
paymentPeriods,
|
||||
} = companyRes;
|
||||
let { error } = companyRes;
|
||||
} = res;
|
||||
let { error } = res;
|
||||
|
||||
if (totalFranchise > MAX_FRANCHISE) {
|
||||
error ||= `Франшиза по страховке превышает максимально допустимое значение: ${Intl.NumberFormat(
|
||||
@ -111,10 +110,11 @@ export const Kasko = observer(() => {
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
const _err = error as Error;
|
||||
$tables.elt.kasko.setRow({
|
||||
...initialData,
|
||||
key,
|
||||
message: error,
|
||||
message: _err.message || String(error),
|
||||
status: 'error',
|
||||
});
|
||||
});
|
||||
|
||||
@ -51,9 +51,8 @@ export const Osago = observer(() => {
|
||||
)
|
||||
.then((res) => {
|
||||
if (res) {
|
||||
const companyRes = res?.[row.id];
|
||||
const { numCalc, premiumSum = 0, message, skCalcId } = companyRes;
|
||||
let { error } = companyRes;
|
||||
const { numCalc, premiumSum = 0, message, skCalcId } = res;
|
||||
let { error } = res;
|
||||
if (premiumSum > MAX_INSURANCE) {
|
||||
error ||= `Сумма по страховке превышает максимально допустимое значение по стоимости ОСАГО: ${Intl.NumberFormat(
|
||||
'ru',
|
||||
|
||||
@ -231,7 +231,8 @@ export async function makeEltOsagoRequest(
|
||||
}
|
||||
|
||||
return {
|
||||
ELTParams: {
|
||||
companyId: row.id,
|
||||
params: {
|
||||
FullDriversInfo: [
|
||||
{
|
||||
kbm: '3',
|
||||
@ -272,7 +273,6 @@ export async function makeEltOsagoRequest(
|
||||
ownerType: 1,
|
||||
tsToRegistrationPlace: 0,
|
||||
},
|
||||
companyIds: [row.id],
|
||||
preparams: {
|
||||
brandId,
|
||||
kladr,
|
||||
@ -611,7 +611,8 @@ export async function makeEltKaskoRequest(
|
||||
}
|
||||
|
||||
return {
|
||||
ELTParams: {
|
||||
companyId: row.id,
|
||||
params: {
|
||||
Insurer: {
|
||||
SubjectType: 1,
|
||||
SubjectTypeSpecified: true,
|
||||
@ -697,7 +698,6 @@ export async function makeEltKaskoRequest(
|
||||
// },
|
||||
// ],
|
||||
},
|
||||
companyIds: [row.id],
|
||||
preparams: {
|
||||
brandId,
|
||||
kladr,
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const RequestEltKaskoSchema = z.object({
|
||||
ELTParams: z.object({
|
||||
companyId: z.string(),
|
||||
params: z.object({
|
||||
Insurer: z.object({
|
||||
SubjectType: z.number(),
|
||||
SubjectTypeSpecified: z.boolean(),
|
||||
@ -82,7 +83,6 @@ export const RequestEltKaskoSchema = z.object({
|
||||
vehicleDateSpecified: z.boolean(),
|
||||
vehicleYear: z.number(),
|
||||
}),
|
||||
companyIds: z.array(z.string()),
|
||||
preparams: z.object({
|
||||
brandId: z.string(),
|
||||
kladr: z.string(),
|
||||
@ -98,85 +98,84 @@ export const RequestEltKaskoSchema = z.object({
|
||||
}),
|
||||
});
|
||||
|
||||
export const ResultEltKaskoSchema = z.record(
|
||||
z.object({
|
||||
calcInfo: z.null(),
|
||||
comment: z.null(),
|
||||
doSum: z.number(),
|
||||
error: z.string(),
|
||||
errorType: z.null(),
|
||||
gapSum: z.number(),
|
||||
goSum: z.number(),
|
||||
insuranceCompanyFranchise: z.object({ id: z.string(), value: z.string() }),
|
||||
insuranceCompanyGo: z.object({ id: z.string(), value: z.string() }),
|
||||
isNeedInspection: z.string(),
|
||||
kaskoSum: z.number(),
|
||||
kbmOsago: z.null(),
|
||||
message: z.string(),
|
||||
nsSum: z.number(),
|
||||
options: z.array(
|
||||
z.union([
|
||||
z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
values: z.array(z.object({ id: z.string(), name: z.string() })),
|
||||
}),
|
||||
z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
values: z.array(z.object({ id: z.string(), name: z.null() })),
|
||||
}),
|
||||
z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
values: z.array(z.object({ id: z.null(), name: z.null() })),
|
||||
}),
|
||||
])
|
||||
),
|
||||
paymentPeriods: z.array(
|
||||
export const ResultEltKaskoSchema = z.object({
|
||||
calcInfo: z.null(),
|
||||
comment: z.null(),
|
||||
doSum: z.number(),
|
||||
error: z.string(),
|
||||
errorType: z.null(),
|
||||
gapSum: z.number(),
|
||||
goSum: z.number(),
|
||||
insuranceCompanyFranchise: z.object({ id: z.string(), value: z.string() }),
|
||||
insuranceCompanyGo: z.object({ id: z.string(), value: z.string() }),
|
||||
isNeedInspection: z.string(),
|
||||
kaskoSum: z.number(),
|
||||
kbmOsago: z.null(),
|
||||
message: z.string(),
|
||||
nsSum: z.number(),
|
||||
options: z.array(
|
||||
z.union([
|
||||
z.object({
|
||||
date: z.string(),
|
||||
doSum: z.number(),
|
||||
doSumSpecified: z.boolean(),
|
||||
duration: z.number(),
|
||||
durationSpecified: z.boolean(),
|
||||
franchiseSum: z.number(),
|
||||
franchiseSumSpecified: z.boolean(),
|
||||
gapSum: z.number(),
|
||||
gapSumSpecified: z.boolean(),
|
||||
goSum: z.number(),
|
||||
goSumSpecified: z.boolean(),
|
||||
id: z.null(),
|
||||
kaskoSum: z.number(),
|
||||
kaskoSumSpecified: z.boolean(),
|
||||
name: z.null(),
|
||||
nsSum: z.number(),
|
||||
nsSumSpecified: z.boolean(),
|
||||
num: z.number(),
|
||||
numSpecified: z.boolean(),
|
||||
premiumSum: z.number(),
|
||||
premiumSumSpecified: z.boolean(),
|
||||
rate: z.number(),
|
||||
rateSpecified: z.boolean(),
|
||||
})
|
||||
),
|
||||
policyNumber: z.null(),
|
||||
premiumSum: z.number(),
|
||||
product: z.string(),
|
||||
productId: z.string(),
|
||||
program: z.string(),
|
||||
programCode: z.string(),
|
||||
programId: z.string(),
|
||||
requestId: z.string(),
|
||||
skCalcId: z.string(),
|
||||
totalFranchise: z.number(),
|
||||
totalFranchiseSpecified: z.boolean(),
|
||||
unicusGUID: z.string(),
|
||||
})
|
||||
);
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
values: z.array(z.object({ id: z.string(), name: z.string() })),
|
||||
}),
|
||||
z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
values: z.array(z.object({ id: z.string(), name: z.null() })),
|
||||
}),
|
||||
z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
values: z.array(z.object({ id: z.null(), name: z.null() })),
|
||||
}),
|
||||
])
|
||||
),
|
||||
paymentPeriods: z.array(
|
||||
z.object({
|
||||
date: z.string(),
|
||||
doSum: z.number(),
|
||||
doSumSpecified: z.boolean(),
|
||||
duration: z.number(),
|
||||
durationSpecified: z.boolean(),
|
||||
franchiseSum: z.number(),
|
||||
franchiseSumSpecified: z.boolean(),
|
||||
gapSum: z.number(),
|
||||
gapSumSpecified: z.boolean(),
|
||||
goSum: z.number(),
|
||||
goSumSpecified: z.boolean(),
|
||||
id: z.null(),
|
||||
kaskoSum: z.number(),
|
||||
kaskoSumSpecified: z.boolean(),
|
||||
name: z.null(),
|
||||
nsSum: z.number(),
|
||||
nsSumSpecified: z.boolean(),
|
||||
num: z.number(),
|
||||
numSpecified: z.boolean(),
|
||||
premiumSum: z.number(),
|
||||
premiumSumSpecified: z.boolean(),
|
||||
rate: z.number(),
|
||||
rateSpecified: z.boolean(),
|
||||
})
|
||||
),
|
||||
policyNumber: z.null(),
|
||||
premiumSum: z.number(),
|
||||
product: z.string(),
|
||||
productId: z.string(),
|
||||
program: z.string(),
|
||||
programCode: z.string(),
|
||||
programId: z.string(),
|
||||
requestId: z.string(),
|
||||
skCalcId: z.string(),
|
||||
totalFranchise: z.number(),
|
||||
totalFranchiseSpecified: z.boolean(),
|
||||
unicusGUID: z.string(),
|
||||
});
|
||||
|
||||
export const RequestEltOsagoSchema = z.object({
|
||||
ELTParams: z.object({
|
||||
companyId: z.string(),
|
||||
params: z.object({
|
||||
FullDriversInfo: z.array(z.object({ kbm: z.string() })),
|
||||
carInfo: z.object({
|
||||
mark: z.string(),
|
||||
@ -244,7 +243,6 @@ export const RequestEltOsagoSchema = z.object({
|
||||
ownerType: z.number(),
|
||||
tsToRegistrationPlace: z.number(),
|
||||
}),
|
||||
companyIds: z.array(z.string()),
|
||||
preparams: z.object({
|
||||
brandId: z.string(),
|
||||
kladr: z.string(),
|
||||
@ -252,27 +250,25 @@ export const RequestEltOsagoSchema = z.object({
|
||||
}),
|
||||
});
|
||||
|
||||
export const ResultEltOsagoSchema = z.record(
|
||||
z.object({
|
||||
calcInfo: z.array(
|
||||
z.object({
|
||||
itemName: z.string(),
|
||||
value: z.number(),
|
||||
valueSpecified: z.boolean(),
|
||||
})
|
||||
),
|
||||
error: z.string(),
|
||||
fullDriversInfo: z.array(z.unknown()),
|
||||
kbm: z.object({ class: z.number(), value: z.number() }),
|
||||
message: z.string(),
|
||||
numCalc: z.number(),
|
||||
premiumSum: z.number(),
|
||||
prevoiusKBM: z.object({ class: z.number(), value: z.number() }),
|
||||
rsaRequestId: z.string(),
|
||||
skCalcId: z.string(),
|
||||
tb: z.number(),
|
||||
})
|
||||
);
|
||||
export const ResultEltOsagoSchema = z.object({
|
||||
calcInfo: z.array(
|
||||
z.object({
|
||||
itemName: z.string(),
|
||||
value: z.number(),
|
||||
valueSpecified: z.boolean(),
|
||||
})
|
||||
),
|
||||
error: z.string(),
|
||||
fullDriversInfo: z.array(z.unknown()),
|
||||
kbm: z.object({ class: z.number(), value: z.number() }),
|
||||
message: z.string(),
|
||||
numCalc: z.number(),
|
||||
premiumSum: z.number(),
|
||||
prevoiusKBM: z.object({ class: z.number(), value: z.number() }),
|
||||
rsaRequestId: z.string(),
|
||||
skCalcId: z.string(),
|
||||
tb: z.number(),
|
||||
});
|
||||
|
||||
export const RowSchema = z.object({
|
||||
id: z.string(),
|
||||
|
||||
@ -28,53 +28,46 @@ const { URL_GET_USER, URL_CORE_FINGAP, URL_1C_TRANSTAX, URL_ELT_OSAGO, URL_ELT_K
|
||||
|
||||
export const handlers = [
|
||||
rest.get(URL_GET_USER, (req, res, ctx) => res(ctx.json(users.akalinina))),
|
||||
rest.post(URL_CORE_FINGAP, (req, res, ctx) => res(
|
||||
rest.post(URL_CORE_FINGAP, (req, res, ctx) =>
|
||||
res(
|
||||
ctx.json({
|
||||
sum: _.random(100000, 200000),
|
||||
premium: _.random(1000, 10000),
|
||||
})
|
||||
)),
|
||||
rest.post(URL_1C_TRANSTAX, (req, res, ctx) => res(
|
||||
)
|
||||
),
|
||||
rest.post(URL_1C_TRANSTAX, (req, res, ctx) =>
|
||||
res(
|
||||
ctx.json({
|
||||
error: null,
|
||||
tax: _.random(100000, 200000),
|
||||
})
|
||||
)
|
||||
),
|
||||
rest.post(URL_ELT_OSAGO, async (req, res, ctx) => res(
|
||||
ctx.json({
|
||||
numCalc: _.random(1000000, 3000000),
|
||||
skCalcId: _.random(50000000, 60000000).toString(),
|
||||
premiumSum: _.random(10000, 20000),
|
||||
message: 'OSAGO Message',
|
||||
})
|
||||
)),
|
||||
rest.post(URL_ELT_OSAGO, async (req, res, ctx) => {
|
||||
const companyId = (await req.json()).companyIds[0];
|
||||
|
||||
return res(
|
||||
rest.post(URL_ELT_KASKO, async (req, res, ctx) => res(
|
||||
ctx.json({
|
||||
[companyId]: {
|
||||
numCalc: _.random(1000000, 3000000),
|
||||
skCalcId: _.random(50000000, 60000000).toString(),
|
||||
premiumSum: _.random(10000, 20000),
|
||||
message: 'OSAGO Message',
|
||||
},
|
||||
requestId: _.random(3000000, 4000000).toString(),
|
||||
skCalcId: _.random(50000000, 60000000).toString(),
|
||||
message: 'KASKO Message',
|
||||
premiumSum: _.random(100000, 200000),
|
||||
kaskoSum: _.random(100000, 200000),
|
||||
paymentPeriods: [
|
||||
{
|
||||
num: 1,
|
||||
kaskoSum: _.random(100000, 200000),
|
||||
},
|
||||
],
|
||||
totalFranchise: _.random(20000, 40000),
|
||||
})
|
||||
);
|
||||
}),
|
||||
rest.post(URL_ELT_KASKO, async (req, res, ctx) => {
|
||||
const companyId = (await req.json()).companyIds[0];
|
||||
return res(
|
||||
ctx.json({
|
||||
[companyId]: {
|
||||
requestId: _.random(3000000, 4000000).toString(),
|
||||
skCalcId: _.random(50000000, 60000000).toString(),
|
||||
message: 'KASKO Message',
|
||||
premiumSum: _.random(100000, 200000),
|
||||
kaskoSum: _.random(100000, 200000),
|
||||
paymentPeriods: [
|
||||
{
|
||||
num: 1,
|
||||
kaskoSum: _.random(100000, 200000),
|
||||
},
|
||||
],
|
||||
totalFranchise: _.random(20000, 40000),
|
||||
},
|
||||
})
|
||||
);
|
||||
}),
|
||||
)),
|
||||
|
||||
// rest.post(URL_CRM_GRAPHQL, (req, res, ctx) => {
|
||||
// return res(ctx.status(503));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user