Compare commits

...

4 Commits

16 changed files with 1476 additions and 1120 deletions

View File

@ -1,6 +1,6 @@
overwrite: true
schema: './graphql/crm.schema.graphql'
documents: '**/*.{graphql,js,ts,jsx,tsx}'
documents: ['./**/!(*.{d,types}).{ts,tsx}', './**/.{js,jsx}', ./**/!(*.schema).graphql]
generates:
./graphql/crm.types.ts:
plugins:

View File

@ -9,15 +9,15 @@ import helper from '@/process/elt/lib/helper';
import { useStore } from '@/stores/hooks';
import { defaultRow } from '@/stores/tables/elt/default-values';
import { useApolloClient } from '@apollo/client';
import type { QueryFunctionContext } from '@tanstack/react-query';
import { useQueries } from '@tanstack/react-query';
import { observer } from 'mobx-react-lite';
import { omit, sift } from 'radash';
import { useCallback } from 'react';
import { Flex } from 'ui/grid';
const storeSelector: StoreSelector = ({ kasko }) => kasko;
const initialData = {
...defaultRow,
...omit(defaultRow, ['name', 'key', 'id']),
error: null,
kaskoSum: 0,
paymentPeriods: [
@ -25,72 +25,48 @@ const initialData = {
kaskoSum: 0,
},
],
sum: 0,
};
export const Kasko = observer(() => {
const store = useStore();
const { $tables, $calculation } = store;
const apolloClient = useApolloClient();
const { init } = helper({ apolloClient, store });
const queries = useQueries({
queries: $tables.elt.kasko.getRows.map((row) => {
const { id, key, name } = row;
const handleOnClick = useCallback(async () => {
$tables.elt.kasko.abortController?.abort();
$tables.elt.kasko.abortController = new AbortController();
return {
enabled: false,
initialData: { ...initialData, id, key, name },
queryFn: async (context: QueryFunctionContext) => {
const payload = await makeEltKaskoRequest({ apolloClient, store }, row);
const res = await getEltKasko(payload, context);
if (res) {
const companyRes = res?.[id];
return { ...companyRes, id, key, name };
}
return { ...initialData, id, key, name };
},
queryKey: ['elt', 'kasko', id],
refetchOnWindowFocus: false,
retry: false,
};
}),
});
async function handleOnClick() {
const { kasko } = await init();
$tables.elt.kasko.setRows(kasko);
const kaskoCompanyIds = $tables.insurance
.row('kasko')
.getOptions('insuranceCompany')
.map((x) => x.value);
const kaskoCompanyIds = sift(
$tables.insurance
.row('kasko')
.getOptions('insuranceCompany')
.map((x) => x.value)
);
const values = $calculation.$values.getValues();
queries
.filter(({ data }) => data?.key && kaskoCompanyIds.includes(data.key))
.forEach(({ refetch, data, remove }) => {
remove();
if (data?.key) $tables.elt.kasko.setRow({ key: data?.key, status: 'fetching' });
refetch()
kaskoCompanyIds.forEach((key) => {
const row = $tables.elt.kasko.getRow(key);
if (row) {
$tables.elt.kasko.setRow({ key, status: 'fetching' });
makeEltKaskoRequest({ apolloClient, store }, row)
.then((payload) =>
getEltKasko(payload, { signal: $tables.elt.kasko.abortController?.signal })
)
.then((res) => {
if (res.data) {
if (res) {
const companyRes = res?.[row.id];
const {
key,
kaskoSum = 0,
message,
skCalcId,
totalFranchise = 0,
requestId,
paymentPeriods,
} = res.data;
let { error } = res.data;
} = companyRes;
let { error } = companyRes;
if (totalFranchise > MAX_FRANCHISE) {
error ||= `Франшиза по страховке превышает максимально допустимое значение: ${Intl.NumberFormat(
@ -129,22 +105,22 @@ export const Kasko = observer(() => {
requestId,
skCalcId,
status: error ? 'error' : null,
sum: values.leasingPeriod <= 16 ? kaskoSum : paymentPeriods?.at(0)?.kaskoSum || 0,
sum: values.leasingPeriod <= 16 ? kaskoSum : paymentPeriods?.[0]?.kaskoSum || 0,
totalFranchise,
});
}
})
.catch((error) => {
if (data?.key)
$tables.elt.kasko.setRow({
...defaultRow,
key: data?.key,
message: error,
status: 'error',
});
$tables.elt.kasko.setRow({
...initialData,
key,
message: error,
status: 'error',
});
});
});
}
}
});
}, [$calculation.$values, $tables.elt.kasko, $tables.insurance, apolloClient, init, store]);
function handleOnSelectRow(row: Row) {
$tables.insurance.row('kasko').column('insuranceCompany').setValue(row.key);

View File

@ -9,75 +9,51 @@ import helper from '@/process/elt/lib/helper';
import { useStore } from '@/stores/hooks';
import { defaultRow } from '@/stores/tables/elt/default-values';
import { useApolloClient } from '@apollo/client';
import type { QueryFunctionContext } from '@tanstack/react-query';
import { useQueries } from '@tanstack/react-query';
import { observer } from 'mobx-react-lite';
import { omit, sift } from 'radash';
import { useCallback } from 'react';
import { Flex } from 'ui/grid';
const storeSelector: StoreSelector = ({ osago }) => osago;
const initialData = {
...defaultRow,
...omit(defaultRow, ['name', 'key', 'id']),
error: null,
premiumSum: 0,
sum: 0,
};
export const Osago = observer(() => {
const store = useStore();
const { $tables } = store;
const apolloClient = useApolloClient();
const { init } = helper({ apolloClient, store });
const queries = useQueries({
queries: $tables.elt.osago.getRows.map((row) => {
const { id, key, name } = row;
const handleOnClick = useCallback(async () => {
$tables.elt.osago.abortController?.abort();
$tables.elt.osago.abortController = new AbortController();
return {
enabled: false,
initialData: { ...initialData, id, key, name },
queryFn: async (context: QueryFunctionContext) => {
const payload = await makeEltOsagoRequest({ apolloClient, store }, row);
const res = await getEltOsago(payload, context);
if (res) {
const companyRes = res?.[id];
return { ...companyRes, id, key, name };
}
return { ...initialData, id, key, name };
},
queryKey: ['elt', 'osago', id],
refetchOnWindowFocus: false,
retry: false,
};
}),
});
async function handleOnClick() {
const { osago } = await init();
$tables.elt.osago.setRows(osago);
const osagoCompanyIds = $tables.insurance
.row('osago')
.getOptions('insuranceCompany')
.map((x) => x.value);
queries
.filter(({ data }) => data?.key && osagoCompanyIds.includes(data?.key))
.forEach(({ refetch, data, remove }) => {
remove();
if (data?.key) $tables.elt.osago.setRow({ key: data?.key, status: 'fetching' });
refetch()
const osagoCompanyIds = sift(
$tables.insurance
.row('osago')
.getOptions('insuranceCompany')
.map((x) => x.value)
);
osagoCompanyIds.forEach((key) => {
const row = $tables.elt.osago.getRow(key);
if (row) {
row.status = 'fetching';
$tables.elt.osago.setRow(row);
makeEltOsagoRequest({ apolloClient, store }, row)
.then((payload) =>
getEltOsago(payload, { signal: $tables.elt.osago.abortController.signal })
)
.then((res) => {
if (res.data) {
const { key, numCalc, premiumSum = 0, message, skCalcId } = res.data;
let { error } = res.data;
if (res) {
const companyRes = res?.[row.id];
const { numCalc, premiumSum = 0, message, skCalcId } = companyRes;
let { error } = companyRes;
if (premiumSum > MAX_INSURANCE) {
error ||= `Сумма по страховке превышает максимально допустимое значение по стоимости ОСАГО: ${Intl.NumberFormat(
'ru',
@ -87,7 +63,6 @@ export const Osago = observer(() => {
}
).format(MAX_INSURANCE)}`;
}
if (premiumSum < MIN_INSURANCE) {
error ||= `Сумма по страховке не должна быть меньше допустимого значения по стоимости ОСАГО: ${Intl.NumberFormat(
'ru',
@ -97,7 +72,6 @@ export const Osago = observer(() => {
}
).format(MIN_INSURANCE)}`;
}
$tables.elt.osago.setRow({
key,
message: error || message,
@ -109,16 +83,16 @@ export const Osago = observer(() => {
}
})
.catch((error) => {
if (data?.key)
$tables.elt.osago.setRow({
...defaultRow,
key: data?.key,
message: error,
status: 'error',
});
$tables.elt.osago.setRow({
...initialData,
key,
message: error,
status: 'error',
});
});
});
}
}
});
}, [$tables.elt.osago, $tables.insurance, apolloClient, init, store]);
function handleOnSelectRow(row: Row) {
$tables.insurance.row('osago').column('insuranceCompany').setValue(row.key);
@ -133,14 +107,12 @@ export const Osago = observer(() => {
title: 'Страховая компания ОСАГО',
};
}
if (column.key === 'status') {
return {
...column,
title: <ReloadButton storeSelector={storeSelector} onClick={() => handleOnClick()} />,
};
}
if (column.key === 'totalFranchise') {
return {
...column,

View File

@ -44,6 +44,7 @@ export const PreparedValuesSchema = z.object({
firstPaymentSum: z.number(),
firstPaymentWithNdsAbs: z.number(),
fuelCardSum: z.number(),
fundingRate: z.number(),
gpsCostPaymentSum: z.number(),
iRR_MSFO_Plan: z.number(),
importProgramSum: z.number(),

View File

@ -2,12 +2,14 @@ import type * as ELT from './types';
import getUrls from '@/config/urls';
import { TIMEOUT } from '@/constants/request';
import { withHandleError } from '@/utils/axios';
import type { QueryFunctionContext } from '@tanstack/react-query';
import axios from 'axios';
const { URL_ELT_KASKO, URL_ELT_OSAGO } = getUrls();
export async function getEltOsago(payload: ELT.RequestEltOsago, { signal }: QueryFunctionContext) {
export async function getEltOsago(
payload: ELT.RequestEltOsago,
{ signal }: { signal: AbortSignal }
) {
return withHandleError(
axios
.post<ELT.ResponseEltOsago>(URL_ELT_OSAGO, payload, { signal, timeout: TIMEOUT })
@ -15,7 +17,10 @@ export async function getEltOsago(payload: ELT.RequestEltOsago, { signal }: Quer
);
}
export async function getEltKasko(payload: ELT.RequestEltKasko, { signal }: QueryFunctionContext) {
export async function getEltKasko(
payload: ELT.RequestEltKasko,
{ signal }: { signal: AbortSignal }
) {
return withHandleError(
axios
.post<ELT.ResponseEltKasko>(URL_ELT_KASKO, payload, { signal, timeout: TIMEOUT })

View File

@ -169,6 +169,7 @@ query GetRate($rateId: Uuid!) {
evo_base_rate
evo_credit_period
evo_id
evo_finance_rate
}
}
@ -447,6 +448,7 @@ query GetRewardConditions($agentid: Uuid!, $currentDate: DateTime) {
label: evo_name
value: evo_reward_conditionid
evo_reward_summ
evo_pl_type
}
}

View File

@ -42,8 +42,8 @@ type Query {
evo_coefficients(evo_client_riskid: Uuid, evo_client_typeid: Uuid, evo_corfficient_type: Int, evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_job_titleid: Uuid, evo_max_period_param: DecimalParamInput, evo_min_period_param: DecimalParamInput, statecode: Int): [evo_coefficient]
evo_contract(evo_contractid: Uuid!): evo_contract
evo_contracts(evo_accountid: Uuid, evo_name: String, orderby: OrderByInput, statecode: Int): [evo_contract]
evo_countries(evo_code_numeric: String): [evo_countryGraphQL]
evo_country(evo_countryid: Uuid!): evo_countryGraphQL
evo_countries(evo_code_numeric: String): [evo_country]
evo_country(evo_countryid: Uuid!): evo_country
evo_currencychanges(evo_coursedate_param: DateParamInput, evo_ref_transactioncurrency: Uuid, statecode: Int): [evo_currencychange]
evo_debtwork_contract(debtworkContractId: Uuid!): evo_debtwork_contract
evo_debtwork_contracts(evo_accountid: Uuid, evo_statuscodeid: Uuid, statecode: Int): [evo_debtwork_contract]
@ -60,6 +60,7 @@ type Query {
evo_graphs(evo_contractid: Uuid, statecode: Int): [evo_graph]
evo_identity_documents(evo_employee_systemuserid: Uuid!): [evo_identity_document]
evo_impairment_groups(statecode: Int): [evo_impairment_group]
evo_insurance_period(evo_insurance_periodid: Uuid!): evo_insurance_period
evo_insurance_periods(evo_contractid: Uuid, statecode: Int): [evo_insurance_period]
evo_job_titles(statecode: Int): [evo_job_title]
evo_leasingobject(evo_leasingobjectid: Uuid!): evo_leasingobject
@ -103,9 +104,9 @@ type Query {
"""Города. statecode по умолчанию 0"""
evo_towns(evo_regionid: Uuid, statecode: Int): [evo_town]
evo_typedocpackages(statecode: Int): [evo_typedocpackage]
evo_vehicle_body_type(evo_vehicle_body_typeid: Uuid!): evo_vehicle_body_typeGraphQL
incident(incidentid: Uuid!): incidentGraphQL
incidents(customerid: Uuid, orderby: OrderByInput, statecode: Int): [incidentGraphQL]
evo_vehicle_body_type(evo_vehicle_body_typeid: Uuid!): evo_vehicle_body_type
incident(incidentid: Uuid!): incident
incidents(customerid: Uuid, orderby: OrderByInput, statecode: Int): [incident]
"""
Лизинговые сделки. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName
@ -132,7 +133,7 @@ type Query {
"""Поставщики ЮЛ салона. statecode по умолчанию 0"""
salon_providers(salonaccountid: Uuid!, statecode: Int): [account]
subjects: [subjectGraphQL]
subjects: [subject]
systemuser(domainname: String, systemuserid: Uuid): systemuser
systemusers(domainname: String, evo_employee_id: String, isdisabled: Boolean = false): [systemuser]
templates(description: String): [template]
@ -143,7 +144,9 @@ type Query {
}
type Mutation {
assosiateLetterContract(evo_contractid: Uuid!, evo_letterid: Uuid!): evo_evo_letter_evo_contract
by(systemuserid: Uuid): MutationBy
createLetter(input: evo_letterInput): evo_letter
createOffer(input: InputCreateOfferInput): quote
}
@ -154,6 +157,8 @@ type account {
childcontacts(statecode: Int): [contact]
createdon: DateTime
emailaddress1: String
evo_1c_date_state: Int
evo_1c_date_update: DateTime
evo_accnumber: String
evo_account_type: [Int!]
evo_address_factid: Uuid
@ -169,6 +174,7 @@ type account {
evo_branch_type: Int
evo_broker_accountid: Uuid
evo_broker_accountidData: account
evo_cession_ban: Boolean
evo_citizenship_countryid: Uuid
evo_client_riskid: Uuid
evo_consent_date: DateTime
@ -182,6 +188,7 @@ type account {
evo_edos: [evo_edo]
evo_employee_count: Int
evo_evokasko_access: Boolean
evo_fedres_xml_date: DateTime
evo_fingap_number_rules: Int
evo_fin_department_accountid: Uuid
evo_fin_department_accountidData: account
@ -190,6 +197,7 @@ type account {
evo_fuel_card_login: String
evo_fuel_card_pass: String
evo_fullname: String
evo_graph_list: Boolean
evo_group_sales_network: Uuid
evo_gt_sc: String
evo_id_elt: String
@ -217,7 +225,10 @@ type account {
evo_licenses_list: String
evo_lkt: String
evo_lk_regdate: DateTime
evo_log_activdate_1c: String
evo_mail_delivery_address_type: Int
evo_main_activity_code: String
evo_main_activity_text: String
evo_management_disqualified: Boolean
evo_ogrn: String
evo_ogrn_date: DateTime
@ -227,10 +238,12 @@ type account {
evo_okpo: String
evo_oktmo: String
evo_okved: String
evo_opportunity_ban: Boolean
evo_orglegalformid: Uuid
evo_orglegalformidData: evo_orglegalform
evo_osago_with_kasko: Boolean
evo_personal_systemuserid: Uuid
evo_report_code: String
evo_request_clients: [evo_request_client]
evo_return_leasing_dealer: Boolean
evo_revenue_source_1: Boolean
@ -252,7 +265,8 @@ type account {
evo_telematic_provider_accountid: Uuid
evo_type_ins_policy: [Int!]
evo_unscrupulous_supplier: Boolean
incidents: [incidentGraphQL]
evo_wm_code: String
incidents: [incident]
link: String
modifiedon: DateTime
name: String
@ -677,6 +691,7 @@ type evo_leasingobject {
evo_motor_power_1: String
evo_name: String
evo_object_number: String
evo_original_pl: Uuid
evo_passport_address: String
evo_passport_brand_model: String
evo_passport_company: String
@ -729,6 +744,7 @@ type evo_reward_condition {
evo_double_agent_accountid: Uuid
evo_min_reward_summ: Decimal
evo_name: String
evo_pl_type: Int
evo_reduce_reward: Boolean
evo_reward_conditionid: Uuid
evo_reward_summ: Decimal
@ -818,6 +834,7 @@ type opportunity {
evo_all_credit_evolight: Decimal
evo_all_credit_evoprofi: Decimal
evo_all_credit_evosmart: Decimal
evo_all_credit_gk: Decimal
evo_approvallogs: [evo_approvallog]
evo_assignor_accountid: Uuid
evo_board_of_directors: String
@ -826,6 +843,8 @@ type opportunity {
evo_cession_incidentid: Uuid
evo_check_type: [Int!]
evo_check_type_fact: [Int!]
evo_claims_legal_entity: Decimal
evo_claims_legal_entity_plaintiff: Decimal
evo_client_riskid: Uuid
evo_client_riskidData: evo_client_risk
evo_collective_executive: String
@ -849,6 +868,7 @@ type opportunity {
evo_founder4_beneficial_owner: Boolean
evo_founder4_contactid: Uuid
evo_founder4_part: Decimal
evo_fssp_legal_entity: Decimal
evo_gt_client_riskid: Uuid
evo_guarantor1_accountid: Uuid
evo_guarantor1_contactid: Uuid
@ -906,6 +926,7 @@ type quote {
customerid_contact: Uuid
evo_accept_control_addproduct_typeid: Uuid
evo_accept_control_addproduct_typeidData: evo_addproduct_type
evo_accept_graph_type: Int
evo_accept_param: [Int!]
evo_accept_period: Int
evo_accept_quoteid: Uuid
@ -1052,6 +1073,8 @@ type quote {
evo_insurance: Boolean
evo_insurance_decentral: Boolean
evo_insurance_period: Int
evo_insurance_special_conditions: [Int!]
evo_insurance_special_conditions_accept: String
evo_insurance_systemuserid: Uuid
evo_insurance_type: Int
evo_insurer_comment: String
@ -1126,6 +1149,7 @@ type quote {
evo_payment_redemption_sum_without_nds: Decimal
evo_percent_subsidy: Decimal
evo_period: Int
evo_pi: Decimal
evo_power: Decimal
evo_price_without_discount: Decimal
evo_price_without_discount_quote: Boolean
@ -1139,6 +1163,7 @@ type quote {
evo_program_import_subsidy_sum: Decimal
evo_pts_type: Int
evo_purchases_participation: Boolean
evo_question_credit_committees: [evo_question_credit_committee]
evo_quotename: String
evo_quotenumber: String
evo_rate: Decimal
@ -1250,7 +1275,7 @@ type evo_model {
evo_subsidies(statecode: Int): [evo_subsidy]
evo_taxi_sign: Boolean
evo_vehicle_body_typeid: Uuid
evo_vehicle_body_typeidData: evo_vehicle_body_typeGraphQL
evo_vehicle_body_typeidData: evo_vehicle_body_type
evo_vehicle_type: Int
modifiedon: DateTime
statecode: Int
@ -1437,6 +1462,7 @@ type transactioncurrency {
type evo_businessunit {
createdon: DateTime
evo_businessunitid: Uuid
evo_id: String
evo_name: String
evo_sale_businessunitid: Uuid
modifiedon: DateTime
@ -1456,6 +1482,7 @@ type evo_request_payment {
evo_bank_detailsid: Uuid
evo_bank_detailsidData: evo_bank_details
evo_businessunitid: Uuid
evo_conditionid: Uuid
evo_contractid: Uuid
evo_contractidData: evo_contract
evo_contract_paysum: Decimal
@ -1465,6 +1492,8 @@ type evo_request_payment {
evo_director_decision: Int
evo_director_systemuserid: Uuid
evo_evobank_detailsid: Uuid
evo_evofact_bank_code: String
evo_evofact_payment_account: String
evo_final_accept: Int
evo_finegibddid: Uuid
evo_finegibddidData: evo_finegibdd
@ -1522,14 +1551,18 @@ type evo_documenttype {
evo_edit_namedoc: Boolean
evo_fill_docname: Boolean
evo_formalized: Boolean
evo_from_letter_queueid: Uuid
evo_id: String
evo_letter: Boolean
evo_name: String
evo_name_save_file: String
evo_objecttypename: String
evo_original_id: String
evo_param_wm: String
evo_place_upload_doc: [Int!]
evo_remove_accept: Boolean
evo_sign_required: Boolean
evo_site_show_set: Int
evo_storagedoc: Int
evo_typedocpackages: [evo_typedocpackage]
evo_validitydoc: Int
@ -1579,11 +1612,14 @@ type evo_contract {
evo_cancel_contract: Boolean
evo_card_bonus_summ: Decimal
evo_cession_opportunityid: Uuid
evo_change_publish_date: DateTime
evo_change_publish_plan_date: DateTime
evo_check_scan_comment: String
evo_check_scan_result: Int
evo_claim_pledge_agreementid: Uuid
evo_client_type: Int
evo_coefficien_bonus_reducttion: Decimal
evo_conditionid: Uuid
evo_contractid: Uuid
evo_contract_status_1c: Int
evo_contract_status_1cname: String
@ -1596,6 +1632,7 @@ type evo_contract {
evo_date_of_pledge_leasobject: DateTime
evo_date_of_sending_dkp: DateTime
evo_date_of_sending_dl: DateTime
evo_date_saldo_from_1c: DateTime
evo_date_sor: DateTime
evo_date_termination: DateTime
evo_dealer_broker_accountid: Uuid
@ -1648,6 +1685,7 @@ type evo_contract {
evo_evokasko_addproduct_typeid: Uuid
evo_expinput_actual_date: DateTime
evo_fedres_xml_date: DateTime
evo_finance_summ: Decimal
evo_finegibdds: [evo_finegibdd]
evo_fingap_bonus_sum: Decimal
evo_fingap_period: Int
@ -1691,6 +1729,7 @@ type evo_contract {
evo_last_payment_redemption: Boolean
evo_leasingobjectid: Uuid
evo_leasingobjectidData: evo_leasingobject
evo_leasing_bonus_pay_date: DateTime
evo_leasing_bonus_summ: Decimal
evo_leasing_pledge_agreementid: Uuid
evo_leasing_profit: Decimal
@ -1703,6 +1742,7 @@ type evo_contract {
evo_name: String
evo_nds_in_price_supplier_currency: Decimal
evo_nds_perc: Decimal
evo_need_change_condition: Boolean
evo_net_irr: Decimal
evo_niatinception_msfo: Decimal
evo_niatinception_msfo_actual: Decimal
@ -1712,6 +1752,7 @@ type evo_contract {
evo_non_payment_count: Decimal
evo_npvni_msfo: Decimal
evo_npvni_msfo_final: Decimal
evo_nsib_addproduct_typeid: Uuid
evo_nsib_bonus_summ: Decimal
evo_ns_bonus_summ: Decimal
evo_number_dkp: String
@ -1722,12 +1763,14 @@ type evo_contract {
evo_payment_redemption_sum_without_nds: Decimal
evo_paysum_before_act_date_plan: Decimal
evo_period: Int
evo_pi: Decimal
evo_previous_accountid: Uuid
evo_price_without_discount: Decimal
evo_price_without_discount_supplier_currency: Decimal
evo_price_wthout_discount_nds_sup_currency: Decimal
evo_program_import_subsidyid: Uuid
evo_program_import_subsidy_sum: Decimal
evo_publish_message_number: String
evo_purchases_participation: Boolean
evo_quoteid: Uuid
evo_rate: Decimal
@ -1746,13 +1789,16 @@ type evo_contract {
evo_returnsum_supplier_full_date: DateTime
evo_returnsum_supplier_plan: Decimal
evo_return_leasing: Boolean
evo_saldo_from_1c: Decimal
evo_sale_without_nds: Boolean
evo_signer_different_contactid: Uuid
evo_signer_different_dkpid: Uuid
evo_signer_different_systemuserid: Uuid
evo_singdoc_systemuserid: Uuid
evo_sor_sign_date: DateTime
evo_statuscodeid: Uuid
evo_statuscodeidData: evo_statuscode
evo_step_statuscodeid: Uuid
evo_storage: String
evo_subsidyid: Uuid
evo_subsidy_solution: Int
@ -1773,6 +1819,7 @@ type evo_contract {
evo_supplier_payfull_date: DateTime
evo_supplier_pay_actual: Decimal
evo_supplier_pay_actual_currency: Decimal
evo_supplier_pay_agreed: Boolean
evo_supplier_signer_contactid: Uuid
evo_supplier_type: Int
evo_tarifid: Uuid
@ -1784,6 +1831,7 @@ type evo_contract {
evo_telematics_service_addproductid: Uuid
evo_termreason: Int
evo_termreasonname: String
evo_term_publish_date: DateTime
evo_tracking_addproductid: Uuid
evo_tracking_addproductidData: evo_addproduct
evo_tracking_addproduct_typeid: Uuid
@ -1794,6 +1842,7 @@ type evo_contract {
evo_transactioncurrencyidData: transactioncurrency
evo_transfer_newdkp_sum: Decimal
evo_uncritical_scan: Boolean
evo_uor_send_date: DateTime
evo_vehicle_tax_period: Decimal
evo_vehicle_tax_year: Decimal
link: String
@ -1827,7 +1876,10 @@ type evo_external_system_request {
evo_number_repetitions_fact: Int
evo_number_repetitions_plan: Int
evo_opportunityid: Uuid
evo_path_prima_fullreport: String
evo_path_prima_report: String
evo_path_report: String
evo_pledge_agreementid: Uuid
evo_prima_requestid: String
evo_question_credit_committeeid: Uuid
evo_request_paymentid: Uuid
@ -1840,11 +1892,14 @@ type evo_external_system_request {
type evo_paymentorder {
createdon: DateTime
evo_account_name_text: String
evo_addcontractid: Uuid
evo_comment: String
evo_contractid: Uuid
evo_correction_date_1c: DateTime
evo_correction_number_1c: String
evo_dds_1c: String
evo_evofact_bank_code: String
evo_evofact_payment_account: String
evo_inn_text: String
evo_insurance_periodid: Uuid
evo_money_transfer_paymentorderid: Uuid
@ -1864,7 +1919,7 @@ type evo_paymentorder {
toObjectString: String
}
type evo_vehicle_body_typeGraphQL {
type evo_vehicle_body_type {
createdon: DateTime
evo_id: Int
evo_id_elt: String
@ -1914,7 +1969,10 @@ type evo_planpayment {
evo_cost_telematics: Decimal
evo_cost_telematics_withoutnds: Decimal
evo_credit_expenses: Decimal
evo_debt_perc: Decimal
evo_debt_summ: Decimal
evo_early_repayment_sum: Decimal
evo_financingid: Uuid
evo_fix_calc_sum: Decimal
evo_graphid: Uuid
evo_name: String
@ -1943,6 +2001,7 @@ type evo_tarif {
evo_baseproductid: Uuid
evo_client_risks(statecode: Int): [evo_client_risk]
evo_client_types(statecode: Int): [evo_client_type]
evo_create_contract_stop: Boolean
evo_cut_irr_with_bonus_coefficient: Decimal
evo_datefrom: DateTime
evo_dateto: DateTime
@ -1991,6 +2050,7 @@ type evo_rate {
evo_credit_period: Int
evo_datefrom: DateTime
evo_dateto: DateTime
evo_finance_rate: Decimal
evo_id: String
evo_name: String
evo_rateid: Uuid
@ -2150,7 +2210,7 @@ type evo_identity_document {
toObjectString: String
}
type evo_countryGraphQL {
type evo_country {
createdon: DateTime
evo_alpha2_code: String
evo_code_numeric: String
@ -2261,6 +2321,7 @@ type evo_addcontract {
evo_agent_reward_tech: Decimal
evo_age_drivers: Int
evo_age_drivers_new: Int
evo_agreed_ukbimo: Boolean
evo_approv_business_analyst: Boolean
evo_balance: Int
evo_balance_change: Boolean
@ -2300,16 +2361,21 @@ type evo_addcontract {
evo_claim_sum_plan: Decimal
evo_color: String
evo_color_new: String
evo_comment_customer_care: String
evo_conditionid: Uuid
evo_conditionid_new: Uuid
evo_contractid: Uuid
evo_contract_term_change: Boolean
evo_cost_change: Boolean
evo_cost_currency_change: Boolean
evo_create_cession: Boolean
evo_dateend: DateTime
evo_date_addcontract: DateTime
evo_date_calculation_done: DateTime
evo_date_offset_change: Boolean
evo_date_offset_type: Int
evo_deadline_date: DateTime
evo_deadline_date_start: Boolean
evo_dealer_broker_accountid: Uuid
evo_dealer_broker_accountid_new: Uuid
evo_dealer_broker_reward: Decimal
@ -2354,6 +2420,7 @@ type evo_addcontract {
evo_ecological_class_new: Int
evo_economic: Decimal
evo_economic_with_nds: Decimal
evo_effective_date: DateTime
evo_emailaddress: String
evo_emailaddress_new: String
evo_engine_model: String
@ -2487,6 +2554,7 @@ type evo_addcontract {
evo_payment_redemption: Int
evo_period: Int
evo_period_new: Int
evo_pi: Decimal
evo_price_calc: Decimal
evo_price_without_discount: Decimal
evo_price_without_discount_new: Decimal
@ -2531,6 +2599,7 @@ type evo_addcontract {
evo_statuscodeidData: evo_statuscode
evo_statuscode_reason: String
evo_storage: String
evo_sumpay_withnds: Decimal
evo_sum_pay_change: Boolean
evo_supplier_accountid: Uuid
evo_supplier_accountid_new: Uuid
@ -2591,6 +2660,7 @@ type email {
regardingobjectid_evo_insurance_period: Uuid
regardingobjectid_evo_insurance_policy: Uuid
regardingobjectid_evo_insurance_policyData: evo_insurance_policy
regardingobjectid_evo_letter: Uuid
regardingobjectid_evo_list: Uuid
regardingobjectid_incident: Uuid
regardingobjectid_opportunity: Uuid
@ -2671,6 +2741,7 @@ type evo_debtwork_contract {
evo_contractid: Uuid
evo_contractidData: evo_contract
evo_date_change_statuscode: DateTime
evo_date_signing_sor: DateTime
evo_db_region_com: String
evo_debtwork_contractid: Uuid
evo_debt_restruct_description: String
@ -2776,11 +2847,13 @@ type evo_debtwork_contract {
evo_term_notice_inspection_unload_date: DateTime
evo_withdrawal_businessunitid: Uuid
evo_withdrawal_businessunitidData: businessunit
evo_withdrawal_doc_keys: [Int!]
evo_withdrawal_done: Boolean
evo_withdrawal_fact_date: DateTime
evo_withdrawal_impossible: Boolean
evo_withdrawal_impossible_reason: String
evo_withdrawal_issue_agreed: Int
evo_withdrawal_issue_doc_keys: [Int!]
evo_withdrawal_issue_done: Int
evo_withdrawal_issue_done_date: DateTime
evo_withdrawal_parking_addressid: Uuid
@ -2806,6 +2879,7 @@ type evo_request_client {
evo_client_request_text: String
evo_comment: String
evo_documents: [evo_document]
evo_evaluation: Int
evo_from_account: Uuid
evo_from_contact: Uuid
evo_number: String
@ -2822,7 +2896,7 @@ type evo_request_client {
evo_statuscodeidData: evo_statuscode
evo_statuscode_reason: String
evo_storage: String
incidents: [incidentGraphQL]
incidents: [incident]
link: String
modifiedon: DateTime
toObjectString: String
@ -2837,12 +2911,13 @@ type evo_subject_incident {
evo_subject_incidentid: Uuid
evo_type_incident: Int
evo_type_incidentname: String
evo_url_wiki: String
link: String
modifiedon: DateTime
toObjectString: String
}
type subjectGraphQL {
type subject {
createdon: DateTime
modifiedon: DateTime
subjectid: Uuid
@ -2850,7 +2925,7 @@ type subjectGraphQL {
toObjectString: String
}
type incidentGraphQL {
type incident {
caseorigincode: Int
createdon: DateTime
customerid: Uuid
@ -2878,7 +2953,7 @@ type incidentGraphQL {
ownerid_systemuser: Uuid
ownerid_team: Uuid
subjectid: Uuid
subjectidData: subjectGraphQL
subjectidData: subject
ticketnumber: String
title: String
toObjectString: String
@ -2891,11 +2966,14 @@ type evo_question_credit_committee {
evo_description_general_solution: String
evo_opportunityid: Uuid
evo_ownerid_systemuser: Uuid
evo_process_for_approvalid: Uuid
evo_qcc_number: String
evo_question_credit_committeeid: Uuid
evo_reason_removal: String
evo_statuscodeid: Uuid
evo_storage: String
evo_summary_judgment: Int
evo_type_of_agreement: Int
modifiedon: DateTime
quotes: [quote]
statecode: Int
@ -2931,6 +3009,7 @@ type role {
createdon: DateTime
evo_connection_roleData: evo_connection_role
evo_documenttypes: [evo_documenttype]
evo_documenttypes_letter: [evo_documenttype]
modifiedon: DateTime
name: String
roleid: Uuid
@ -2966,6 +3045,7 @@ type evo_systemparameters {
evo_director_max: Decimal
evo_director_min: Decimal
evo_docstorage_crm: String
evo_dossier_file_store: String
evo_elt_login: String
evo_elt_pass: String
evo_entityrecord_url_template: String
@ -3003,6 +3083,55 @@ input InputCreateOfferInput {
update: UpdateEntitiesInput
}
input evo_letterInput {
createdon: DateTime
evo_direction: Int
evo_documenttypeid: Uuid
evo_equipment_add: String
evo_executor: Int
evo_facsimile: Boolean
evo_incidentid: Uuid
evo_insurance_periodid: Uuid
evo_letterid: Uuid
evo_name: String
evo_polis_type: Int
evo_recipient: String
evo_regdate_outgoing: DateTime
evo_regnumber_outgoing: String
evo_territory_use: String
modifiedon: DateTime
}
type evo_letter {
createdon: DateTime
evo_direction: Int
evo_documenttypeid: Uuid
evo_equipment_add: String
evo_executor: Int
evo_facsimile: Boolean
evo_incidentid: Uuid
evo_insurance_periodid: Uuid
evo_letterid: Uuid
evo_name: String
evo_polis_type: Int
evo_recipient: String
evo_regdate_outgoing: DateTime
evo_regnumber_outgoing: String
evo_territory_use: String
modifiedon: DateTime
toObjectString: String
}
type evo_evo_letter_evo_contract {
childEntityId: Uuid!
childEntityName: String
evo_contractid: Uuid!
evo_letterid: Uuid!
parentEntityId: Uuid!
parentEntityName: String
relationShipName: String
}
input AssosiateQuoteInput {
evo_addproduct_types: [Uuid!]
}
@ -3105,6 +3234,7 @@ type businessunit {
evo_boss_systemuserid: Uuid
evo_deputy_director_systemuserid: Uuid
evo_director_systemuserid: Uuid
evo_id: String
evo_region_director_systgemuserid: Uuid
evo_region_director_systgemuseridname: String
modifiedon: DateTime
@ -3214,6 +3344,7 @@ type evo_edo {
}
type team {
businessunitid: Uuid
createdon: DateTime
evo_baseproducts(statecode: Int): [evo_baseproduct]
evo_identity_documents: [evo_identity_document]
@ -3302,7 +3433,10 @@ input evo_planpaymentInput {
evo_cost_telematics: Decimal
evo_cost_telematics_withoutnds: Decimal
evo_credit_expenses: Decimal
evo_debt_perc: Decimal
evo_debt_summ: Decimal
evo_early_repayment_sum: Decimal
evo_financingid: Uuid
evo_fix_calc_sum: Decimal
evo_graphid: Uuid
evo_name: String
@ -3356,6 +3490,7 @@ input evo_logInput {
evo_external_system_requestid: Uuid
evo_insurance_policyid: Uuid
evo_leadid: Uuid
evo_listid: Uuid
evo_logid: Uuid
evo_name: String
evo_opportunityid: Uuid
@ -3371,6 +3506,7 @@ input quoteInput {
customerid_account: Uuid
customerid_contact: Uuid
evo_accept_control_addproduct_typeid: Uuid
evo_accept_graph_type: Int
evo_accept_param: [Int!]
evo_accept_period: Int
evo_accept_quoteid: Uuid
@ -3511,6 +3647,8 @@ input quoteInput {
evo_insurance: Boolean
evo_insurance_decentral: Boolean
evo_insurance_period: Int
evo_insurance_special_conditions: [Int!]
evo_insurance_special_conditions_accept: String
evo_insurance_systemuserid: Uuid
evo_insurance_type: Int
evo_insurer_comment: String
@ -3582,6 +3720,7 @@ input quoteInput {
evo_payment_redemption_sum_without_nds: Decimal
evo_percent_subsidy: Decimal
evo_period: Int
evo_pi: Decimal
evo_power: Decimal
evo_price_without_discount: Decimal
evo_price_without_discount_quote: Boolean
@ -3705,6 +3844,7 @@ input evo_leasingobjectInput {
evo_motor_power_1: String
evo_name: String
evo_object_number: String
evo_original_pl: Uuid
evo_passport_address: String
evo_passport_brand_model: String
evo_passport_company: String

File diff suppressed because it is too large Load Diff

View File

@ -40,10 +40,10 @@
"zod": "^3.20.6"
},
"devDependencies": {
"@graphql-codegen/cli": "^3.2.1",
"@graphql-codegen/typed-document-node": "^3.0.1",
"@graphql-codegen/typescript": "^3.0.1",
"@graphql-codegen/typescript-operations": "^3.0.1",
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/typed-document-node": "^5.0.1",
"@graphql-codegen/typescript": "^4.0.1",
"@graphql-codegen/typescript-operations": "^4.0.1",
"@graphql-typed-document-node/patch-cli": "^3.0.9",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",

View File

@ -47,6 +47,8 @@ export default function reactions(context: ProcessContext) {
if (initialValues) {
$tables.elt.osago.setRows(initialValues.osago);
}
$tables.elt.osago.abortController?.abort();
},
{
delay: 10,
@ -100,6 +102,8 @@ export default function reactions(context: ProcessContext) {
if (initialValues) {
$tables.elt.kasko.setRows(initialValues.kasko);
}
$tables.elt.kasko.abortController?.abort();
},
{
delay: 10,

View File

@ -114,8 +114,14 @@ export function common({ store, apolloClient }: ProcessContext) {
);
debouncedReaction(
() => $calculation.$values.getValues(['leasingPeriod', 'leasingWithoutKasko']),
async ({ leasingPeriod, leasingWithoutKasko }) => {
() =>
$calculation.$values.getValues([
'leasingPeriod',
'leasingWithoutKasko',
'dealer',
'leaseObjectCategory',
]),
async ({ leasingPeriod, leasingWithoutKasko, dealer: dealerId, leaseObjectCategory }) => {
const {
data: { accounts },
} = await apolloClient.query({
@ -166,6 +172,29 @@ export function common({ store, apolloClient }: ProcessContext) {
$tables.insurance.row('kasko').column('insTerm').block();
$tables.insurance.row('kasko').column('insured').unblock();
}
/**
* @see 'apps\web\process\supplier-agent\reactions\leaseback.ts'
*/
if (dealerId) {
const {
data: { dealer },
} = await apolloClient.query({
query: CRMTypes.GetDealerDocument,
variables: {
dealerId,
},
});
if (dealer?.evo_return_leasing_dealer === true) {
$tables.insurance.row('kasko').column('insured').setValue(100_000_000).block();
}
// объединили реакцию для прицепа и возвратного лизинга
const isTrailer = leaseObjectCategory === 100_000_004;
if (isTrailer || dealer?.evo_return_leasing_dealer === true) {
$tables.insurance.row('osago').column('insured').setValue(100_000_000).block();
}
}
}
},
{

View File

@ -6,7 +6,7 @@ import { disposableReaction } from '@/utils/mobx';
import type { ApolloClient } from '@apollo/client';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import { reaction } from 'mobx';
import { comparer, reaction } from 'mobx';
dayjs.extend(utc);
@ -22,14 +22,23 @@ export function fillAgentRewardReaction(
const { agentField, rewardConditionField } = agentParams;
reaction(
() => $calculation.element(agentField).getValue(),
async (agentid) => {
() => {
const agentid = $calculation.element(agentField).getValue();
const leaseObjectUsed = $calculation.element('cbxLeaseObjectUsed').getValue();
return {
agentid,
leaseObjectUsed,
};
},
async ({ agentid, leaseObjectUsed }) => {
if (!agentid) {
$calculation.element(rewardConditionField).reset();
return;
}
const {
let {
data: { evo_reward_conditions },
} = await apolloClient.query({
query: CRMTypes.GetRewardConditionsDocument,
@ -39,6 +48,16 @@ export function fillAgentRewardReaction(
},
});
if (evo_reward_conditions) {
evo_reward_conditions = evo_reward_conditions?.filter(
(x) =>
x?.evo_pl_type &&
(leaseObjectUsed ? [100_000_000, 100_000_002] : [100_000_000, 100_000_001]).includes(
x?.evo_pl_type
)
);
}
if (evo_reward_conditions?.length) {
$calculation
.element(rewardConditionField)
@ -46,6 +65,9 @@ export function fillAgentRewardReaction(
} else {
$calculation.element(rewardConditionField).reset();
}
},
{
equals: comparer.shallow,
}
);
}

View File

@ -3,7 +3,7 @@ import type { ProcessContext } from '@/process/types';
import { reaction } from 'mobx';
export function common({ store, apolloClient }: ProcessContext) {
const { $calculation, $tables } = store;
const { $calculation } = store;
/**
* Дополнить реакцию на изменение поля Салон приобретения selectDealer:
*
@ -35,41 +35,9 @@ export function common({ store, apolloClient }: ProcessContext) {
if (dealer?.evo_return_leasing_dealer === true) {
$calculation.element('selectDealerPerson').block().resetValue();
$tables.insurance.row('kasko').setValue('insured', 100_000_000).block('insured');
$calculation.element('cbxLeaseObjectUsed').setValue(true);
} else {
$calculation.element('selectDealerPerson').unblock();
$tables.insurance.row('kasko').resetStatus('insured');
}
}
);
// объединили реакцию для прицепа и возвратного лизинга
reaction(
() => ({
dealerId: $calculation.element('selectDealer').getValue(),
leaseObjectCategory: $calculation.element('selectLeaseObjectCategory').getValue(),
}),
async ({ dealerId, leaseObjectCategory }) => {
const isTrailer = leaseObjectCategory === 100_000_004;
let returnLeasing = false;
if (dealerId) {
const {
data: { dealer },
} = await apolloClient.query({
query: CRMTypes.GetDealerDocument,
variables: {
dealerId,
},
});
returnLeasing = dealer?.evo_return_leasing_dealer === true;
}
if (isTrailer || returnLeasing) {
$tables.insurance.row('osago').setValue('insured', 100_000_000).block('insured');
} else {
$tables.insurance.row('osago').resetStatus('insured');
}
}
);

View File

@ -620,6 +620,25 @@ export async function createRequestData({
return 0;
},
async fundingRate() {
if (!values.rate) {
return 0;
}
const {
data: { evo_rate },
} = await apolloClient.query({
query: CRMTypes.GetRateDocument,
variables: { rateId: values.rate },
});
if (!evo_rate?.evo_finance_rate) {
return 0;
}
return evo_rate?.evo_finance_rate / 100;
},
async gpsCostPaymentSum() {
return sum(preparedPayments.rows, (p) => p.gpsCostPayment);
},
@ -1214,7 +1233,6 @@ export async function createRequestData({
async transportTaxGr() {
return values.vehicleTaxInLeasingPeriod;
},
async transportTaxGrYear() {
return values.vehicleTaxInYear;
},

View File

@ -17,6 +17,8 @@ export default class PolicyStore {
private rows: IObservableArray<ELT.Row>;
private selectedKey: string | null = null;
public abortController = new AbortController();
constructor({ rootStore, validationConfig }: ConstructorInput) {
this.rows = observable<ELT.Row>([]);
makeAutoObservable(this);
@ -55,6 +57,10 @@ export default class PolicyStore {
if (index >= 0) this.rows[index] = { ...this.rows[index], ...row };
};
public getRow(key: string) {
return this.rows.find((x) => x.key === key);
}
public get getRows() {
return toJS(this.rows);
}

849
yarn.lock

File diff suppressed because it is too large Load Diff