diff --git a/Gemfile b/Gemfile index b686f71..cc840dd 100644 --- a/Gemfile +++ b/Gemfile @@ -52,6 +52,8 @@ gem "money-rails" gem "net-http" +gem "data_migrate" + group :development, :test do gem "capybara" gem "factory_bot_rails" diff --git a/Gemfile.lock b/Gemfile.lock index 7035a0b..985be7e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,6 +88,9 @@ GEM coderay (1.1.3) concurrent-ruby (1.2.2) crass (1.0.6) + data_migrate (9.4.0) + activerecord (>= 6.1) + railties (>= 6.1) date (3.3.3) diff-lcs (1.5.0) docile (1.4.0) @@ -302,6 +305,7 @@ DEPENDENCIES annotate bootsnap capybara + data_migrate factory_bot_rails faker importmap-rails diff --git a/db/data/20240711124610_create_tax_tables.rb b/db/data/20240711124610_create_tax_tables.rb new file mode 100644 index 0000000..44d430b --- /dev/null +++ b/db/data/20240711124610_create_tax_tables.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class CreateTaxTables < ActiveRecord::Migration[7.0] + def up + FederalTaxBracket.create(tier: "Tier 1", bottom_range: 0, top_range: 23_200, rate: 0.1, cumulative: 0) + FederalTaxBracket.create(tier: "Tier 2", bottom_range: 23_001, top_range: 94_300, rate: 0.12, cumulative: 2_320) + FederalTaxBracket.create(tier: "Tier 3", bottom_range: 94_301, top_range: 201_050, rate: 0.22, cumulative: 10_852) + FederalTaxBracket.create(tier: "Tier 4", bottom_range: 201_051, top_range: 383_900, rate: 0.24, cumulative: 34_337) + FederalTaxBracket.create(tier: "Tier 5", bottom_range: 383_901, top_range: 487_450, rate: 0.32, cumulative: 78_221) + FederalTaxBracket.create(tier: "Tier 6", bottom_range: 487_451, top_range: 731_200, rate: 0.35, cumulative: 111_357) + FederalTaxBracket.create(tier: "Tier 7", bottom_range: 731_201, top_range: 10_000_000, rate: 0.35, cumulative: 196_669) + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/data/20240711125841_create_incomes.rb b/db/data/20240711125841_create_incomes.rb new file mode 100644 index 0000000..5ebaee7 --- /dev/null +++ b/db/data/20240711125841_create_incomes.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class CreateIncomes < ActiveRecord::Migration[7.0] + def up + Income.create(income_type: "Salary", rate: 100000, hours: 40, weekly_income: 1923.08) + Income.create(income_type: "Hourly", rate: 47, hours: 40, weekly_income: 1880.0) + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/data/20240711130514_create_expense.rb b/db/data/20240711130514_create_expense.rb new file mode 100644 index 0000000..77ba657 --- /dev/null +++ b/db/data/20240711130514_create_expense.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class CreateExpense < ActiveRecord::Migration[7.0] + def up + FixedExpense.create(expense_name: "Rent", annual_cost: 12000, monthly_cost: 100, bi_weekly_cost: 461.54) + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/data/20240711132613_create_savings_rates.rb b/db/data/20240711132613_create_savings_rates.rb new file mode 100644 index 0000000..7433d0c --- /dev/null +++ b/db/data/20240711132613_create_savings_rates.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class CreateSavingsRates < ActiveRecord::Migration[7.0] + def up + SavingsRate.create(name: "savings", rate: 0.02) + SavingsRate.create(name: "investing", rate: 0.02) + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/data_schema.rb b/db/data_schema.rb new file mode 100644 index 0000000..5bff260 --- /dev/null +++ b/db/data_schema.rb @@ -0,0 +1 @@ +DataMigrate::Data.define(version: 20240711132613) diff --git a/db/schema.rb b/db/schema.rb index 98d2dd2..500628b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -14,6 +14,9 @@ # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "data_migrations", primary_key: "version", id: :string, force: :cascade do |t| + end + create_table "federal_tax_brackets", force: :cascade do |t| t.string "tier" t.integer "bottom_range_cents", default: 0, null: false