Skip to content

Refactor run_taxation result tuple to struct - #156

Merged
jczaja merged 3 commits into
mainfrom
sfraczek/refactor-tuple
Jun 28, 2025
Merged

Refactor run_taxation result tuple to struct#156
jczaja merged 3 commits into
mainfrom
sfraczek/refactor-tuple

Conversation

@sfraczek

Copy link
Copy Markdown
Collaborator

Introduced struct TaxCalculationResult instead of large tuple returned from run_taxation

Introduced struct TaxCalculationResult instead of large tuple returned
from run_taxation
@sfraczek
sfraczek requested review from Copilot and jczaja June 26, 2025 13:27
@sfraczek sfraczek added the enhancement New feature or request label Jun 26, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 return value of run_taxation from a large tuple into a named TaxCalculationResult struct for improved clarity and maintainability.

  • Introduced TaxCalculationResult struct and updated run_taxation signature and return.
  • Updated callers in main.rs and gui.rs to 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_div implies it's only dividend tax, but it now represents total tax. Rename to tax or total_tax for 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 TaxCalculationResult lacks 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, .. }) => {

Comment thread src/main.rs Outdated
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) {

Copilot AI Jun 26, 2025

Copy link

Choose a reason for hiding this comment

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

[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.

Copilot uses AI. Check for mistakes.
Comment thread src/lib.rs Outdated
transactions: transactions,
revolut_dividends_transactions: revolut_dividends_transactions,
sold_transactions: sold_transactions,
revolut_sold_transactions: revolut_sold_transactions})

Copilot AI Jun 26, 2025

Copy link

Choose a reason for hiding this comment

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

[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,})

Copilot uses AI. Check for mistakes.
Comment thread src/lib.rs Outdated
@sfraczek
sfraczek force-pushed the sfraczek/refactor-tuple branch from cd3fc03 to 3a1cf87 Compare June 26, 2025 13:57
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@jczaja jczaja left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@jczaja
jczaja merged commit a0c190d into main Jun 28, 2025
5 checks passed
@sfraczek
sfraczek deleted the sfraczek/refactor-tuple branch June 29, 2025 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants