Allow input of decimal numbers for GroupOrderArticle-result.

This commit is contained in:
Benjamin Meichsner 2009-04-05 15:23:21 +02:00
parent 40886b71f9
commit 36f9bffdb8
3 changed files with 48 additions and 30 deletions

View file

@ -32,6 +32,11 @@ class GroupOrderArticle < ActiveRecord::Base
named_scope :ordered, :conditions => 'result > 0' named_scope :ordered, :conditions => 'result > 0'
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def result=(result)
self[:result] = String.delocalized_decimal(result)
end
# Updates the quantity/tolerance for this GroupOrderArticle by updating both GroupOrderArticle properties # Updates the quantity/tolerance for this GroupOrderArticle by updating both GroupOrderArticle properties
# and the associated GroupOrderArticleQuantities chronologically. # and the associated GroupOrderArticleQuantities chronologically.
# #

View file

@ -0,0 +1,9 @@
class ModifyGroupOrderArticleResult < ActiveRecord::Migration
def self.up
change_column :group_order_articles, :result, :decimal, :precision => 8, :scale => 3
end
def self.down
change_column :group_order_articles, :result, :integer
end
end

View file

@ -9,7 +9,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20090317175355) do ActiveRecord::Schema.define(:version => 20090405131156) do
create_table "article_categories", :force => true do |t| create_table "article_categories", :force => true do |t|
t.string "name", :default => "", :null => false t.string "name", :default => "", :null => false
@ -37,16 +37,16 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
t.string "manufacturer" t.string "manufacturer"
t.string "origin" t.string "origin"
t.datetime "shared_updated_on" t.datetime "shared_updated_on"
t.decimal "price" t.decimal "price", :precision => 8, :scale => 2
t.float "tax" t.float "tax"
t.decimal "deposit", :default => 0.0 t.decimal "deposit", :precision => 8, :scale => 2, :default => 0.0
t.integer "unit_quantity", :default => 1, :null => false t.integer "unit_quantity", :default => 1, :null => false
t.string "order_number" t.string "order_number"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "quantity", :default => 0
t.datetime "deleted_at" t.datetime "deleted_at"
t.string "type" t.string "type"
t.integer "quantity", :default => 0
end end
add_index "articles", ["name", "supplier_id"], :name => "index_articles_on_name_and_supplier_id" add_index "articles", ["name", "supplier_id"], :name => "index_articles_on_name_and_supplier_id"
@ -98,7 +98,7 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
t.integer "quantity", :default => 0, :null => false t.integer "quantity", :default => 0, :null => false
t.integer "tolerance", :default => 0, :null => false t.integer "tolerance", :default => 0, :null => false
t.datetime "updated_on", :null => false t.datetime "updated_on", :null => false
t.integer "result" t.decimal "result", :precision => 8, :scale => 3
end end
add_index "group_order_articles", ["group_order_id", "order_article_id"], :name => "goa_index", :unique => true add_index "group_order_articles", ["group_order_id", "order_article_id"], :name => "goa_index", :unique => true
@ -118,7 +118,7 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
t.string "type", :default => "", :null => false t.string "type", :default => "", :null => false
t.string "name", :default => "", :null => false t.string "name", :default => "", :null => false
t.string "description" t.string "description"
t.decimal "account_balance", :default => 0.0, :null => false t.decimal "account_balance", :precision => 8, :scale => 2, :default => 0.0, :null => false
t.datetime "account_updated" t.datetime "account_updated"
t.datetime "created_on", :null => false t.datetime "created_on", :null => false
t.boolean "role_admin", :default => false, :null => false t.boolean "role_admin", :default => false, :null => false
@ -152,16 +152,16 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
create_table "invoices", :force => true do |t| create_table "invoices", :force => true do |t|
t.integer "supplier_id" t.integer "supplier_id"
t.integer "delivery_id" t.integer "delivery_id"
t.integer "order_id"
t.string "number" t.string "number"
t.date "date" t.date "date"
t.date "paid_on" t.date "paid_on"
t.text "note" t.text "note"
t.decimal "amount", :precision => 8, :scale => 2, :default => 0.0, :null => false t.decimal "amount", :precision => 8, :scale => 2, :default => 0.0, :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "order_id"
t.decimal "deposit", :precision => 8, :scale => 2, :default => 0.0, :null => false t.decimal "deposit", :precision => 8, :scale => 2, :default => 0.0, :null => false
t.decimal "deposit_credit", :precision => 8, :scale => 2, :default => 0.0, :null => false t.decimal "deposit_credit", :precision => 8, :scale => 2, :default => 0.0, :null => false
t.datetime "created_at"
t.datetime "updated_at"
end end
create_table "memberships", :force => true do |t| create_table "memberships", :force => true do |t|
@ -211,6 +211,10 @@ ActiveRecord::Schema.define(:version => 20090317175355) do
t.decimal "foodcoop_result", :precision => 8, :scale => 2 t.decimal "foodcoop_result", :precision => 8, :scale => 2
end end
create_table "schema_info", :id => false, :force => true do |t|
t.integer "version"
end
create_table "stock_changes", :force => true do |t| create_table "stock_changes", :force => true do |t|
t.integer "delivery_id" t.integer "delivery_id"
t.integer "order_id" t.integer "order_id"