Skip to content

Refactor savings tax calculation and breakdown#13

Merged
raymondjstone merged 1 commit into
masterfrom
develop
May 3, 2026
Merged

Refactor savings tax calculation and breakdown#13
raymondjstone merged 1 commit into
masterfrom
develop

Conversation

@raymondjstone
Copy link
Copy Markdown
Owner

Refactored CalculateSavingsTax to accept TaxCalculationResult and generate detailed breakdown lines for each savings tax band. Moved savings tax breakdown logic into the method, ensuring rUK/Welsh bands are always used and improving transparency in tax calculation results.

Refactored CalculateSavingsTax to accept TaxCalculationResult and generate detailed breakdown lines for each savings tax band. Moved savings tax breakdown logic into the method, ensuring rUK/Welsh bands are always used and improving transparency in tax calculation results.
Copilot AI review requested due to automatic review settings May 3, 2026 16:59
@raymondjstone raymondjstone merged commit 8879042 into master May 3, 2026
2 of 3 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the savings tax calculation to generate a more detailed, per-band savings tax breakdown directly inside CalculateSavingsTax, and wires the breakdown into the overall TaxCalculationResult.

Changes:

  • Updated CalculateSavingsTax to accept TaxCalculationResult and append detailed savings breakdown lines.
  • Replaced the previous single “Tax on Savings” breakdown insertion at the call site with breakdown generation inside CalculateSavingsTax.
  • Switched savings tax band selection to explicitly avoid Scottish bands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Services/TaxCalculator.cs
Comment on lines +405 to +408
decimal incomeSoFar = taxableNonSavings;
int bandIdx = 0;
while (bandIdx < bands.Count && bands[bandIdx].UpperGrossThreshold > 0 && incomeSoFar >= bands[bandIdx].UpperGrossThreshold)
bandIdx++;
Comment thread Services/TaxCalculator.cs
Comment on lines +412 to +416
var band = bands[bandIdx];
decimal bandUpper = band.UpperGrossThreshold > 0 ? band.UpperGrossThreshold : decimal.MaxValue;
decimal bandWidth = bandUpper - incomeSoFar;
decimal inBand = Math.Min(savingsRemaining, bandWidth);
if (inBand > 0)
Comment thread Services/TaxCalculator.cs
Comment on lines +404 to +405
// Find the taxable income position where savings start
decimal incomeSoFar = taxableNonSavings;
Comment thread Services/TaxCalculator.cs

decimal startingRateAvailable = 0;
// 1. Starting rate for savings (if non-savings income after PA is below limit)
decimal nonSavingsAbovePA = Math.Max(0, nonSavingsIncome - rules.PersonalAllowance);
Comment thread Services/TaxCalculator.cs
Comment on lines +374 to +376
// Collect breakdown lines for savings in a temporary list
var savingsBreakdown = new List<TaxBreakdownLine>();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants