Module: Spree::Admin::ShipmentHelper

Includes:
ShipmentHelper
Defined in:
app/helpers/spree/admin/shipment_helper.rb

Instance Method Summary collapse

Instance Method Details

#can_ship?(shipment) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'app/helpers/spree/admin/shipment_helper.rb', line 5

def can_ship?(shipment)
  can?(:update, shipment) && shipment.shippable?
end

#shipments_for_transfer(current_shipment) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/spree/admin/shipment_helper.rb', line 18

def shipments_for_transfer(current_shipment)
  current_shipment.
    order.
    shipments.
    ready_or_pending.
    where(stock_location: available_stock_locations).
    where.not(id: current_shipment.id).
    pluck(:number, :id).
    map { |n, i| [n, "shipment_#{i}"] }
end

#stock_locations_for_split(variant) ⇒ Object



9
10
11
12
13
14
15
16
# File 'app/helpers/spree/admin/shipment_helper.rb', line 9

def stock_locations_for_split(variant)
  available_stock_locations.
    joins(:stock_items).
    where(spree_stock_items: { variant_id: variant.id }).
    group(:id).
    pluck(:name, "sum(spree_stock_items.count_on_hand)", :id).
    map { |name, count, id| ["#{name.capitalize} (#{count} on hand)", "stock-location_#{id}"] }
end