diff --git a/.idea/.idea.EvoCalculator.Core/.idea/contentModel.xml b/.idea/.idea.EvoCalculator.Core/.idea/contentModel.xml
index 147cde8..166b9ef 100644
--- a/.idea/.idea.EvoCalculator.Core/.idea/contentModel.xml
+++ b/.idea/.idea.EvoCalculator.Core/.idea/contentModel.xml
@@ -38,6 +38,7 @@
+
@@ -121,6 +122,7 @@
+
diff --git a/.idea/.idea.EvoCalculator.Core/.idea/workspace.xml b/.idea/.idea.EvoCalculator.Core/.idea/workspace.xml
index a75753d..271c436 100644
--- a/.idea/.idea.EvoCalculator.Core/.idea/workspace.xml
+++ b/.idea/.idea.EvoCalculator.Core/.idea/workspace.xml
@@ -14,18 +14,14 @@
+
+
+
-
-
-
-
-
-
-
+
-
@@ -36,29 +32,32 @@
-
+
+
+
+
-
-
+
+
+
+
+
+
+
+
@@ -211,7 +216,10 @@
-
+
+
+
+
1602593830686
@@ -269,7 +277,21 @@
1603890043823
-
+
+ 1605710694822
+
+
+
+ 1605710694822
+
+
+ 1605810502844
+
+
+
+ 1605810502844
+
+
@@ -300,7 +322,9 @@
-
+
+
+
@@ -319,131 +343,131 @@
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
@@ -452,10 +476,10 @@
-
+
-
+
@@ -465,15 +489,19 @@
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
@@ -486,11 +514,11 @@
-
+
-
+
@@ -504,17 +532,17 @@
- file://$PROJECT_DIR$/EvoCalculator.Core/Controllers/v1/CalculationController.cs
- 222
-
+ file://$PROJECT_DIR$/EvoCalculator.Core.Calculation/Columns/SumColumn.cs
+ 64
+
-
+
-
+
-
+
@@ -533,6 +561,11 @@
+
+
+
+
+
diff --git a/EvoCalculator.Core.Calculation/Columns/SumColumn.cs b/EvoCalculator.Core.Calculation/Columns/SumColumn.cs
index 0398ccc..09ed026 100644
--- a/EvoCalculator.Core.Calculation/Columns/SumColumn.cs
+++ b/EvoCalculator.Core.Calculation/Columns/SumColumn.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using EvoCalculator.Core.Calculation.Post;
using EvoCalculator.Core.Models.Calculation.Models.Prepared;
using TridentGoalSeek;
@@ -36,6 +37,15 @@ namespace EvoCalculator.Core.Calculation.Columns
Values[^1] = _preparedValues.LastPaymentSum;
}
+ private void PostCheck()
+ {
+ if (Values[1] / Values.Skip(1).Sum() >= 0.5m)
+ {
+ throw new Exception(
+ "Первый платеж по графику более 50% от суммы лизинговых платежей. Необходимо уменьшить первый платеж");
+ }
+ }
+
public override void ComputeValues(decimal requiredValue)
{
var goalSeek = new GoalSeek(this);
@@ -50,6 +60,8 @@ namespace EvoCalculator.Core.Calculation.Columns
// , focusPercentage: 100
// , trimFinalInputValue: true
));
+
+ PostCheck();
}
}
}
\ No newline at end of file
diff --git a/EvoCalculator.Core.Calculation/Validation.cs b/EvoCalculator.Core.Calculation/Validation.cs
new file mode 100644
index 0000000..c7f38ce
--- /dev/null
+++ b/EvoCalculator.Core.Calculation/Validation.cs
@@ -0,0 +1,45 @@
+using System.Collections.Generic;
+using EvoCalculator.Core.Models.Calculation.Models.Request;
+
+namespace EvoCalculator.Core.Calculation
+{
+ public class Validation
+ {
+ public object ValidatePreparedData(RequestCalculation requestCalculation)
+ {
+ var preparedValues = requestCalculation.preparedValues;
+
+ var errors = new List();
+
+ 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 (errors.Count > 0)
+ return new
+ {
+ errors
+ };
+
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/EvoCalculator.Core/Controllers/v1/CalculationController.cs b/EvoCalculator.Core/Controllers/v1/CalculationController.cs
index a5b3b96..0daf9d8 100644
--- a/EvoCalculator.Core/Controllers/v1/CalculationController.cs
+++ b/EvoCalculator.Core/Controllers/v1/CalculationController.cs
@@ -1,8 +1,12 @@
using System;
+using System.Threading.Tasks;
+using EvoCalculator.Core.Calculation;
using EvoCalculator.Core.Calculation.Columns;
using EvoCalculator.Core.Calculation.Post;
using EvoCalculator.Core.Models.Calculation.Models.Request;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json;
namespace EvoCalculator.Core.Controllers.V1
{
@@ -18,10 +22,21 @@ namespace EvoCalculator.Core.Controllers.V1
}
[HttpPost("[action]")]
- public ActionResult