diff --git a/app/models/recurring_item.rb b/app/models/recurring_item.rb index f036383c0a5ecce209167e77872c7365aeea4b27..51d288e3bc65ee7b1795fe95cf836c98aba44a80 100644 --- a/app/models/recurring_item.rb +++ b/app/models/recurring_item.rb @@ -1,3 +1,4 @@ class RecurringItem < ActiveRecord::Base belongs_to :schedule + has_many :recurring_item_ranges end diff --git a/app/models/recurring_item_range.rb b/app/models/recurring_item_range.rb index 55bced0a622d6a6808171d7084e40958f56f7941..2932349ca162c055f4bbbec81eceab0e48de6deb 100644 --- a/app/models/recurring_item_range.rb +++ b/app/models/recurring_item_range.rb @@ -1,2 +1,3 @@ class RecurringItemRange < ActiveRecord::Base + belongs_to :recurring_item end diff --git a/db/migrate/005_create_recurring_item_ranges.rb b/db/migrate/005_create_recurring_item_ranges.rb index d3b827e7cf68ad9f944497704cf6bad0e529ef33..ea97dcd918f481563271b9d7fa2dac2ac8425314 100644 --- a/db/migrate/005_create_recurring_item_ranges.rb +++ b/db/migrate/005_create_recurring_item_ranges.rb @@ -1,8 +1,30 @@ +# -*- coding: utf-8 -*- class CreateRecurringItemRanges < ActiveRecord::Migration def self.up create_table :recurring_item_ranges do |t| - # t.column :name, :string + t.column :recurring_item_id, :integer + + t.column :amount, :integer + t.column :startdate, :date + t.column :enddate, :date + t.column :schedule_id, :integer end + + pay = RecurringItem.find_by_description("Pers lön") + telia = RecurringItem.find_by_description("Telia") + + month = Schedule.find_by_name("Månad") + quarter = Schedule.find_by_name("Kvartal") + + RecurringItemRange.create(:recurring_item_id => pay.id, + :amount => "22200", + :startdate => Date.civil(2006, 8, 25), + :schedule_id => month.id) + + RecurringItemRange.create(:recurring_item_id => telia.id, + :amount => "-1200", + :startdate => Date.civil(2006, 9, 10), + :schedule_id => quarter.id) end def self.down