-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove default address dependency #2686
Changes from all commits
8abe045
5a3b5ea
8994b5b
a1a783a
18c51b7
3486072
cecc03c
f7cd81e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ class ReimbursementsController < ResourceController | |
rescue_from Spree::Core::GatewayError, with: :spree_core_gateway_error | ||
|
||
def perform | ||
@reimbursement.perform! | ||
@reimbursement.perform!(try_spree_current_user) | ||
redirect_to location_after_save | ||
end | ||
|
||
|
@@ -57,7 +57,7 @@ def load_stock_locations | |
end | ||
|
||
def load_simulated_refunds | ||
@reimbursement_objects = @reimbursement.simulate | ||
@reimbursement_objects = @reimbursement.simulate(try_spree_current_user) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here as well @reimbursement.simulate(creator: try_spree_current_user) |
||
end | ||
|
||
def spree_core_gateway_error(error) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,13 +83,17 @@ def cancel_unit(inventory_unit, reason: Spree::UnitCancel::DEFAULT_REASON, whodu | |
# @api public | ||
# @param [Array<InventoryUnit>] inventory_units the inventory units to be reimbursed | ||
# @return [Reimbursement] the reimbursement for inventory being canceled | ||
def reimburse_units(inventory_units) | ||
def reimburse_units(inventory_units, creator = nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we use a named argument here? def reimburse_units(inventory_units, creator: nil) |
||
unless creator | ||
creator = Spree.user_class.where(email: 'spree@example.com').first | ||
Spree::Deprecation.warn("Calling #reimburse_units on #{self} without creator is deprecated") | ||
end | ||
reimbursement = nil | ||
|
||
Spree::OrderMutex.with_lock!(@order) do | ||
return_items = inventory_units.map(&:current_or_new_return_item) | ||
reimbursement = Spree::Reimbursement.new(order: @order, return_items: return_items) | ||
reimbursement.return_all | ||
reimbursement.return_all(creator) | ||
end | ||
|
||
reimbursement | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,12 +98,16 @@ def unpaid_amount | |
total - paid_amount | ||
end | ||
|
||
def perform! | ||
def perform!(creator = nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A named parameter would help the self-documentation of this method. |
||
unless creator | ||
creator = Spree.user_class.where(email: 'spree@example.com').first | ||
Spree::Deprecation.warn("Calling #perform on #{self} without creator is deprecated") | ||
end | ||
reimbursement_tax_calculator.call(self) | ||
reload | ||
update!(total: calculated_total) | ||
|
||
reimbursement_performer.perform(self) | ||
reimbursement_performer.perform(self, creator) | ||
|
||
if unpaid_amount_within_tolerance? | ||
reimbursed! | ||
|
@@ -116,12 +120,16 @@ def perform! | |
end | ||
end | ||
|
||
def simulate | ||
def simulate(creator = nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto: Named argument |
||
unless creator | ||
creator = Spree.user_class.where(email: 'spree@example.com').first | ||
Spree::Deprecation.warn("Calling #simulate on #{self} without creator is deprecated") | ||
end | ||
reimbursement_simulator_tax_calculator.call(self) | ||
reload | ||
update!(total: calculated_total) | ||
|
||
reimbursement_performer.simulate(self) | ||
reimbursement_performer.simulate(self, creator) | ||
end | ||
|
||
def return_items_requiring_exchange | ||
|
@@ -140,10 +148,14 @@ def all_exchanges? | |
# | ||
# @api public | ||
# @return [void] | ||
def return_all | ||
def return_all(creator = nil) | ||
unless creator | ||
creator = Spree.user_class.where(email: 'spree@example.com').first | ||
Spree::Deprecation.warn("Calling #return_all on #{self} without creator is deprecated") | ||
end | ||
return_items.each(&:accept!) | ||
save! | ||
perform! | ||
perform!(creator) | ||
end | ||
|
||
private | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A named argument would explain the purpose of this argument: