Introduced group_order_article.result to save the result for each group/article.
This commit is contained in:
parent
6fd5d825f9
commit
251ced4fa1
27 changed files with 106 additions and 137 deletions
|
|
@ -111,10 +111,10 @@ class Finance::BalancingController < ApplicationController
|
|||
end
|
||||
|
||||
def new_group_order_article
|
||||
group_order_article = OrderArticle.find(params[:id]).group_order_articles.build
|
||||
goa = OrderArticle.find(params[:id]).group_order_articles.build
|
||||
render :update do |page|
|
||||
page["edit_box"].replace_html :partial => "new_group_order_article",
|
||||
:locals => {:group_order_article => group_order_article}
|
||||
:locals => {:group_order_article => goa}
|
||||
page["edit_box"].show
|
||||
end
|
||||
end
|
||||
|
|
@ -185,7 +185,6 @@ class Finance::BalancingController < ApplicationController
|
|||
page["edit_box"].hide
|
||||
page["group_order_articles_#{goa.order_article.id}"].replace_html :partial => 'group_order_articles',
|
||||
:locals => {:order_article => goa.order_article}
|
||||
page["group_order_article_#{goa.id}"].visual_effect :highlight, :duration => 2
|
||||
page["summary"].replace_html :partial => 'summary', :locals => {:order => goa.order_article.order}
|
||||
page["order_profit"].visual_effect :highlight, :duration => 2
|
||||
end
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class Finance::TransactionsController < ApplicationController
|
|||
amount = params[:financial_transaction][:amount]
|
||||
note = params[:financial_transaction][:note]
|
||||
begin
|
||||
@group.addFinancialTransaction(amount, note, @current_user)
|
||||
@group.add_financial_transaction(amount, note, @current_user)
|
||||
flash[:notice] = 'Transaktion erfolgreich angelegt.'
|
||||
redirect_to :action => 'index'
|
||||
rescue => e
|
||||
|
|
@ -90,7 +90,7 @@ class Finance::TransactionsController < ApplicationController
|
|||
params[:financial_transactions].each do |trans|
|
||||
# ignore empty amount fields ...
|
||||
unless trans[:amount].blank?
|
||||
Ordergroup.find(trans[:ordergroup_id]).addFinancialTransaction trans[:amount], note, @current_user
|
||||
Ordergroup.find(trans[:ordergroup_id]).add_financial_transaction trans[:amount], note, @current_user
|
||||
end
|
||||
end
|
||||
flash[:notice] = 'Saved all transactions successfully'
|
||||
|
|
|
|||
|
|
@ -16,18 +16,19 @@ class OrderingController < ApplicationController
|
|||
@open_orders = Order.open
|
||||
@other_orders = @open_orders.reject{|order| order == @order}
|
||||
# Load order article data...
|
||||
@articles_by_category = @order.get_articles
|
||||
@articles_grouped_by_category = @order.articles_grouped_by_category
|
||||
# save results of earlier orders in array
|
||||
ordered_articles = Array.new
|
||||
@group_order = @order.group_orders.find(:first, :conditions => "ordergroup_id = #{@ordergroup.id}", :include => :group_order_articles)
|
||||
@group_order = @order.group_orders.find(:first,
|
||||
:conditions => "ordergroup_id = #{@ordergroup.id}", :include => :group_order_articles)
|
||||
|
||||
if @group_order
|
||||
# Group has already ordered, so get the results...
|
||||
for article in @group_order.group_order_articles
|
||||
result = article.result
|
||||
ordered_articles[article.order_article_id] = {'quantity' => article.quantity,
|
||||
'tolerance' => article.tolerance,
|
||||
'quantity_result' => result[:quantity],
|
||||
'tolerance_result' => result[:tolerance]}
|
||||
for goa in @group_order.group_order_articles
|
||||
ordered_articles[goa.order_article_id] = {:quantity => goa.quantity,
|
||||
:tolerance => goa.tolerance,
|
||||
:quantity_result => goa.result(:quantity),
|
||||
:tolerance_result => goa.result(:tolerance)}
|
||||
end
|
||||
@version = @group_order.lock_version
|
||||
@availableFunds = @ordergroup.get_available_funds(@group_order)
|
||||
|
|
@ -41,19 +42,19 @@ class OrderingController < ApplicationController
|
|||
@others_quantity = Array.new; @quantity = Array.new; @quantity_result = Array.new; @used_quantity = Array.new; @unused_quantity = Array.new
|
||||
@others_tolerance = Array.new; @tolerance = Array.new; @tolerance_result = Array.new; @used_tolerance = Array.new; @unused_tolerance = Array.new
|
||||
i = 0;
|
||||
@articles_by_category.each do |category_name, order_articles|
|
||||
@articles_grouped_by_category.each do |category_name, order_articles|
|
||||
for order_article in order_articles
|
||||
# price/unit size
|
||||
@price[i] = order_article.article.fc_price
|
||||
@unit[i] = order_article.article.unit_quantity
|
||||
# quantity
|
||||
@quantity[i] = (ordered_articles[order_article.id] ? ordered_articles[order_article.id]['quantity'] : 0)
|
||||
@quantity[i] = (ordered_articles[order_article.id] ? ordered_articles[order_article.id][:quantity] : 0)
|
||||
@others_quantity[i] = order_article.quantity - @quantity[i]
|
||||
@used_quantity[i] = (ordered_articles[order_article.id] ? ordered_articles[order_article.id]['quantity_result'] : 0)
|
||||
@used_quantity[i] = (ordered_articles[order_article.id] ? ordered_articles[order_article.id][:quantity_result] : 0)
|
||||
# tolerance
|
||||
@tolerance[i] = (ordered_articles[order_article.id] ? ordered_articles[order_article.id]['tolerance'] : 0)
|
||||
@tolerance[i] = (ordered_articles[order_article.id] ? ordered_articles[order_article.id][:tolerance] : 0)
|
||||
@others_tolerance[i] = order_article.tolerance - @tolerance[i]
|
||||
@used_tolerance[i] = (ordered_articles[order_article.id] ? ordered_articles[order_article.id]['tolerance_result'] : 0)
|
||||
@used_tolerance[i] = (ordered_articles[order_article.id] ? ordered_articles[order_article.id][:tolerance_result] : 0)
|
||||
i += 1
|
||||
end
|
||||
end
|
||||
|
|
@ -90,8 +91,8 @@ class OrderingController < ApplicationController
|
|||
end
|
||||
|
||||
# Get ordered quantities and update group_order_articles/_quantities...
|
||||
quantities = ordered.fetch(order_article.id.to_s, {'quantity' => 0, 'tolerance' => 0})
|
||||
group_order_article.update_quantities(quantities['quantity'].to_i, quantities['tolerance'].to_i)
|
||||
quantities = ordered.fetch(order_article.id.to_s, {:quantity => 0, :tolerance => 0})
|
||||
group_order_article.update_quantities(quantities[:quantity].to_i, quantities[:tolerance].to_i)
|
||||
|
||||
# Also update results for the order_article
|
||||
order_article.update_results!
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class OrdersController < ApplicationController
|
|||
def new
|
||||
@supplier = Supplier.find(params[:supplier_id])
|
||||
@order = @supplier.orders.build :ends => 4.days.from_now
|
||||
@template_orders = @supplier.orders.finished :order => 'starts DESC', :include => "order_article_results"
|
||||
@template_orders = @supplier.orders.finished :order => 'starts DESC', :limit => 5
|
||||
end
|
||||
|
||||
# Save a new order.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue