update filter in sale and order and creditnote
This commit is contained in:
@@ -378,13 +378,46 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.search(search)
|
||||
if search
|
||||
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
|
||||
where("receipt_no LIKE ?", "%#{search}%",)
|
||||
def self.search(filter,from,to)
|
||||
|
||||
if filter.blank?
|
||||
keyword = ''
|
||||
else
|
||||
find(:all)
|
||||
keyword = "receipt_no 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
|
||||
|
||||
def self.search_credit_sales(customer,filter,from,to)
|
||||
|
||||
if filter.blank?
|
||||
keyword = ''
|
||||
else
|
||||
keyword = "and receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%"
|
||||
end
|
||||
|
||||
if customer.blank?
|
||||
custo = ''
|
||||
else
|
||||
custo = "and customer_id = '#{customer}'"
|
||||
end
|
||||
|
||||
if from.present? && to.present?
|
||||
sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
||||
.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and sp.payment_method = 'creditnote' #{keyword} #{custo}", from,to)
|
||||
else
|
||||
sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
||||
.where("sp.payment_method =? #{keyword} #{custo}",'creditnote')
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def self.get_rounding_adjustment(num)
|
||||
|
||||
Reference in New Issue
Block a user