change promotion with menu item and menu item instance
This commit is contained in:
@@ -48,16 +48,30 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
|
||||
unique_code = "CloseCashierPdf"
|
||||
shop_details = Shop.find(1)
|
||||
puts "shop details"
|
||||
p shop_details
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
puts "shift obj"
|
||||
p shift_obj
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
puts "sale taxes"
|
||||
p @sale_taxes
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
puts "other payment"
|
||||
p @other_payment
|
||||
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
puts "total amount by account"
|
||||
p @total_amount_by_account
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
puts "total_discount_by_account"
|
||||
p @total_discount_by_account
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
puts "total_member_discount"
|
||||
p @total_member_discount
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
|
||||
@@ -29,8 +29,12 @@ class Settings::PromotionsController < ApplicationController
|
||||
def create
|
||||
@promotion = Promotion.new(promotion_params)
|
||||
@promotion.created_by = current_login_employee.id
|
||||
@promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30)
|
||||
@promotion.promo_end_hour = @promotion.promo_end_hour.to_datetime.advance(hours: +6, minutes: +30)
|
||||
if !@promotion.promo_start_hour.nil?
|
||||
@promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30)
|
||||
end
|
||||
if !@promotion.promo_end_hour.nil?
|
||||
@promotion.promo_end_hour = @promotion.promo_end_hour.to_datetime.advance(hours: +6, minutes: +30)
|
||||
end
|
||||
respond_to do |format|
|
||||
if @promotion.save
|
||||
promo_pros = @promotion.promotion_products
|
||||
@@ -95,16 +99,23 @@ class Settings::PromotionsController < ApplicationController
|
||||
|
||||
def find_parent_item
|
||||
res = []
|
||||
item = MenuItemInstance.find_by_item_instance_code(params[:item_instance_code])
|
||||
if item.nil?
|
||||
arr_inst = []
|
||||
item_inst = MenuItemInstance.find_by_item_instance_code(params[:item_instance_code])
|
||||
if item_inst.nil?
|
||||
product = Product.where("item_code = ?",params[:item_instance_code]).pluck(:name,:item_code)
|
||||
res.push(product.name)
|
||||
res.push(product.item_code)
|
||||
else
|
||||
# menu_item = item.menu_item.pluck(:name,:item_code)
|
||||
res.push(item.item_instance_name)
|
||||
res.push(item.menu_item.item_code)
|
||||
# menu_item = item_inst.menu_item.pluck(:name,:item_code)
|
||||
# res.push(item_inst.item_instance_name)
|
||||
# res.push(item_inst.menu_item.item_code)
|
||||
item_inst.menu_item.menu_item_instances.each do |inst|
|
||||
arr_inst.push({inst.item_instance_code => inst.item_instance_name})
|
||||
end
|
||||
res.push({item_inst.menu_item.item_code => arr_inst})
|
||||
end
|
||||
puts "res"
|
||||
p res
|
||||
render json: res
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user