From 8bcc56a00b1369d5d1bbf1de8fce3cd6b833cac3 Mon Sep 17 00:00:00 2001 From: Per Cederqvist <ceder@lysator.liu.se> Date: Mon, 14 Aug 2006 08:13:34 +0000 Subject: [PATCH] Database and model for RecurringItemRange --- app/models/recurring_item.rb | 1 + app/models/recurring_item_range.rb | 1 + .../005_create_recurring_item_ranges.rb | 24 ++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/models/recurring_item.rb b/app/models/recurring_item.rb index f036383..51d288e 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 55bced0..2932349 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 d3b827e..ea97dcd 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 -- GitLab