Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## AASM stuff
- state_machine :state, :initial => :pending do
- state :pending
- state :placed
- state :completed
- state :back_ordered
- state :partial_back_ordered
- state :cancelled
- state :holding
- before_transition :to => :placed, :do => :prepare_to_be_placed
- ## Prepare to be placed
- def prepare_to_be_placed
- return false unless order_number.blank?
- # Sets gsa information about the order if needed.
- if user.eligible_for_gsa_pricing && order_contains_gsa_items?
- self.gsa = true
- add_gsa_pricing_type_to_line_items
- end
- # Set the tax jurisdiction
- self.tax_jurisdiction = find_tax_jurisdiction
- # Get a new order number
- if valid?
- self.order_number = NextNumber.get_next_number_for(self)
- self.placed_at = Time.now
- self.save
- else
- return false
- end
- end
- ## Tax jurisdiction
- def find_tax_jurisdiction
- if @shipto_country == "US" && %w(TN TX GA MA).include?(@shipto_state)
- ...
- end
- end
Add Comment
Please, Sign In to add comment