fixed conflict after merch dev for current shop
This commit is contained in:
@@ -440,7 +440,8 @@ class Sale < ApplicationRecord
|
||||
|
||||
#compute - invoice total
|
||||
def compute_by_sale_items(total_discount, discount_type=nil, order_source=nil, tax_type=nil, type=nil)
|
||||
# shop = Shop.first
|
||||
|
||||
shop = Shop.current_shop
|
||||
|
||||
#Computation Fields
|
||||
subtotal_price = 0
|
||||
@@ -507,7 +508,8 @@ class Sale < ApplicationRecord
|
||||
|
||||
# Tax Re-Calculte
|
||||
def compute_tax(total_taxable, total_discount = 0, order_source = nil, tax_type=nil)
|
||||
shop = Shop.find_by_shop_code(self.shop_code)
|
||||
|
||||
shop = Shop.current_shop
|
||||
|
||||
#if tax is not apply create new record
|
||||
# SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
|
||||
@@ -627,7 +629,8 @@ class Sale < ApplicationRecord
|
||||
|
||||
# Tax Calculate
|
||||
def apply_tax(total_taxable, order_source = nil, tax_type = nil)
|
||||
shop = Shop.find_by_shop_code(self.shop_code)
|
||||
|
||||
shop = Shop.current_shop
|
||||
|
||||
#if tax is not apply create new record
|
||||
# SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
|
||||
@@ -645,7 +648,7 @@ class Sale < ApplicationRecord
|
||||
order_source = "cashier"
|
||||
end
|
||||
|
||||
# tax_data = TaxProfile.unscoped.where("group_type=?",order_source).pluck(:id)
|
||||
# tax_data = TaxProfile.unscope(:order).where("group_type=?",order_source).pluck(:id)
|
||||
# customer = Customer.find(self.customer_id).tax_profiles
|
||||
|
||||
tax_profiles = unique_tax_profiles(order_source, self.customer_id)
|
||||
@@ -710,7 +713,8 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
def adjust_rounding
|
||||
shop_details = Shop.find_by_shop_code(self.shop_code)
|
||||
|
||||
shop_details = Shop.current_shop
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(self.grand_total)
|
||||
@@ -726,7 +730,8 @@ class Sale < ApplicationRecord
|
||||
#Generate new Receipt No when it is not assigned
|
||||
def generate_receipt_no
|
||||
#shop_code and client_code
|
||||
shop_details = Shop.find_by_shop_code(self.shop_code)
|
||||
|
||||
shop_details = Shop.current_shop
|
||||
#Date-Shift-
|
||||
if self.receipt_no.nil?
|
||||
prefix = DateTime.now().utc
|
||||
@@ -1239,7 +1244,7 @@ end
|
||||
|
||||
#product sale report query
|
||||
def self.get_menu_item_query(order_by)
|
||||
query = MenuItem.unscoped.select("acc.id as account_id,
|
||||
query = MenuItem.unscope(:order).select("acc.id as account_id,
|
||||
acc.title as account_name,
|
||||
mii.item_instance_code as item_code, " +
|
||||
"(CASE WHEN si.qty IS NOT NULL THEN SUM(si.qty) ELSE 0 END) as total_item," +
|
||||
@@ -1588,6 +1593,8 @@ end
|
||||
|
||||
if !from.nil? && !to.nil?
|
||||
query = query.receipt_date_between(from, to)
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -1613,6 +1620,8 @@ end
|
||||
|
||||
if !from.nil? && !to.nil?
|
||||
query = query.receipt_date_between(from, to)
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -1649,6 +1658,8 @@ end
|
||||
if (!from.nil? && !to.nil?)
|
||||
query = query.receipt_date_between(from, to)
|
||||
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -1668,6 +1679,8 @@ end
|
||||
if (!from.nil? && !to.nil?)
|
||||
query = query.receipt_date_between(from, to)
|
||||
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -1691,6 +1704,8 @@ end
|
||||
|
||||
if (!from.nil? && !to.nil?)
|
||||
query = query.merge(Sale.receipt_date_between(from, to))
|
||||
else
|
||||
query = query.merge(Sale.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day))
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -1710,6 +1725,8 @@ end
|
||||
if (!from.nil? && !to.nil?)
|
||||
query = query.receipt_date_between(from, to)
|
||||
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -1730,6 +1747,8 @@ end
|
||||
|
||||
if (!from.nil? && !to.nil?)
|
||||
query = query.receipt_date_between(from, to)
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -1760,6 +1779,8 @@ end
|
||||
|
||||
if (!from.nil? && !to.nil?)
|
||||
query = query.receipt_date_between(from, to)
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -1812,6 +1833,8 @@ end
|
||||
if (!from.nil? && !to.nil?)
|
||||
query = query.receipt_date_between(from, to)
|
||||
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -1832,6 +1855,8 @@ end
|
||||
if (!from.nil? && !to.nil?)
|
||||
query = query.receipt_date_between(from, to)
|
||||
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -1899,6 +1924,8 @@ end
|
||||
|
||||
if (!from.nil? && !to.nil?)
|
||||
query = query.receipt_date_between(from, to)
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -1919,6 +1946,8 @@ end
|
||||
if (!from.nil? && !to.nil?)
|
||||
query = query.receipt_date_between(from, to)
|
||||
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -1939,6 +1968,8 @@ end
|
||||
if (!from.nil? && !to.nil?)
|
||||
query = query.receipt_date_between(from, to)
|
||||
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -1960,6 +1991,8 @@ end
|
||||
if (!from.nil? && !to.nil?)
|
||||
query = query.receipt_date_between(from, to)
|
||||
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
@@ -2112,6 +2145,8 @@ def self.employee_sale(shift=nil,from=nil,to=nil,from_time=nil,to_time=nil, curr
|
||||
.paid.completed.where("sales.shop_code='#{current_shop.shop_code}'")
|
||||
if !from.nil? && !to.nil?
|
||||
query = query.receipt_date_between(from, to)
|
||||
else
|
||||
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
|
||||
end
|
||||
|
||||
if !shift.nil?
|
||||
|
||||
Reference in New Issue
Block a user