From c5d28419deca1567dc70d679645b427abcc96030 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 7 Nov 2011 10:24:12 +0100 Subject: [PATCH] Updated the tasks model for fixed cost tasks and added invoices. --- stoptime.rb | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/stoptime.rb b/stoptime.rb index a15b273..0c4e639 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -75,10 +75,20 @@ module StopTime::Models class Task < Base has_many :time_entries belongs_to :customer + + def fixed_cost? + not self.fixed_cost.blank? + end end class TimeEntry < Base belongs_to :task + has_one :invoice + end + + class Invoice < Base + has_many :time_entries + belongs_to :customer end class StopTimeTables < V 1.0 @@ -95,7 +105,7 @@ module StopTime::Models t.timestamps end create_table TimeEntry.table_name do |t| - t.integer :task_id + t.integer :task_id, :invoice_id t.datetime :start, :end t.timestamps end @@ -139,6 +149,32 @@ module StopTime::Models end end + class FixedCostTaskSupport < V 1.4 + def self.up + add_column(Task.table_name, :billed, :boolean) + end + + def self.down + add_column(Task.table_name, :billed) + end + end + + class InvoiceSupport < V 1.5 + def self.up + create_table Invoice.table_name do |t| + t.integer :number, :customer_id + t.boolean :payed + t.timestamps + end + add_column(TimeEntry.table_name, :invoice_id, :integer) + end + + def self.down + drop_table Invoice.table_name + remove_column(TimeEntry.table_name, :invoice_id) + end + end + end # StopTime::Models module StopTime::Controllers