remove conflict data
This commit is contained in:
@@ -913,9 +913,14 @@ def self.get_other_charges()
|
||||
query = query.group("i.sale_item_id")
|
||||
end
|
||||
|
||||
def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,account_type)
|
||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||
|
||||
if account_type.blank?
|
||||
account_type = ''
|
||||
else
|
||||
account_type = " and acc.title = '#{account_type}'"
|
||||
end
|
||||
|
||||
query = self.get_item_query(type)
|
||||
|
||||
discount_query = 0
|
||||
@@ -931,7 +936,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
product = self.get_product_sale()
|
||||
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
end
|
||||
@@ -954,7 +959,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
|
||||
### => get all sales range in shift_sales
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift_sale_range.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
end
|
||||
@@ -977,11 +982,13 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
||||
|
||||
else
|
||||
query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to)
|
||||
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
end
|
||||
product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
|
||||
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
@@ -1061,6 +1068,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")
|
||||
|
||||
Reference in New Issue
Block a user