Introduced invoices and deliveries. Integration (especially of deliveries) isn't finished yet.
This commit is contained in:
parent
1894f27fe0
commit
30f3d199d3
65 changed files with 1193 additions and 209 deletions
|
|
@ -127,5 +127,5 @@ class ApplicationController < ActionController::Base
|
|||
def send_email_messages
|
||||
Message.send_emails if Message.pending?
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
94
app/controllers/deliveries_controller.rb
Normal file
94
app/controllers/deliveries_controller.rb
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
class DeliveriesController < ApplicationController
|
||||
|
||||
before_filter :find_supplier
|
||||
|
||||
# GET /deliveries
|
||||
# GET /deliveries.xml
|
||||
def index
|
||||
@deliveries = @supplier.deliveries.find(:all)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @deliveries }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /deliveries/1
|
||||
# GET /deliveries/1.xml
|
||||
def show
|
||||
@delivery = Delivery.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.xml { render :xml => @delivery }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /deliveries/new
|
||||
# GET /deliveries/new.xml
|
||||
def new
|
||||
@delivery = @supplier.deliveries.build
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @delivery }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /deliveries/1/edit
|
||||
def edit
|
||||
@delivery = Delivery.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /deliveries
|
||||
# POST /deliveries.xml
|
||||
def create
|
||||
@delivery = Delivery.new(params[:delivery])
|
||||
|
||||
respond_to do |format|
|
||||
if @delivery.save
|
||||
flash[:notice] = 'Delivery was successfully created.'
|
||||
format.html { redirect_to([@supplier,@delivery]) }
|
||||
format.xml { render :xml => @delivery, :status => :created, :location => @delivery }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @delivery.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /deliveries/1
|
||||
# PUT /deliveries/1.xml
|
||||
def update
|
||||
@delivery = Delivery.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @delivery.update_attributes(params[:delivery])
|
||||
flash[:notice] = 'Delivery was successfully updated.'
|
||||
format.html { redirect_to([@supplier,@delivery]) }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.xml { render :xml => @delivery.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /deliveries/1
|
||||
# DELETE /deliveries/1.xml
|
||||
def destroy
|
||||
@delivery = Delivery.find(params[:id])
|
||||
@delivery.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(supplier_deliveries_url(@supplier)) }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def find_supplier
|
||||
@supplier = Supplier.find(params[:supplier_id]) if params[:supplier_id]
|
||||
end
|
||||
end
|
||||
79
app/controllers/invoices_controller.rb
Normal file
79
app/controllers/invoices_controller.rb
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
class InvoicesController < ApplicationController
|
||||
|
||||
def index
|
||||
@invoices = Invoice.find(:all, :order => "date DESC")
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @invoices }
|
||||
end
|
||||
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
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @invoice }
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@invoice = Invoice.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /invoices
|
||||
# POST /invoices.xml
|
||||
def create
|
||||
@invoice = Invoice.new(params[:invoice])
|
||||
|
||||
respond_to do |format|
|
||||
if @invoice.save
|
||||
flash[:notice] = 'Invoice was successfully created.'
|
||||
format.html { redirect_to(@invoice) }
|
||||
format.xml { render :xml => @invoice, :status => :created, :location => @invoice }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @invoice.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
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(@invoice) }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.xml { render :xml => @invoice.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
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(invoices_path) }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,19 +1,12 @@
|
|||
class SuppliersController < ApplicationController
|
||||
before_filter :authenticate_suppliers, :except => [:index, :list]
|
||||
|
||||
verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list }
|
||||
|
||||
# messages
|
||||
MSG_SUPPLIER_DESTOYED = "Lieferant wurde gelöscht"
|
||||
MSG_SUPPLIER_UPDATED = 'Lieferant wurde aktualisiert'
|
||||
MSG_SUPPLIER_CREATED = "Lieferant wurde erstellt"
|
||||
|
||||
def index
|
||||
list
|
||||
render :action => 'list'
|
||||
end
|
||||
|
||||
def list
|
||||
@supplier_column_names = ["Name", "Telefon", "Email", "Kundennummer"]
|
||||
@supplier_columns = ["name", "phone", "email", "customer_number"]
|
||||
@suppliers = Supplier.find :all
|
||||
|
|
@ -40,7 +33,7 @@ class SuppliersController < ApplicationController
|
|||
@supplier = Supplier.new(params[:supplier])
|
||||
if @supplier.save
|
||||
flash[:notice] = MSG_SUPPLIER_CREATED
|
||||
redirect_to :action => 'list'
|
||||
redirect_to suppliers_path
|
||||
else
|
||||
render :action => 'new'
|
||||
end
|
||||
|
|
@ -54,19 +47,20 @@ class SuppliersController < ApplicationController
|
|||
@supplier = Supplier.find(params[:id])
|
||||
if @supplier.update_attributes(params[:supplier])
|
||||
flash[:notice] = MSG_SUPPLIER_UPDATED
|
||||
redirect_to :action => 'show', :id => @supplier
|
||||
redirect_to @supplier
|
||||
else
|
||||
render :action => 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
Supplier.find(params[:id]).destroy
|
||||
@supplier = Supplier.find(params[:id])
|
||||
@supplier.destroy
|
||||
flash[:notice] = MSG_SUPPLIER_DESTOYED
|
||||
redirect_to :action => 'list'
|
||||
redirect_to suppliers_path
|
||||
rescue => e
|
||||
flash[:error] = _("An error has occurred: ") + e.message
|
||||
redirect_to :action => 'show', :id => params[:id]
|
||||
redirect_to @supplier
|
||||
end
|
||||
|
||||
# gives a list with all available shared_suppliers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue