Module: Crm::TechBenchHelper
- Defined in:
- app/helpers/crm/tech_bench_helper.rb
Overview
View helpers for the CRM tech bench: builds the per-item action dropdown
(label printing, B-stock reclass, location transfers, inventory adjustment)
shown on tech bench views, gated by the current user's abilities.
Instance Method Summary collapse
-
#reclass_to_bstock_link(store_item) ⇒ String?
Builds a reclass-to-B-Stock URL shortcut for a store item.
-
#render_tech_bench_item_actions(store_item) ⇒ ActiveSupport::SafeBuffer
Renders the action dropdown for a tech bench store item.
Instance Method Details
#reclass_to_bstock_link(store_item) ⇒ String?
Builds a reclass-to-B-Stock URL shortcut for a store item.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/helpers/crm/tech_bench_helper.rb', line 79 def reclass_to_bstock_link(store_item) return unless (refurbished_version = store_item.item.refurbished_version) reclass_params = { store: store_item.store_id, from: store_item.location, from_store_item_id: store_item.id, return_path: request.url, to: 'AVAILABLE', to_item_id: refurbished_version.id } item_reclassification_item_ledger_entries_path(reclass_params) end |
#render_tech_bench_item_actions(store_item) ⇒ ActiveSupport::SafeBuffer
Renders the action dropdown for a tech bench store item.
13 14 15 16 17 18 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 |
# File 'app/helpers/crm/tech_bench_helper.rb', line 13 def render_tech_bench_item_actions(store_item) = ['Select Action'] can_reclass = can?(:do_item_reclassification, ItemLedgerEntry) can_location_transfer = can?(:do_location_transfer, ItemLedgerEntry) << link_to("Print Item Label for #{store_item.item.sku}", print_label_item_path(store_item.item_id, return_path: request.url)) if (refurb_item = store_item.item.refurbished_version) << link_to("Print Item Label for #{refurb_item.sku}", print_label_item_path(refurb_item, return_path: request.url)) elsif store_item.item.condition_new? && can?(:create, Item) catalog_ids = store_item.item.catalog_items.map(&:catalog_id).uniq # using map instead of a pluck since this association is preloaded via includes << link_to('Create B-Stock SKU', clone_item_path(store_item.item_id, item: { action_type: 'refurbish', catalogs: catalog_ids }, return_path: request.url)) end if can_reclass # If we have a b-stock version, quick shortcut to reclass to b-stock if (bl = reclass_to_bstock_link(store_item)) << link_to('Re-class to B-Stock', bl) end end if can_location_transfer && store_item.item.condition_new? # Create a location transfer shortcut to A-stock location_transfer_params = { store_id: store_item.store_id, store: store_item.store_id, from: store_item.location, item_id: store_item.item_id, return_path: request.url, to: 'AVAILABLE' } << link_to('Transfer to A-Stock', location_transfer_item_ledger_entries_path(location_transfer_params)) end if can_reclass reclass_params = { store: store_item.store_id, from: store_item.location, from_store_item_id: store_item.id, return_path: request.url } << link_to('Item Re-classification', item_reclassification_item_ledger_entries_path(reclass_params)) end if can_location_transfer << link_to('Location Transfer', location_transfer_item_ledger_entries_path(store_id: store_item.store_id, store: store_item.store_id, from: store_item.location, item_id: store_item.item_id, return_path: request.url)) end << link_to('Inventory Adjustment', inventory_adjustment_item_ledger_entries_path(store_item_id: store_item.id, return_path: request.url)) if can?(:do_inventory_adjustment, ItemLedgerEntry) if can?(:read, ItemLedgerEntrySearch) query_params = { store_id_in: [store_item.store_id], location_in: [store_item.location], item_id_in: [store_item.item_id] } << link_to('Item Ledger Search', search_and_show_searches_path(search_mode: :full, type: 'ItemLedgerEntrySearch', query_params: query_params)) end render_simple_drop_down end |