shift update

This commit is contained in:
Yan
2017-12-07 12:07:06 +06:30
parent 04b27489dd
commit 69b786a91d
4 changed files with 12 additions and 4 deletions

View File

@@ -5,7 +5,8 @@ class Api::BillController < Api::ApiController
def create def create
@status = false @status = false
@error_message = "Order ID or Booking ID is require to request for a bill." @error_message = "Order ID or Booking ID is require to request for a bill."
if ShiftSale.current_shift
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
#create Bill by Booking ID #create Bill by Booking ID
table = 0 table = 0
if (params[:booking_id]) if (params[:booking_id])
@@ -22,9 +23,11 @@ class Api::BillController < Api::ApiController
if booking.sale_id.nil? if booking.sale_id.nil?
@sale = Sale.new @sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier_by_terminal) @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier_by_terminal)
@sale_data = Sale.find_by_sale_id(@sale_id)
else else
@status = true @status = true
@sale_id = booking.sale_id @sale_id = booking.sale_id
@sale_data = Sale.find_by_sale_id(@sale_id)
end end
end end
@@ -36,6 +39,11 @@ class Api::BillController < Api::ApiController
booking = Booking.find_by_sale_id(@sale_id) booking = Booking.find_by_sale_id(@sale_id)
table = DiningFacility.find(booking.dining_facility_id) table = DiningFacility.find(booking.dining_facility_id)
end end
# Bind shift sale id to sale
@sale_data.shift_sale_id = shift_by_terminal.id
@sale_data.save
Promotion.promo_activate(@sale) Promotion.promo_activate(@sale)
BillBroadcastJob.perform_later(table) BillBroadcastJob.perform_later(table)

View File

@@ -3,7 +3,7 @@ class Api::CheckInProcessController < Api::ApiController
def check_in_time def check_in_time
if params[:dining_id] if params[:dining_id]
dining_facility = DiningFacility.find(params[:dining_id]) dining_facility = DiningFacility.find(params[:dining_id])
booking = dining_facility.get_current_checkout_booking booking = dining_facility.get_current_booking
if !booking.nil? if !booking.nil?
check_in_time = booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") check_in_time = booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")

View File

@@ -115,7 +115,7 @@ class Sale < ApplicationRecord
booking.sale_id = self.id booking.sale_id = self.id
booking.checkout_at = Time.now.utc.getlocal booking.checkout_at = Time.now.utc.getlocal
booking.checkout_by = requested_by.name # booking.checkout_by = requested_by.name
booking.save booking.save
InventoryJob.perform_now(self.id) InventoryJob.perform_now(self.id)

View File

@@ -282,7 +282,7 @@ class SalePayment < ApplicationRecord
end end
def sale_update_payment_status(paid_amount) def sale_update_payment_status(paid_amount)
#update amount_outstanding #update amount_outstanding
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
self.sale.save! self.sale.save!