diff --git a/Components/Calculation/Form/Leasing/config.ts b/Components/Calculation/Form/Leasing/config.ts index a7b55c2..d51d72a 100644 --- a/Components/Calculation/Form/Leasing/config.ts +++ b/Components/Calculation/Form/Leasing/config.ts @@ -10,7 +10,7 @@ export const rows: FormTabRows = [ [['selectSupplierCurrency', 'tbxSupplierDiscountRub', 'tbxSupplierDiscountPerc']], [['tbxFirstPaymentPerc', 'tbxFirstPaymentRub']], [['tbxLeasingPeriod', 'tbxSaleBonus', 'tbxRedemptionPaymentSum']], - [['selectSubsidy', 'tbxSubsidySum']], + [['selectSubsidy', 'tbxSubsidySum'], { gridTemplateColumns: '2fr 1fr' }], [['selectImportProgram', 'tbxImportProgramSum', 'tbxAddEquipmentPrice']], [['radioLastPaymentRule'], { gridTemplateColumns: '1fr' }], [['tbxLastPaymentPerc', 'tbxLastPaymentRub']], diff --git a/process/init/__generated__/GetMainOptions.ts b/process/init/__generated__/GetMainOptions.ts new file mode 100644 index 0000000..446aa4b --- /dev/null +++ b/process/init/__generated__/GetMainOptions.ts @@ -0,0 +1,33 @@ +/* tslint:disable */ +/* eslint-disable */ +// @generated +// This file was automatically generated and should not be edited. + +// ==================================================== +// GraphQL query operation: GetMainOptions +// ==================================================== + +export interface GetMainOptions_selectSupplierCurrency { + __typename: "transactioncurrency"; + label: string | null; + currencysymbol: string | null; + value: any | null; +} + +export interface GetMainOptions_selectProduct { + __typename: "evo_baseproduct"; + label: string | null; + value: any | null; +} + +export interface GetMainOptions { + /** + * Валюта. statecode по умолчанию 0 + */ + selectSupplierCurrency: (GetMainOptions_selectSupplierCurrency | null)[] | null; + selectProduct: (GetMainOptions_selectProduct | null)[] | null; +} + +export interface GetMainOptionsVariables { + currentDate?: any | null; +} diff --git a/process/init/__generated__/GetSubsidies.ts b/process/init/__generated__/GetSubsidies.ts new file mode 100644 index 0000000..fcc86c1 --- /dev/null +++ b/process/init/__generated__/GetSubsidies.ts @@ -0,0 +1,23 @@ +/* tslint:disable */ +/* eslint-disable */ +// @generated +// This file was automatically generated and should not be edited. + +// ==================================================== +// GraphQL query operation: GetSubsidies +// ==================================================== + +export interface GetSubsidies_evo_subsidies { + __typename: "evo_subsidy"; + label: string | null; + value: any | null; + evo_subsidy_type: number | null; +} + +export interface GetSubsidies { + evo_subsidies: (GetSubsidies_evo_subsidies | null)[] | null; +} + +export interface GetSubsidiesVariables { + currentDate?: any | null; +} diff --git a/process/init/__generated__/GetTransactionCurrencies.ts b/process/init/__generated__/GetTransactionCurrencies.ts deleted file mode 100644 index a7586b4..0000000 --- a/process/init/__generated__/GetTransactionCurrencies.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -// ==================================================== -// GraphQL query operation: GetTransactionCurrencies -// ==================================================== - -export interface GetTransactionCurrencies_selectSupplierCurrency { - __typename: "transactioncurrency"; - label: string | null; - currencysymbol: string | null; - value: any | null; -} - -export interface GetTransactionCurrencies { - /** - * Валюта. statecode по умолчанию 0 - */ - selectSupplierCurrency: (GetTransactionCurrencies_selectSupplierCurrency | null)[] | null; -} diff --git a/process/init/get-data.ts b/process/init/get-data.ts index 4ece2f7..6eda786 100644 --- a/process/init/get-data.ts +++ b/process/init/get-data.ts @@ -1,12 +1,17 @@ /* eslint-disable import/prefer-default-export */ import type { ApolloClient, NormalizedCache } from '@apollo/client'; import { gql } from '@apollo/client'; +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; import { getDomainName } from 'services/user/tools'; import type { User } from 'services/user/types'; import { normalizeOptions } from 'tools/entity'; import type { GetInsuranceData } from './__generated__/GetInsuranceData'; +import type { GetMainOptions } from './__generated__/GetMainOptions'; import type { GetOwnerData, GetOwnerDataVariables } from './__generated__/GetOwnerData'; -import type { GetTransactionCurrencies } from './__generated__/GetTransactionCurrencies'; +import type { GetSubsidies } from './__generated__/GetSubsidies'; + +dayjs.extend(utc); const QUERY_GET_OWNER_DATA = gql` query GetOwnerData($domainname: String) { @@ -21,13 +26,37 @@ const QUERY_GET_OWNER_DATA = gql` } `; -const QUERY_GET_TRANSACTION_CURRENCIES = gql` - query GetTransactionCurrencies { +const QUERY_GET_MAIN_OPTIONS = gql` + query GetMainOptions($currentDate: DateTime) { selectSupplierCurrency: transactioncurrencies { label: currencyname currencysymbol value: transactioncurrencyid } + + selectProduct: evo_baseproducts( + statecode: 0 + evo_relation: [100000000] + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + label: evo_name + value: evo_baseproductid + } + } +`; + +const QUERY_GET_SUBSIDIES = gql` + query GetSubsidies($currentDate: DateTime) { + evo_subsidies( + statecode: 0 + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + ) { + label: evo_name + value: evo_subsidyid + evo_subsidy_type + } } `; @@ -73,8 +102,11 @@ export async function getCRMData(apolloClient: ApolloClient, us }); // prettier-ignore - const { data: { selectSupplierCurrency } } = await apolloClient.query({ - query: QUERY_GET_TRANSACTION_CURRENCIES, + const { data: options } = await apolloClient.query({ + query: QUERY_GET_MAIN_OPTIONS, + variables: { + currentDate: dayjs().utc().toISOString() + } }); const { @@ -95,11 +127,28 @@ export async function getCRMData(apolloClient: ApolloClient, us }, }; + const { data: subsidies } = await apolloClient.query({ + query: QUERY_GET_SUBSIDIES, + variables: { + currentDate: dayjs().utc().toISOString(), + }, + }); + + const selectSubsidy = subsidies.evo_subsidies?.filter( + (x) => x?.evo_subsidy_type && [100_000_000, 100_000_001].includes(x?.evo_subsidy_type) + ); + + const selectImportProgram = subsidies.evo_subsidies?.filter( + (x) => x?.evo_subsidy_type && [100_000_002].includes(x?.evo_subsidy_type) + ); + return { options: { selectLead, selectOpportunity, - selectSupplierCurrency, + selectSubsidy, + selectImportProgram, + ...options, }, tables: { insurance: insuranceData,