From 9ec189ab54e4a71b31ae3bd30a0882ff7b787ead Mon Sep 17 00:00:00 2001 From: Aung Kyaw Phyoe Date: Wed, 13 Feb 2019 14:48:01 +0630 Subject: [PATCH] change query --- app/models/sale.rb | 4 ++-- app/views/reports/receipt_no/index.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index 05442b1e..9de1b245 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1167,7 +1167,7 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty end query = Sale.all.select("sales.*,sale_payments.*,df.name,df.type") - .where("#{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0") + .where("sale_status= 'completed' and sale_payments.payment_amount != 0 #{payment_type}") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") .joins("join bookings on bookings.sale_id = sales.sale_id") .joins("left join dining_facilities df on df.id = bookings.dining_facility_id") @@ -1191,7 +1191,7 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay end query = Sale.select("sales.*,bookings.dining_facility_id as table_id") - .where("#{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0") + .where("sale_status= 'completed' and sale_payments.payment_amount != 0 #{payment_type}") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") .joins("join bookings on bookings.sale_id = sales.sale_id") .group("sales.sale_id") diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index 883e03ce..12eb1096 100755 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -94,7 +94,7 @@ %> - <%if @sale_data %> + <%if !@sale_data.nil? %> <% @sale_data.each do |result| %> <% grand_total +=result.grand_total.to_f %>