Refactor run_taxation result tuple to struct - #156
Merged
Conversation
Introduced struct TaxCalculationResult instead of large tuple returned from run_taxation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Refactors the return value of run_taxation from a large tuple into a named TaxCalculationResult struct for improved clarity and maintainability.
- Introduced
TaxCalculationResultstruct and updatedrun_taxationsignature and return. - Updated callers in
main.rsandgui.rsto destructure the new struct. - Adjusted test cases to match the new return type.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/lib.rs | Added TaxCalculationResult struct; changed run_taxation to return it. |
| src/main.rs | Updated run_taxation call and destructuring in main and tests. |
| src/gui.rs | Refactored GUI logic to unpack TaxCalculationResult instead of tuple. |
Comments suppressed due to low confidence (3)
src/main.rs:85
- [nitpick] The variable
tax_divimplies it's only dividend tax, but it now represents total tax. Rename totaxortotal_taxfor clarity.
let TaxCalculationResult { gross_income: gross_div, tax: tax_div, gross_sold, cost_sold, .. } = match run_taxation(&rd, pdfnames) {
src/lib.rs:249
- Public struct
TaxCalculationResultlacks documentation. Add a doc comment summarizing its purpose and explaining each field.
pub struct TaxCalculationResult {
src/main.rs:312
- Tests currently only validate four fields of the struct. Consider adding assertions for the other fields (
interests,transactions, etc.) to ensure they are populated correctly.
Ok(TaxCalculationResult { gross_income: gross_div, tax: tax_div, gross_sold, cost_sold, .. }) => {
| Ok((gross_div, tax_div, gross_sold, cost_sold, _, _, _, _, _)) => { | ||
| (gross_div, tax_div, gross_sold, cost_sold) | ||
| } | ||
| let TaxCalculationResult { gross_income: gross_div, tax: tax_div, gross_sold, cost_sold, .. } = match run_taxation(&rd, pdfnames) { |
There was a problem hiding this comment.
[nitpick] The variable gross_div now holds total gross income (interests + dividends + revolut), which is misleading. Consider renaming it to gross_income or total_gross to reflect its new meaning.
| transactions: transactions, | ||
| revolut_dividends_transactions: revolut_dividends_transactions, | ||
| sold_transactions: sold_transactions, | ||
| revolut_sold_transactions: revolut_sold_transactions}) |
There was a problem hiding this comment.
[nitpick] Add a trailing comma after the last field in the struct initializer for cleaner diffs and consistency.
Suggested change
| revolut_sold_transactions: revolut_sold_transactions}) | |
| revolut_sold_transactions: revolut_sold_transactions,}) |
sfraczek
force-pushed
the
sfraczek/refactor-tuple
branch
from
June 26, 2025 13:57
cd3fc03 to
3a1cf87
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduced struct TaxCalculationResult instead of large tuple returned from run_taxation