From f1bc6a697822c37b79f5fadfcab2258e72e7812f Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Tue, 20 Nov 2012 21:02:05 +0100 Subject: [PATCH] fix bug for supplier display and tables without a section --- app/controllers/supplier_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/supplier_controller.rb b/app/controllers/supplier_controller.rb index 60c1d969..a3630100 100644 --- a/app/controllers/supplier_controller.rb +++ b/app/controllers/supplier_controller.rb @@ -49,7 +49,7 @@ class SupplierController < ApplicationController ho[:total_amount] = order_total.round(2) ho[:state] = order.state ho[:table_number] = order.table_number - ho[:section_title] = order.list.table.section.title + ho[:section_title] = order.list.table.section.try(:title) ho[:id] = order.id list_total += ho[:total_amount] h[:orders] << ho @@ -74,7 +74,7 @@ class SupplierController < ApplicationController 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] - hl[:section_title] = list.table.section.title + hl[:section_title] = list.table.section.try(:title) h[:lists] << hl end h[:total_amount] = grand_total.round(2)