Class: StockTakingsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

current

Methods included from PathHelper

#finance_group_transactions_path

Instance Method Details

#createObject



20
21
22
# File 'app/controllers/stock_takings_controller.rb', line 20

def create
  create!(notice: I18n.t('stock_takings.create.notice'))
end

#indexObject



4
5
6
# File 'app/controllers/stock_takings_controller.rb', line 4

def index
  @stock_takings = StockTaking.order('date DESC').page(params[:page]).per(@per_page)
end

#newObject



8
9
10
11
# File 'app/controllers/stock_takings_controller.rb', line 8

def new
  @stock_taking = StockTaking.new
  StockArticle.undeleted.each { |a| @stock_taking.stock_changes.build(stock_article: a) }
end

#new_on_stock_article_createObject

See publish/subscribe design pattern in /doc.



13
14
15
16
17
18
# File 'app/controllers/stock_takings_controller.rb', line 13

def new_on_stock_article_create # See publish/subscribe design pattern in /doc.
  stock_article = StockArticle.find(params[:stock_article_id])
  @stock_change = StockChange.new(stock_article: stock_article)

  render layout: false
end

#updateObject



24
25
26
# File 'app/controllers/stock_takings_controller.rb', line 24

def update
  update!(notice: I18n.t('stock_takings.update.notice'))
end