Module: Shoppy::ShipmentsHelper
- Defined in:
- app/helpers/shoppy/shipments_helper.rb
Class Method Summary collapse
- .mark_shipment_delivered(shipment) ⇒ Object
- .prepare_shipment(order, order_lines, stock_location, customer_address) ⇒ Object
- .ship_shipment(shipment, tracking_number) ⇒ Object
Class Method Details
.mark_shipment_delivered(shipment) ⇒ Object
36 37 38 39 40 41 |
# File 'app/helpers/shoppy/shipments_helper.rb', line 36 def self.mark_shipment_delivered(shipment) s = shipment s.status = "Delivered" s.delivery_date = Date.today return s.save end |
.prepare_shipment(order, order_lines, stock_location, customer_address) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/shoppy/shipments_helper.rb', line 3 def self.prepare_shipment(order, order_lines, stock_location, customer_address) if(order.customer_address == customer_address.customer) && ((order_lines - order.orderlines).empty?) Shipment.transaction do s = Shipment.new s.order = order s.stock_location = stock_location s.order_lines = order_lines order_lines.each do |ol| InventoriesHelper::deduct_variant_from_stuck_location(ol.variant, ol.quantity, stock_location) end s.name = customer_address.customer.name s.phone = customer_address.customer.phone s.add_line1 = customer_address.add_line1 s.add_line2 = customer_address.add_line2 s.city = customer_address.city s.state = customer_address.state s.country = customer_address.country s.zip = customer_address.zip return s.save end else return false end end |
.ship_shipment(shipment, tracking_number) ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/helpers/shoppy/shipments_helper.rb', line 28 def self.ship_shipment(shipment, tracking_number) s = shipment s.tracking_number = tracking_number s.shipment_date = Date.today s.status = "Shipped" return s.save end |