vchikalkin 7797325f8c По итогам расчета графика платежей перед выводм результата расчета заложить валидацию
если Пересчете без пересмотра recalcWithRevision = True и если в Предложении selectQuote в поле "КП по итогам КК" = Да

и значение из итогов расчета npvBonusExpensesColumn (3я строка)/ (1 + PreparedValue.SalaryRate) больше значения суммы в полях Сумма бонуса МПЛ за лизинг, руб. quote.evo_leasing_bonus_summ + Сумма бонуса МПЛ за РАТ, руб quote.evo_card_bonus_summ + Сумма бонуса МПЛ за НСИБ, руб. quote.evo_nsib_bonus_summ из Предложения , которое указано в Предложении selectQuote в поле Одобренное КА quote.evo_accept_quoteid, больше 100,

то выводить сообщение "Нельзя увеличивать бонус МПЛ после рассмотрения предложения на КК"
2024-05-08 14:03:27 +03:00

58 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { CalculateInput, Context } from '../types';
import type { ResponseCalculate } from '@/api/core/types';
import * as CRMTypes from '@/graphql/crm.types';
export async function validateResults({
input,
context,
calculateResult,
}: {
calculateResult: ResponseCalculate;
context: Context;
input: CalculateInput;
}) {
const { recalcWithRevision, quote: quoteId } = input.values;
if (recalcWithRevision && quoteId) {
const { apolloClient } = context;
const {
data: { quote },
} = await apolloClient.query({
query: CRMTypes.GetQuoteDocument,
variables: {
quoteId,
},
});
if (quote?.evo_committee_quote && quote.evo_accept_quoteid) {
const { preparedValues } = calculateResult;
const { npvBonusExpensesColumn } = calculateResult.columns;
const {
data: { quote: accept_quote },
} = await apolloClient.query({
query: CRMTypes.GetQuoteDocument,
variables: { quoteId: quote.evo_accept_quoteid },
});
if (
Math.abs(npvBonusExpensesColumn.values.at(3) || 0) / (1 + preparedValues.salaryRate) -
((accept_quote?.evo_leasing_bonus_summ || 0) +
(accept_quote?.evo_card_bonus_summ || 0) +
(accept_quote?.evo_nsib_bonus_summ || 0)) >
100
) {
return {
message: 'Нельзя увеличивать бонус МПЛ после рассмотрения предложения на КК',
success: false,
};
}
}
}
return {
message: '',
success: true,
};
}