change saleitem query and js for order reservation
This commit is contained in:
@@ -870,9 +870,9 @@ def self.get_item_query(type)
|
||||
elsif type == "discount"
|
||||
sale_type = "i.status = 'Discount'"
|
||||
elsif type == "foc"
|
||||
sale_type = "i.status = 'foc' and i.qty > 0"
|
||||
sale_type = "i.status = 'foc' and i.item_instance_code IS NOT NULL and i.qty > 0"
|
||||
elsif type == "void"
|
||||
sale_type = "i.status = 'void' and i.qty > 0"
|
||||
sale_type = "i.status = 'void' and i.item_instance_code IS NOT NULL and i.qty > 0"
|
||||
elsif type == "other"
|
||||
sale_type = "i.item_instance_code IS NULL"
|
||||
end
|
||||
@@ -907,12 +907,8 @@ end
|
||||
|
||||
def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||
if type == "other"
|
||||
other_charges = self.get_other_charges()
|
||||
query = self.get_item_query(type)
|
||||
else
|
||||
query = self.get_item_query(type)
|
||||
end
|
||||
|
||||
query = self.get_item_query(type)
|
||||
|
||||
discount_query = 0
|
||||
total_card_amount = 0
|
||||
@@ -921,12 +917,16 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
total_foc_amount = 0
|
||||
total_grand_total = 0
|
||||
|
||||
other_charges = self.get_other_charges()
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = self.get_other_charges()
|
||||
end
|
||||
product = self.get_product_sale()
|
||||
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
|
||||
@@ -947,7 +947,9 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
### => get all sales range in shift_sales
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
|
||||
@@ -968,7 +970,9 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
|
||||
else
|
||||
query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
end
|
||||
product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||
|
||||
Reference in New Issue
Block a user