Class: Search::PurchaseOrderPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::PurchaseOrderPresenter
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/purchase_order_presenter.rb
Overview
Row presenter for PurchaseOrderSearch — renders the cells in the CRM purchase
order search/results table. Wraps a ViewPurchaseOrder projection rather than
a fully-loaded PurchaseOrder so the search grid stays light.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
-
#items_report_link ⇒ ActiveSupport::SafeBuffer?
Partial-rendered items report for the purchase order.
-
#order_date ⇒ String
Purchase order date rendered through the shared
render_datehelper. -
#promised_delivery_date ⇒ String
Promised delivery date rendered through the shared
render_datehelper. -
#purchase_order_link ⇒ ActiveSupport::SafeBuffer
Linked purchase order reference number → purchase order show page.
-
#supplier_link ⇒ ActiveSupport::SafeBuffer?
Linked supplier name → supplier show page; nil when the user lacks read permission or the required columns are not selected.
-
#terms ⇒ ActiveSupport::SafeBuffer, ...
Payment terms; shows a lock icon when the user cannot manage item costs.
-
#total_costs ⇒ ActiveSupport::SafeBuffer, String
Total cost formatted as currency; shows a lock icon when the user cannot manage item costs.
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
#items_report_link ⇒ ActiveSupport::SafeBuffer?
Partial-rendered items report for the purchase order.
31 32 33 34 35 |
# File 'app/presenters/search/purchase_order_presenter.rb', line 31 def items_report_link return unless r.has_columns?(:items_report) h.render partial: '/purchase_orders/search_items_report', locals: { items_report: r.items_report, search_result: r } end |
#order_date ⇒ String
Purchase order date rendered through the shared render_date helper.
66 67 68 |
# File 'app/presenters/search/purchase_order_presenter.rb', line 66 def order_date h.render_date r.order_date end |
#promised_delivery_date ⇒ String
Promised delivery date rendered through the shared render_date helper.
59 60 61 |
# File 'app/presenters/search/purchase_order_presenter.rb', line 59 def promised_delivery_date h.render_date r.promised_delivery_date end |
#purchase_order_link ⇒ ActiveSupport::SafeBuffer
Linked purchase order reference number → purchase order show page.
14 15 16 |
# File 'app/presenters/search/purchase_order_presenter.rb', line 14 def purchase_order_link h.link_to r.reference_number, h.purchase_order_path(r.id) end |
#supplier_link ⇒ ActiveSupport::SafeBuffer?
Linked supplier name → supplier show page; nil when the user lacks read
permission or the required columns are not selected.
22 23 24 25 26 |
# File 'app/presenters/search/purchase_order_presenter.rb', line 22 def supplier_link return unless r.has_columns?(:supplier_full_name, :supplier_id) && h.can?(:read, Supplier) h.link_to r.supplier_full_name, h.supplier_path(r.supplier_id) end |
#terms ⇒ ActiveSupport::SafeBuffer, ...
Payment terms; shows a lock icon when the user cannot manage item costs.
50 51 52 53 54 |
# File 'app/presenters/search/purchase_order_presenter.rb', line 50 def terms return h.fa_icon('lock') unless h.can?(:manage_item_costs, r) r.terms end |
#total_costs ⇒ ActiveSupport::SafeBuffer, String
Total cost formatted as currency; shows a lock icon when the user cannot
manage item costs.
41 42 43 44 45 |
# File 'app/presenters/search/purchase_order_presenter.rb', line 41 def total_costs return h.fa_icon('lock') unless h.can?(:manage_item_costs, r) h.number_to_currency(r.total_cost || 0) end |