2022-12-15 11:15:46 +03:00

46 lines
2.4 KiB
C#
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.

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