Skip to content

Conversation

Sajjon
Copy link
Owner

@Sajjon Sajjon commented Jul 11, 2025

No description provided.

@Sajjon Sajjon requested a review from Copilot July 11, 2025 19:39
Copy link

@Copilot 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

This PR generalizes the invoice period logic by introducing an IsPeriod trait and replacing all hard-coded monthly concepts with a generic Period parameter that can be monthly or fortnightly. Key changes include:

  • Refactored ValidInput, Data, ProtoInvoiceInfo, and related functions to use period generically instead of month.
  • Added a new YearMonthAndFortnight submodel and PeriodAnno enum to support bi-weekly invoicing alongside monthly.
  • Updated error variants, snapshots, CLI commands, and tests to cover the new generic period abstraction.

Reviewed Changes

Copilot reviewed 65 out of 67 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/core/src/models/data/submodels/is_period.rs Introduces the IsPeriod trait and PeriodMarker marker interface.
crates/core/src/models/data/submodels/year_month_and_fortnight.rs Adds the fortnight period type and its IsPeriod implementation.
crates/core/src/models/valid_input.rs Makes ValidInput generic on Period and renames month to period.
crates/core/src/models/data/data.rs Makes Data generic on Period and replaces expensed_months with expensed_periods.
crates/cli/src/dispatch_command.rs Updates CLI commands to handle generic periods instead of months.
crates/cli/src/input/tui.rs Adds build_period to prompt for monthly or bi-weekly periods.
crates/render/src/render_test_helpers.rs Adjusts PDF comparison helpers to be generic over Period.
Comments suppressed due to low confidence (3)

crates/core/src/models/data/submodels/year_month_and_fortnight.rs:36

  • Add unit tests for elapsed_periods_since and to_date_end_of_period to validate the new fortnight-period logic.
impl YearMonthAndFortnight {

Comment on lines 173 to 188
// match cadence {
// Cadence::Monthly => if let Some(default) = default {
// match default {
// PeriodAnno::YearAndMonth(ym) => {
// build_year_month_inner(help, Some(*ym.year()), Some(*ym.month()))
// }
// PeriodAnno::YearMonthAndFortnight(_) => {
// panic!("Expected YearAndMonth since Cadence is Monthly")
// }
// }
// } else {
// build_year_month_inner(help, None, None)
// }
// .map(|ok| ok.map(PeriodAnno::from)),
// Cadence::BiWeekly => build_year_month_inner(),
// }
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider removing or refactoring the large commented-out block to improve readability and maintainability of the period-building logic.

Suggested change
// match cadence {
// Cadence::Monthly => if let Some(default) = default {
// match default {
// PeriodAnno::YearAndMonth(ym) => {
// build_year_month_inner(help, Some(*ym.year()), Some(*ym.month()))
// }
// PeriodAnno::YearMonthAndFortnight(_) => {
// panic!("Expected YearAndMonth since Cadence is Monthly")
// }
// }
// } else {
// build_year_month_inner(help, None, None)
// }
// .map(|ok| ok.map(PeriodAnno::from)),
// Cadence::BiWeekly => build_year_month_inner(),
// }
// Removed redundant commented-out block for improved readability and maintainability.

Copilot uses AI. Check for mistakes.

Copy link

codecov bot commented Jul 11, 2025

Codecov Report

Attention: Patch coverage is 93.01075% with 39 lines in your changes missing coverage. Please review.

Project coverage is 94.33%. Comparing base (9bf70d7) to head (a17c853).
Report is 1 commits behind head on invoice_cadence_and_granularity.

Files with missing lines Patch % Lines
crates/core/src/logic/calendar_logic.rs 83.72% 14 Missing ⚠️
crates/core/src/models/data/data.rs 79.48% 8 Missing ⚠️
...rates/core/src/models/data/submodels/month_half.rs 80.76% 5 Missing ⚠️
...ates/core/src/models/data/submodels/period_anno.rs 85.71% 4 Missing ⚠️
.../models/data/submodels/year_month_and_fortnight.rs 94.23% 3 Missing ⚠️
...ore/src/logic/encryption/encrypted_app_password.rs 71.42% 2 Missing ⚠️
crates/core/src/models/data/submodels/cadence.rs 0.00% 2 Missing ⚠️
crates/cli/src/input/time_off_input.rs 90.00% 1 Missing ⚠️
Additional details and impacted files
@@                         Coverage Diff                         @@
##           invoice_cadence_and_granularity      #22      +/-   ##
===================================================================
- Coverage                            95.80%   94.33%   -1.47%     
===================================================================
  Files                                   79       88       +9     
  Lines                                 1717     2084     +367     
===================================================================
+ Hits                                  1645     1966     +321     
- Misses                                  72      118      +46     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Sajjon Sajjon merged commit a0e65e2 into invoice_cadence_and_granularity Jul 13, 2025
3 of 5 checks passed
@Sajjon Sajjon deleted the cadence_rate_logic branch July 13, 2025 17:53
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.

1 participant