Class: Spree::ReimbursementType::Credit

Inherits:
Spree::ReimbursementType show all
Extended by:
ReimbursementHelpers
Defined in:
core/app/models/spree/reimbursement_type/credit.rb

Constant Summary

Constants inherited from Spree::ReimbursementType

ORIGINAL

Instance Attribute Summary

Attributes included from ReimbursementHelpers

#eligible_refund_methods

Class Method Summary collapse

Methods included from ReimbursementHelpers

create_credits, create_refunds

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Class Method Details

.reimburse(reimbursement, return_items, simulate, created_by: nil) ⇒ Object



8
9
10
11
12
13
14
15
# File 'core/app/models/spree/reimbursement_type/credit.rb', line 8

def reimburse(reimbursement, return_items, simulate, created_by: nil)
  unless created_by
    Spree::Deprecation.warn("Calling #reimburse on #{self} without created_by is deprecated")
  end
  unpaid_amount = return_items.sum(&:total).round(2, :down)
  reimbursement_list, _unpaid_amount = create_credits(reimbursement, unpaid_amount, simulate, created_by: created_by)
  reimbursement_list
end