promotion by order_id
This commit is contained in:
@@ -11,6 +11,7 @@ class Promotion < ApplicationRecord
|
|||||||
PROMO_TYPE4 = "Percentage"
|
PROMO_TYPE4 = "Percentage"
|
||||||
|
|
||||||
def self.promo_activate(saleObj)
|
def self.promo_activate(saleObj)
|
||||||
|
array_same =[]
|
||||||
current_day = Time.now.strftime("%Y-%m-%d")
|
current_day = Time.now.strftime("%Y-%m-%d")
|
||||||
current_time = Time.now.strftime('%H:%M:%S')
|
current_time = Time.now.strftime('%H:%M:%S')
|
||||||
day = Date.today.wday
|
day = Date.today.wday
|
||||||
@@ -18,7 +19,6 @@ class Promotion < ApplicationRecord
|
|||||||
puts "promoList - " + promoList.size.to_s
|
puts "promoList - " + promoList.size.to_s
|
||||||
if promoList.size > 0
|
if promoList.size > 0
|
||||||
itemList = combine_item(saleObj)
|
itemList = combine_item(saleObj)
|
||||||
puts itemList.to_json
|
|
||||||
is_promo_day(promoList,day, itemList, saleObj.sale_id)
|
is_promo_day(promoList,day, itemList, saleObj.sale_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -31,6 +31,7 @@ class Promotion < ApplicationRecord
|
|||||||
def self.combine_item(saleObj)
|
def self.combine_item(saleObj)
|
||||||
# order_id = saleObj.sale_orders[0][0].order_id
|
# order_id = saleObj.sale_orders[0][0].order_id
|
||||||
# itemList = OrderItem.where("order_id = ?", order_id).group(:item_instance_code).sum(:qty)
|
# itemList = OrderItem.where("order_id = ?", order_id).group(:item_instance_code).sum(:qty)
|
||||||
|
# array_same =[]
|
||||||
itemList = []
|
itemList = []
|
||||||
saleObj.sale_orders.each do |so|
|
saleObj.sale_orders.each do |so|
|
||||||
itemList << OrderItem.where("order_id = ?",so.order_id).group(["item_instance_code", "order_id"]).sum(:qty)
|
itemList << OrderItem.where("order_id = ?",so.order_id).group(["item_instance_code", "order_id"]).sum(:qty)
|
||||||
|
|||||||
@@ -80,12 +80,13 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
booking.sale_id = sale_id
|
booking.sale_id = sale_id
|
||||||
saleObj = Sale.find(sale_id)
|
saleObj = Sale.find(sale_id)
|
||||||
|
# order = booking.booking_orders.take.order
|
||||||
|
link_order_sale(order.order_id)
|
||||||
end
|
end
|
||||||
# InventoryJob.perform_now(self.id)
|
# InventoryJob.perform_now(self.id)
|
||||||
InventoryDefinition.calculate_product_count(saleObj)
|
InventoryDefinition.calculate_product_count(saleObj)
|
||||||
|
|
||||||
order = booking.booking_orders.take.order
|
|
||||||
link_order_sale(order.id)
|
|
||||||
|
|
||||||
# dining charges
|
# dining charges
|
||||||
charges = DiningCharge.where('dining_facility_id=?',booking.dining_facility_id).take
|
charges = DiningCharge.where('dining_facility_id=?',booking.dining_facility_id).take
|
||||||
|
|||||||
Reference in New Issue
Block a user