Module: PurchaseOrderShipmentHelper

Defined in:
app/helpers/purchase_order_shipment_helper.rb

Instance Method Summary collapse

Instance Method Details

#purchase_order_shipment_actions(purchase_order_shipment:, purchase_order: nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/purchase_order_shipment_helper.rb', line 5

def purchase_order_shipment_actions(purchase_order_shipment:, purchase_order: nil)
  pos = purchase_order_shipment
  purchase_order ||= @purchase_order
  purchase_order ||= poi.purchase_orders.first
  actions = []
  unless pos.fully_receipted?
    actions << link_to('Edit', edit_purchase_order_shipment_path(pos, return_path: purchase_order_path(purchase_order)), class: 'dropdown-item')
    actions << link_to('Enter Receipt', new_shipment_receipt_path(purchase_order_shipment_id: pos.id), class: 'dropdown-item')
  end
  unless pos.fully_receipted? || pos.partially_receipted?
    actions << link_to('Delete', purchase_order_shipment_path(pos, return_path: purchase_order_path(purchase_order)), data: { turbo_confirm: 'Are you sure?', turbo_method: :delete }, class: 'dropdown-item')
  end
  if pos.fully_receipted? && pos.landed_cost.nil? && !pos.fully_landed_costed? && !purchase_order.pending_service_fulfillment?
    actions << link_to('Enter Landed Cost', enter_landed_costs_purchase_order_shipment_path(pos), class: 'dropdown-item')
  end
  if pos.fully_receipted? && pos.fully_landed_costed?
    actions << link_to('Edit Landed Cost', edit_landed_costs_purchase_order_shipment_path(pos), class: 'dropdown-item')
  end
  actions
end