19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'app/presenters/delivery_presenter.rb', line 19
def actions(return_path: nil, shipping_document_print_profile_id: nil, warehouse_context: nil)
return_path ||= h.delivery_path(delivery)
actions = []
if delivery.future_release?
actions << warehouse_action_link('Release Now', :release_delivery_path, return_path:, warehouse_context:)
actions << h.link_to('Edit Release Date', h.edit_release_date_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
actions << h.link_to('Cancel/Hold Order (and reserve stock)', h.hold_delivery_path(delivery, reserve_stock: '1'), class: 'dropdown-item') unless delivery.locked_for_fba? && !h.user_has_role?('admin')
actions << h.link_to('Cancel/Hold Order (and DO NOT reserve stock', h.hold_delivery_path(delivery), class: 'dropdown-item') unless delivery.locked_for_fba? && !h.user_has_role?('admin')
elsif delivery.at_warehouse?
if shipping_document_print_profile_id
actions << h.link_to('Print Pick Slip', h.print_pick_slip_delivery_path(delivery, return_path: return_path, print_profile_id: shipping_document_print_profile_id), class: 'dropdown-item')
actions << h.link_to('Print Pick Slip - Expand Kits/SN', h.print_pick_slip_delivery_path(delivery, split_kits: true, return_path: return_path, print_profile_id: shipping_document_print_profile_id), class: 'dropdown-item')
end
actions << h.link_to('Print Pick Slip (Open PDF)', h.print_pick_slip_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
actions << h.link_to('Print Pick Slip - Expand Kits/SN (Open PDF)', h.print_pick_slip_delivery_path(delivery, split_kits: true, return_path: return_path), class: 'dropdown-item')
actions << workflow_action_link('Advance to Picking', 'picking', return_path:, warehouse_context:)
actions << h.link_to('Schedule Future Release', h.edit_release_date_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
actions << h.link_to('Print Serial Numbers', h.print_serial_numbers_delivery_path(delivery, return_path: return_path), class: 'dropdown-item') if delivery.line_items.any?(&:require_reservation?)
actions << workflow_action_link('Advance to Pending Ship Confirm', 'advance_to_pending_ship_confirm', return_path:, warehouse_context:) if delivery.can_advance_to_pending_ship_confirm?
actions << h.link_to('Cancel/Hold Order (and reserve stock)', h.hold_delivery_path(delivery, reserve_stock: '1'), class: 'dropdown-item')
actions << h.link_to('Cancel/Hold Order (and DO NOT reserve stock', h.hold_delivery_path(delivery), class: 'dropdown-item')
elsif delivery.awaiting_po_fulfillment?
actions << h.link_to('Cancel/Hold Order (and reserve stock)', h.hold_delivery_path(delivery, reserve_stock: '1'), class: 'dropdown-item')
actions << h.link_to('Cancel/Hold Order (and DO NOT reserve stock', h.hold_delivery_path(delivery), class: 'dropdown-item')
elsif delivery.pending_pickup_confirm? && !delivery.has_dropship_items? actions << warehouse_action_link('Cancel Pickup/Re-pick', :cancel_pickup_delivery_path, return_path:, warehouse_context:)
actions << warehouse_action_link('Delivery Shipped', :shipped_delivery_path, return_path:, warehouse_context:)
elsif delivery.picking?
actions << h.link_to('Picked', h.picked_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
actions << h.link_to('Reprint Pick Slip', h.print_pick_slip_delivery_path(delivery, return_path: return_path, print_profile_id: shipping_document_print_profile_id), class: 'dropdown-item') if shipping_document_print_profile_id
actions << h.link_to('Reprint Pick Slip (PDF)', h.print_pick_slip_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
if shipping_document_print_profile_id
actions << h.link_to('Reprint Pick Slip - Split Kit/SN', h.print_pick_slip_delivery_path(delivery, return_path: return_path, split_kits: true, print_profile_id: shipping_document_print_profile_id),
class: 'dropdown-item')
end
actions << h.link_to('Reprint Pick Slip - Split Kit/SN (PDF)', h.print_pick_slip_delivery_path(delivery, return_path: return_path, split_kits: true), class: 'dropdown-item')
actions << h.link_to('Schedule Future Release', h.edit_release_date_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
actions << h.link_to('Print Serial Numbers', h.print_serial_numbers_delivery_path(delivery, return_path: return_path), class: 'dropdown-item') if delivery.line_items.any?(&:require_reservation?)
actions << h.link_to('Cancel/Hold Order (and reserve stock)', h.hold_delivery_path(delivery, reserve_stock: '1'), class: 'dropdown-item')
actions << h.link_to('Cancel/Hold Order (and DO NOT reserve stock', h.hold_delivery_path(delivery), class: 'dropdown-item')
elsif delivery.pre_pack?
actions << h.link_to('Estimate Packaging', h.picked_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
elsif delivery.pending_ship_labels?
actions << h.link_to('Ship Label', h.ship_label_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
actions << workflow_action_link('Re-Pick', 'repick', return_path:, warehouse_context:) if delivery.can_repick?
actions << h.link_to('Void Shipments', h.void_shipments_delivery_path(delivery, return_path: return_path), class: 'dropdown-item') if delivery.shipments.completed.any? && delivery.carrier != 'UPSFreight'
actions << h.link_to('Picked', h.picked_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
actions << h.link_to('Reprint Pick Slip', h.print_pick_slip_delivery_path(delivery, return_path: return_path, print_profile_id: shipping_document_print_profile_id), class: 'dropdown-item') if shipping_document_print_profile_id
actions << h.link_to('Reprint Pick Slip (PDF)', h.print_pick_slip_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
if shipping_document_print_profile_id
actions << h.link_to('Reprint Pick Slip - Split Kit/SN', h.print_pick_slip_delivery_path(delivery, return_path: return_path, split_kits: true, print_profile_id: shipping_document_print_profile_id),
class: 'dropdown-item')
end
actions << h.link_to('Reprint Pick Slip - Split Kit/SN (PDF)', h.print_pick_slip_delivery_path(delivery, return_path: return_path, split_kits: true), class: 'dropdown-item')
actions << h.link_to('Schedule Future Release', h.edit_release_date_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
actions << h.link_to('Cancel/Hold Order (and reserve stock)', h.hold_delivery_path(delivery, reserve_stock: '1'), class: 'dropdown-item') unless delivery.locked_for_fba? && !h.user_has_role?('admin')
actions << h.link_to('Cancel/Hold Order (and DO NOT reserve stock)', h.hold_delivery_path(delivery), class: 'dropdown-item') unless delivery.locked_for_fba? && !h.user_has_role?('admin')
actions << workflow_action_link('Advance to Pending Ship Confirm', 'advance_to_pending_ship_confirm', return_path:, warehouse_context:) if delivery.can_advance_to_pending_ship_confirm?
elsif delivery.pending_ship_confirm? || delivery.pending_pickup_confirm?
actions << warehouse_action_link('Delivery Shipped', :shipped_delivery_path, return_path:, warehouse_context:)
actions << h.link_to('Picked', h.picked_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
actions << h.link_to('Reprint Pick Slip', h.print_pick_slip_delivery_path(delivery, return_path: return_path, print_profile_id: shipping_document_print_profile_id), class: 'dropdown-item') if shipping_document_print_profile_id
actions << h.link_to('Reprint Pick Slip (PDF)', h.print_pick_slip_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
if shipping_document_print_profile_id
actions << h.link_to('Reprint Pick Slip - Split Kit/SN', h.print_pick_slip_delivery_path(delivery, return_path: return_path, split_kits: true, print_profile_id: shipping_document_print_profile_id),
class: 'dropdown-item')
end
actions << h.link_to('Reprint Pick Slip - Split Kit/SN (PDF)', h.print_pick_slip_delivery_path(delivery, return_path: return_path, split_kits: true), class: 'dropdown-item')
if delivery.shipments.completed.any? && !delivery.is_part_of_manifest?
actions << h.link_to('Void Shipments', h.void_shipments_delivery_path(delivery, return_path: return_path), class: 'dropdown-item') if delivery.carrier != 'UPSFreight'
end
actions << workflow_action_link('Cancel Shipment', 'cancel_shipments', return_path:, warehouse_context:) if delivery.can_cancel_shipments?
elsif delivery.pending_manifest_completion?
actions << h.link_to('Void Shipments', h.void_shipments_delivery_path(delivery, return_path: return_path), class: 'dropdown-item') if delivery.shipments.completed.any? && !delivery.is_part_of_manifest?
elsif delivery.pending_carrier_confirm?
actions << h.link_to('Retry Asynch Carrier Confirm', h.retry_asynch_carrier_confirm_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
elsif delivery.shipped? && !delivery.is_part_of_manifest?
actions << h.link_to('Picked', h.picked_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
actions << h.link_to('Reprint Pick Slip', h.print_pick_slip_delivery_path(delivery, return_path: return_path, print_profile_id: shipping_document_print_profile_id), class: 'dropdown-item') if shipping_document_print_profile_id
actions << h.link_to('Reprint Pick Slip (PDF)', h.print_pick_slip_delivery_path(delivery, return_path: return_path), class: 'dropdown-item')
if shipping_document_print_profile_id
actions << h.link_to('Reprint Pick Slip - Split Kit/SN', h.print_pick_slip_delivery_path(delivery, return_path: return_path, split_kits: true, print_profile_id: shipping_document_print_profile_id),
class: 'dropdown-item')
end
actions << h.link_to('Reprint Pick Slip - Split Kit/SN (PDF)', h.print_pick_slip_delivery_path(delivery, return_path: return_path, split_kits: true), class: 'dropdown-item')
if h.user_has_role?('warehouse_rep')
actions << warehouse_action_link('Mark as pending ship/pickup confirm', :pending_confirm_delivery_path, return_path:, warehouse_context:)
actions << h.link_to('Void Shipments', h.void_shipments_delivery_path(delivery, return_path: return_path), class: 'dropdown-item') if delivery.shipments.completed.any? && (delivery.carrier != 'UPSFreight')
end
actions << warehouse_action_link('Mark Invoiced', :trigger_invoiced_delivery_path, return_path:, warehouse_context:, html_opts: { method: :post }) if h.user_has_role?('accounting_rep')
elsif delivery.service_ready_to_fulfill?
actions << warehouse_action_link('Mark as Shipped', :shipped_delivery_path, return_path:, warehouse_context:)
end
if (bol_pdf = begin
delivery.shipments.completed.first.bol_pdf
rescue StandardError
nil
end)
actions << h.link_to('View Bill of Lading', h.upload_path(bol_pdf), class: 'dropdown-item')
end
actions << h.link_to(fa_icon('external-link-alt', text: 'Generate Heatwave Bill of Lading'), h.bol_delivery_path(delivery, format: :pdf), class: 'dropdown-item', target: '_blank', rel: 'noopener noreferrer') if delivery.ltl_freight?
actions << h.link_to(fa_icon('external-link-alt', text: 'Generate Commercial Invoice'), h.ci_delivery_path(delivery, format: :pdf), class: 'dropdown-item', target: '_blank', rel: 'noopener noreferrer') if delivery.is_international?
if (ship_ci_pdf = begin
delivery.ship_ci_pdf
rescue StandardError
nil
end)
actions << h.link_to('View Commercial Invoice', h.upload_path(ship_ci_pdf), class: 'dropdown-item')
end
if (electronic_ship_ci_pdf = begin
delivery.electronic_ship_ci_pdf
rescue StandardError
nil
end)
actions << h.link_to('View Electronic Commercial Invoice (DO NOT PRINT)', h.upload_path(electronic_ship_ci_pdf), class: 'dropdown-item')
end
if delivery.is_cross_border?
unless delivery.electronic_ship_ci_pdf.presence || h.user_has_role?('admin')
actions << h.link_to(fa_icon('external-link-alt', text: 'Generate Heatwave Commercial Invoice'), h.ci_delivery_path(delivery, format: :pdf), class: 'dropdown-item',
target: '_blank', rel: 'noopener noreferrer')
end
end
if delivery.can_print_carton_labels?
actions << h.link_to('Print Carton/UCC-128 Labels', h.generate_carton_labels_path(delivery_id: delivery.id, return_path: return_path), class: 'dropdown-item')
actions << h.link_to('Export Shipments Contents To CSV', h.export_shipments_contents_to_csv_delivery_path(delivery_id: delivery.id, return_path: return_path), class: 'dropdown-item')
end
actions << h.link_to(fa_icon('barcode', text: 'Print UPC Labels'), h.generate_barcodes_path(delivery_id: delivery.id, return_path: return_path), class: 'dropdown-item')
actions << h.link_to(fa_icon('truck', text: 'Edit tracking numbers'), h.edit_tracking_delivery_path(delivery), class: 'dropdown-item') if delivery.can_update_tracking_info?
actions
end
|