-
Notifications
You must be signed in to change notification settings - Fork 8
Feature: implement fiscal year configuration with FYTD period #1540
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
Draft
BurningDog
wants to merge
13
commits into
we-promise:main
Choose a base branch
from
BurningDog:feature/define-a-financial-year
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
585f176
feat: added fiscal year
BurningDog 7f13542
test: fiscal years
BurningDog a548c98
feat: conditionally exclude FYTD when family has default fiscal year
BurningDog 5b2df58
feat: hide FYTD when fiscal year isn't used
BurningDog b6cfd3e
test: on the boundary
BurningDog 8a5dd3b
fix: unnecessary if
BurningDog c600b60
feat: check for available period
BurningDog d289893
test: nitpick
BurningDog 5fd41b7
feat: improvement
BurningDog af71b73
refactor: minor redundancy
BurningDog 5edbe40
fix: tests
BurningDog 83b563a
fix: available_key
BurningDog c053c27
revert: undo commits back to b6cfd3e
BurningDog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
14 changes: 14 additions & 0 deletions
14
db/migrate/20260421000000_add_fiscal_year_start_to_families.rb
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| class AddFiscalYearStartToFamilies < ActiveRecord::Migration[7.2] | ||
| def change | ||
| add_column :families, :fiscal_year_start_month, :integer, default: 1, null: false | ||
| add_column :families, :fiscal_year_start_day, :integer, default: 1, null: false | ||
|
|
||
| add_check_constraint :families, | ||
| "fiscal_year_start_month >= 1 AND fiscal_year_start_month <= 12", | ||
| name: "fiscal_year_start_month_range" | ||
|
|
||
| add_check_constraint :families, | ||
| "fiscal_year_start_day >= 1 AND fiscal_year_start_day <= 28", | ||
| name: "fiscal_year_start_day_range" | ||
| end | ||
| end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| require "test_helper" | ||
|
|
||
| class Family::FiscalYearTest < ActiveSupport::TestCase | ||
| setup do | ||
| @family = families(:dylan_family) | ||
| end | ||
|
|
||
| test "fiscal_year_start_month and fiscal_year_start_day default to 1" do | ||
| assert_equal 1, @family.fiscal_year_start_month | ||
| assert_equal 1, @family.fiscal_year_start_day | ||
| end | ||
|
|
||
| test "validates fiscal_year_start_month is between 1 and 12" do | ||
| @family.fiscal_year_start_month = 0 | ||
| assert_not @family.valid? | ||
|
|
||
| @family.fiscal_year_start_month = 13 | ||
| assert_not @family.valid? | ||
|
|
||
| @family.fiscal_year_start_month = 3 | ||
| assert @family.valid? | ||
| end | ||
|
|
||
| test "validates fiscal_year_start_day is between 1 and 28" do | ||
| @family.fiscal_year_start_day = 0 | ||
| assert_not @family.valid? | ||
|
|
||
| @family.fiscal_year_start_day = 29 | ||
| assert_not @family.valid? | ||
|
|
||
| @family.fiscal_year_start_day = 1 | ||
| assert @family.valid? | ||
| end | ||
|
|
||
| test "uses_fiscal_year? returns false when start is January 1" do | ||
| @family.fiscal_year_start_month = 1 | ||
| @family.fiscal_year_start_day = 1 | ||
| assert_not @family.uses_fiscal_year? | ||
| end | ||
|
|
||
| test "uses_fiscal_year? returns true when start month is not January" do | ||
| @family.fiscal_year_start_month = 3 | ||
| assert @family.uses_fiscal_year? | ||
| end | ||
|
|
||
| test "uses_fiscal_year? returns true when start day is not 1" do | ||
| @family.fiscal_year_start_day = 15 | ||
| assert @family.uses_fiscal_year? | ||
| end | ||
|
|
||
| test "current_fiscal_year_start returns this year's start when today is on or after it" do | ||
| @family.fiscal_year_start_month = 3 | ||
| @family.fiscal_year_start_day = 1 | ||
|
|
||
| travel_to Date.new(2026, 4, 21) do | ||
| assert_equal Date.new(2026, 3, 1), @family.current_fiscal_year_start | ||
| end | ||
| end | ||
|
|
||
| test "current_fiscal_year_start returns this year's start on the exact boundary date" do | ||
| @family.fiscal_year_start_month = 3 | ||
| @family.fiscal_year_start_day = 1 | ||
|
|
||
| travel_to Date.new(2026, 3, 1) do | ||
| assert_equal Date.new(2026, 3, 1), @family.current_fiscal_year_start | ||
| end | ||
| end | ||
|
|
||
| test "current_fiscal_year_start rolls back one year when today is before the start" do | ||
| @family.fiscal_year_start_month = 7 | ||
| @family.fiscal_year_start_day = 1 | ||
|
|
||
| travel_to Date.new(2026, 4, 21) do | ||
| assert_equal Date.new(2025, 7, 1), @family.current_fiscal_year_start | ||
| end | ||
| end | ||
|
|
||
| test "current_fiscal_year_start returns Jan 1 of current year for default settings" do | ||
| travel_to Date.new(2026, 4, 21) do | ||
| assert_equal Date.new(2026, 1, 1), @family.current_fiscal_year_start | ||
| end | ||
| end | ||
| end |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.