app/controllers/refunds_controller.rb in artfully_ose-1.2.0.beta.1 vs app/controllers/refunds_controller.rb in artfully_ose-1.2.0.pre
- old
+ new
@@ -7,14 +7,18 @@
def create
@order = Order.find(params[:order_id])
@items = params[:items].collect { |item_id| Item.find(item_id) }
@refund = Refund.new(@order, @items)
- @refund.submit(:and_return => return_items?, :send_email_confirmation => send_email_confirmation?)
+ @refund.submit(:and_return => return_items?)
if @refund.successful?
- flash[:notice] = "Successfully refunded #{@refund.items.size} items."
+ if return_items?
+ flash[:notice] = "Successfully refunded and returned #{@refund.items.size} items."
+ else
+ flash[:notice] = "Successfully refunded #{@refund.items.size} items."
+ end
else
if @refund.message.nil?
flash[:error] = "Unable to refund items. Please contact support and we'll try to help!"
else
flash[:error] = "Unable to refund items: " + @refund.message
@@ -24,13 +28,9 @@
redirect_to order_url(@order)
end
private
- def send_email_confirmation?
- params[:send_email_confirmation] == "1"
- end
-
def return_items?
- params[:return_to_inventory] == "1"
+ @return_items ||= (params[:commit] == "Issue Refund and Return" and @items.all?(&:returnable?))
end
end
\ No newline at end of file