promotion by order_id

This commit is contained in:
Myat Zin Wai Maw
2019-07-18 15:22:13 +06:30
parent 5594f587fd
commit a378caed08
2 changed files with 5 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ class Promotion < ApplicationRecord
PROMO_TYPE4 = "Percentage"
def self.promo_activate(saleObj)
array_same =[]
current_day = Time.now.strftime("%Y-%m-%d")
current_time = Time.now.strftime('%H:%M:%S')
day = Date.today.wday
@@ -18,7 +19,6 @@ class Promotion < ApplicationRecord
puts "promoList - " + promoList.size.to_s
if promoList.size > 0
itemList = combine_item(saleObj)
puts itemList.to_json
is_promo_day(promoList,day, itemList, saleObj.sale_id)
end
end
@@ -31,6 +31,7 @@ class Promotion < ApplicationRecord
def self.combine_item(saleObj)
# order_id = saleObj.sale_orders[0][0].order_id
# itemList = OrderItem.where("order_id = ?", order_id).group(:item_instance_code).sum(:qty)
# array_same =[]
itemList = []
saleObj.sale_orders.each do |so|
itemList << OrderItem.where("order_id = ?",so.order_id).group(["item_instance_code", "order_id"]).sum(:qty)

View File

@@ -80,12 +80,13 @@ class Sale < ApplicationRecord
end
booking.sale_id = sale_id
saleObj = Sale.find(sale_id)
# order = booking.booking_orders.take.order
link_order_sale(order.order_id)
end
# InventoryJob.perform_now(self.id)
InventoryDefinition.calculate_product_count(saleObj)
order = booking.booking_orders.take.order
link_order_sale(order.id)
# dining charges
charges = DiningCharge.where('dining_facility_id=?',booking.dining_facility_id).take