improvements

This commit is contained in:
2012-09-06 14:49:22 +02:00
parent 27d7fd304e
commit 161da7a82d
18 changed files with 209 additions and 81 deletions
+13 -2
View File
@@ -39,7 +39,7 @@ class SupplierController < ApplicationController
h = @supplier.as_json
h[:orders] = []
list_total = 0.0
for order in @supplier.active_orders
for order in @supplier.active_orders(section_id: params[:section_id].presence)
ho = {products: []}
order_total = 0.0
for product_order in order.product_orders
@@ -70,7 +70,7 @@ class SupplierController < ApplicationController
h = @supplier.as_json
h[:lists] = []
grand_total = 0.0
for list in @supplier.active_lists
for list in @supplier.active_lists(section_id: params[:section_id].presence)
hl = list.as_json
hl[:total_amount] = list.orders.inject(0.0){|sum, o| sum + o.product_orders.inject(0.0){|s, po| s + (po.amount * po.price).round(2)}}.round(2)
grand_total += hl[:total_amount]
@@ -111,4 +111,15 @@ class SupplierController < ApplicationController
@order.is_delivered!
render nothing: true
end
# GET /supplier/lists/1
def show_list
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:list_id])
respond_to do |format|
format.html {}
format.json do
render json: @list.with_orders_as_json
end
end
end
end