Merge branch 'adminbsb_material_ui'
This commit is contained in:
@@ -66,7 +66,7 @@ class Promotion < ApplicationRecord
|
||||
|
||||
def self.check_promo_type(promo, orderitem, sale_id)
|
||||
promo.promotion_products.each do |promo_product|
|
||||
if promo_product.item_code == orderitem[0]
|
||||
if promo_product.item_code.downcase == orderitem[0]
|
||||
same = true
|
||||
else
|
||||
# return false, promo_product
|
||||
@@ -133,13 +133,12 @@ class Promotion < ApplicationRecord
|
||||
charge_qty += qty
|
||||
end
|
||||
item = OrderItem.find_by_item_instance_code(orderitem[0])
|
||||
if promo_product == OrderItem.find_by_item_instance_code(orderitem[0]).item_instance_code
|
||||
if promo_product.downcase == OrderItem.find_by_item_instance_code(orderitem[0]).item_instance_code
|
||||
item = OrderItem.find_by_item_instance_code(orderitem[0])
|
||||
else
|
||||
item = OrderItem.find_by_item_code(promo_product)
|
||||
end
|
||||
source = Order.find(item.order_id).source
|
||||
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion", item.price,source)
|
||||
|
||||
puts "Charged - " + charge_qty.to_s
|
||||
@@ -184,14 +183,14 @@ class Promotion < ApplicationRecord
|
||||
|
||||
def self.give_promotion_nett_off(same, promo_product, foc_min_qty, orderitem, sale_id)
|
||||
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
||||
|
||||
if same
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
item = OrderItem.find_by_item_instance_code(orderitem[0])
|
||||
source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
|
||||
else
|
||||
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
# foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
||||
item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||
source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
|
||||
@@ -204,14 +203,14 @@ class Promotion < ApplicationRecord
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
item = OrderItem.find_by_item_instance_code(orderitem[0]) # need to specify with menu item instance
|
||||
price = item.price.to_i - promo_product.net_price.to_i
|
||||
|
||||
source = Order.find(item.order_id).source
|
||||
source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
|
||||
else
|
||||
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
||||
# foc_qty = find_second_item_qty(sale_id, promo_product.item_code)# need to check for qty
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||
price = item.price - promo_product.net_price
|
||||
source = Order.find(item.order_id).source
|
||||
source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
|
||||
end
|
||||
end
|
||||
@@ -227,7 +226,8 @@ class Promotion < ApplicationRecord
|
||||
source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
|
||||
else
|
||||
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
||||
# foc_qty = find_second_item_qty(sale_id, promo_product.item_code) #need to check
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
# give total qty is 1
|
||||
#foc_qty = (foc_qty - foc_qty) + 1
|
||||
|
||||
@@ -253,7 +253,7 @@ class Promotion < ApplicationRecord
|
||||
return 0
|
||||
end
|
||||
|
||||
def self.calculate_discount(total, discount)
|
||||
return (total.to_i * discount.to_i) / 100
|
||||
def self.calculate_discount(total, percentage)
|
||||
return (total.to_i * percentage.to_i) / 100
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user