Class: DeliveriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/deliveries_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

current

Methods included from PathHelper

#finance_group_transactions_path

Instance Method Details

#add_stock_changeObject


53
54
55
56
57
# File 'app/controllers/deliveries_controller.rb', line 53

def add_stock_change
  @stock_change = StockChange.new
  @stock_change.stock_article = StockArticle.find(params[:stock_article_id])
  render :layout => false
end

#createObject


19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/deliveries_controller.rb', line 19

def create
  @delivery = Delivery.new(params[:delivery])
  
  if @delivery.save
    flash[:notice] = I18n.t('deliveries.create.notice')
    redirect_to [@supplier, @delivery]
  else
    render :action => "new"
  end
end

#destroyObject


45
46
47
48
49
50
51
# File 'app/controllers/deliveries_controller.rb', line 45

def destroy
  @delivery = Delivery.find(params[:id])
  @delivery.destroy

  flash[:notice] = I18n.t('deliveries.destroy.notice')
  redirect_to supplier_deliveries_url(@supplier)
end

#editObject


30
31
32
# File 'app/controllers/deliveries_controller.rb', line 30

def edit
  @delivery = Delivery.find(params[:id])
end

#form_on_stock_article_createObject

See publish/subscribe design pattern in /doc.


59
60
61
62
63
# File 'app/controllers/deliveries_controller.rb', line 59

def form_on_stock_article_create # See publish/subscribe design pattern in /doc.
  @stock_article = StockArticle.find(params[:id])
  
  render :layout => false
end

#form_on_stock_article_updateObject

See publish/subscribe design pattern in /doc.


65
66
67
68
69
# File 'app/controllers/deliveries_controller.rb', line 65

def form_on_stock_article_update # See publish/subscribe design pattern in /doc.
  @stock_article = StockArticle.find(params[:id])
  
  render :layout => false
end

#indexObject


6
7
8
# File 'app/controllers/deliveries_controller.rb', line 6

def index
  @deliveries = @supplier.deliveries.order('delivered_on DESC')
end

#newObject


14
15
16
17
# File 'app/controllers/deliveries_controller.rb', line 14

def new
  @delivery = @supplier.deliveries.build
  @delivery.delivered_on = Date.today #TODO: move to model/database
end

#showObject


10
11
12
# File 'app/controllers/deliveries_controller.rb', line 10

def show
  @delivery = Delivery.find(params[:id])
end

#updateObject


34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/deliveries_controller.rb', line 34

def update
  @delivery = Delivery.find(params[:id])

  if @delivery.update_attributes(params[:delivery])
    flash[:notice] = I18n.t('deliveries.update.notice')
    redirect_to [@supplier,@delivery]
  else
    render :action => "edit"
  end
end