mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Inspecting 1721 files
........................................W...................................................................W................W..W.......W................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Offenses:
app/controllers/admin/order_cycles_controller.rb:212:9: W: [Corrected] Rails/RedirectBackOrTo: Use redirect_back_or_to instead of redirect_back with :fallback_location keyword argument.
redirect_back(fallback_location: root_path)
^^^^^^^^^^^^^
app/controllers/locales_controller.rb:6:5: W: [Corrected] Rails/RedirectBackOrTo: Use redirect_back_or_to instead of redirect_back with :fallback_location keyword argument.
redirect_back fallback_location: main_app.root_url
^^^^^^^^^^^^^
app/controllers/spree/admin/invoices_controller.rb:31:9: W: [Corrected] Rails/RedirectBackOrTo: Use redirect_back_or_to instead of redirect_back with :fallback_location keyword argument.
redirect_back(fallback_location: spree.admin_dashboard_path)
^^^^^^^^^^^^^
app/controllers/spree/admin/orders_controller.rb:83:9: W: [Corrected] Rails/RedirectBackOrTo: Use redirect_back_or_to instead of redirect_back with :fallback_location keyword argument.
redirect_back fallback_location: spree.admin_dashboard_path
^^^^^^^^^^^^^
app/controllers/spree/admin/orders_controller.rb:91:25: W: [Corrected] Rails/RedirectBackOrTo: Use redirect_back_or_to instead of redirect_back with :fallback_location keyword argument.
format.html { redirect_back(fallback_location: spree.admin_dashboard_path) }
^^^^^^^^^^^^^
app/controllers/spree/admin/return_authorizations_controller.rb:13:9: W: [Corrected] Rails/RedirectBackOrTo: Use redirect_back_or_to instead of redirect_back with :fallback_location keyword argument.
redirect_back fallback_location: spree.admin_dashboard_path
^^^^^^^^^^^^^
1721 files inspected, 6 offenses detected, 6 offenses corrected
42 lines
1.1 KiB
Ruby
42 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Spree
|
|
module Admin
|
|
class InvoicesController < Spree::Admin::BaseController
|
|
respond_to :json
|
|
|
|
def index
|
|
@order = Spree::Order.find_by(number: params[:order_id])
|
|
authorize! :invoice, @order
|
|
end
|
|
|
|
def show
|
|
invoice_id = params[:id]
|
|
invoice_pdf = filepath(invoice_id)
|
|
|
|
send_file(invoice_pdf, type: 'application/pdf', disposition: :inline)
|
|
rescue ActionController::MissingFile
|
|
render "errors/not_found", status: :not_found, formats: :html
|
|
end
|
|
|
|
def generate
|
|
@order = Order.find_by(number: params[:order_id])
|
|
if @order.distributor.can_invoice?
|
|
authorize! :invoice, @order
|
|
::Orders::GenerateInvoiceService.new(@order).generate_or_update_latest_invoice
|
|
else
|
|
flash[:error] = t(:must_have_valid_business_number,
|
|
enterprise_name: @order.distributor.name)
|
|
end
|
|
redirect_back_or_to(spree.admin_dashboard_path)
|
|
end
|
|
|
|
private
|
|
|
|
def filepath(invoice_id)
|
|
"tmp/invoices/#{invoice_id}.pdf"
|
|
end
|
|
end
|
|
end
|
|
end
|