foodsoft/app/models/group_order_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

21 lines
669 B
Ruby

# OrderGroups, which participate on a specific order will have a line
# Properties:
# * order_id, int
# * group_name, the name of the group
# * price, decimal
# * group_order_article_results: collection of associated GroupOrderArticleResults
#
class GroupOrderResult < ActiveRecord::Base
belongs_to :order
has_many :group_order_article_results, :dependent => :destroy
# Calculates the Order-Price for the OrderGroup and updates the price-attribute
def updatePrice
total = 0
group_order_article_results.each do |result|
total += result.order_article_result.gross_price * result.quantity
end
update_attribute(:price, total)
end
end