add booking list in transaction

This commit is contained in:
Aung Myo
2017-11-14 13:42:00 +06:30
parent f1a28d64e1
commit 6f06e7a9d7
17 changed files with 351 additions and 42 deletions

View File

@@ -41,6 +41,22 @@ class Booking < ApplicationRecord
return new_dining.type
end
def self.search(filter,from,to)
if filter.blank?
keyword = ''
else
keyword = "booking_id LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%"
end
if from.present? && to.present?
sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and NOT sale_status = 'void' ", from,to)
query = sale.where(keyword)
else
where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%",)
end
end
private
def generate_custom_id
self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI")