Move helper to service for re-use

This commit is contained in:
Maikel Linke
2020-02-18 10:40:58 +11:00
parent 2c2023df03
commit 3e0a5bac6a
2 changed files with 6 additions and 4 deletions

View File

@@ -1,5 +1,7 @@
module OrdersHelper
def order_paid_via(order)
# frozen_string_literal: true
module OrderPaymentFinder
def self.last_payment_method(order)
# `sort_by` avoids additional database queries when payments are loaded
# already. There is usually only one payment and this shouldn't cause
# any overhead compared to `order(:updated_at)`.

View File

@@ -13,9 +13,9 @@
.pad
.text-big
= t :order_payment
%strong= order_paid_via(order).andand.name
%strong= OrderPaymentFinder.last_payment_method(order).andand.name
%p.text-small.text-skinny.pre-line
%em= order_paid_via(order).andand.description
%em= OrderPaymentFinder.last_payment_method(order).andand.description
.order-summary.text-small
%strong