diff --git a/.idea/.idea.EvoCalculator.Core/.idea/contentModel.xml b/.idea/.idea.EvoCalculator.Core/.idea/contentModel.xml
index 352ac57..8527655 100644
--- a/.idea/.idea.EvoCalculator.Core/.idea/contentModel.xml
+++ b/.idea/.idea.EvoCalculator.Core/.idea/contentModel.xml
@@ -47,6 +47,7 @@
+
@@ -59,13 +60,16 @@
+
+
+
@@ -117,7 +121,9 @@
-
+
+
+
@@ -146,6 +152,7 @@
+
@@ -158,19 +165,24 @@
+
+
-
+
+
-
+
+
+
diff --git a/.idea/.idea.EvoCalculator.Core/.idea/workspace.xml b/.idea/.idea.EvoCalculator.Core/.idea/workspace.xml
index aaa4375..6abc885 100644
--- a/.idea/.idea.EvoCalculator.Core/.idea/workspace.xml
+++ b/.idea/.idea.EvoCalculator.Core/.idea/workspace.xml
@@ -14,34 +14,32 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -58,11 +56,17 @@
+
+
+
+
+
+
@@ -70,35 +74,11 @@
@@ -191,7 +195,9 @@
-
+
+
+
1602593830686
@@ -200,7 +206,14 @@
1602593830686
-
+
+ 1603291353748
+
+
+
+ 1603291353749
+
+
@@ -224,7 +237,8 @@
-
+
+
@@ -239,90 +253,90 @@
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
@@ -343,22 +357,22 @@
-
+
-
-
+
+
-
+
-
+
-
+
@@ -389,10 +403,10 @@
143
-
+
-
+
@@ -402,14 +416,40 @@
183
-
+
-
+
+
+ file://$PROJECT_DIR$/EvoCalculator.Core.Calculation/Columns/SumColumn.cs
+ 35
+
+
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/EvoCalculator.Core.Calculation/Columns/SumColumn.cs
+ 17
+
+
+
+
+
+
+
+
+
+
@@ -419,5 +459,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/EvoCalculator.Core.Calculation/Columns/BaseColumnWithXIRR.cs b/EvoCalculator.Core.Calculation/Columns/BaseColumnWithXIRR.cs
index 0002e64..ac2033f 100644
--- a/EvoCalculator.Core.Calculation/Columns/BaseColumnWithXIRR.cs
+++ b/EvoCalculator.Core.Calculation/Columns/BaseColumnWithXIRR.cs
@@ -4,6 +4,7 @@ using EvoCalculator.Core.Models.Calculation.Models;
namespace EvoCalculator.Core.Calculation.Columns
{
+ //TODO: GET IRR HERE
public class BaseColumnWithXIRR : BaseColumn
{
public double IRR { get; set; }
diff --git a/EvoCalculator.Core.Calculation/Columns/CashflowColumn.cs b/EvoCalculator.Core.Calculation/Columns/CashflowColumn.cs
new file mode 100644
index 0000000..1d9b8b6
--- /dev/null
+++ b/EvoCalculator.Core.Calculation/Columns/CashflowColumn.cs
@@ -0,0 +1,26 @@
+using EvoCalculator.Core.FinanceFormulas;
+using EvoCalculator.Core.Models.Calculation.Models.Prepared;
+
+namespace EvoCalculator.Core.Calculation.Columns
+{
+ public class CashflowColumn : BaseColumnWithXIRR
+ {
+ public CashflowColumn(int count, DateTempColumn dateTempColumn) : base(count, dateTempColumn)
+ {
+ }
+
+ public void ComputeValues(PreparedValues preparedValues, SumColumn sumColumn,
+ NegativeCashflowColumn negativeCashflowColumn)
+ {
+ Values[0] = -preparedValues.AcquisitionExpenses;
+ Values[1] = sumColumn.Values[1];
+ for (var i = 2; i < Values.Length; i++)
+ {
+ Values[i] = sumColumn.Values[i] + negativeCashflowColumn.Values[i];
+ }
+
+ var XIRR = new XIRR(Flows);
+ IRR = XIRR.GetResult();
+ }
+ }
+}
\ No newline at end of file
diff --git a/EvoCalculator.Core.Calculation/Columns/GPS_GrColumn.cs b/EvoCalculator.Core.Calculation/Columns/GPS_GrColumn.cs
index 2c73e97..0f18b73 100644
--- a/EvoCalculator.Core.Calculation/Columns/GPS_GrColumn.cs
+++ b/EvoCalculator.Core.Calculation/Columns/GPS_GrColumn.cs
@@ -13,7 +13,7 @@ namespace EvoCalculator.Core.Calculation.Columns
{
for (var i = 1; i < Values.Length; i++)
{
- Values[i] = preparedPayments.Rows[i - 1].TlmCostPayment;
+ Values[i] = preparedPayments.Rows[i - 1].GpsCostPayment;
}
diff --git a/EvoCalculator.Core.Calculation/Columns/NSIBBruttoGrColumn.cs b/EvoCalculator.Core.Calculation/Columns/NSIBBruttoGrColumn.cs
new file mode 100644
index 0000000..0c43098
--- /dev/null
+++ b/EvoCalculator.Core.Calculation/Columns/NSIBBruttoGrColumn.cs
@@ -0,0 +1,23 @@
+using System.Linq;
+using EvoCalculator.Core.Models.Calculation.Models.Prepared;
+
+namespace EvoCalculator.Core.Calculation.Columns
+{
+ public class NSIBBruttoGrColumn : BaseColumn
+ {
+ public NSIBBruttoGrColumn(int count) : base(count)
+ {
+ }
+
+ public void ComputeValues(PreparedValues preparedValues)
+ {
+ Values[1] = 0;
+ for (var i = 2; i < Values.Length; i++)
+ {
+ Values[i] = preparedValues.NsibBrutto / (preparedValues.Nmper - 1);
+ }
+
+ Values[0] = Values.Skip(1).Sum(x => x);
+ }
+ }
+}
\ No newline at end of file
diff --git a/EvoCalculator.Core.Calculation/Columns/NegativeCashflowColumn.cs b/EvoCalculator.Core.Calculation/Columns/NegativeCashflowColumn.cs
new file mode 100644
index 0000000..0a91307
--- /dev/null
+++ b/EvoCalculator.Core.Calculation/Columns/NegativeCashflowColumn.cs
@@ -0,0 +1,21 @@
+using System.Linq;
+
+namespace EvoCalculator.Core.Calculation.Columns
+{
+ public class NegativeCashflowColumn : BaseColumn
+ {
+ public NegativeCashflowColumn(int count) : base(count)
+ {
+ }
+
+ public void ComputeValues(KaskoNmperGrColumn kaskoNmperGrColumn)
+ {
+ for (var i = 1; i < Values.Length; i++)
+ {
+ Values[i] = -kaskoNmperGrColumn.Values[i];
+ }
+
+ Values[0] = Values.Skip(1).Sum(x => x);
+ }
+ }
+}
\ No newline at end of file
diff --git a/EvoCalculator.Core.Calculation/Columns/SumColumn.cs b/EvoCalculator.Core.Calculation/Columns/SumColumn.cs
index e572815..b96db64 100644
--- a/EvoCalculator.Core.Calculation/Columns/SumColumn.cs
+++ b/EvoCalculator.Core.Calculation/Columns/SumColumn.cs
@@ -47,7 +47,9 @@ namespace EvoCalculator.Core.Calculation.Columns
var goalSeek = new GoalSeek(this);
goalSeek.SeekResult(requiredIRR,
new GoalSeekOptions(
- startingStabPoint: Convert.ToDecimal(this._preparedValues.BaseCost / this._preparedValues.Nmper)
+ startingStabPoint: Convert.ToDecimal(
+ (this._preparedValues.BaseCost - this._preparedValues.FirstPaymentSum) /
+ this._preparedValues.Nmper)
, tineExplorePercentage: 10
// , maximumAttempts: 10000
// , initialTineSpacing: 1
diff --git a/EvoCalculator.Core.Calculation/Columns/TaxColumn.cs b/EvoCalculator.Core.Calculation/Columns/TaxColumn.cs
new file mode 100644
index 0000000..9389557
--- /dev/null
+++ b/EvoCalculator.Core.Calculation/Columns/TaxColumn.cs
@@ -0,0 +1,40 @@
+using System.Linq;
+
+namespace EvoCalculator.Core.Calculation.Columns
+{
+ public class TaxColumn : BaseColumn
+ {
+ public TaxColumn(int count) : base(count)
+ {
+ }
+
+ public void ComputeValues(Constants.Calculation constants, SumColumn sumColumn,
+ AcceptInsuranceColumn acceptInsuranceColumn, DeprecationColumn deprecationColumn,
+ RatExpensesColumn ratExpensesColumn, RegistrExpensesColumn registrExpensesColumn,
+ ComissionBonusExpensesColumn comissionBonusExpensesColumn, TransExprensesColumn transExprensesColumn,
+ NPVBonusExpensesColumn npvBonusExpensesColumn, AgentComissionExpensesColumn agentComissionExpensesColumn,
+ InsuranceBonusExpensesColumn insuranceBonusExpensesColumn, TLMExpensesColumn tlmExpensesColumn,
+ GPSExpensesColumn gpsExpensesColumn)
+ {
+ for (var i = 1; i < Values.Length; i++)
+ {
+ Values[i] = constants.IncomeTaxValue * (sumColumn.Values[i]
+ - acceptInsuranceColumn.Values[i]
+ - deprecationColumn.Values[i]
+ + ratExpensesColumn.Values[i]
+ + registrExpensesColumn.Values[i]
+ + comissionBonusExpensesColumn.Values[i]
+ + transExprensesColumn.Values[i]
+ + npvBonusExpensesColumn.Values[i]
+ + agentComissionExpensesColumn.Values[i]
+ + insuranceBonusExpensesColumn.Values[i]
+ + tlmExpensesColumn.Values[i]
+ + gpsExpensesColumn.Values[i]
+ );
+ }
+
+
+ Values[0] = Values.Skip(1).Sum(x => x);
+ }
+ }
+}
\ No newline at end of file
diff --git a/EvoCalculator.Core.Calculation/EvoCalculator.Core.Calculation.csproj b/EvoCalculator.Core.Calculation/EvoCalculator.Core.Calculation.csproj
index 0bf3914..7aff275 100644
--- a/EvoCalculator.Core.Calculation/EvoCalculator.Core.Calculation.csproj
+++ b/EvoCalculator.Core.Calculation/EvoCalculator.Core.Calculation.csproj
@@ -9,4 +9,8 @@
+
+
+
+
diff --git a/EvoCalculator.Core.Constants/EvoCalculator.Core.Constants.csproj b/EvoCalculator.Core.Constants/EvoCalculator.Core.Constants.csproj
index f28989b..e3223da 100644
--- a/EvoCalculator.Core.Constants/EvoCalculator.Core.Constants.csproj
+++ b/EvoCalculator.Core.Constants/EvoCalculator.Core.Constants.csproj
@@ -5,4 +5,8 @@
Constants
+
+
+
+
diff --git a/EvoCalculator.Core.FinanceFormulas/EvoCalculator.Core.FinanceFormulas.csproj b/EvoCalculator.Core.FinanceFormulas/EvoCalculator.Core.FinanceFormulas.csproj
index abd3f1d..6b48a81 100644
--- a/EvoCalculator.Core.FinanceFormulas/EvoCalculator.Core.FinanceFormulas.csproj
+++ b/EvoCalculator.Core.FinanceFormulas/EvoCalculator.Core.FinanceFormulas.csproj
@@ -10,6 +10,7 @@
+
diff --git a/EvoCalculator.Core.Models/Calculation/Models/Request/RequestCalculation.cs b/EvoCalculator.Core.Models/Calculation/Models/Request/RequestCalculation.cs
new file mode 100644
index 0000000..c3f3b4e
--- /dev/null
+++ b/EvoCalculator.Core.Models/Calculation/Models/Request/RequestCalculation.cs
@@ -0,0 +1,10 @@
+using EvoCalculator.Core.Models.Calculation.Models.Prepared;
+
+namespace EvoCalculator.Core.Models.Calculation.Models.Request
+{
+ public class RequestCalculation
+ {
+ public PreparedValues preparedValues;
+ public PreparedPayments preparedPayments;
+ }
+}
\ No newline at end of file
diff --git a/EvoCalculator.Core.Models/EvoCalculator.Core.Models.csproj b/EvoCalculator.Core.Models/EvoCalculator.Core.Models.csproj
index bf72b0e..b57da84 100644
--- a/EvoCalculator.Core.Models/EvoCalculator.Core.Models.csproj
+++ b/EvoCalculator.Core.Models/EvoCalculator.Core.Models.csproj
@@ -5,7 +5,6 @@
-
@@ -13,4 +12,8 @@
+
+
+
+
diff --git a/EvoCalculator.Core.Tests/Calculation/Columns/CashflowTests.cs b/EvoCalculator.Core.Tests/Calculation/Columns/CashflowTests.cs
new file mode 100644
index 0000000..f791566
--- /dev/null
+++ b/EvoCalculator.Core.Tests/Calculation/Columns/CashflowTests.cs
@@ -0,0 +1,200 @@
+using System;
+using EvoCalculator.Core.Calculation.Columns;
+using EvoCalculator.Core.Models.Calculation.Models.Prepared;
+using Xunit;
+
+namespace EvoCalculator.Core.Tests.Calculation.Columns
+{
+ public class CashflowTests
+ {
+ [Fact]
+ public void CashflowTest1()
+ {
+ var preparedValues = new PreparedValues()
+ {
+ Nmper = 25,
+ AcquisitionExpenses = 2507300
+ };
+
+ var dateTempColumn = new DateTempColumn(67)
+ {
+ Values = new[]
+ {
+ new DateTime(2018, 10, 31),
+ new DateTime(2018, 10, 31),
+ new DateTime(2018, 11, 30),
+ new DateTime(2018, 12, 31),
+ new DateTime(2019, 1, 31),
+ new DateTime(2019, 2, 28),
+ new DateTime(2019, 3, 31),
+ new DateTime(2019, 4, 30),
+ new DateTime(2019, 5, 31),
+ new DateTime(2019, 6, 30),
+ new DateTime(2019, 7, 31),
+ new DateTime(2019, 8, 31),
+ new DateTime(2019, 9, 30),
+ new DateTime(2019, 10, 31),
+ new DateTime(2019, 11, 30),
+ new DateTime(2019, 12, 31),
+ new DateTime(2020, 1, 31),
+ new DateTime(2020, 2, 29),
+ new DateTime(2020, 3, 31),
+ new DateTime(2020, 4, 30),
+ new DateTime(2020, 5, 31),
+ new DateTime(2020, 6, 30),
+ new DateTime(2020, 7, 31),
+ new DateTime(2020, 8, 31),
+ new DateTime(2020, 9, 30),
+ new DateTime(2020, 10, 31),
+ new DateTime(2020, 11, 30),
+ new DateTime(2020, 12, 31),
+ new DateTime(2021, 1, 31),
+ new DateTime(2021, 2, 28),
+ new DateTime(2021, 3, 31),
+ new DateTime(2021, 4, 30),
+ new DateTime(2021, 5, 31),
+ new DateTime(2021, 6, 30),
+ new DateTime(2021, 7, 31),
+ new DateTime(2021, 8, 31),
+ new DateTime(2021, 9, 30),
+ new DateTime(2021, 10, 31),
+ new DateTime(2021, 11, 30),
+ new DateTime(2021, 12, 31),
+ new DateTime(2022, 1, 31),
+ new DateTime(2022, 2, 28),
+ new DateTime(2022, 3, 31),
+ new DateTime(2022, 4, 30),
+ new DateTime(2022, 5, 31),
+ new DateTime(2022, 6, 30),
+ new DateTime(2022, 7, 31),
+ new DateTime(2022, 8, 31),
+ new DateTime(2022, 9, 30),
+ new DateTime(2022, 10, 31),
+ new DateTime(2022, 11, 30),
+ new DateTime(2022, 12, 31),
+ new DateTime(2023, 1, 31),
+ new DateTime(2023, 2, 28),
+ new DateTime(2023, 3, 31),
+ new DateTime(2023, 4, 30),
+ new DateTime(2023, 5, 31),
+ new DateTime(2023, 6, 30),
+ new DateTime(2023, 7, 31),
+ new DateTime(2023, 8, 31),
+ new DateTime(2023, 9, 30),
+ new DateTime(2023, 10, 31),
+ new DateTime(2023, 11, 30),
+ new DateTime(2023, 12, 31),
+ new DateTime(2024, 1, 31),
+ new DateTime(2024, 2, 29),
+ new DateTime(2024, 3, 31),
+ }
+ };
+
+ var sumColumn = new SumColumn(preparedValues.Nmper + 1, dateTempColumn, preparedValues,
+ new PercentPaymentColumn(preparedValues.Nmper + 1))
+ {
+ Values = new[]
+ {
+ -2542903.66268442,
+ 625000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 96000,
+ 96000,
+ 25000,
+ }
+ };
+
+ var negativeCashFlow = new NegativeCashflowColumn(preparedValues.Nmper + 1)
+ {
+ Values = new[]
+ {
+ -110416.666666667,
+ -53000,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ -57416.6666666667,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ }
+ };
+
+ var cashflowColumn = new CashflowColumn(preparedValues.Nmper + 1, dateTempColumn);
+ cashflowColumn.ComputeValues(preparedValues, sumColumn, negativeCashFlow);
+
+
+ var expected = new[]
+ {
+ -2507300,
+ 625000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 108000,
+ 50583.3333333333,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 96000,
+ 96000,
+ 25000,
+ };
+
+
+ Assert.Equal(expected.Length, cashflowColumn.Values.Length);
+ Assert.Equal(0.3878, cashflowColumn.IRR, new DoubleArrayComparer(0.1));
+ Assert.Equal(expected, cashflowColumn.Values, new DoubleArrayComparer());
+ }
+ }
+}
\ No newline at end of file
diff --git a/EvoCalculator.Core.Tests/Calculation/Columns/DeprecationTests.cs b/EvoCalculator.Core.Tests/Calculation/Columns/DeprecationTests.cs
index ed8c7b9..170cbc4 100644
--- a/EvoCalculator.Core.Tests/Calculation/Columns/DeprecationTests.cs
+++ b/EvoCalculator.Core.Tests/Calculation/Columns/DeprecationTests.cs
@@ -53,7 +53,7 @@ namespace EvoCalculator.Core.Tests.Calculation.Columns
}
};
- var deprectionLDColumn = new DeprecationLDColumn(preparedValues.NmperDeprecation + 2)
+ var deprecationLDColumn = new DeprecationLDColumn(preparedValues.NmperDeprecation + 2)
{
Values = new[]
{
@@ -100,7 +100,7 @@ namespace EvoCalculator.Core.Tests.Calculation.Columns
};
var deprecationColumn = new DeprecationColumn(preparedValues.NmperDeprecation + 2);
- deprecationColumn.ComputeValues(deprecationLPColumn, deprectionLDColumn);
+ deprecationColumn.ComputeValues(deprecationLPColumn, deprecationLDColumn);
var expected = new[]
{
diff --git a/EvoCalculator.Core.Tests/Calculation/Columns/InsuranceBonusExpensesTests.cs b/EvoCalculator.Core.Tests/Calculation/Columns/InsuranceBonusExpensesTests.cs
index 3568067..2b9c521 100644
--- a/EvoCalculator.Core.Tests/Calculation/Columns/InsuranceBonusExpensesTests.cs
+++ b/EvoCalculator.Core.Tests/Calculation/Columns/InsuranceBonusExpensesTests.cs
@@ -16,8 +16,8 @@ namespace EvoCalculator.Core.Tests.Calculation.Columns
Nmper = 27
};
- var targetColumn = new InsuranceBonusExpensesColumn(preparedValues.Nmper + 1);
- targetColumn.ComputeValues(preparedValues);
+ var insuranceBonusExpensesColumn = new InsuranceBonusExpensesColumn(preparedValues.Nmper + 1);
+ insuranceBonusExpensesColumn.ComputeValues(preparedValues);
var expected = new[]
@@ -53,8 +53,8 @@ namespace EvoCalculator.Core.Tests.Calculation.Columns
};
- Assert.Equal(expected.Length, targetColumn.Values.Length);
- Assert.Equal(expected, targetColumn.Values, new DoubleArrayComparer());
+ Assert.Equal(expected.Length, insuranceBonusExpensesColumn.Values.Length);
+ Assert.Equal(expected, insuranceBonusExpensesColumn.Values, new DoubleArrayComparer());
}
[Fact]
@@ -67,8 +67,8 @@ namespace EvoCalculator.Core.Tests.Calculation.Columns
Nmper = 24
};
- var targetColumn = new InsuranceBonusExpensesColumn(preparedValues.Nmper + 1);
- targetColumn.ComputeValues(preparedValues);
+ var insuranceBonusExpensesColumn = new InsuranceBonusExpensesColumn(preparedValues.Nmper + 1);
+ insuranceBonusExpensesColumn.ComputeValues(preparedValues);
var expected = new[]
@@ -101,8 +101,8 @@ namespace EvoCalculator.Core.Tests.Calculation.Columns
};
- Assert.Equal(expected.Length, targetColumn.Values.Length);
- Assert.Equal(expected, targetColumn.Values, new DoubleArrayComparer());
+ Assert.Equal(expected.Length, insuranceBonusExpensesColumn.Values.Length);
+ Assert.Equal(expected, insuranceBonusExpensesColumn.Values, new DoubleArrayComparer());
}
[Fact]
@@ -115,8 +115,8 @@ namespace EvoCalculator.Core.Tests.Calculation.Columns
Nmper = 15
};
- var targetColumn = new InsuranceBonusExpensesColumn(preparedValues.Nmper + 1);
- targetColumn.ComputeValues(preparedValues);
+ var insuranceBonusExpensesColumn = new InsuranceBonusExpensesColumn(preparedValues.Nmper + 1);
+ insuranceBonusExpensesColumn.ComputeValues(preparedValues);
var expected = new[]
@@ -140,8 +140,8 @@ namespace EvoCalculator.Core.Tests.Calculation.Columns
};
- Assert.Equal(expected.Length, targetColumn.Values.Length);
- Assert.Equal(expected, targetColumn.Values, new DoubleArrayComparer());
+ Assert.Equal(expected.Length, insuranceBonusExpensesColumn.Values.Length);
+ Assert.Equal(expected, insuranceBonusExpensesColumn.Values, new DoubleArrayComparer());
}
[Fact]
diff --git a/EvoCalculator.Core.Tests/Calculation/Columns/NPVBonusExpensesTests.cs b/EvoCalculator.Core.Tests/Calculation/Columns/NPVBonusExpensesTests.cs
index 6c6edaf..827b95e 100644
--- a/EvoCalculator.Core.Tests/Calculation/Columns/NPVBonusExpensesTests.cs
+++ b/EvoCalculator.Core.Tests/Calculation/Columns/NPVBonusExpensesTests.cs
@@ -9,7 +9,7 @@ namespace EvoCalculator.Core.Tests.Calculation.Columns
[Fact]
public void NPVBonusExpensesTest1()
{
- var preparedValue = new PreparedValues
+ var preparedValues = new PreparedValues
{
SalaryRate = 0.3,
MarketRate = 0.01,
@@ -24,8 +24,8 @@ namespace EvoCalculator.Core.Tests.Calculation.Columns
};
- var npvBonusExpensesColumn = new NPVBonusExpensesColumn(preparedValue.Nmper + 1);
- npvBonusExpensesColumn.ComputeValues(preparedValue);
+ var npvBonusExpensesColumn = new NPVBonusExpensesColumn(preparedValues.Nmper + 1);
+ npvBonusExpensesColumn.ComputeValues(preparedValues);
var expected = new[]
{
diff --git a/EvoCalculator.Core.Tests/Calculation/Columns/NSIBBruttoGrTests.cs b/EvoCalculator.Core.Tests/Calculation/Columns/NSIBBruttoGrTests.cs
new file mode 100644
index 0000000..cb2d07f
--- /dev/null
+++ b/EvoCalculator.Core.Tests/Calculation/Columns/NSIBBruttoGrTests.cs
@@ -0,0 +1,62 @@
+using EvoCalculator.Core.Calculation.Columns;
+using EvoCalculator.Core.Models.Calculation.Models.Prepared;
+using Xunit;
+
+namespace EvoCalculator.Core.Tests.Calculation.Columns
+{
+ public class NSIBBruttoGrTests
+ {
+ [Fact]
+ public void NSIBBruttoGrTest1()
+ {
+ var preparedValues = new PreparedValues()
+ {
+ Nmper = 30,
+ NsibBrutto = 23842.50
+ };
+
+ var nsibBruttoGrColumn = new NSIBBruttoGrColumn(preparedValues.Nmper + 1);
+ nsibBruttoGrColumn.ComputeValues(preparedValues);
+
+
+ var expected = new[]
+ {
+ 23842.5,
+ 0,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ 822.155172413793,
+ };
+
+
+ Assert.Equal(expected.Length, nsibBruttoGrColumn.Values.Length);
+ Assert.Equal(expected, nsibBruttoGrColumn.Values, new DoubleArrayComparer());
+ }
+ }
+}
\ No newline at end of file
diff --git a/EvoCalculator.Core.Tests/Calculation/Columns/NegativeCashflowTests.cs b/EvoCalculator.Core.Tests/Calculation/Columns/NegativeCashflowTests.cs
new file mode 100644
index 0000000..c9ebf89
--- /dev/null
+++ b/EvoCalculator.Core.Tests/Calculation/Columns/NegativeCashflowTests.cs
@@ -0,0 +1,100 @@
+using EvoCalculator.Core.Calculation.Columns;
+using EvoCalculator.Core.Models.Calculation.Models.Prepared;
+using Xunit;
+
+namespace EvoCalculator.Core.Tests.Calculation.Columns
+{
+ public class NegativeCashflowTests
+ {
+ [Fact]
+ public void NegativeCashflowTest1()
+ {
+ var preparedValues = new PreparedValues()
+ {
+ Nmper = 30
+ };
+
+ var kaskoNmperGrColumn =
+ new KaskoNmperGrColumn(preparedValues.Nmper + 1, new DateTempColumn(preparedValues.Nmper))
+ {
+ Values = new[]
+ {
+ -114237.279504698,
+ 53000,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 53000,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 26500,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ }
+ };
+
+ var negativeCashflowColumn = new NegativeCashflowColumn(preparedValues.Nmper + 1);
+ negativeCashflowColumn.ComputeValues(kaskoNmperGrColumn);
+
+
+ var expected = new[]
+ {
+ -132500.00,
+ -53000.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ -53000.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ -26500.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ };
+
+
+ Assert.Equal(expected.Length, negativeCashflowColumn.Values.Length);
+ Assert.Equal(expected, negativeCashflowColumn.Values, new DoubleArrayComparer());
+ }
+ }
+}
\ No newline at end of file
diff --git a/EvoCalculator.Core.Tests/Calculation/Columns/SumColumnTest.cs b/EvoCalculator.Core.Tests/Calculation/Columns/SumTest.cs
similarity index 68%
rename from EvoCalculator.Core.Tests/Calculation/Columns/SumColumnTest.cs
rename to EvoCalculator.Core.Tests/Calculation/Columns/SumTest.cs
index f1feb90..1281747 100644
--- a/EvoCalculator.Core.Tests/Calculation/Columns/SumColumnTest.cs
+++ b/EvoCalculator.Core.Tests/Calculation/Columns/SumTest.cs
@@ -5,10 +5,10 @@ using Xunit;
namespace EvoCalculator.Core.Tests.Calculation.Columns
{
- public class SumColumnTests
+ public class SumTests
{
[Fact]
- public void SumColumnTest1()
+ public void SumTest1()
{
var preparedValues =
new PreparedValues()
@@ -180,7 +180,7 @@ namespace EvoCalculator.Core.Tests.Calculation.Columns
}
[Fact]
- public void SumColumnTest2()
+ public void SumTest2()
{
var preparedValues =
new PreparedValues()
@@ -308,5 +308,143 @@ namespace EvoCalculator.Core.Tests.Calculation.Columns
var values = sumColumn.Values;
Assert.Equal(expected, values, new DoubleArrayComparer(100));
}
+
+ [Fact]
+ public void SumTest3()
+ {
+ var preparedValues =
+ new PreparedValues()
+ {
+ BaseCost = 2586532.79187453,
+ FirstPaymentSum = 805000,
+ Nmper = 16,
+ LastPaymentSum = 23000,
+ IrrExpected = 0.23
+ };
+
+
+ var percentPaymentColumn = new PercentPaymentColumn(preparedValues.Nmper + 1)
+ {
+ Values = new[]
+ {
+ 0.00,
+ 0.00,
+ 100.00,
+ 100.00,
+ 100.00,
+ 100.00,
+ 100.00,
+ 100.00,
+ 100.00,
+ 100.00,
+ 100.00,
+ 100.00,
+ 100.00,
+ 100.00,
+ 100.00,
+ 100.00,
+ 0.00,
+ }
+ };
+
+ var dateTempColumn = new DateTempColumn(67)
+ {
+ Values = new[]
+ {
+ new DateTime(2020, 10, 12),
+ new DateTime(2020, 10, 12),
+ new DateTime(2020, 11, 12),
+ new DateTime(2020, 12, 12),
+ new DateTime(2021, 1, 12),
+ new DateTime(2021, 2, 12),
+ new DateTime(2021, 3, 12),
+ new DateTime(2021, 4, 12),
+ new DateTime(2021, 5, 12),
+ new DateTime(2021, 6, 12),
+ new DateTime(2021, 7, 12),
+ new DateTime(2021, 8, 12),
+ new DateTime(2021, 9, 12),
+ new DateTime(2021, 10, 12),
+ new DateTime(2021, 11, 12),
+ new DateTime(2021, 12, 12),
+ new DateTime(2022, 1, 12),
+ new DateTime(2022, 2, 12),
+ new DateTime(2022, 3, 12),
+ new DateTime(2022, 4, 12),
+ new DateTime(2022, 5, 12),
+ new DateTime(2022, 6, 12),
+ new DateTime(2022, 7, 12),
+ new DateTime(2022, 8, 12),
+ new DateTime(2022, 9, 12),
+ new DateTime(2022, 10, 12),
+ new DateTime(2022, 11, 12),
+ new DateTime(2022, 12, 12),
+ new DateTime(2023, 1, 12),
+ new DateTime(2023, 2, 12),
+ new DateTime(2023, 3, 12),
+ new DateTime(2023, 4, 12),
+ new DateTime(2023, 5, 12),
+ new DateTime(2023, 6, 12),
+ new DateTime(2023, 7, 12),
+ new DateTime(2023, 8, 12),
+ new DateTime(2023, 9, 12),
+ new DateTime(2023, 10, 12),
+ new DateTime(2023, 11, 12),
+ new DateTime(2023, 12, 12),
+ new DateTime(2024, 1, 12),
+ new DateTime(2024, 2, 12),
+ new DateTime(2024, 3, 12),
+ new DateTime(2024, 4, 12),
+ new DateTime(2024, 5, 12),
+ new DateTime(2024, 6, 12),
+ new DateTime(2024, 7, 12),
+ new DateTime(2024, 8, 12),
+ new DateTime(2024, 9, 12),
+ new DateTime(2024, 10, 12),
+ new DateTime(2024, 11, 12),
+ new DateTime(2024, 12, 12),
+ new DateTime(2025, 1, 12),
+ new DateTime(2025, 2, 12),
+ new DateTime(2025, 3, 12),
+ new DateTime(2025, 4, 12),
+ new DateTime(2025, 5, 12),
+ new DateTime(2025, 6, 12),
+ new DateTime(2025, 7, 12),
+ new DateTime(2025, 8, 12),
+ new DateTime(2025, 9, 12),
+ }
+ };
+
+
+ var expected = new[]
+ {
+ -2586532.79187453,
+ 805000,
+ 143021.219846191,
+ 143021.219846191,
+ 143021.219846191,
+ 143021.219846191,
+ 143021.219846191,
+ 143021.219846191,
+ 143021.219846191,
+ 143021.219846191,
+ 143021.219846191,
+ 143021.219846191,
+ 143021.219846191,
+ 143021.219846191,
+ 143021.219846191,
+ 143021.219846191,
+ 23000,
+ };
+
+ var sumColumn = new SumColumn(
+ preparedValues.Nmper + 1
+ , dateTempColumn
+ , preparedValues
+ , percentPaymentColumn);
+ sumColumn.ComputeValues(Convert.ToDecimal(preparedValues.IrrExpected));
+ var values = sumColumn.Values;
+ Assert.Equal(expected, values, new DoubleArrayComparer(100));
+ }
}
}
\ No newline at end of file
diff --git a/EvoCalculator.Core.Tests/Calculation/Columns/TaxColumnTests.cs b/EvoCalculator.Core.Tests/Calculation/Columns/TaxColumnTests.cs
new file mode 100644
index 0000000..e28bc4b
--- /dev/null
+++ b/EvoCalculator.Core.Tests/Calculation/Columns/TaxColumnTests.cs
@@ -0,0 +1,457 @@
+using EvoCalculator.Core.Calculation.Columns;
+using EvoCalculator.Core.Models.Calculation.Models.Prepared;
+using Xunit;
+
+namespace EvoCalculator.Core.Tests.Calculation.Columns
+{
+ public class TaxColumnTests
+ {
+ [Fact]
+ public void TaxColumnTest1()
+ {
+ var preparedValues = new PreparedValues()
+ {
+ Nmper = 25
+ };
+
+ var sumColumn = new SumColumn(preparedValues.Nmper + 1, new DateTempColumn(preparedValues.Nmper + 1),
+ preparedValues, new PercentPaymentColumn(preparedValues.Nmper + 1))
+ {
+ Values = new[]
+ {
+ -2542903.66268442,
+ 625000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 120000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 108000,
+ 96000,
+ 96000,
+ 25000,
+ }
+ };
+
+ var acceptInsuranceColumn = new AcceptInsuranceColumn(preparedValues.Nmper + 1)
+ {
+ Values = new[]
+ {
+ 140416.666666667,
+ 0.00,
+ 7327.96717171717,
+ 7327.96717171717,
+ 7327.96717171717,
+ 7327.96717171717,
+ 7327.96717171717,
+ 7327.96717171717,
+ 7327.96717171717,
+ 7327.96717171717,
+ 7327.96717171717,
+ 7327.96717171717,
+ 7327.96717171717,
+ 4600.69444444444,
+ 4600.69444444444,
+ 4600.69444444444,
+ 4600.69444444444,
+ 4600.69444444444,
+ 4600.69444444444,
+ 4600.69444444444,
+ 4600.69444444444,
+ 4600.69444444444,
+ 4600.69444444444,
+ 4600.69444444444,
+ 4600.69444444444,
+ 4600.69444444444,
+ }
+ };
+
+ var deprecationColumn = new DeprecationColumn(preparedValues.Nmper + 1)
+ {
+ Values = new[]
+ {
+ 2525456.22292856,
+ 488671.869761719,
+ 93824.99899425,
+ 93824.99899425,
+ 93824.99899425,
+ 93824.99899425,
+ 93824.99899425,
+ 93824.99899425,
+ 93824.99899425,
+ 93824.99899425,
+ 93824.99899425,
+ 93824.99899425,
+ 84442.499094825,
+ 84442.499094825,
+ 84442.499094825,
+ 84442.499094825,
+ 84442.499094825,
+ 84442.499094825,
+ 84442.499094825,
+ 84442.499094825,
+ 84442.499094825,
+ 84442.499094825,
+ 84442.499094825,
+ 75059.9991954,
+ 75059.9991954,
+ 19546.8747904687,
+ }
+ };
+
+ var ratExpensesColumn = new RatExpensesColumn(preparedValues.Nmper + 1)
+ {
+ Values = new[]
+ {
+ -6000,
+ -12000,
+ 0.00,
+ 0.00,
+ 6000,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ }
+ };
+
+ var registrExpensesColumn = new RegistrExpensesColumn(preparedValues.Nmper + 1)
+ {
+ Values = new[]
+ {
+ -2300,
+ -2300,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ }
+ };
+
+ var comissionBonusExpensesColumn = new ComissionBonusExpensesColumn(preparedValues.Nmper + 1)
+ {
+ Values = new[]
+ {
+ 125000,
+ 125000,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ }
+ };
+
+ var transExprensesColumn = new TransExprensesColumn(preparedValues.Nmper + 1)
+ {
+ Values = new[]
+ {
+ -18750,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ -9000,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ -9000,
+ -750,
+ }
+ };
+
+ var npvBonusExpensesColumn = new NPVBonusExpensesColumn(preparedValues.Nmper + 1)
+ {
+ Values = new[]
+ {
+ -19774.2041520833,
+ -1389.58909375,
+ -18384.6150583333,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ }
+ };
+
+ var agentComissionExpensesColumn = new AgentComissionExpensesColumn(preparedValues.Nmper + 1)
+ {
+ Values = new[]
+ {
+ -446104.166666667,
+ 0.00,
+ -446104.166666667,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ }
+ };
+
+ var insuranceBonusExpensesColumn = new InsuranceBonusExpensesColumn(preparedValues.Nmper + 1)
+ {
+ Values = new[]
+ {
+ 26337.50,
+ 0.00,
+ 12642.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 13695.50,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ 0.00,
+ }
+ };
+
+ var tlmExpensesColumn = new TLMExpensesColumn(preparedValues.Nmper + 1)
+ {
+ Values = new double[]
+ {
+ -40000,
+ -20000,
+ -1600,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ -800,
+ }
+ };
+
+ var gpsExpensesColumn = new GPSExpensesColumn(preparedValues.Nmper + 1)
+ {
+ Values = new double[]
+ {
+ -30000,
+ -15000,
+ -1200,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ -600,
+ }
+ };
+
+
+ var incomeTaxColumn = new TaxColumn(preparedValues.Nmper + 1);
+ incomeTaxColumn.ComputeValues(new Constants.Calculation(), sumColumn, acceptInsuranceColumn,
+ deprecationColumn, ratExpensesColumn, registrExpensesColumn, comissionBonusExpensesColumn,
+ transExprensesColumn, npvBonusExpensesColumn, agentComissionExpensesColumn,
+ insuranceBonusExpensesColumn, tlmExpensesColumn, gpsExpensesColumn);
+
+
+ var expected = new[]
+ {
+ 30507.2479172043,
+ 42127.7082289063,
+ -87159.9495781934,
+ 3489.40676680657,
+ 4689.40676680657,
+ 3489.40676680657,
+ 3489.40676680657,
+ 3489.40676680657,
+ 3489.40676680657,
+ 3489.40676680657,
+ 3489.40676680657,
+ 3489.40676680657,
+ 1165.90674669157,
+ 6250.46129214612,
+ 3511.36129214612,
+ 3511.36129214612,
+ 3511.36129214612,
+ 3511.36129214612,
+ 3511.36129214612,
+ 3511.36129214612,
+ 3511.36129214612,
+ 3511.36129214612,
+ 3511.36129214612,
+ 2987.86127203112,
+ 1187.86127203112,
+ -259.513846982638,
+ };
+
+
+ Assert.Equal(expected.Length, incomeTaxColumn.Values.Length);
+ Assert.Equal(expected, incomeTaxColumn.Values, new DoubleArrayComparer());
+ }
+ }
+}
\ No newline at end of file
diff --git a/EvoCalculator.Core.Tests/Calculation/Controller/CalculationControllerV1Tests.cs b/EvoCalculator.Core.Tests/Calculation/Controller/CalculationControllerV1Tests.cs
new file mode 100644
index 0000000..afedb72
--- /dev/null
+++ b/EvoCalculator.Core.Tests/Calculation/Controller/CalculationControllerV1Tests.cs
@@ -0,0 +1,850 @@
+using System;
+using System.IO;
+using EvoCalculator.Core.Controllers.V1;
+using EvoCalculator.Core.Models.Calculation.Models.Prepared;
+using EvoCalculator.Core.Models.Calculation.Models.Request;
+using Newtonsoft.Json;
+using Xunit;
+
+namespace EvoCalculator.Core.Tests.Calculation.Controller
+{
+ public class CalculationControllerV1Tests
+ {
+ [Fact]
+ public void Test1()
+ {
+ var preparedValues = new PreparedValues()
+ {
+ CalcDate = new DateTime(2020, 01, 01),
+ IrrExpected = 0.23,
+ NpvniExpected = 0.05,
+ TotalExpected = 0,
+ Leasing0K = 1,
+ LoanRate = 0.07,
+ BalanceHolder = 100000000,
+ DogDate = new DateTime(2020, 10, 12),
+ DeliveryTime = 100000001,
+ Nmper = 16,
+ FirstPayment = 0.35,
+ FirstPaymentSum = 805000,
+ FirstPaymentAbs = 0,
+ FirstPaymentNdsAbs = 0,
+ FirstPaymentWithNdsAbs = 0,
+ LastPayment = 0.01,
+ LastPaymentSum = 23000,
+ ScheduleOfPayments = 100000000,
+ ComissionRub = 46000,
+ PlPrice = 2300000,
+ Discount = 115000,
+ AcceptSum = 2185000,
+ PlYear = 0,
+ CarCapacity = 0,
+ MotorVolume = 0,
+ PlEngineType = 0,
+ CarCarrying = 0,
+ AgentsSum = 13885.675,
+ DoubleAgentsSum = 16662.81,
+ DeliverySum = 15295,
+ BrokerSum = 17480,
+ BrokerOfDeliverySum = 19665,
+ FinancialDeptOfDeliverySum = 21850,
+ ImporterSum = 19166.6666666667,
+ Bonus = 0.011,
+ BonusFix = 0,
+ MarketRate = 0.01,
+ DistrictRate = 0.02,
+ SalaryRate = 0.3,
+ RatBonus = 210,
+ NsBonus = 210,
+ NsibBonus = 592.64688,
+ Rats = 7000,
+ BaseRatCost = 7000,
+ RetroBonus = 3500,
+ Registration = 3000,
+ BaseRegistration = 2570,
+ TransTax = 0,
+ TransIncludeGr = true,
+ TransportTaxGrYear = 35000,
+ TransportTaxGr = 46666.6666666667,
+ TrackerCost = 15000,
+ TLMCost = 22000,
+ InsuranceKasko = 85548,
+ NmperInsurance = 16,
+ InsuranceOsago = 12560,
+ Insurance = 98108,
+ InsuranceKaskoNmper = 213870,
+ InsuranceContract = 226430,
+ InsuranceBonus = 0,
+ NsibBase = 2116596,
+ NsibBrutto = 19754.896,
+ NsibNetto = 2822.128,
+ Repayment = 0.25,
+ NmperDeprecation = 37,
+ DeprecationTime = 5.6,
+ CalculationCost = 2445108,
+ PriceUpTotal = 2703584.896,
+ AcquisitionExpenses = 2283678,
+ NpvBase = 1480794.596,
+ NiAtInception = 19166.6666666667,
+ BonusBase = 1513378.6,
+ BaseCost = 2586532.79187453,
+ };
+
+ var preparedPayments = new PreparedPayments()
+ {
+ Rows = new[]
+ {
+ new PaymentRow
+ {
+ NumberPayment = 1,
+ PercentPayment = 0.00,
+ GpsBasePayment = 0.00,
+ GpsCostPayment = 0.00,
+ TlmBasePayment = 0.00,
+ TlmCostPayment = 0.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 2,
+ PercentPayment = 100.00,
+ GpsBasePayment = 1500.00,
+ GpsCostPayment = 1800.00,
+ TlmBasePayment = 1220.00,
+ TlmCostPayment = 1500.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 3,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 4,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 5,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 6,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 7,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 8,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 9,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 10,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 11,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 12,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 13,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 14,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 15,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ new PaymentRow
+ {
+ NumberPayment = 16,
+ PercentPayment = 100.00,
+ GpsBasePayment = 750.00,
+ GpsCostPayment = 900.00,
+ TlmBasePayment = 610.00,
+ TlmCostPayment = 800.00
+ },
+ }
+ };
+ var requestCalculation = new RequestCalculation()
+ {
+ preparedValues = preparedValues,
+ preparedPayments = preparedPayments
+ };
+
+ var calculationController = new CalculationController();
+ var res = calculationController.Calculate(requestCalculation);
+
+ using var file =
+ File.CreateText(String.Concat(@".\Logs\CalculationController"
+ , "_"
+ , "v1"
+ , "_"
+ , "test1"
+ , "_"
+ , DateTime.Now.ToString("dd.MM.yyyy_hh.mm.ss")
+ , ".json"));
+ var serializer = new JsonSerializer();
+ serializer.Serialize(file, res);
+ }
+
+ [Fact]
+ public void Test2()
+ {
+ var preparedValues = new PreparedValues()
+ {
+ CalcDate = new DateTime(2020, 1, 1),
+ IrrExpected = 0.22,
+ NpvniExpected = 0.05,
+ TotalExpected = 0,
+ Leasing0K = 1,
+ LoanRate = 0.07,
+ BalanceHolder = 100000001,
+ DogDate = new DateTime(2020, 10, 22),
+ DeliveryTime = 100000000,
+ Nmper = 30,
+ FirstPayment = 0.25,
+ FirstPaymentSum = 875000,
+ FirstPaymentAbs = 0,
+ FirstPaymentNdsAbs = 0,
+ FirstPaymentWithNdsAbs = 0,
+ LastPayment = 0.01,
+ LastPaymentSum = 35000,
+ ScheduleOfPayments = 100000000,
+ ComissionRub = 0,
+ PlPrice = 3500000,
+ Discount = 175000,
+ AcceptSum = 3325000,
+ PlYear = 0,
+ CarCapacity = 0,
+ MotorVolume = 0,
+ PlEngineType = 0,
+ CarCarrying = 0,
+ AgentsSum = 21130.375,
+ DoubleAgentsSum = 25356.45,
+ DeliverySum = 23275,
+ BrokerSum = 26600,
+ BrokerOfDeliverySum = 29925,
+ FinancialDeptOfDeliverySum = 33250,
+ ImporterSum = 19166.6666666667,
+ Bonus = 0.011,
+ BonusFix = 0,
+ MarketRate = 0.01,
+ DistrictRate = 0.02,
+ SalaryRate = 0.3,
+ RatBonus = 210,
+ NsBonus = 210,
+ NsibBonus = 121.74786,
+ Rats = 7000,
+ BaseRatCost = 7000,
+ RetroBonus = 3500,
+ Registration = 3000,
+ BaseRegistration = 2570,
+ TransTax = 0,
+ TransIncludeGr = true,
+ TransportTaxGrYear = 35000,
+ TransportTaxGr = 87500,
+ TrackerCost = 15000,
+ TLMCost = 22000,
+ InsuranceKasko = 85548,
+ NmperInsurance = 12,
+ InsuranceOsago = 12560,
+ Insurance = 98108,
+ InsuranceKaskoNmper = 85548,
+ InsuranceContract = 98108,
+ InsuranceBonus = 37089.8791666667,
+ NsibBase = 3246609.6,
+ NsibBrutto = 4058.262,
+ NsibNetto = 7304.8716,
+ Repayment = 0.25,
+ NmperDeprecation = 37,
+ DeprecationTime = 5.6,
+ CalculationCost = 3645108,
+ PriceUpTotal = 3759566.262,
+ AcquisitionExpenses = 3469678,
+ NpvBase = 2597599.94864,
+ NiAtInception = 19166.6666666667,
+ BonusBase = 2548108,
+ BaseCost = 3689559.59284717,
+ };
+
+ var preparedPayments = new PreparedPayments()
+ {
+ Rows = new[]
+ {
+ new PaymentRow
+ {
+ NumberPayment = 1,
+
+ PercentPayment = 0.00,
+
+ GpsBasePayment = 0.00,
+
+ GpsCostPayment = 0.00,
+
+ TlmBasePayment = 0.00,
+
+ TlmCostPayment = 0.00
+ },
+
+ new PaymentRow
+ {
+ NumberPayment = 2,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 1500.00,
+
+ GpsCostPayment = 1800.00,
+
+ TlmBasePayment = 1220.00,
+
+ TlmCostPayment = 1500.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 3,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 4,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 5,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 6,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 7,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 8,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 9,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 10,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 11,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 12,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 13,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 14,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 15,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 16,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 17,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 18,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 19,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 20,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 21,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 22,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 23,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 24,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 25,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 26,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 27,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 28,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 29,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+
+ new PaymentRow
+
+ {
+ NumberPayment = 30,
+
+ PercentPayment = 100.00,
+
+ GpsBasePayment = 750.00,
+
+ GpsCostPayment = 900.00,
+
+ TlmBasePayment = 610.00,
+
+ TlmCostPayment = 800.00
+ },
+ }
+ };
+ var requestCalculation = new RequestCalculation()
+ {
+ preparedValues = preparedValues,
+ preparedPayments = preparedPayments
+ };
+
+ var calculationController = new CalculationController();
+ var res = calculationController.Calculate(requestCalculation);
+
+ using var file =
+ File.CreateText(String.Concat(@".\Logs\CalculationController"
+ , "_"
+ , "v1"
+ , "_"
+ , "test2"
+ , "_"
+ , DateTime.Now.ToString("dd.MM.yyyy_hh.mm.ss")
+ , ".json"));
+ var serializer = new JsonSerializer();
+ serializer.Serialize(file, res);
+ }
+ }
+}
\ No newline at end of file
diff --git a/EvoCalculator.Core.Tests/Calculation/FinanceFormulas/FinanceFormulasTests.cs b/EvoCalculator.Core.Tests/Calculation/FinanceFormulas/FinanceFormulasTests.cs
index 75d0d7e..13d322e 100644
--- a/EvoCalculator.Core.Tests/Calculation/FinanceFormulas/FinanceFormulasTests.cs
+++ b/EvoCalculator.Core.Tests/Calculation/FinanceFormulas/FinanceFormulasTests.cs
@@ -2,11 +2,10 @@
using System.Linq;
using EvoCalculator.Core.FinanceFormulas;
using EvoCalculator.Core.Models.Calculation.Models;
-using TridentGoalSeek;
using Xunit;
using Xunit.Abstractions;
-namespace EvoCalculator.Core.Tests.Calculation.Suite
+namespace EvoCalculator.Core.Tests.Calculation.FinanceFormulas
{
public class FinanceFormulasTests
{
diff --git a/EvoCalculator.Core.Tests/EvoCalculator.Core.Tests.csproj b/EvoCalculator.Core.Tests/EvoCalculator.Core.Tests.csproj
index bc8cb62..b6fd66a 100644
--- a/EvoCalculator.Core.Tests/EvoCalculator.Core.Tests.csproj
+++ b/EvoCalculator.Core.Tests/EvoCalculator.Core.Tests.csproj
@@ -8,6 +8,7 @@
+
@@ -18,8 +19,4 @@
-
-
-
-
diff --git a/EvoCalculator.Core/Controllers/v1/CalculationController.cs b/EvoCalculator.Core/Controllers/v1/CalculationController.cs
new file mode 100644
index 0000000..9e9b598
--- /dev/null
+++ b/EvoCalculator.Core/Controllers/v1/CalculationController.cs
@@ -0,0 +1,167 @@
+using System;
+using EvoCalculator.Core.Calculation.Columns;
+using EvoCalculator.Core.Models.Calculation.Models.Request;
+using Microsoft.AspNetCore.Mvc;
+
+namespace EvoCalculator.Core.Controllers.V1
+{
+ [ApiController]
+ [ApiVersion("1.0")]
+ [Route("api/v{version:apiVersion}/[controller]")]
+ public class CalculationController : Controller
+ {
+ [HttpPost]
+ public ActionResult