Skip to content

Commit

Permalink
Fix zero and last item
Browse files Browse the repository at this point in the history
  • Loading branch information
liguori committed Mar 5, 2024
1 parent efc2b67 commit d1c9818
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Savings.SPA/Pages/Projection.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,22 @@ async Task InitializeList()
{
materializedMoneyItems = await savingsAPI.GetSavings(null, FilterDateTo);

MaterializedMoneyItem? lastBeforeToday = null;
//Remove first zero
if (!ShowZero)
{
materializedMoneyItems = materializedMoneyItems.Where(x => x.Amount != 0).ToArray();
}

//The decide to remove past items (when zero is already excluded)
if (!ShowPastItems)
{
lastBeforeToday = materializedMoneyItems.LastOrDefault(x => x.Date <= DateTime.Now.Date);
var lastBeforeToday = materializedMoneyItems.LastOrDefault(x => x.Date <= DateTime.Now.Date);
if (lastBeforeToday != null)
{
materializedMoneyItems = materializedMoneyItems[Array.IndexOf(materializedMoneyItems, lastBeforeToday)..];
}
}
if(!ShowZero)
{
materializedMoneyItems = materializedMoneyItems.Where(x => x.Amount != 0 || x.ID == lastBeforeToday?.ID).ToArray();
}

}

async Task AdjustRecurrency(MaterializedMoneyItem item)
Expand Down

0 comments on commit d1c9818

Please sign in to comment.