diff --git a/app/models/sale.rb b/app/models/sale.rb index 4dcbba14..104a7280 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1143,16 +1143,25 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty query = Sale.all if shift.present? - query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a) + query = query.select("sales.*,sale_payments.*,df.name,df.type") + .where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a) .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") .group("sales.sale_id") elsif shift_sale_range.present? - query = query.where("sale_status='completed' #{payment_type} and sale_payments.payment_amount != 0 and sales.shift_sale_id in (?)",shift_sale_range.to_a) + query = query.select("sales.*,sale_payments.*,df.name,df.type") + .where("sale_status='completed' #{payment_type} and sale_payments.payment_amount != 0 and sales.shift_sale_id in (?)",shift_sale_range.to_a) .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") .group("sales.sale_id") else - query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sale_payments.payment_amount != 0",from,to) + query = query.select("sales.*,sale_payments.*,df.name,df.type") + .where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sale_payments.payment_amount != 0",from,to) .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") .group("sales.sale_id") end return query diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index 689db837..883e03ce 100755 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -42,6 +42,7 @@ <% end %>