Fixed finance module to work with bootstrap design.

This commit is contained in:
benni 2012-11-10 16:44:05 +01:00
parent 16de9124fe
commit 0236fb5a60
55 changed files with 440 additions and 486 deletions

View file

@ -1,15 +1,8 @@
# encoding: utf-8
class Finance::BalancingController < ApplicationController
before_filter :authenticate_finance
class Finance::BalancingController < Finance::BaseController
def index
@financial_transactions = FinancialTransaction.order('created_on DESC').limit(8)
@orders = Order.finished_not_closed
@unpaid_invoices = Invoice.unpaid
end
def list
@orders = Order.finished.paginate :page => params[:page], :per_page => 10, :order => 'ends DESC'
@orders = Order.finished.page(params[:page]).per(@per_page).order('ends DESC')
end
def new
@ -62,10 +55,10 @@ class Finance::BalancingController < ApplicationController
def close
@order = Order.find(params[:id])
@order.close!(@current_user)
redirect_to finance_balancing_url, notice: "Bestellung wurde erfolgreich abgerechnet, die Kontostände aktualisiert."
redirect_to finance_root_url, notice: "Bestellung wurde erfolgreich abgerechnet, die Kontostände aktualisiert."
rescue => error
redirect_to finance_balancing_url, alert: "Ein Fehler ist beim Abrechnen aufgetreten: #{error.message}"
redirect_to new_finance_order_url(order_id: @order.id), alert: "Ein Fehler ist beim Abrechnen aufgetreten: #{error.message}"
end
# Close the order directly, without automaticly updating ordergroups account balances

View file

@ -0,0 +1,11 @@
class Finance::BaseController < ApplicationController
before_filter :authenticate_finance
def index
@financial_transactions = FinancialTransaction.order('created_on DESC').limit(8)
@orders = Order.finished_not_closed
@unpaid_invoices = Invoice.unpaid
render template: 'finance/index'
end
end

View file

@ -19,15 +19,10 @@ class Finance::FinancialTransactionsController < ApplicationController
sort = "created_on DESC"
end
@financial_transactions = @ordergroup.financial_transactions.order(sort)
@financial_transactions = @ordergroup.financial_transactions.unscoped.order(sort)
@financial_transactions = @financial_transactions.where('note LIKE ?', "%#{params[:query]}%") unless params[:query].nil?
@financial_transactions = @financial_transactions.paginate :page => params[:page], :per_page => 10
respond_to do |format|
format.html
format.js { render :layout => false }
end
@financial_transactions = @financial_transactions.page(params[:page]).per(@per_page)
end
def new
@ -55,9 +50,9 @@ class Finance::FinancialTransactionsController < ApplicationController
Ordergroup.find(trans[:ordergroup_id]).add_financial_transaction!(trans[:amount], params[:note], @current_user)
end
end
redirect_to finance_ordergroups_url, :notice => "Alle Transaktionen wurden gespeichert."
redirect_to finance_ordergroups_url, notice: "Alle Transaktionen wurden gespeichert."
rescue => error
redirect_to :action => 'new_collection', :alert => "Ein Fehler ist aufgetreten: " + error.to_s
redirect_to finance_new_transaction_collection_url, alert: "Ein Fehler ist aufgetreten: " + error.to_s
end
protected

View file

@ -1,39 +1,23 @@
class Finance::InvoicesController < ApplicationController
def index
@invoices = Invoice.includes(:supplier, :delivery, :order).order('date DESC').paginate(page: params[:page])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @invoices }
end
@invoices = Invoice.includes(:supplier, :delivery, :order).order('date DESC').page(params[:page]).per(@per_page)
end
def show
@invoice = Invoice.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @invoice }
end
end
def new
@invoice = Invoice.new :supplier_id => params[:supplier_id],
:delivery_id => params[:delivery_id], :order_id => params[:order_id]
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @invoice }
end
:delivery_id => params[:delivery_id],
:order_id => params[:order_id]
end
def edit
@invoice = Invoice.find(params[:id])
end
# POST /invoices
# POST /invoices.xml
def create
@invoice = Invoice.new(params[:invoice])
@ -41,7 +25,7 @@ class Finance::InvoicesController < ApplicationController
flash[:notice] = "Rechnung wurde erstellt."
if @invoice.order
# Redirect to balancing page
redirect_to :controller => 'balancing', :action => 'new', :id => @invoice.order
redirect_to new_finance_order_url(order_id: @invoice.order.id)
else
redirect_to [:finance, @invoice]
end
@ -50,32 +34,20 @@ class Finance::InvoicesController < ApplicationController
end
end
# PUT /invoices/1
# PUT /invoices/1.xml
def update
@invoice = Invoice.find(params[:id])
respond_to do |format|
if @invoice.update_attributes(params[:invoice])
flash[:notice] = 'Invoice was successfully updated.'
format.html { redirect_to([:finance, @invoice]) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @invoice.errors, :status => :unprocessable_entity }
end
if @invoice.update_attributes(params[:invoice])
redirect_to [:finance, @invoice], notice: "Rechnung wurde aktualisiert."
else
render :edit
end
end
# DELETE /invoices/1
# DELETE /invoices/1.xml
def destroy
@invoice = Invoice.find(params[:id])
@invoice.destroy
respond_to do |format|
format.html { redirect_to(finance_invoices_path) }
format.xml { head :ok }
end
redirect_to finance_invoices_url
end
end

View file

@ -1,6 +1,5 @@
class Finance::OrdergroupsController < ApplicationController
before_filter :authenticate_finance
class Finance::OrdergroupsController < Finance::BaseController
def index
if params["sort"]
sort = case params["sort"]
@ -16,11 +15,6 @@ class Finance::OrdergroupsController < ApplicationController
@ordergroups = Ordergroup.order(sort)
@ordergroups = @ordergroups.where('name LIKE ?', "%#{params[:query]}%") unless params[:query].nil?
@ordergroups = @ordergroups.paginate :page => params[:page], :per_page => @per_page
respond_to do |format|
format.html
format.js { render :layout => false }
end
@ordergroups = @ordergroups.page(params[:page]).per(@per_page)
end
end