9f8d0d28ac
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.
21 lines
669 B
Ruby
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
|