-
Notifications
You must be signed in to change notification settings - Fork 4
Cadence rate logic #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 useperiod
generically instead ofmonth
. - Added a new
YearMonthAndFortnight
submodel andPeriodAnno
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
andto_date_end_of_period
to validate the new fortnight-period logic.
impl YearMonthAndFortnight {
crates/cli/src/input/tui.rs
Outdated
// 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(), | ||
// } |
There was a problem hiding this comment.
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.
// 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.
Codecov ReportAttention: Patch coverage is
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. 🚀 New features to boost your workflow:
|
No description provided.