Added shop code

This commit is contained in:
Nweni
2019-11-27 15:51:06 +06:30
parent a0b7557f06
commit f13e05f849
2 changed files with 5 additions and 5 deletions

View File

@@ -1579,10 +1579,10 @@ end
return tax return tax
end 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") query = Sale.joins("JOIN sale_items ON sale_items.sale_id = sales.sale_id")
.completed .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)") .group("SUBSTRING_INDEX(product_name, ' - ', 1)")
if !from.nil? && !to.nil? if !from.nil? && !to.nil?
@@ -1609,7 +1609,7 @@ end
query.limit(20).sum('qty') query.limit(20).sum('qty')
end 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')") query = Sale.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
.order('receipt_date').completed .order('receipt_date').completed
@@ -1911,7 +1911,7 @@ end
query = query.first query = query.first
end 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") 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") .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}'") .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 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) query = Sale.joins(:cashier)
.joins(:sale_payments) .joins(:sale_payments)
.paid.completed.where("sales.shop_code='#{shop.shop_code}'") .paid.completed.where("sales.shop_code='#{shop.shop_code}'")

BIN
dump.rdb

Binary file not shown.