app/models/order.rb
# check to see if shipments (status 'shipped') contain all items orders
check to see if shipments (status 'shipped') contain all items orders
check to see if shipments ( status ' shipped ' ) contain all items orders
def complete_order_shipped?
    shipped_items = ShipmentItem.joins(:shipment)
                        .where("store_shipments.order_id = ? AND store_shipments.status = 'shipped'", id)
    items.each do |i|
      if i.quantity > shipped_items.select { |x| x.order_item_id == i.id }.sum(&:quantity)
        return false
      end
    end
    true
  end
def complete_order_shipped? shipped_items = ShipmentItem . joins ( :shipment ) . where ( "store_shipments.order_id = ? AND store_shipments.status = 'shipped'" , id ) items . each do | i | if i . quantity > shipped_items . select { | x | x . order_item_id == i . id } . sum ( & :quantity ) return false end end true end
check to see if shipments (status 'shipped') contain all items orders
check to see if shipments ( status ' shipped ' ) contain all items orders