Class: Search::ItemLedgerEntryPresenter

Inherits:
BasePresenter
  • Object
show all
Includes:
Presenters::Timeable
Defined in:
app/presenters/search/item_ledger_entry_presenter.rb

Overview

Presenter: item ledger entry presenter.

Direct Known Subclasses

ItemLedgerEntryTextPresenter

Instance Attribute Summary

Attributes inherited from BasePresenter

#current_account, #options, #url_helper

Instance Method Summary collapse

Methods inherited from BasePresenter

#can?, #capture, #concat, #content_tag, #fa_icon, #h, #initialize, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u

Constructor Details

This class inherits a constructor from BasePresenter

Instance Method Details

#categoryString?

Short type abbreviation (POR, INV, …) from
ItemLedgerEntry::TYPE_ABBREVIATIONS, or nil when the
search row has no category column.

Returns:

  • (String, nil)


18
19
20
21
22
# File 'app/presenters/search/item_ledger_entry_presenter.rb', line 18

def category
  return unless r.has_columns?(:category)

  ItemLedgerEntry::TYPE_ABBREVIATIONS[r.category]
end

Link to the cycle-count session that produced this entry.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


79
80
81
82
83
# File 'app/presenters/search/item_ledger_entry_presenter.rb', line 79

def cycle_count_link
  return unless r.has_columns?(:cycle_count_id)

  h.link_to r.cycle_count_id, h.cycle_count_path(r.cycle_count_id)
end

Link to the Delivery this entry was written for (store
transfers, mostly).

Returns:

  • (ActiveSupport::SafeBuffer, nil)


63
64
65
66
67
# File 'app/presenters/search/item_ledger_entry_presenter.rb', line 63

def delivery_link
  return unless r.has_columns?(:delivery_id)

  h.link_to r.delivery_id, h.delivery_path(r.delivery_id)
end

First non-nil source-document link in priority order:
PO → Invoice → RMA → cycle-count.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


96
97
98
# File 'app/presenters/search/item_ledger_entry_presenter.rb', line 96

def document_link
  po_link || invoice_link || rma_link || cycle_count_link
end

#entry_linkActiveSupport::SafeBuffer

Link to the ItemLedgerEntry detail page.

Returns:

  • (ActiveSupport::SafeBuffer)


10
11
12
# File 'app/presenters/search/item_ledger_entry_presenter.rb', line 10

def entry_link
  h.link_to r.id, h.item_ledger_entry_path(r.id)
end

Link to the GL LedgerTransaction this ILE is paired with.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


87
88
89
90
91
# File 'app/presenters/search/item_ledger_entry_presenter.rb', line 87

def gl_link
  return unless r.has_columns?(:gl_number, :ledger_transaction_id)

  h.link_to r.gl_number, h.ledger_transaction_path(r.ledger_transaction_id)
end

Link to the source Invoice, when this entry came from a
fulfillment.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


54
55
56
57
58
# File 'app/presenters/search/item_ledger_entry_presenter.rb', line 54

def invoice_link
  return unless r.has_columns?(:invoice_number, :invoice_id)

  h.link_to r.invoice_number, h.invoice_path(r.invoice_id)
end

Link to the Item this entry refers to.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


26
27
28
29
30
# File 'app/presenters/search/item_ledger_entry_presenter.rb', line 26

def item_link
  return unless r.has_columns?(:item_id, :item_sku)

  h.link_to r.item_sku, h.item_path(r.item_id)
end

Link to the source PurchaseOrder, when this entry came from
a PO receipt.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


45
46
47
48
49
# File 'app/presenters/search/item_ledger_entry_presenter.rb', line 45

def po_link
  return unless r.has_columns?(:po_number, :po_id)

  h.link_to r.po_number, h.purchase_order_path(r.po_id)
end

Link to the source RMA when the entry came from a return.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


71
72
73
74
75
# File 'app/presenters/search/item_ledger_entry_presenter.rb', line 71

def rma_link
  return unless r.has_columns?(:rma_number, :rma_id)

  h.link_to r.rma_number, h.rma_path(r.rma_id)
end

#serial_numbersString?

Comma-joined list of serial numbers (per-item-instance ids)
attached to the entry, or nil for searches that don't select
the column.

Returns:

  • (String, nil)


36
37
38
39
40
# File 'app/presenters/search/item_ledger_entry_presenter.rb', line 36

def serial_numbers
  return unless r.has_columns?(:serial_numbers)

  r.serial_numbers.join(', ')
end