Class: Spree::ReimbursementType::StoreCredit
- Inherits:
-
Spree::ReimbursementType
- Object
- ActiveRecord::Base
- Base
- Spree::ReimbursementType
- Spree::ReimbursementType::StoreCredit
- Extended by:
- ReimbursementHelpers
- Defined in:
- app/models/spree/reimbursement_type/store_credit.rb
Constant Summary
Constants inherited from Spree::ReimbursementType
Instance Attribute Summary
Attributes included from ReimbursementHelpers
Class Method Summary collapse
Methods included from ReimbursementHelpers
create_credits, create_refunds
Methods inherited from Base
Methods included from Core::Permalinks
#generate_permalink, #save_permalink
Class Method Details
.reimburse(reimbursement, return_items, simulate, created_by:) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/spree/reimbursement_type/store_credit.rb', line 7 def reimburse(reimbursement, return_items, simulate, created_by:) unpaid_amount = return_items.sum(&:total).to_d.round(2, :down) payments = store_credit_payments(reimbursement) reimbursement_list = [] # Credit each store credit that was used on the order reimbursement_list, unpaid_amount = create_refunds( reimbursement, payments, unpaid_amount, simulate, reimbursement_list ) # If there is any amount left to pay out to the customer, then create credit with that amount if unpaid_amount > 0.0 reimbursement_list, _unpaid_amount = create_credits( reimbursement, unpaid_amount, simulate, reimbursement_list, created_by: ) end reimbursement_list end |