Class: Spree::ReimbursementType::Credit

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

Constant Summary

Constants inherited from Spree::ReimbursementType

KINDS, ORIGINAL

Class Method Summary collapse

Methods included from ReimbursementHelpers

create_credits, create_refunds

Methods inherited from Base

belongs_to_required_by_default, page, spree_base_scopes

Methods included from Preferences::Preferable

#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Class Method Details

.reimburse(reimbursement, return_items, simulate) ⇒ Object


6
7
8
9
10
# File 'app/models/spree/reimbursement_type/credit.rb', line 6

def reimburse(reimbursement, return_items, simulate)
  unpaid_amount = return_items.map { |ri| ri.total.to_d.round(2) }.sum
  reimbursement_list, unpaid_amount = create_credits(reimbursement, unpaid_amount, simulate)
  reimbursement_list
end