From 17bdca11843ce06912b4871edc4484ac7b6f51b6 Mon Sep 17 00:00:00 2001
From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com>
Date: Mon, 14 Jan 2019 12:09:58 +0900
Subject: [PATCH] 30day sales to dashboard

---
 Core/DataObjects/ProfitTrailerData.cs     |  8 ++++++++
 Monitor/Pages/_get/DashboardBottom.cshtml | 14 ++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/Core/DataObjects/ProfitTrailerData.cs b/Core/DataObjects/ProfitTrailerData.cs
index 045fe37..1def18e 100644
--- a/Core/DataObjects/ProfitTrailerData.cs
+++ b/Core/DataObjects/ProfitTrailerData.cs
@@ -101,6 +101,14 @@ namespace Core.Main.DataObjects
       }
     }
 
+    public List<SellLogData> SellLogLast30Days
+    {
+      get
+      {
+        return _sellLog.FindAll(sl => sl.SoldDate.Date >= _dateTimeNow.DateTime.AddDays(-30).Date);
+      }
+    }
+
     public List<DCALogData> DCALog
     {
       get
diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml b/Monitor/Pages/_get/DashboardBottom.cshtml
index 6b5b588..585f0cd 100644
--- a/Monitor/Pages/_get/DashboardBottom.cshtml
+++ b/Monitor/Pages/_get/DashboardBottom.cshtml
@@ -70,6 +70,13 @@
         double last7DaysProfit = Model.PTData.SellLogLast7Days.Sum(s => s.Profit);
         double last7DaysProfitFiat = Math.Round(last7DaysProfit * Model.Summary.MainMarketPrice, 2);
         double last7DaysPercentGain = Math.Round(last7DaysProfit / last7DaysStartBalance * 100, 2);
+
+        double last30DaysStartBalance = Model.PTData.GetSnapshotBalance(Model.DateTimeNow.DateTime.AddDays(-30));
+        double last30DaysProfit = Model.PTData.SellLogLast30Days.Sum(s => s.Profit);
+        double last30DaysProfitFiat = Math.Round(last30DaysProfit * Model.Summary.MainMarketPrice, 2);
+        double last30DaysPercentGain = Math.Round(last30DaysProfit / last30DaysStartBalance * 100, 2);
+      }
+
       }
 
       <table class="table table-sm">
@@ -104,6 +111,13 @@
             <td class="text-right text-autocolor">@Html.Raw(Model.MainFiatCurrencySymbol + last7DaysProfitFiat.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")))</td>
             <td class="text-right text-autocolor">@last7DaysPercentGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))%</td>
           </tr>
+          <tr>
+            <th>Last 30 Days</th>
+            <td class="text-right">@Model.PTData.SellLogLast30Days.Count</td>
+            <td class="text-right text-autocolor">@last30DaysProfit.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
+            <td class="text-right text-autocolor">@Html.Raw(Model.MainFiatCurrencySymbol + last30DaysProfitFiat.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")))</td>
+            <td class="text-right text-autocolor">@last30DaysPercentGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))%</td>
+          </tr>
           <tr>
             <th>Total</th>
             <td class="text-right">@Model.PTData.SellLog.Count</td>