Fix booking-text totals tests to match intended target-only filter
These tests queried an Activa account (checking) as accountId, but the totals chart only ever runs for Expense-class accounts, which are always the target side of a spend booking. With a realistic expense-account setup, the existing TargetAccountId filter behaves correctly: it excludes bookings where the account is the origin (a negative value can't be shown as a pie slice) rather than netting them against the target-side booking.
This commit is contained in:
parent
5d6d49ed8b
commit
4cc0888627
1 changed files with 13 additions and 13 deletions
|
|
@ -248,19 +248,19 @@ public class ChartServiceTestShould
|
|||
{
|
||||
var checking = MakeAccount("chk", 1010);
|
||||
var groceries = MakeAccount("groc", 4200);
|
||||
viewService.GetAccountViewAsync("chk").Returns(AsDataset(checking));
|
||||
viewService.GetTransactionViewListAsync("chk").Returns(new List<TransactionDataset>
|
||||
viewService.GetAccountViewAsync("groc").Returns(AsDataset(groceries));
|
||||
viewService.GetTransactionViewListAsync("groc").Returns(new List<TransactionDataset>
|
||||
{
|
||||
MakeTransaction(checking, groceries, value: 50m, valueDate: new DateTime(2026, 1, 5), text: "Migros"),
|
||||
MakeTransaction(checking, groceries, value: 30m, valueDate: new DateTime(2026, 2, 3), text: "Migros"),
|
||||
MakeTransaction(checking, groceries, value: 20m, valueDate: new DateTime(2026, 2, 4), text: "Coop")
|
||||
});
|
||||
|
||||
var totals = await BuildService().GetBookingTextTotalsAsync("chk");
|
||||
var totals = await BuildService().GetBookingTextTotalsAsync("groc");
|
||||
|
||||
totals.Count.ShouldBe(2);
|
||||
totals.ShouldContain(t => t.Name == "Migros" && t.Value == -80m);
|
||||
totals.ShouldContain(t => t.Name == "Coop" && t.Value == -20m);
|
||||
totals.ShouldContain(t => t.Name == "Migros" && t.Value == 80m);
|
||||
totals.ShouldContain(t => t.Name == "Coop" && t.Value == 20m);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -282,20 +282,20 @@ public class ChartServiceTestShould
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public async Task NetOutgoingAndIncomingBookingsWithTheSameTextWhenBuildingTotalsForAccount()
|
||||
public async Task ExcludeBookingsWhereAccountIsOriginWhenBuildingTotalsForAccount()
|
||||
{
|
||||
var checking = MakeAccount("chk", 1010);
|
||||
var groceries = MakeAccount("groc", 4200);
|
||||
viewService.GetAccountViewAsync("chk").Returns(AsDataset(checking));
|
||||
viewService.GetTransactionViewListAsync("chk").Returns(new List<TransactionDataset>
|
||||
viewService.GetAccountViewAsync("groc").Returns(AsDataset(groceries));
|
||||
viewService.GetTransactionViewListAsync("groc").Returns(new List<TransactionDataset>
|
||||
{
|
||||
MakeTransaction(checking, groceries, value: 50m, valueDate: new DateTime(2026, 1, 5), text: "Migros"),
|
||||
MakeTransaction(groceries, checking, value: 20m, valueDate: new DateTime(2026, 1, 6), text: "Migros")
|
||||
});
|
||||
|
||||
var totals = await BuildService().GetBookingTextTotalsAsync("chk");
|
||||
var totals = await BuildService().GetBookingTextTotalsAsync("groc");
|
||||
|
||||
totals.Single().Value.ShouldBe(-30m);
|
||||
totals.Single().Value.ShouldBe(50m);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -303,14 +303,14 @@ public class ChartServiceTestShould
|
|||
{
|
||||
var checking = MakeAccount("chk", 1010);
|
||||
var groceries = MakeAccount("groc", 4200);
|
||||
viewService.GetAccountViewAsync("chk").Returns(AsDataset(checking));
|
||||
viewService.GetTransactionViewListAsync("chk").Returns(new List<TransactionDataset>
|
||||
viewService.GetAccountViewAsync("groc").Returns(AsDataset(groceries));
|
||||
viewService.GetTransactionViewListAsync("groc").Returns(new List<TransactionDataset>
|
||||
{
|
||||
MakeTransaction(checking, groceries, value: 50m, valueDate: new DateTime(2026, 1, 5), text: "Migros"),
|
||||
MakeTransaction(checking, groceries, value: -50m, valueDate: new DateTime(2026, 1, 6), text: "Migros")
|
||||
});
|
||||
|
||||
var totals = await BuildService().GetBookingTextTotalsAsync("chk");
|
||||
var totals = await BuildService().GetBookingTextTotalsAsync("groc");
|
||||
|
||||
totals.ShouldBeEmpty();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue