receipt detail report

This commit is contained in:
Aung Myo
2018-07-24 13:48:57 +06:30
parent 682722bf9e
commit c111b004d0
2 changed files with 10 additions and 6 deletions

View File

@@ -1087,24 +1087,21 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay
payment_type = " and sale_payments.payment_method = '#{payment_type}'"
end
query = Sale.select("sales.*,dining_facilities.name as table_name,dining_facilities.type as table_type")
query = Sale.select("sales.*,bookings.dining_facility_id as table_id")
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)
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.joins("join bookings on bookings.sale_id = sales.sale_id")
.joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.joins("join bookings on bookings.sale_id = sales.sale_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)
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.joins("join bookings on bookings.sale_id = sales.sale_id")
.joins("join dining_facilities on dining_facilities.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)
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.joins("join bookings on bookings.sale_id = sales.sale_id")
.joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.group("sales.sale_id")
end
return query

View File

@@ -45,10 +45,17 @@
<tbody>
<% grand_total = 0 %>
<% @sale_data.each do |result| %>
<% table_name=nil
table_type =nil
if result.table_id.to_i>0
table = DiningFacility.find(result.table_id)
table_type = table.type
table_name = table.name
end %>
<% grand_total = grand_total.to_f + result.grand_total.to_f%>
<tr style="border-top:4px double #666;">
<td><%= @shift_from %> - <%= @shift_to %></td>
<td><%= result.table_type %> - <%= result.table_name %></td>
<td><%= table_type %> - <%= table_name %></td>
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%=result.grand_total%></td>