Skip to content

Commit

Permalink
✨ New column on Consolidate Controller to show the movements amount p…
Browse files Browse the repository at this point in the history
…er day.
  • Loading branch information
brunovicenteb committed Mar 16, 2023
1 parent 79f7739 commit c4b153e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Application/Interfaces/IMovementAppService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public interface IMovementAppService
Task<IEnumerable<MovementViewModel>> GetAllAsync();
Task<IEnumerable<MovementViewModel>> GetTodayMovimentationAsync();
Task<IEnumerable<MovementTypeViewModel>> GetAllTypesAsync();
Task<IEnumerable<Tuple<DateTime, decimal>>> GetTotalizersAsync();
Task<IEnumerable<Tuple<DateTime, decimal, int>>> GetTotalizersAsync();
Task<MovementViewModel> GetByIdAsync(int id);
Task<bool> DeleteAsync(int id);
Task<MovementViewModel> CreateAsync(MovementViewModel movement);
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Services/MovementAppService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task<bool> DeleteAsync(int id)
=> await _repository.DeleteAsync(id);


public async Task<IEnumerable<Tuple<DateTime, decimal>>> GetTotalizersAsync()
public async Task<IEnumerable<Tuple<DateTime, decimal, int>>> GetTotalizersAsync()
=> await _repository.GetTotalizersAsync();

public async Task<MovementViewModel> CreateAsync(MovementViewModel movement)
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Interfaces/IMovementRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public interface IMovementRepository : IBaseRepository<Movement>

Task<IEnumerable<Movement>> GetTodayMovimentationAsync();

Task<IEnumerable<Tuple<DateTime, decimal>>> GetTotalizersAsync();
Task<IEnumerable<Tuple<DateTime, decimal, int>>> GetTotalizersAsync();
}
4 changes: 2 additions & 2 deletions src/Infra/Data/Repository/MovementRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public async Task<IEnumerable<Movement>> GetTodayMovimentationAsync()
.ToListAsync();
}

public async Task<IEnumerable<Tuple<DateTime, decimal>>> GetTotalizersAsync()
public async Task<IEnumerable<Tuple<DateTime, decimal, int>>> GetTotalizersAsync()
{
var resultSet = await GetAllAsync();
return resultSet
.GroupBy(row => new { row.CreatedAt.Value.Date })
.Select(g => new Tuple<DateTime, decimal>(g.Key.Date, g.Sum(o => o.Value)))
.Select(g => new Tuple<DateTime, decimal, int>(g.Key.Date, g.Sum(o => o.Value), g.Count()))
.OrderByDescending(o => o.Item1);
}

Expand Down
4 changes: 3 additions & 1 deletion src/Presentation/Views/Consolidate/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@using Mttechne.Toolkit;
@using Mttechne.Application.ViewModel;
@model IEnumerable<Tuple<DateTime, decimal>>
@model IEnumerable<Tuple<DateTime, decimal,int>>
@{
ViewBag.Subtitulo = "Consolidate";
}
Expand All @@ -20,6 +20,7 @@
<thead>
<tr>
<th>Date</th>
<th>Ammount movements on day</th>
<th>Balance</th>
</tr>
</thead>
Expand All @@ -28,6 +29,7 @@
{
<tr>
<td>@item.Item1.ToString("dd/MM/yyyy")</td>
<td>@item.Item3</td>
<td><strong><span class="@(@item.Item2 >= 0 ? "text-success": "text-danger")">@item.Item2.ToEnglishString()</span></strong></td>
</tr>
}
Expand Down

0 comments on commit c4b153e

Please sign in to comment.