process: add leasing-without-kasko
add subsidy (calculate importProgramSum)
This commit is contained in:
parent
8a6a537590
commit
5ea1fe3925
@ -127,7 +127,7 @@ export type GetRisksDataFromQuoteQueryVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type GetRisksDataFromQuoteQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_fingap_accountid: string | null, evo_fingap_payer: number | null, evo_fingap_period: number | null, evo_product_risks: Array<{ __typename?: 'evo_product_risk', evo_addproduct_typeid: string | null }> | null } | null };
|
||||
export type GetRisksDataFromQuoteQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_fingap_accountid: string | null, evo_fingap_payer: number | null, evo_fingap_period: number | null, evo_product_risks: Array<{ __typename?: 'evo_product_risk', evo_addproduct_typeid: string | null } | null> | null } | null };
|
||||
|
||||
export type GetFinGapAddProductTypesQueryVariables = Exact<{
|
||||
currentDate: InputMaybe<Scalars['DateTime']>;
|
||||
@ -236,7 +236,7 @@ export type GetPaymentsDataFromQuoteQueryVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type GetPaymentsDataFromQuoteQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_period: number | null, evo_accept_period: number | null, evo_first_payment_perc: number | null, evo_last_payment_perc: number | null, evo_graph_type: number | null, evo_payments_decrease_perc: number | null, evo_seasons_type: number | null, evo_high_season: number | null, evo_graphs: Array<{ __typename?: 'evo_graph', createdon: string, evo_sumpay_withnds: number | null, evo_planpayments: Array<{ __typename?: 'evo_planpayment', evo_payment_ratio: number | null }> | null }> | null } | null };
|
||||
export type GetPaymentsDataFromQuoteQuery = { __typename?: 'Query', quote: { __typename?: 'quote', evo_period: number | null, evo_accept_period: number | null, evo_first_payment_perc: number | null, evo_last_payment_perc: number | null, evo_graph_type: number | null, evo_payments_decrease_perc: number | null, evo_seasons_type: number | null, evo_high_season: number | null, evo_graphs: Array<{ __typename?: 'evo_graph', createdon: string | null, evo_sumpay_withnds: number | null, evo_planpayments: Array<{ __typename?: 'evo_planpayment', evo_payment_ratio: number | null } | null> | null } | null> | null } | null };
|
||||
|
||||
export type GetCurrencyChangesQueryVariables = Exact<{
|
||||
currentDate: InputMaybe<Scalars['DateTime']>;
|
||||
@ -252,6 +252,13 @@ export type GetCurrencyIsoCodeQueryVariables = Exact<{
|
||||
|
||||
export type GetCurrencyIsoCodeQuery = { __typename?: 'Query', transactioncurrency: { __typename?: 'transactioncurrency', isocurrencycode: string | null } | null };
|
||||
|
||||
export type GetImportProgramSubsidyQueryVariables = Exact<{
|
||||
importProgramId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetImportProgramSubsidyQuery = { __typename?: 'Query', importProgram: { __typename?: 'evo_subsidy', evo_subsidy_summ: number | null, evo_percent_subsidy: number | null, evo_max_subsidy_summ: number | null } | null };
|
||||
|
||||
export type GetRewardRulesQueryVariables = Exact<{
|
||||
conditionId: Scalars['Uuid'];
|
||||
}>;
|
||||
@ -323,13 +330,6 @@ export type GetAgentQueryVariables = Exact<{
|
||||
|
||||
export type GetAgentQuery = { __typename?: 'Query', agent: { __typename?: 'account', label: string | null, value: string | null } | null };
|
||||
|
||||
export type GetRewardWithoutOtherAgentQueryVariables = Exact<{
|
||||
conditionId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetRewardWithoutOtherAgentQuery = { __typename?: 'Query', evo_reward_condition: { __typename?: 'evo_reward_condition', evo_agency_agreementidData: { __typename?: 'evo_agency_agreement', evo_reward_without_other_agent: boolean | null } | null } | null };
|
||||
|
||||
export type GetDealerReturnLeasingQueryVariables = Exact<{
|
||||
dealerId: Scalars['Uuid'];
|
||||
}>;
|
||||
@ -337,6 +337,13 @@ export type GetDealerReturnLeasingQueryVariables = Exact<{
|
||||
|
||||
export type GetDealerReturnLeasingQuery = { __typename?: 'Query', dealer: { __typename?: 'account', evo_return_leasing_dealer: boolean | null } | null };
|
||||
|
||||
export type GetRewardWithoutOtherAgentQueryVariables = Exact<{
|
||||
conditionId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetRewardWithoutOtherAgentQuery = { __typename?: 'Query', evo_reward_condition: { __typename?: 'evo_reward_condition', evo_agency_agreementidData: { __typename?: 'evo_agency_agreement', evo_reward_without_other_agent: boolean | null } | null } | null };
|
||||
|
||||
export type GetDealerPersonQueryVariables = Exact<{
|
||||
dealerId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
@ -2,8 +2,10 @@ import loadKpReactions from 'process/load-kp/reactions';
|
||||
import * as calculateReactions from '../../calculate/reactions';
|
||||
import * as fingapReactions from '../../fingap/reactions';
|
||||
import * as leadOpportunityReactions from '../../lead-opportunity/reactions';
|
||||
import * as leasingWithoutKaskoReactions from '../../leasing-without-kasko/reactions';
|
||||
import paymentsReactions from '../../payments/reactions';
|
||||
import * as priceReactions from '../../price/reactions';
|
||||
import * as subsidyReactions from '../../subsidy/reactions';
|
||||
import * as agentsReactions from '../../supplier-agent/reactions/agents';
|
||||
import leasebackReactions from '../../supplier-agent/reactions/leaseback';
|
||||
import * as supplierReactions from '../../supplier-agent/reactions/supplier';
|
||||
@ -25,4 +27,7 @@ export default function injectDefaultReactions(context) {
|
||||
fingapReactions.validation(context);
|
||||
setInitialValuesReactions(context);
|
||||
loadKpReactions(context);
|
||||
leasingWithoutKaskoReactions.common(context);
|
||||
subsidyReactions.computedReactions(context);
|
||||
subsidyReactions.commonReactions(context);
|
||||
}
|
||||
|
||||
33
apps/web/process/leasing-without-kasko/reactions/common.ts
Normal file
33
apps/web/process/leasing-without-kasko/reactions/common.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { reaction } from 'mobx';
|
||||
import type { ReactionsContext } from 'process/types';
|
||||
import { uid } from 'radash';
|
||||
import notification from 'ui/elements/notification';
|
||||
|
||||
const NOTIFICATION_KEY = uid(7);
|
||||
export default function commonReactions({ store, apolloClient, queryClient }: ReactionsContext) {
|
||||
const { $calculation, $tables } = store;
|
||||
|
||||
reaction(
|
||||
() => $calculation.element('selectLeasingWithoutKasko').getValue(),
|
||||
(nextValue, prevValue) => {
|
||||
if (prevValue && !nextValue) {
|
||||
notification.warning({
|
||||
key: NOTIFICATION_KEY,
|
||||
message: 'Внимание',
|
||||
description: 'Лизинг без КАСКО был сброшен',
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
reaction(
|
||||
() => $calculation.element('selectLeasingWithoutKasko').getValue(),
|
||||
(leasingWithoutKasko) => {
|
||||
if (leasingWithoutKasko) {
|
||||
$tables.insurance.row('fingap').resetValue('insuranceCompany').block('insuranceCompany');
|
||||
} else {
|
||||
$tables.insurance.row('fingap').unblock('insuranceCompany');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
export { default as common } from './common';
|
||||
56
apps/web/process/subsidy/reactions.ts
Normal file
56
apps/web/process/subsidy/reactions.ts
Normal file
@ -0,0 +1,56 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { gql } from '@apollo/client';
|
||||
import type * as CRMTypes from 'graphql/crm.types';
|
||||
import { autorun } from 'mobx';
|
||||
import type { ReactionsContext } from 'process/types';
|
||||
|
||||
const QUERY_GET_IMPORT_PROGRAM_SUBSIDY = gql`
|
||||
query GetImportProgramSubsidy($importProgramId: Uuid!) {
|
||||
importProgram: evo_subsidy(evo_subsidyid: $importProgramId) {
|
||||
evo_subsidy_summ
|
||||
evo_percent_subsidy
|
||||
evo_max_subsidy_summ
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export function computedReactions({ store, apolloClient, queryClient }: ReactionsContext) {
|
||||
const { $calculation } = store;
|
||||
|
||||
autorun(async () => {
|
||||
const importProgramId = $calculation.element('selectImportProgram').getValue();
|
||||
|
||||
if (importProgramId) {
|
||||
const {
|
||||
data: { importProgram },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetImportProgramSubsidyQuery,
|
||||
CRMTypes.GetImportProgramSubsidyQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_IMPORT_PROGRAM_SUBSIDY,
|
||||
variables: {
|
||||
importProgramId,
|
||||
},
|
||||
});
|
||||
|
||||
if (importProgram?.evo_subsidy_summ && importProgram?.evo_subsidy_summ > 0) {
|
||||
$calculation.element('tbxImportProgramSum').setValue(importProgram?.evo_subsidy_summ);
|
||||
} else {
|
||||
const plPriceRub = $calculation.$values.getValue('plPriceRub');
|
||||
const supplierDiscountRub = $calculation.element('tbxSupplierDiscountRub').getValue();
|
||||
const subsidyPercent = (importProgram?.evo_percent_subsidy || 0) / 100;
|
||||
|
||||
const sum = (plPriceRub - supplierDiscountRub) * subsidyPercent;
|
||||
const maxSum = importProgram?.evo_max_subsidy_summ || 0;
|
||||
|
||||
$calculation.element('tbxImportProgramSum').setValue(Math.min(sum, maxSum));
|
||||
}
|
||||
} else {
|
||||
$calculation.element('tbxImportProgramSum').setValue(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function commonReactions({ store, apolloClient, queryClient }: ReactionsContext) {
|
||||
const { $calculation, $tables } = store;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user