update remove job from cable and cup control in print

This commit is contained in:
Aung Myo
2018-02-01 15:30:30 +06:30
parent f608aa8516
commit 9efd54e68b
8 changed files with 110 additions and 12 deletions

View File

@@ -128,7 +128,9 @@ class Sale < ApplicationRecord
booking.checkout_by = requested_by.name
booking.save
InventoryJob.perform_now(self.id)
# InventoryJob.perform_now(self.id)
saleObj = Sale.find(self.id)
InventoryDefinition.calculate_product_count(saleObj)
return true, self.id
end
@@ -137,6 +139,41 @@ class Sale < ApplicationRecord
end
#fOR Quick Service pay and create
def self.request_bill(order,current_user,current_login_employee)
@sale = Sale.new
sale_order=SaleOrder.new
if shift = ShiftSale.current_open_shift(current_user.id)
order_id = order.order_id # order_id
bk_order = BookingOrder.find_by_order_id(order_id)
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
if check_booking.sale_id.nil?
# Create Sale if it doesn't exist
# puts "current_login_employee"
# puts current_login_employee.name
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil)
@sale_data = Sale.find_by_sale_id(@sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_id)
else
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
end
# Bind shift sale id to sale
@sale_data.shift_sale_id = shift.id
@sale_data.save
# Promotion Activation
Promotion.promo_activate(@sale)
@status = true
return @status, @sale
else
@status = false
@message = "No Current Open Shift for This Employee"
end
end
#This is when spilt bill is request - then we cannot link order to invoice
#Cos there will be multiple orders - and items are spilt from there.
#Unless order is spilt by then it is possible.