diff --git a/apps/web/process/gibdd/reactions.ts b/apps/web/process/gibdd/reactions.ts index ca83fa1..3496d17 100644 --- a/apps/web/process/gibdd/reactions.ts +++ b/apps/web/process/gibdd/reactions.ts @@ -2,8 +2,10 @@ import type { ProcessContext } from '../types'; import { getTransTax } from '@/api/1c/query'; import { selectObjectCategoryTax } from '@/config/default-options'; +import { STALE_TIME } from '@/constants/request'; import * as CRMTypes from '@/graphql/crm.types'; import ValidationHelper from '@/stores/validation/helper'; +import type { QueryFunctionContext } from '@tanstack/react-query'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import { reaction } from 'mobx'; @@ -224,7 +226,7 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) { if (OKTMO) { const currentDate = dayjs().utc(false).toDate(); - const { tax, error } = await queryClient.fetchQuery(['1c', 'trans-tax'], (context) => + const request = (context: QueryFunctionContext) => getTransTax( { OKTMO, @@ -234,10 +236,15 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) { year: leaseObjectYear, }, context - ) - ); + ); + const { tax, error } = await queryClient.fetchQuery(['1c', 'trans-tax'], request, { + staleTime: STALE_TIME, + }); + if (!error && tax) { $calculation.element('tbxVehicleTaxInYear').setValue(tax); + } else { + $calculation.element('tbxVehicleTaxInYear').resetValue(); } } else { $calculation.element('tbxVehicleTaxInYear').resetValue();