Class: OrderArticlesController
Instance Method Summary
collapse
current
Methods included from PathHelper
#finance_group_transactions_path
Instance Method Details
#create ⇒ Object
16
17
18
19
20
21
22
23
24
25
|
# File 'app/controllers/order_articles_controller.rb', line 16
def create
@order_article = @order.order_articles.where(article_id: params[:order_article][:article_id]).first
@order_article = @order.order_articles.build(params[:order_article]) unless @order_article && @order_article.units_to_order == 0
@order_article.save!
rescue StandardError
render action: :new
end
|
#destroy ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/controllers/order_articles_controller.rb', line 36
def destroy
@order_article = OrderArticle.find(params[:id])
if @order_article.group_order_articles.count == 0
@order_article.destroy
else
@order_article.group_order_articles.each { |goa| goa.update_attribute(:result, 0) }
@order_article.update_results!
end
end
|
#edit ⇒ Object
12
13
14
|
# File 'app/controllers/order_articles_controller.rb', line 12
def edit
@order_article = OrderArticle.find(params[:id])
end
|
#new ⇒ Object
8
9
10
|
# File 'app/controllers/order_articles_controller.rb', line 8
def new
@order_article = @order.order_articles.build(params[:order_article])
end
|
#update ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'app/controllers/order_articles_controller.rb', line 27
def update
@order_article = OrderArticle.find(params[:id])
begin
@order_article.update_article_and_price!(params[:order_article], params[:article], params[:article_price])
rescue StandardError
render action: :edit
end
end
|