app/models/carts/cart.rb in artfully_ose-1.2.0.pre.16 vs app/models/carts/cart.rb in artfully_ose-1.2.0.pre.17

- old
+ new

@@ -1,11 +1,11 @@ class Cart < ActiveRecord::Base include ActiveRecord::Transitions has_many :donations, :dependent => :destroy - has_many :tickets - has_many :memberships + has_many :tickets, :after_add => :calculate_fees + has_many :memberships, :after_add => :calculate_fees after_destroy :clear! before_validation :set_token attr_accessor :special_instructions attr_accessible :token, :reseller_id @@ -72,17 +72,20 @@ def fee_in_cents items.sum(&:service_fee) end + def calculate_fees(obj) + FeeCalculator.apply(FeeStrategy.new).to(self) + end + def <<(tkts) tkts = Array.wrap(tkts) tkts.each do |t| raise "Cannot add tickets to a cart without a ticket type set on the Ticket" if t.ticket_type.nil? t.cart_price = t.ticket_type.price end self.tickets << tkts.flatten - FeeCalculator.apply(FeeStrategy.new).to(self) end def subtotal items.sum(&:price) end