Added shop code
This commit is contained in:
@@ -1579,10 +1579,10 @@ end
|
||||
return tax
|
||||
end
|
||||
|
||||
def self.top_bottom_products(today,current_user,from,to,from_time,to_time,type)
|
||||
def self.top_bottom_products(today,current_user,from,to,from_time,to_time,type, shop)
|
||||
query = Sale.joins("JOIN sale_items ON sale_items.sale_id = sales.sale_id")
|
||||
.completed
|
||||
.where("qty > 0 AND price > 0")
|
||||
.where("qty > 0 AND price > 0 AND shop_code='#{shop.shop_code}'")
|
||||
.group("SUBSTRING_INDEX(product_name, ' - ', 1)")
|
||||
|
||||
if !from.nil? && !to.nil?
|
||||
@@ -1609,7 +1609,7 @@ end
|
||||
query.limit(20).sum('qty')
|
||||
end
|
||||
|
||||
def self.hourly_sales(today,current_user,from,to,from_time,to_time)
|
||||
def self.hourly_sales(today,current_user,from,to,from_time,to_time, shop)
|
||||
query = Sale.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
|
||||
.order('receipt_date').completed
|
||||
|
||||
@@ -1911,7 +1911,7 @@ end
|
||||
query = query.first
|
||||
end
|
||||
|
||||
def self.account_data(account_id, today, current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
def self.account_data(shop, account_id, today, current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
|
||||
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||
.where("sales.shop_code='#{shop.shop_code}' and sales.sale_status = 'completed' and a.account_id ='#{account_id}'")
|
||||
@@ -2107,7 +2107,7 @@ def unique_tax_profiles(order_source, customer_id)
|
||||
end
|
||||
|
||||
|
||||
def self.employee_sale(today,shift=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
def self.employee_sale(shop, today,shift=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
query = Sale.joins(:cashier)
|
||||
.joins(:sale_payments)
|
||||
.paid.completed.where("sales.shop_code='#{shop.shop_code}'")
|
||||
|
||||
Reference in New Issue
Block a user