end of day commit for users and suppliers authenticated handling

This commit is contained in:
2012-08-25 15:55:56 +02:00
parent b7c57d41ce
commit e56badcbf8
29 changed files with 435 additions and 582 deletions
+1 -42
View File
@@ -82,51 +82,10 @@ class ListsController < ApplicationController
end
end
def current
@list = List.find(params[:id])
@list.orders.include_relations(product_orders: :product)
respond_to do |format|
format.json do
h = @list.as_json
h[:orders] = []
list_total = 0.0
for order in @list.orders
ho = {products: []}
order_total = 0.0
for product_order in order.product_orders
order_total += (product_order.amount * product_order.price).round(2)
ho[:products] << {name: product_order.product.name, id: product_order.product_id, number: product_order.amount, price: product_order.price}
end
ho[:total_amount] = order_total.round(2)
ho[:state] = order.state
list_total += ho[:total_amount]
h[:orders] << ho
end
h[:total_amount] = list_total.round(2)
render json: h
end
end
end
# POST /orders/1/is_closed
def is_closed
@list = List.find(params[:id])
@list.close!
render nothing: true
end
# POST /orders/1/is_helped
def is_helped
@list = List.find(params[:id])
@list.needs_help = false
@list.save
render nothing: true
end
private
def set_relation_options
@tables = Table.all
@suppliers = Supplier.all
end
end