Merge branch 'master' into license

This commit is contained in:
Yan
2017-11-20 13:54:54 +06:30
23 changed files with 369 additions and 556 deletions

View File

@@ -1,7 +1,7 @@
class Crm::DiningQueuesController < BaseCrmController
load_and_authorize_resource
before_action :set_dining_queue, only: [:show, :edit, :update, :destroy]
# GET /crm/dining_queues
# GET /crm/dining_queues.json
def index
@@ -86,6 +86,17 @@ class Crm::DiningQueuesController < BaseCrmController
queue = DiningQueue.find(params[:id])
table_id = params[:table_id]
dining_facility = DiningFacility.find(params[:table_id])
if dining_facility.type == "Table"
type = "TableBooking"
else
type = "RoomBooking"
end
booking = Booking.create({:dining_facility_id => params[:table_id],:type => type,
:checkin_at => Time.now.utc,:customer_id => queue.customer_id,:booking_status => "assign" })
booking.save!
status = queue.update_attributes(dining_facility_id: table_id,status:"Assign")
# status = DiningFacility.find(table_id).update_attributes(status: "occupied")

View File

@@ -121,8 +121,9 @@ class Origami::CustomersController < BaseOrigamiController
if status == true
render json: JSON.generate({:status => true})
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount)
if(id == "SAL")
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount)
end
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end

View File

@@ -114,7 +114,8 @@ class Origami::DiscountsController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
dining = DiningFacility.find(table_id)
table_type = dining.type
discount_items = []
#destroy all discount sale item
@@ -133,14 +134,14 @@ class Origami::DiscountsController < BaseOrigamiController
sale.sale_items.destroy(discount_items)
action_by = current_user.id
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{dining.name} "
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEALLDISCOUNT" )
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
result = {:status=> "Success", :table_id => table_id, :table_type => table_type }
result = {:status=> "Success", :table_id => table_id, :dining => dining.name, :table_type => table_type }
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table_type }
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => dining.name, :table_type => table_type }
end
render :json => result.to_json