merge branch 'release/dyn-4762'
This commit is contained in:
parent
89f2b3b68c
commit
81eca1c6e0
@ -47,6 +47,8 @@ ARG URL_CORE_CALCULATE_DIRECT
|
|||||||
ARG URL_1C_TRANSTAX_DIRECT
|
ARG URL_1C_TRANSTAX_DIRECT
|
||||||
ARG URL_ELT_OSAGO_DIRECT
|
ARG URL_ELT_OSAGO_DIRECT
|
||||||
ARG URL_ELT_KASKO_DIRECT
|
ARG URL_ELT_KASKO_DIRECT
|
||||||
|
ARG USERNAME_1C_TRANSTAX
|
||||||
|
ARG PASSWORD_1C_TRANSTAX
|
||||||
RUN pnpm dotenv -v NODE_ENV=production -e .env turbo run prebuild --filter=web...
|
RUN pnpm dotenv -v NODE_ENV=production -e .env turbo run prebuild --filter=web...
|
||||||
RUN pnpm dotenv -e .env turbo run build --filter=web...
|
RUN pnpm dotenv -e .env turbo run build --filter=web...
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
export type RequestTransTax = {
|
export type RequestTransTax = {
|
||||||
|
CalcDate: string;
|
||||||
|
CarCategory: string;
|
||||||
OKTMO: string;
|
OKTMO: string;
|
||||||
calcDate: Date;
|
Power: number;
|
||||||
carCategory: string;
|
Year: number;
|
||||||
power: number;
|
|
||||||
year: number;
|
|
||||||
};
|
};
|
||||||
export type ResponseTransTax = {
|
export type ResponseTransTax = {
|
||||||
error: string;
|
Error: string;
|
||||||
tax: number;
|
Tax: number;
|
||||||
|
TaxRate: number;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,6 +2,8 @@ const { z } = require('zod');
|
|||||||
|
|
||||||
const envSchema = z.object({
|
const envSchema = z.object({
|
||||||
BASE_PATH: z.string().optional().default(''),
|
BASE_PATH: z.string().optional().default(''),
|
||||||
|
DEV_AUTH_TOKEN: z.string().optional(),
|
||||||
|
PASSWORD_1C_TRANSTAX: z.string(),
|
||||||
PORT: z.string().optional(),
|
PORT: z.string().optional(),
|
||||||
SENTRY_AUTH_TOKEN: z.string(),
|
SENTRY_AUTH_TOKEN: z.string(),
|
||||||
SENTRY_DSN: z.string(),
|
SENTRY_DSN: z.string(),
|
||||||
@ -11,7 +13,6 @@ const envSchema = z.object({
|
|||||||
URL_CACHE_GET_QUERIES_DIRECT: z.string().default('http://api:3001/proxy/get-queries'),
|
URL_CACHE_GET_QUERIES_DIRECT: z.string().default('http://api:3001/proxy/get-queries'),
|
||||||
URL_CACHE_GET_QUERY_DIRECT: z.string().default('http://api:3001/proxy/get-query'),
|
URL_CACHE_GET_QUERY_DIRECT: z.string().default('http://api:3001/proxy/get-query'),
|
||||||
URL_CACHE_RESET_QUERIES_DIRECT: z.string().default('http://api:3001/proxy/reset'),
|
URL_CACHE_RESET_QUERIES_DIRECT: z.string().default('http://api:3001/proxy/reset'),
|
||||||
DEV_AUTH_TOKEN: z.string().optional(),
|
|
||||||
URL_CORE_CALCULATE_DIRECT: z.string(),
|
URL_CORE_CALCULATE_DIRECT: z.string(),
|
||||||
URL_CORE_FINGAP_DIRECT: z.string(),
|
URL_CORE_FINGAP_DIRECT: z.string(),
|
||||||
URL_CRM_CREATEKP_DIRECT: z.string(),
|
URL_CRM_CREATEKP_DIRECT: z.string(),
|
||||||
@ -22,6 +23,7 @@ const envSchema = z.object({
|
|||||||
URL_ELT_OSAGO_DIRECT: z.string(),
|
URL_ELT_OSAGO_DIRECT: z.string(),
|
||||||
URL_GET_USER_DIRECT: z.string(),
|
URL_GET_USER_DIRECT: z.string(),
|
||||||
USE_DEV_COLORS: z.unknown().optional().transform(Boolean),
|
USE_DEV_COLORS: z.unknown().optional().transform(Boolean),
|
||||||
|
USERNAME_1C_TRANSTAX: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = envSchema;
|
module.exports = envSchema;
|
||||||
|
|||||||
@ -11,6 +11,7 @@ const publicRuntimeConfigSchema = envSchema.pick({
|
|||||||
const serverRuntimeConfigSchema = envSchema.pick({
|
const serverRuntimeConfigSchema = envSchema.pick({
|
||||||
BASE_PATH: true,
|
BASE_PATH: true,
|
||||||
DEV_AUTH_TOKEN: true,
|
DEV_AUTH_TOKEN: true,
|
||||||
|
PASSWORD_1C_TRANSTAX: true,
|
||||||
PORT: true,
|
PORT: true,
|
||||||
SENTRY_DSN: true,
|
SENTRY_DSN: true,
|
||||||
SENTRY_ENVIRONMENT: true,
|
SENTRY_ENVIRONMENT: true,
|
||||||
@ -27,6 +28,7 @@ const serverRuntimeConfigSchema = envSchema.pick({
|
|||||||
URL_ELT_KASKO_DIRECT: true,
|
URL_ELT_KASKO_DIRECT: true,
|
||||||
URL_ELT_OSAGO_DIRECT: true,
|
URL_ELT_OSAGO_DIRECT: true,
|
||||||
URL_GET_USER_DIRECT: true,
|
URL_GET_USER_DIRECT: true,
|
||||||
|
USERNAME_1C_TRANSTAX: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@ -39,20 +39,23 @@ export const handlers = [
|
|||||||
rest.post(URL_1C_TRANSTAX, (req, res, ctx) =>
|
rest.post(URL_1C_TRANSTAX, (req, res, ctx) =>
|
||||||
res(
|
res(
|
||||||
ctx.json({
|
ctx.json({
|
||||||
error: null,
|
Error: null,
|
||||||
tax: _.random(100000, 200000),
|
Tax: _.random(100000, 200000),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
rest.post(URL_ELT_OSAGO, async (req, res, ctx) => res(
|
rest.post(URL_ELT_OSAGO, async (req, res, ctx) =>
|
||||||
|
res(
|
||||||
ctx.json({
|
ctx.json({
|
||||||
numCalc: _.random(1000000, 3000000),
|
numCalc: _.random(1000000, 3000000),
|
||||||
skCalcId: _.random(50000000, 60000000).toString(),
|
skCalcId: _.random(50000000, 60000000).toString(),
|
||||||
premiumSum: _.random(10000, 20000),
|
premiumSum: _.random(10000, 20000),
|
||||||
message: 'OSAGO Message',
|
message: 'OSAGO Message',
|
||||||
})
|
})
|
||||||
)),
|
)
|
||||||
rest.post(URL_ELT_KASKO, async (req, res, ctx) => res(
|
),
|
||||||
|
rest.post(URL_ELT_KASKO, async (req, res, ctx) =>
|
||||||
|
res(
|
||||||
ctx.json({
|
ctx.json({
|
||||||
requestId: _.random(3000000, 4000000).toString(),
|
requestId: _.random(3000000, 4000000).toString(),
|
||||||
skCalcId: _.random(50000000, 60000000).toString(),
|
skCalcId: _.random(50000000, 60000000).toString(),
|
||||||
@ -67,7 +70,8 @@ export const handlers = [
|
|||||||
],
|
],
|
||||||
totalFranchise: _.random(20000, 40000),
|
totalFranchise: _.random(20000, 40000),
|
||||||
})
|
})
|
||||||
)),
|
)
|
||||||
|
),
|
||||||
|
|
||||||
// rest.post(URL_CRM_GRAPHQL, (req, res, ctx) => {
|
// rest.post(URL_CRM_GRAPHQL, (req, res, ctx) => {
|
||||||
// return res(ctx.status(503));
|
// return res(ctx.status(503));
|
||||||
|
|||||||
@ -66,10 +66,10 @@ module.exports = withSentryConfig(
|
|||||||
destination: env.URL_CORE_FINGAP_DIRECT,
|
destination: env.URL_CORE_FINGAP_DIRECT,
|
||||||
source: urls.URL_CORE_FINGAP_PROXY,
|
source: urls.URL_CORE_FINGAP_PROXY,
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
destination: env.URL_1C_TRANSTAX_DIRECT,
|
// destination: env.URL_1C_TRANSTAX_DIRECT,
|
||||||
source: urls.URL_1C_TRANSTAX_PROXY,
|
// source: urls.URL_1C_TRANSTAX_PROXY,
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
destination: env.URL_ELT_KASKO_DIRECT,
|
destination: env.URL_ELT_KASKO_DIRECT,
|
||||||
source: urls.URL_ELT_KASKO_PROXY,
|
source: urls.URL_ELT_KASKO_PROXY,
|
||||||
|
|||||||
38
apps/web/pages/api/1c/transtax.ts
Normal file
38
apps/web/pages/api/1c/transtax.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import type { ResponseTransTax } from '@/api/1c/types';
|
||||||
|
import { serverRuntimeConfigSchema } from '@/config/schema/runtime-config';
|
||||||
|
import { withHandleError } from '@/utils/axios';
|
||||||
|
import type { HttpError } from '@/utils/error';
|
||||||
|
import axios from 'axios';
|
||||||
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||||
|
import getConfig from 'next/config';
|
||||||
|
|
||||||
|
const { serverRuntimeConfig } = getConfig();
|
||||||
|
const { USERNAME_1C_TRANSTAX, PASSWORD_1C_TRANSTAX, URL_1C_TRANSTAX_DIRECT } =
|
||||||
|
serverRuntimeConfigSchema.parse(serverRuntimeConfig);
|
||||||
|
|
||||||
|
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
const abortController = new AbortController();
|
||||||
|
|
||||||
|
req.on('close', () => {
|
||||||
|
abortController.abort();
|
||||||
|
});
|
||||||
|
|
||||||
|
const params = req.body as ResponseTransTax;
|
||||||
|
|
||||||
|
withHandleError(
|
||||||
|
axios.get<ResponseTransTax>(URL_1C_TRANSTAX_DIRECT, {
|
||||||
|
auth: {
|
||||||
|
password: PASSWORD_1C_TRANSTAX,
|
||||||
|
username: USERNAME_1C_TRANSTAX,
|
||||||
|
},
|
||||||
|
params,
|
||||||
|
signal: abortController.signal,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(({ data }) => res.json(data))
|
||||||
|
.catch((error) => {
|
||||||
|
const _err = error as HttpError;
|
||||||
|
|
||||||
|
return res.json({ message: _err.message });
|
||||||
|
});
|
||||||
|
}
|
||||||
@ -9,7 +9,6 @@ import * as CRMTypes from '@/graphql/crm.types';
|
|||||||
import { getCurrentDateString } from '@/utils/date';
|
import { getCurrentDateString } from '@/utils/date';
|
||||||
import { normalizeOptions } from '@/utils/entity';
|
import { normalizeOptions } from '@/utils/entity';
|
||||||
import { disposableReaction } from '@/utils/mobx';
|
import { disposableReaction } from '@/utils/mobx';
|
||||||
import dayjs from 'dayjs';
|
|
||||||
import { reaction } from 'mobx';
|
import { reaction } from 'mobx';
|
||||||
|
|
||||||
export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
||||||
@ -186,18 +185,16 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
|||||||
const carCategory = getCarCategory(objectTypeTax);
|
const carCategory = getCarCategory(objectTypeTax);
|
||||||
|
|
||||||
if (OKTMO) {
|
if (OKTMO) {
|
||||||
const currentDate = dayjs().utc(false).toDate();
|
|
||||||
|
|
||||||
const response = await queryClient.fetchQuery(
|
const response = await queryClient.fetchQuery(
|
||||||
['1c', 'trans-tax', carCategory, leaseObjectMotorPower, leaseObjectYear],
|
['1c', 'trans-tax', carCategory, leaseObjectMotorPower, leaseObjectYear, OKTMO],
|
||||||
(context) =>
|
(context) =>
|
||||||
getTransTax(
|
getTransTax(
|
||||||
{
|
{
|
||||||
|
CalcDate: getCurrentDateString(),
|
||||||
|
CarCategory: carCategory,
|
||||||
OKTMO,
|
OKTMO,
|
||||||
calcDate: currentDate,
|
Power: leaseObjectMotorPower,
|
||||||
carCategory,
|
Year: leaseObjectYear,
|
||||||
power: leaseObjectMotorPower,
|
|
||||||
year: leaseObjectYear,
|
|
||||||
},
|
},
|
||||||
context
|
context
|
||||||
),
|
),
|
||||||
@ -206,8 +203,8 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response?.tax) {
|
if (response?.Tax) {
|
||||||
$calculation.element('tbxVehicleTaxInYear').setValue(response.tax);
|
$calculation.element('tbxVehicleTaxInYear').setValue(response.Tax);
|
||||||
} else {
|
} else {
|
||||||
$calculation.element('tbxVehicleTaxInYear').resetValue();
|
$calculation.element('tbxVehicleTaxInYear').resetValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,10 +4,17 @@ import type { AxiosError } from 'axios';
|
|||||||
import { isAxiosError } from 'axios';
|
import { isAxiosError } from 'axios';
|
||||||
import { pick } from 'radash';
|
import { pick } from 'radash';
|
||||||
|
|
||||||
function getErrorMessage<
|
type ResponseError = {
|
||||||
T extends { error?: string; errors?: string[]; fullMessage?: string; message?: string }
|
Error?: string;
|
||||||
>(error: AxiosError<T>) {
|
error?: string;
|
||||||
|
errors?: string[];
|
||||||
|
fullMessage?: string;
|
||||||
|
message?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
function getErrorMessage<T extends ResponseError>(error: AxiosError<T>) {
|
||||||
return (
|
return (
|
||||||
|
error.response?.data?.Error ||
|
||||||
error.response?.data?.error ||
|
error.response?.data?.error ||
|
||||||
error.response?.data?.errors?.[0] ||
|
error.response?.data?.errors?.[0] ||
|
||||||
error.response?.data.fullMessage ||
|
error.response?.data.fullMessage ||
|
||||||
|
|||||||
@ -16,6 +16,8 @@ services:
|
|||||||
- URL_CORE_FINGAP_DIRECT=${URL_CORE_FINGAP_DIRECT}
|
- URL_CORE_FINGAP_DIRECT=${URL_CORE_FINGAP_DIRECT}
|
||||||
- URL_CORE_CALCULATE_DIRECT=${URL_CORE_CALCULATE_DIRECT}
|
- URL_CORE_CALCULATE_DIRECT=${URL_CORE_CALCULATE_DIRECT}
|
||||||
- URL_1C_TRANSTAX_DIRECT=${URL_1C_TRANSTAX_DIRECT}
|
- URL_1C_TRANSTAX_DIRECT=${URL_1C_TRANSTAX_DIRECT}
|
||||||
|
- USERNAME_1C_TRANSTAX=${USERNAME_1C_TRANSTAX}
|
||||||
|
- PASSWORD_1C_TRANSTAX=${PASSWORD_1C_TRANSTAX}
|
||||||
- URL_ELT_OSAGO_DIRECT=${URL_ELT_OSAGO_DIRECT}
|
- URL_ELT_OSAGO_DIRECT=${URL_ELT_OSAGO_DIRECT}
|
||||||
- URL_ELT_KASKO_DIRECT=${URL_ELT_KASKO_DIRECT}
|
- URL_ELT_KASKO_DIRECT=${URL_ELT_KASKO_DIRECT}
|
||||||
build:
|
build:
|
||||||
@ -34,6 +36,8 @@ services:
|
|||||||
- URL_CORE_FINGAP_DIRECT=${URL_CORE_FINGAP_DIRECT}
|
- URL_CORE_FINGAP_DIRECT=${URL_CORE_FINGAP_DIRECT}
|
||||||
- URL_CORE_CALCULATE_DIRECT=${URL_CORE_CALCULATE_DIRECT}
|
- URL_CORE_CALCULATE_DIRECT=${URL_CORE_CALCULATE_DIRECT}
|
||||||
- URL_1C_TRANSTAX_DIRECT=${URL_1C_TRANSTAX_DIRECT}
|
- URL_1C_TRANSTAX_DIRECT=${URL_1C_TRANSTAX_DIRECT}
|
||||||
|
- USERNAME_1C_TRANSTAX=${USERNAME_1C_TRANSTAX}
|
||||||
|
- PASSWORD_1C_TRANSTAX=${PASSWORD_1C_TRANSTAX}
|
||||||
- URL_ELT_OSAGO_DIRECT=${URL_ELT_OSAGO_DIRECT}
|
- URL_ELT_OSAGO_DIRECT=${URL_ELT_OSAGO_DIRECT}
|
||||||
- URL_ELT_KASKO_DIRECT=${URL_ELT_KASKO_DIRECT}
|
- URL_ELT_KASKO_DIRECT=${URL_ELT_KASKO_DIRECT}
|
||||||
context: .
|
context: .
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user