From 83617962c667a57e9a68d043817dfbfee0a6ca71 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 8 Aug 2018 17:48:22 +0630 Subject: [PATCH] add table in receipt detail report --- app/models/sale.rb | 15 ++++++++++++--- app/views/reports/receipt_no/index.html.erb | 12 ++++++++++-- app/views/reports/receipt_no/index.xls.erb | 13 ++++++++++--- 3 files changed, 32 insertions(+), 8 deletions(-) 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 %> + <%= t("views.right_panel.detail.dining") %> <%= t("views.right_panel.detail.receipt_no") %> <%= t :cashier %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %> @@ -113,6 +114,13 @@ + + <%if result.type %> + <%= result.type %> - <%= result.name %> + <% else %> + - + <% end %> + <%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %> <%= number_with_precision(result.total_amount, precision: precision.to_i ,delimiter: delimiter) %> @@ -157,7 +165,7 @@ <% end %> -   +   <%= number_with_precision(total_sum, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <%= number_with_precision(discount_amt, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>