-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store country band details in database
- Loading branch information
1 parent
f86e5d0
commit d02c82a
Showing
9 changed files
with
88 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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 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 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,6 @@ | ||
# frozen_string_literal: true | ||
|
||
class CountryBandDetail < ApplicationRecord | ||
scope :active, -> { where(end_date: nil).or(inactive.invert_where) } | ||
scope :inactive, -> { where(end_date: ..Date.today) } | ||
end |
This file contains 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 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 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 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateCountryBandDetails < ActiveRecord::Migration[7.2] | ||
def change | ||
create_table :country_band_details do |t| | ||
t.integer "number", null: false | ||
t.date "start_date", null: false | ||
t.date "end_date" | ||
t.integer "due_amount_per_competitor_in_cents", null: false | ||
t.integer "due_percent_registration_fee", null: false | ||
t.timestamps | ||
end | ||
end | ||
end |
42 changes: 42 additions & 0 deletions
42
db/migrate/20241225031242_populate_country_band_details.rb
This file contains 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,42 @@ | ||
# frozen_string_literal: true | ||
|
||
class PopulateCountryBandDetails < ActiveRecord::Migration[7.2] | ||
def change | ||
CountryBandDetail.create!( | ||
number: 0, | ||
start_date: '2018-01-01', | ||
due_amount_per_competitor_in_cents: 0, | ||
due_percent_registration_fee: 0, | ||
) | ||
CountryBandDetail.create!( | ||
number: 1, | ||
start_date: '2018-01-01', | ||
due_amount_per_competitor_in_cents: 19, | ||
due_percent_registration_fee: 5, | ||
) | ||
CountryBandDetail.create!( | ||
number: 2, | ||
start_date: '2018-01-01', | ||
due_amount_per_competitor_in_cents: 32, | ||
due_percent_registration_fee: 5, | ||
) | ||
CountryBandDetail.create!( | ||
number: 3, | ||
start_date: '2018-01-01', | ||
due_amount_per_competitor_in_cents: 45, | ||
due_percent_registration_fee: 15, | ||
) | ||
CountryBandDetail.create!( | ||
number: 4, | ||
start_date: '2018-01-01', | ||
due_amount_per_competitor_in_cents: 228, | ||
due_percent_registration_fee: 15, | ||
) | ||
CountryBandDetail.create!( | ||
number: 5, | ||
start_date: '2018-01-01', | ||
due_amount_per_competitor_in_cents: 300, | ||
due_percent_registration_fee: 15, | ||
) | ||
end | ||
end |
This file contains 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 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