Module: EffectiveQbOnlineHelper

Defined in:
app/helpers/effective_qb_online_helper.rb

Instance Method Summary collapse

Instance Method Details

#qb_receipt_effective_orders_collection(qb_receipt) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/effective_qb_online_helper.rb', line 2

def qb_receipt_effective_orders_collection(qb_receipt)
  raise('expected a non-persisted Effective::QbReceipt') unless qb_receipt.kind_of?(Effective::QbReceipt) && qb_receipt.new_record?

  existing = Effective::QbReceipt.select('order_id')
  orders = Effective::Order.purchased.sorted.includes(:user).where.not(id: existing)

  orders.map do |order|
    label = "#{order} - #{order.billing_name} - #{order.email} - #{price_to_currency(order.total)}"
    [label, order.to_param]
  end

end