2009-01-08 16:33:27 +01:00
|
|
|
# == Schema Information
|
|
|
|
# Schema version: 20090102171850
|
|
|
|
#
|
|
|
|
# Table name: group_order_results
|
|
|
|
#
|
|
|
|
# id :integer(4) not null, primary key
|
|
|
|
# order_id :integer(4) default(0), not null
|
|
|
|
# group_name :string(255) default(""), not null
|
|
|
|
# price :decimal(8, 2) default(0.0), not null
|
|
|
|
#
|
|
|
|
|
2009-01-14 12:46:01 +01:00
|
|
|
# Ordergroups, which participate on a specific order will have a line
|
2009-01-06 11:49:19 +01:00
|
|
|
class GroupOrderResult < ActiveRecord::Base
|
|
|
|
|
|
|
|
belongs_to :order
|
|
|
|
has_many :group_order_article_results, :dependent => :destroy
|
|
|
|
|
2009-01-14 12:46:01 +01:00
|
|
|
# Calculates the Order-Price for the Ordergroup and updates the price-attribute
|
2009-01-06 11:49:19 +01:00
|
|
|
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
|