add table in receipt detail report

This commit is contained in:
phyusin
2018-08-08 17:48:22 +06:30
parent 78cbbbb956
commit 83617962c6
3 changed files with 32 additions and 8 deletions

View File

@@ -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