Module: PurchaseOrderShipmentReceiptHelper

Defined in:
app/helpers/purchase_order_shipment_receipt_helper.rb

Instance Method Summary collapse

Instance Method Details

#purchase_order_shipment_receipt_actions(shipment_receipt:, purchase_order: nil) ⇒ Object



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/purchase_order_shipment_receipt_helper.rb', line 5

def purchase_order_shipment_receipt_actions(shipment_receipt:, purchase_order: nil)
  sr = shipment_receipt
  purchase_order ||= @purchase_order
  purchase_order ||= sr.purchase_orders.first
  actions = []
  unless sr.voided?
    if (sr.landed_costs.map(&:estimated) == false || sr.landed_costs.map(&:estimated).empty?) && sr.landed_cost.nil?
      actions << link_to('Void Shipment Receipt', void_shipment_receipt_path(sr), data: { turbo_confirm: 'Are you sure?' }, class: 'dropdown-item')
    end
    if sr.awaiting_assignment?
      actions << link_to('Assign Serial Numbers', assign_serial_numbers_shipment_receipt_path(sr), class: 'dropdown-item')
    end
    if sr.landed_cost.nil? && !purchase_order.pending_service_fulfillment?
      actions << link_to('Enter Landed Costs', enter_landed_costs_shipment_receipt_path(sr), class: 'dropdown-item')
    end
    if sr.landed_cost.present?
      actions << link_to('Edit Landed Costs', edit_landed_costs_shipment_receipt_path(sr), data: { turbo_confirm: 'Are you sure you want to edit current landed costs for this receipt?' }, class: 'dropdown-item')
      actions << link_to('Void Landed Costs', void_landed_costs_shipment_receipt_path(sr), data: { turbo_confirm: 'Are you sure you want to void landed costs for this receipt?' }, class: 'dropdown-item')
    end
  end
  actions
end

#purchase_order_shipment_receipt_button(shipment_receipt:, purchase_order: nil) ⇒ Object



28
29
30
# File 'app/helpers/purchase_order_shipment_receipt_helper.rb', line 28

def purchase_order_shipment_receipt_button(shipment_receipt:, purchase_order: nil)
  render_simple_drop_down [shipment_receipt.human_state_name.titleize, purchase_order_shipment_receipt_actions(shipment_receipt: shipment_receipt, purchase_order: purchase_order)], dropdown_options: { right_menu: false }
end