app/models/job/order_processor.rb in artfully_ose-1.2.0.pre.23 vs app/models/job/order_processor.rb in artfully_ose-1.2.0.pre.24

- old
+ new

@@ -17,11 +17,11 @@ self.options = options self.order = order end def self.process(order, options = {}) - job = OrderProcessor.new(order, options) + job = order.processor_class.new(order, options) Delayed::Job.enqueue job, :queue => QUEUE end def perform ActiveRecord::Base.transaction do @@ -29,20 +29,27 @@ self.order.create_purchase_action unless skip_actions process_memberships process_passes end + generate_qr_codes_and_pdf + send_confirmation + end + + def generate_qr_codes_and_pdf begin order.tickets.each do |item| item.product.generate_qr_code_without_delay generate_pdf if order.organization.can? :access, :scannable_tickets end rescue Exception => e Exceptional.context(:order_id => order.id) Exceptional.handle(e, "Could not generate PDF for order") end + end + def send_confirmation begin OrderMailer.confirmation_for(order).deliver unless skip_email rescue Exception => e Exceptional.context(:order_id => order.id) Exceptional.handle(e, "Could not send order confirmation for order") @@ -56,21 +63,26 @@ def skip_email self.options[:skip_email] == true end def process_memberships - self.order.memberships.each do |membership_item| - Member.for(membership_item.product, self.order.person) + unless self.order.memberships.empty? + self.order.memberships.each do |membership_item| + Member.for(membership_item.product, self.order.person) + end + self.order.create_generic_action("memberships") end - self.order.create_generic_action("memberships") end def process_passes - self.order.passes.each do |pass_item| - pass_item.product.person = self.order.person - pass_item.product.save + unless self.order.passes.empty? || order.is_a?(RefundOrder) + self.order.passes.each do |pass_item| + pass_item.product.person = self.order.person + pass_item.product.save + end + self.order.create_generic_action("passes") + PassMailer.pass_info_for(self.order.person, self.order.organization.email,self.order.passes.collect(&:product)).deliver end - self.order.create_generic_action("passes") end def generate_pdf pdf_generator = PdfGeneration.new(order) download_url = pdf_generator.generate