Browse Source

Fixed stats error (removed transactions)

feature/billing
Teknikode 7 months ago
parent
commit
c5bcbadf2a
  1. 89
      Teknik/Areas/Stats/Controllers/StatsController.cs
  2. 4
      Teknik/Areas/Stats/Views/Stats/Index.cshtml

89
Teknik/Areas/Stats/Controllers/StatsController.cs

@ -46,95 +46,6 @@ namespace Teknik.Areas.Stats.Controllers @@ -46,95 +46,6 @@ namespace Teknik.Areas.Stats.Controllers
model.VaultCount = _dbContext.Vaults.Count();
#endregion
// Get Transaction Inforomation
#region Transactions
DateTime curTime = DateTime.Now;
var billSums = _dbContext.Transactions.OfType<Bill>().GroupBy(b => new { b.Currency, b.DateSent.Month, b.DateSent.Year }).Select(b => new { month = b.Key.Month, year = b.Key.Year, currency = b.Key.Currency, total = b.Sum(c => c.Amount) }).ToList();
foreach (var sum in billSums)
{
decimal exchangeRate = CurrencyHelper.GetExchangeRate(sum.currency);
decimal realValue = sum.total * exchangeRate;
model.Transactions.TotalBills += realValue;
model.Transactions.TotalNet += realValue;
if (curTime.Month == sum.month && curTime.Year == sum.year)
{
model.Transactions.CurrentMonthBills += Math.Abs(realValue);
}
}
var oneSums = _dbContext.Transactions.OfType<OneTime>().GroupBy(b => new { b.Currency, b.DateSent.Month, b.DateSent.Year }).Select(b => new { month = b.Key.Month, year = b.Key.Year, currency = b.Key.Currency, total = b.Sum(c => c.Amount) }).ToList();
foreach (var sum in oneSums)
{
decimal exchangeRate = CurrencyHelper.GetExchangeRate(sum.currency);
decimal realValue = sum.total * exchangeRate;
model.Transactions.TotalOneTimes += realValue;
model.Transactions.TotalNet += realValue;
if (curTime.Month == sum.month && curTime.Year == sum.year)
{
model.Transactions.CurrentMonthBills += Math.Abs(realValue);
}
}
var donationSums = _dbContext.Transactions.OfType<Donation>().GroupBy(b => new { b.Currency, b.DateSent.Month, b.DateSent.Year }).Select(b => new { month = b.Key.Month, year = b.Key.Year, currency = b.Key.Currency, total = b.Sum(c => c.Amount) }).ToList();
foreach (var sum in donationSums)
{
decimal exchangeRate = CurrencyHelper.GetExchangeRate(sum.currency);
decimal realValue = sum.total * exchangeRate;
model.Transactions.TotalDonations += realValue;
model.Transactions.TotalNet += realValue;
if (curTime.Month == sum.month && curTime.Year == sum.year)
{
model.Transactions.CurrentMonthIncome += Math.Abs(realValue);
}
}
List<Bill> bills = _dbContext.Transactions.OfType<Bill>().OrderByDescending(b => b.DateSent).ToList();
if (bills != null)
{
foreach (Bill bill in bills)
{
BillViewModel billModel = new BillViewModel();
billModel.Amount = bill.Amount;
billModel.Currency = bill.Currency;
billModel.Reason = bill.Reason;
billModel.DateSent = bill.DateSent;
billModel.Recipient = bill.Recipient;
model.Transactions.Bills.Add(billModel);
}
}
List<OneTime> oneTimes = _dbContext.Transactions.OfType<OneTime>().OrderByDescending(b => b.DateSent).ToList();
if (oneTimes != null)
{
foreach (OneTime oneTime in oneTimes)
{
OneTimeViewModel oneTimeModel = new OneTimeViewModel();
oneTimeModel.Amount = oneTime.Amount;
oneTimeModel.Currency = oneTime.Currency;
oneTimeModel.Reason = oneTime.Reason;
oneTimeModel.DateSent = oneTime.DateSent;
oneTimeModel.Recipient = oneTime.Recipient;
model.Transactions.OneTimes.Add(oneTimeModel);
}
}
List<Donation> donations = _dbContext.Transactions.OfType<Donation>().OrderByDescending(b => b.DateSent).ToList();
if (donations != null)
{
foreach (Donation donation in donations)
{
DonationViewModel donationModel = new DonationViewModel();
donationModel.Amount = donation.Amount;
donationModel.Currency = donation.Currency;
donationModel.Reason = donation.Reason;
donationModel.DateSent = donation.DateSent;
donationModel.Sender = donation.Sender;
model.Transactions.Donations.Add(donationModel);
}
}
#endregion
// Takedown information
#region Takedowns
List<Takedown> takedowns = _dbContext.Takedowns.OrderByDescending(b => b.DateRequested).ToList();

4
Teknik/Areas/Stats/Views/Stats/Index.cshtml

@ -15,7 +15,6 @@ @@ -15,7 +15,6 @@
{
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#site-stats" role="tab" data-toggle="tab">Site Statistics</a></li>
<li role="presentation"><a href="#transactions" role="tab" data-toggle="tab">Transactions</a></li>
<li role="presentation"><a href="#takedowns" role="tab" data-toggle="tab">Takedowns</a></li>
</ul>
@ -58,9 +57,6 @@ @@ -58,9 +57,6 @@
</div>
</div>
<div role="tabpanel" class="tab-pane" id="transactions">
@await Html.PartialAsync("~/Areas/Stats/Views/Stats/Transactions.cshtml", Model.Transactions)
</div>
<div role="tabpanel" class="tab-pane" id="takedowns">
@await Html.PartialAsync("~/Areas/Stats/Views/Stats/Takedowns.cshtml", Model.Takedowns)
</div>

Loading…
Cancel
Save