[#4410] Replace Payment Terms with an Enumeration

Instead of using a hard coded value for Payment Terms, they will use
Redmine's Enumeration table.  This provides an admin gui to managing
the value as well as ordering them.
This commit is contained in:
Eric Davis
2010-08-12 09:26:09 -07:00
parent c17e8eaf1b
commit a2b810a4d8
18 changed files with 110 additions and 31 deletions

View File

@@ -0,0 +1,9 @@
class AddPaymentTermIdToContracts < ActiveRecord::Migration
def self.up
add_column :contracts, :payment_term_id, :integer
end
def self.down
remove_column :contracts, :payment_term_id
end
end

View File

@@ -0,0 +1,9 @@
class RemovePaymentTermsFromContracts < ActiveRecord::Migration
def self.up
remove_column :contracts, :payment_terms
end
def self.down
add_column :contracts, :payment_terms, :string
end
end

View File

@@ -0,0 +1,14 @@
class PopulatePaymentTerms < ActiveRecord::Migration
def self.up
[0, 15, 30, 45, 60, 75, 90].each_with_index do |days, index|
name = "Net #{days}"
unless PaymentTerm.find_by_name(name)
PaymentTerm.create!(:name => name, :position => index + 1)
end
end
end
def self.down
# No-op
end
end