Run rubocop --fix-layout and remove encoding comments

This commit is contained in:
Patrick Gansterer 2021-03-01 15:27:26 +01:00
parent fa63e6e81d
commit ea2862fdef
283 changed files with 1164 additions and 1969 deletions

View file

@ -1,6 +1,4 @@
# encoding: utf-8
class Finance::BalancingController < Finance::BaseController
def index
@orders = Order.finished.page(params[:page]).per(@per_page).order('ends DESC')
end
@ -11,20 +9,20 @@ class Finance::BalancingController < Finance::BaseController
@comments = @order.comments
@articles = @order.order_articles.ordered_or_member.includes(:article, :article_price,
group_order_articles: {group_order: :ordergroup})
group_order_articles: { group_order: :ordergroup })
sort_param = params['sort'] || 'name'
@articles = case sort_param
when 'name' then
@articles.order('articles.name ASC')
when 'name_reverse' then
@articles.order('articles.name DESC')
when 'order_number' then
@articles.order('articles.order_number ASC')
when 'order_number_reverse' then
@articles.order('articles.order_number DESC')
else
@articles
when 'name' then
@articles.order('articles.name ASC')
when 'name_reverse' then
@articles.order('articles.name DESC')
when 'order_number' then
@articles.order('articles.order_number ASC')
when 'order_number_reverse' then
@articles.order('articles.order_number DESC')
else
@articles
end
render layout: false if request.xhr?
@ -84,7 +82,6 @@ class Finance::BalancingController < Finance::BaseController
@type = FinancialTransactionType.find_by_id(params.permit(:type)[:type])
@order.close!(@current_user, @type)
redirect_to finance_order_index_url, notice: t('finance.balancing.close.notice')
rescue => error
redirect_to new_finance_order_url(order_id: @order.id), alert: t('finance.balancing.close.alert', message: error.message)
end
@ -110,5 +107,4 @@ class Finance::BalancingController < Finance::BaseController
rescue => error
redirect_to finance_order_index_url, alert: t('errors.general_msg', msg: error.message)
end
end

View file

@ -1,5 +1,4 @@
class Finance::BankAccountsController < Finance::BaseController
def index
@bank_accounts = BankAccount.order('name')
redirect_to finance_bank_account_transactions_url(@bank_accounts.first) if @bank_accounts.count == 1
@ -26,7 +25,7 @@ class Finance::BankAccountsController < Finance::BaseController
flash.notice = t('.notice', count: importer.count) if ok
@auto_submit = importer.auto_submit
@controls = importer.controls
#TODO: encrypt state
# TODO: encrypt state
@state = YAML.dump importer.dump
else
ok = true
@ -39,6 +38,7 @@ class Finance::BankAccountsController < Finance::BaseController
needs_redirect = true
ensure
return unless needs_redirect
redirect_path = finance_bank_account_transactions_url(@bank_account)
if request.post?
@js_redirect = redirect_path
@ -46,5 +46,4 @@ class Finance::BankAccountsController < Finance::BaseController
redirect_to redirect_path
end
end
end

View file

@ -5,12 +5,12 @@ class Finance::BankTransactionsController < ApplicationController
def index
if params["sort"]
sort = case params["sort"]
when "date" then "date"
when "amount" then "amount"
when "financial_link" then "financial_link_id"
when "date_reverse" then "date DESC"
when "amount_reverse" then "amount DESC"
when "financial_link_reverse" then "financial_link_id DESC"
when "date" then "date"
when "amount" then "amount"
when "financial_link" then "financial_link_id"
when "date_reverse" then "date DESC"
when "amount_reverse" then "amount DESC"
when "financial_link_reverse" then "financial_link_id DESC"
end
else
sort = "date DESC"

View file

@ -110,13 +110,13 @@ class Finance::FinancialLinksController < Finance::BaseController
redirect_to finance_link_url(@financial_link), notice: t('.notice')
end
protected
protected
def find_financial_link
@financial_link = FinancialLink.find(params[:id])
end
private
private
def financial_transaction_params
params.require(:financial_transaction).permit(:financial_transaction_type_id, :ordergroup_id, :amount, :note)
@ -128,5 +128,4 @@ private
JOIN bank_transactions b ON a.iban = b.iban AND b.financial_link_id = #{financial_link_id.to_i}
SQL
end
end

View file

@ -1,20 +1,19 @@
# encoding: utf-8
class Finance::FinancialTransactionsController < ApplicationController
before_action :authenticate_finance
before_action :find_ordergroup, :except => [:new_collection, :create_collection, :index_collection]
inherit_resources
# belongs_to :ordergroup
# belongs_to :ordergroup
def index
if params['sort']
sort = case params['sort']
when "date" then "created_on"
when "note" then "note"
when "amount" then "amount"
when "date_reverse" then "created_on DESC"
when "note_reverse" then "note DESC"
when "amount_reverse" then "amount DESC"
end
when "date" then "created_on"
when "note" then "note"
when "amount" then "amount"
when "date_reverse" then "created_on DESC"
when "note_reverse" then "note DESC"
when "amount_reverse" then "amount DESC"
end
else
sort = "created_on DESC"
end
@ -79,6 +78,7 @@ class Finance::FinancialTransactionsController < ApplicationController
def create_collection
raise I18n.t('finance.financial_transactions.controller.create_collection.error_note_required') if params[:note].blank?
type = FinancialTransactionType.find_by_id(params[:type_id])
financial_link = nil
@ -103,12 +103,12 @@ class Finance::FinancialTransactionsController < ApplicationController
if params[:create_foodcoop_transaction]
ft = FinancialTransaction.new({
financial_transaction_type: type,
user: @current_user,
amount: foodcoop_amount,
note: params[:note],
financial_link: financial_link,
})
financial_transaction_type: type,
user: @current_user,
amount: foodcoop_amount,
note: params[:note],
financial_link: financial_link,
})
ft.save!
end
@ -131,5 +131,4 @@ class Finance::FinancialTransactionsController < ApplicationController
@foodcoop = true
end
end
end

View file

@ -1,5 +1,4 @@
class Finance::OrdergroupsController < Finance::BaseController
def index
m = /^(?<col>name|sum_of_class_\d+)(?<reverse>_reverse)?$/.match params["sort"]
if m