app/models/orders/order.rb in artfully_ose-1.2.0.pre.15 vs app/models/orders/order.rb in artfully_ose-1.2.0.pre.16
- old
+ new
@@ -23,11 +23,11 @@
belongs_to :gateway_transaction, :primary_key => :transaction_id, :foreign_key => :transaction_id
has_many :children, :class_name => "Order", :foreign_key => "parent_id"
has_many :items, :dependent => :destroy
has_many :actions, :foreign_key => "subject_id", :dependent => :destroy
- attr_accessor :skip_actions
+ attr_accessor :skip_actions, :skip_email
set_watch_for :created_at, :local_to => :organization
set_watch_for :created_at, :local_to => :self, :as => :admins
validates_presence_of :person_id
@@ -47,10 +47,12 @@
scope :not_imported, where("fa_id IS NULL")
scope :csv_imported, where("import_id IS NOT NULL")
scope :csv_not_imported, where("import_id IS NULL")
scope :artfully, where("transaction_id IS NOT NULL")
+ has_attached_file :pdf
+
searchable do
text :details, :id, :type, :location, :transaction_id, :payment_method, :special_instructions
[:first_name, :last_name, :email].each do |person_field|
text person_field do
@@ -113,10 +115,14 @@
end
def discount_codes
tickets.collect(&:discount).uniq.compact
end
+
+ def imported?
+ !self.import_id.nil?
+ end
def total_discount
tickets.collect(&:total_discount).sum
end
@@ -167,10 +173,19 @@
end
def destroyable?
( (type.eql? "ApplicationOrder") || (type.eql? "ImportedOrder") ) && !is_fafs? && !artfully? && has_single_donation?
end
+
+ def skip_confirmation_email?
+ @skip_email || anonymous_purchase? || imported? || self.person.email.blank?
+ end
+
+ def process
+ @skip_actions ||= false
+ OrderProcessor.process(self, {:skip_actions => @skip_actions, :skip_email => self.skip_confirmation_email?})
+ end
def assignable?
anonymous_purchase? && parent.nil?
end
@@ -351,13 +366,9 @@
def calculate_lifetime_value
# All of these methods are async on person
self.person.calculate_lifetime_value
self.person.calculate_lifetime_ticket_value
self.person.calculate_lifetime_donations
- end
-
- def process
- OrderProcessor.process(self, @skip_actions)
end
def purchase_action_class
GetAction
end