From f13e05f849502c24ee8846fdf5fb31e8898fd4eb Mon Sep 17 00:00:00 2001 From: Nweni Date: Wed, 27 Nov 2019 15:51:06 +0630 Subject: [PATCH] Added shop code --- app/models/sale.rb | 10 +++++----- dump.rdb | Bin 1864 -> 1864 bytes 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index 580bd204..f11ab9cd 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -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}'") diff --git a/dump.rdb b/dump.rdb index f5202ce56cf3a7611b5db82bab3d44f76caca6d9..afd1b003e76cf87b41aa7900f5fc423b829eea2b 100644 GIT binary patch delta 156 zcmX@XcY<$%fw-ahz1UwIrNyZ!y1A*jhd!+3WBAALTXgaTHkpZYl_q|ZVlme>GMIdx zO^n4t*T4wGV6)IQvOK`Bc`xG^mWkgKCMPorPhQ9UyRpAGN{drdbaPX44;5_WWBAALTXeD_yA+eL;pB^~ViV`HPhP?% z#$ussY%noF6-)!gC72A1CNE@@o_wBFZn7nt`{cQ7?1Fs7C5a_g1x5MEsl`Ae53o-x z6k)N{H87lfgH4OgLf6Rh0Nci!Us!-l1ET|sAX$(g$Ql-NT|*0?fyO|Fkr|L7$q&+a QfZ@O8&AA=@%CBbv0HeV=A^-pY