Skip to content

Commit

Permalink
Fix nullable bug with txn bucket being legitamitely null - this is va…
Browse files Browse the repository at this point in the history
…lid before a bucket is manually entered by user.
  • Loading branch information
Benrnz committed Jan 7, 2025
1 parent 1d4409d commit 9c27c2a
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 236 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void AnalyseShouldReturnZeroLineElementsTotalingToZero()
[TestInitialize]
public void TestInitialise()
{
Act();
Act();
}

private void Act()
Expand Down
8 changes: 4 additions & 4 deletions BudgetAnalyser.Engine/Ledger/LedgerCalculation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ List<ReportTransaction> GetOverSpentTransactions() //private function
do
{
var currentDateCopy = currentDate;
foreach (var transaction in statement.Transactions.Where(t => t.Date == currentDateCopy))
foreach (var transaction in statement.Transactions.Where(t => t.Date == currentDateCopy && t.BudgetBucket is not null))
{
if (runningBalances.ContainsKey(transaction.BudgetBucket))
if (runningBalances.ContainsKey(transaction.BudgetBucket!))
{
runningBalances[transaction.BudgetBucket] += transaction.Amount;
runningBalances[transaction.BudgetBucket!] += transaction.Amount;
}
}

Expand Down Expand Up @@ -318,7 +318,7 @@ private decimal CalculateTransactionTotal(DateTime inclBeginDate, DateTime inclE
}
else
{
transactions = transactions.Where(t => t.BudgetBucket.Code == bucketCode);
transactions = transactions.Where(t => t.BudgetBucket is not null && t.BudgetBucket.Code == bucketCode);
}

this.logger.LogInfo(_ =>
Expand Down
2 changes: 1 addition & 1 deletion BudgetAnalyser.Engine/Statement/NamedTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public NamedTransaction(string name, bool isDebit = false)
IsDebit = isDebit;
}

public static NamedTransaction Empty => new NamedTransaction("");
public static NamedTransaction Empty => new NamedTransaction("default");

/// <summary>
/// Gets the transaction type name.
Expand Down
Loading

0 comments on commit 9c27c2a

Please sign in to comment.