[#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:
9
db/migrate/008_add_payment_term_id_to_contracts.rb
Normal file
9
db/migrate/008_add_payment_term_id_to_contracts.rb
Normal 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
|
||||
9
db/migrate/009_remove_payment_terms_from_contracts.rb
Normal file
9
db/migrate/009_remove_payment_terms_from_contracts.rb
Normal 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
|
||||
14
db/migrate/010_populate_payment_terms.rb
Normal file
14
db/migrate/010_populate_payment_terms.rb
Normal 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
|
||||
Reference in New Issue
Block a user