Second part of stock-integration.
Introduced StockArticle and a special page for ordering from stock. StockChanges will be created and the StockArticle.quantity updated in 'order.close!'.
This commit is contained in:
parent
1912a3fd80
commit
c17b63b192
37 changed files with 616 additions and 340 deletions
|
|
@ -22,17 +22,14 @@ class DeliveriesController < ApplicationController
|
|||
|
||||
def new
|
||||
@delivery = @supplier.deliveries.build
|
||||
3.times { @delivery.stock_changes.build }
|
||||
@supplier.stock_articles.each { |article| @delivery.stock_changes.build(:stock_article => article) }
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @delivery }
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@delivery = Delivery.find(params[:id])
|
||||
end
|
||||
|
||||
def create
|
||||
@delivery = Delivery.new(params[:delivery])
|
||||
|
||||
|
|
@ -48,8 +45,10 @@ class DeliveriesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# PUT /deliveries/1
|
||||
# PUT /deliveries/1.xml
|
||||
def edit
|
||||
@delivery = Delivery.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
@delivery = Delivery.find(params[:id])
|
||||
|
||||
|
|
@ -75,12 +74,29 @@ class DeliveriesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def add_stock_article
|
||||
article = @supplier.stock_articles.build(params[:stock_article])
|
||||
render :update do |page|
|
||||
if article.save
|
||||
logger.debug "new StockArticle: #{article.id}"
|
||||
page.insert_html :top, 'stock_changes', :partial => 'stock_change',
|
||||
:locals => {:stock_change => article.stock_changes.build}
|
||||
|
||||
page.replace_html 'new_stock_article', :partial => 'new_stock_article',
|
||||
:locals => {:stock_article => @supplier.stock_articles.build}
|
||||
else
|
||||
page.replace_html 'new_stock_article', :partial => 'new_stock_article',
|
||||
:locals => {:stock_article => article}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def drop_stock_change
|
||||
stock_change = StockChange.find(params[:stock_change_id])
|
||||
stock_change.destroy
|
||||
|
||||
render :update do |page|
|
||||
page.visual_effect(:DropOut, "stock_change_#{stock_change.id}")
|
||||
page.visual_effect :DropOut, "stock_change_#{stock_change.id}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue