added receipt no detail report

This commit is contained in:
Aung Myo
2018-07-09 17:27:51 +06:30
parent 1635db7247
commit bfce0dc044
6 changed files with 714 additions and 0 deletions

View File

@@ -1061,6 +1061,37 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty
return query
end
def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,payment_type)
## => left join -> show all sales although no orders
if payment_type.blank?
payment_type = ''
else
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")
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")
.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
end
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to)
query = SalePayment.select("s.receipt_no, sale_payments.*,s.receipt_date as sale_date,
s.cashier_name as cashier_name")