foodsoft/app/models/group_order_article_result.rb
Benjamin Meichsner 9f8d0d28ac Removed gettext and simplified_localization-plugin. L18n is now the appropriate module.
Upgraded to rails 2.2.2 and replaced complex foodsoft.rb-loader with simple
initializers/load_app_config.rb. Multiple foodcoops option is temporarly deactivated.
2009-01-06 15:45:19 +01:00

27 lines
1 KiB
Ruby

# An GroupOrderArticleResult represents a group-order for a single Article and its quantities,
# according to the order quantity/tolerance.
# The GroupOrderArticleResult is part of a finished Order, see OrderArticleResult.
#
# Properties:
# * order_article_result_id (int)
# * group_order_result_id (int): associated with OrderGroup through GroupOrderResult.group_name
# * quantity (int)
#
class GroupOrderArticleResult < ActiveRecord::Base
belongs_to :order_article_result
belongs_to :group_order_result
validates_presence_of :order_article_result, :group_order_result, :quantity
validates_numericality_of :quantity, :minimum => 0
# updates the price attribute for the appropriate GroupOrderResult
after_update {|result| result.group_order_result.updatePrice }
after_destroy {|result| result.group_order_result.updatePrice }
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def quantity=(quantity)
self[:quantity] = String.delocalized_decimal(quantity)
end
end