Module: SpreeNpAtobarai::OrderDecorator

Defined in:
app/models/spree_np_atobarai/order_decorator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/models/spree_np_atobarai/order_decorator.rb', line 3

def self.prepended(base)
  base.set_callback :updating_from_params, :before, :adjust_np_atobarai_fee, prepend: true
  base.set_callback :updating_from_params, :after, :update_np_atobarai_invoice_sending, prepend: true

  base.scope :np_atobarai_orders, -> {
    joins(:payments)
      .where(spree_payments: { payment_method_id: Spree::PaymentMethod::NpAtobarai.ids })
      .merge(Spree::Payment.unscoped.valid).distinct
  }
end

Instance Method Details

#human_invoice_sending_nameObject



14
15
16
# File 'app/models/spree_np_atobarai/order_decorator.rb', line 14

def human_invoice_sending_name
  payments.last&.human_invoice_sending_name
end

#np_atobarai_order?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/models/spree_np_atobarai/order_decorator.rb', line 18

def np_atobarai_order?
  Spree::Order.np_atobarai_orders.exists?(id: id)
end