Class: Spree::CustomerReturn
- Inherits:
-
Object
- Object
- Spree::CustomerReturn
- Extended by:
- DisplayMoney
- Includes:
- Metadata, Metafields, NumberIdentifier, Webhooks::HasWebhooks
- Defined in:
- app/models/spree/customer_return.rb
Instance Method Summary collapse
- #can_create_reimbursement? ⇒ Boolean
- #completely_decided? ⇒ Boolean
- #currency ⇒ Object
- #fully_reimbursed? ⇒ Boolean
- #no_pending_reimbursements? ⇒ Boolean
-
#order ⇒ Object
Temporarily tie a customer_return to one order.
- #pre_tax_total ⇒ Object
Methods included from DisplayMoney
Instance Method Details
#can_create_reimbursement? ⇒ Boolean
58 59 60 |
# File 'app/models/spree/customer_return.rb', line 58 def can_create_reimbursement? !fully_reimbursed? && completely_decided? && no_pending_reimbursements? end |
#completely_decided? ⇒ Boolean
34 35 36 |
# File 'app/models/spree/customer_return.rb', line 34 def completely_decided? !return_items.undecided.exists? end |
#currency ⇒ Object
42 43 44 |
# File 'app/models/spree/customer_return.rb', line 42 def currency order&.currency end |
#fully_reimbursed? ⇒ Boolean
38 39 40 |
# File 'app/models/spree/customer_return.rb', line 38 def fully_reimbursed? completely_decided? && return_items.accepted.includes(:reimbursement).all? { |return_item| return_item.reimbursement.try(:reimbursed?) } end |
#no_pending_reimbursements? ⇒ Boolean
62 63 64 65 66 67 68 |
# File 'app/models/spree/customer_return.rb', line 62 def no_pending_reimbursements? if association(:reimbursements).loaded? reimbursements.select(&:pending?).empty? else reimbursements.where(reimbursement_status: :pending).none? end end |
#order ⇒ Object
Temporarily tie a customer_return to one order
47 48 49 50 51 52 |
# File 'app/models/spree/customer_return.rb', line 47 def order return nil if return_items.blank? return nil if return_items.first.inventory_unit.blank? return_items.first.inventory_unit.order end |
#pre_tax_total ⇒ Object
54 55 56 |
# File 'app/models/spree/customer_return.rb', line 54 def pre_tax_total return_items.sum(:pre_tax_amount) end |