Guest User

Untitled

a guest
Jun 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. ## AASM stuff
  2. state_machine :state, :initial => :pending do
  3. state :pending
  4. state :placed
  5. state :completed
  6. state :back_ordered
  7. state :partial_back_ordered
  8. state :cancelled
  9. state :holding
  10.  
  11. before_transition :to => :placed, :do => :prepare_to_be_placed
  12.  
  13. ## Prepare to be placed
  14. def prepare_to_be_placed
  15. return false unless order_number.blank?
  16.  
  17. # Sets gsa information about the order if needed.
  18. if user.eligible_for_gsa_pricing && order_contains_gsa_items?
  19. self.gsa = true
  20. add_gsa_pricing_type_to_line_items
  21. end
  22.  
  23. # Set the tax jurisdiction
  24. self.tax_jurisdiction = find_tax_jurisdiction
  25.  
  26. # Get a new order number
  27. if valid?
  28. self.order_number = NextNumber.get_next_number_for(self)
  29. self.placed_at = Time.now
  30. self.save
  31. else
  32. return false
  33. end
  34. end
  35.  
  36. ## Tax jurisdiction
  37. def find_tax_jurisdiction
  38. if @shipto_country == "US" && %w(TN TX GA MA).include?(@shipto_state)
  39. ...
  40. end
  41. end
Add Comment
Please, Sign In to add comment