update promotio for netprice and percentage

This commit is contained in:
Aung Myo
2018-06-01 16:19:41 +06:30
parent 3df824fc42
commit b1adb9810f

View File

@@ -154,7 +154,8 @@ class Promotion < ApplicationRecord
promotion_qty = foc_qty
end
# 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
update_existing_item(promotion_qty, item, sale_id, "promotion", item.price,source)
end
@@ -211,8 +212,12 @@ class Promotion < ApplicationRecord
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)# 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
if foc_qty > order_qty
foc_qty = order_qty
end
# 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
price = item.price - promo_product.net_price
@@ -233,11 +238,13 @@ 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) #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
# give total qty is 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.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
# total = item.price * foc_qty