2023-11-27 10:54:10 +03:00

42 lines
2.4 KiB
C#
Raw Permalink 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.

using System;
using EvoCalculator.Core.Models.Calculation.Models.Request;
using EvoCalculator.Core.Tools.Errors;
namespace EvoCalculator.Core.Calculation.Tools;
public class Validation
{
public void ValidateRequest(RequestCalculation requestCalculation)
{
var preparedValues = requestCalculation.preparedValues;
var additionalData = requestCalculation.additionalData;
if (preparedValues.AcceptSum <= 0)
throw new AppException("Стоимость ПЛ с учетом скидки не указана или меньше или равна 0");
if (preparedValues.Nmper <= 0) throw new AppException("Некорректно указан Срок лизинга");
if (preparedValues.IrrExpected <= 0 && preparedValues.Discount <= 0 && preparedValues.ComissionRub <= 0)
throw new AppException(
"Невозможно посчитать график с IRR=0, необходимо указать или Скидку поставщика или Комиссию");
if (preparedValues.PaymentDateNew < preparedValues.DogDate)
throw new AppException(
"Некорректно указана Дата второго платежа, она не может быть раньше Даты заключения ДЛ");
if (preparedValues.PaymentDateNew == null)
if (preparedValues.FirstPaymentSum / preparedValues.AcceptSum >= 0.500001m)
throw new AppException(
"Первый платеж по графику более 50% от стоимости ПЛ с учетом скидки. Необходимо уменьшить первый платеж");
var AllAgencyPerc = Math.Round(
((preparedValues.AgentsSum + preparedValues.DoubleAgentsSum) / (decimal)new Constants.Calculation().ESN +
preparedValues.DeliverySum +
preparedValues.BrokerOfDeliverySum + preparedValues.BrokerSum +
preparedValues.FinancialDeptOfDeliverySum) / preparedValues.AcceptSum * 100, 2);
if (additionalData.MaxAllAgencyPerc != null && AllAgencyPerc > (decimal)additionalData.MaxAllAgencyPerc)
throw new AppException(
"По итогам расчета сумма заложенного АВ превышает максимальный уровень % АВ по Предложению");
}
}