remember member order when order article is deleted + test

This commit is contained in:
wvengen 2013-09-13 15:37:30 +02:00
parent ee31c0c2af
commit 1bb257c41b
2 changed files with 35 additions and 1 deletions

View file

@ -42,6 +42,14 @@ class Finance::OrderArticlesController < ApplicationController
def destroy
@order_article = OrderArticle.find(params[:id])
@order_article.destroy
# only destroy if there are no associated GroupOrders; if we would, the requested
# quantity and tolerance would be gone. Instead of destroying, we set all result
# quantities to zero.
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
end