update promotio for netprice and percentage
This commit is contained in:
@@ -154,7 +154,8 @@ class Promotion < ApplicationRecord
|
|||||||
promotion_qty = foc_qty
|
promotion_qty = foc_qty
|
||||||
end
|
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
|
item = OrderItem.where("item_instance_code = '#{promo_product}' and order_id = '#{orderitem[0][1]}'").first
|
||||||
|
|
||||||
source = Order.find(item.order_id).source
|
source = Order.find(item.order_id).source
|
||||||
update_existing_item(promotion_qty, item, sale_id, "promotion", item.price,source)
|
update_existing_item(promotion_qty, item, sale_id, "promotion", item.price,source)
|
||||||
end
|
end
|
||||||
@@ -211,8 +212,12 @@ class Promotion < ApplicationRecord
|
|||||||
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)
|
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
|
||||||
else
|
else
|
||||||
# foc_qty = find_second_item_qty(sale_id, promo_product.item_code)# need to check for qty
|
order_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
|
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||||
|
|
||||||
|
if foc_qty > order_qty
|
||||||
|
foc_qty = order_qty
|
||||||
|
end
|
||||||
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||||
item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' 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
|
price = item.price - promo_product.net_price
|
||||||
@@ -233,11 +238,13 @@ class Promotion < ApplicationRecord
|
|||||||
source = Order.find(item.order_id).source
|
source = Order.find(item.order_id).source
|
||||||
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
|
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
|
||||||
else
|
else
|
||||||
# foc_qty = find_second_item_qty(sale_id, promo_product.item_code) #need to check
|
order_qty = find_second_item_qty(sale_id, promo_product.item_code) #need to check
|
||||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||||
# give total qty is 1
|
# give total qty is 1
|
||||||
#foc_qty = (foc_qty - foc_qty) + 1
|
#foc_qty = (foc_qty - foc_qty) + 1
|
||||||
|
if foc_qty > order_qty
|
||||||
|
foc_qty = order_qty
|
||||||
|
end
|
||||||
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||||
item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' 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 * foc_qty
|
||||||
|
|||||||
Reference in New Issue
Block a user