update promotion
This commit is contained in:
@@ -153,7 +153,8 @@ class Promotion < ApplicationRecord
|
||||
if (foc_qty < promotion_qty)
|
||||
promotion_qty = foc_qty
|
||||
end
|
||||
item = OrderItem.find_by_item_instance_code(promo_product)
|
||||
# item = OrderItem.find_by_item_instance_code(promo_product)
|
||||
item = OrderItem.where("item_code = '#{promo_product}' and order_id = '#{orderitem[0][1]}'").first
|
||||
source = Order.find(item.order_id).source
|
||||
update_existing_item(promotion_qty, item, sale_id, "promotion", item.price,source)
|
||||
end
|
||||
@@ -194,8 +195,7 @@ class Promotion < ApplicationRecord
|
||||
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)
|
||||
item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
|
||||
|
||||
item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
|
||||
source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
|
||||
end
|
||||
@@ -214,7 +214,7 @@ class Promotion < ApplicationRecord
|
||||
# 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)
|
||||
item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
|
||||
item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
|
||||
price = item.price - promo_product.net_price
|
||||
source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
|
||||
@@ -239,7 +239,7 @@ class Promotion < ApplicationRecord
|
||||
#foc_qty = (foc_qty - foc_qty) + 1
|
||||
|
||||
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||
item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
|
||||
item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
|
||||
# total = item.price * foc_qty
|
||||
total = item.price
|
||||
price = calculate_discount(total, promo_product.percentage)
|
||||
|
||||
Reference in New Issue
Block a user