From e9d7b9e2f5918671c4d91ea63311852b94063718 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 1 Feb 2018 15:31:48 +0630 Subject: [PATCH 1/6] change utc to utc.getlocal --- app/controllers/api/check_in_process_controller.rb | 6 +++--- app/controllers/origami/check_in_process_controller.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 883fb1ea..45d3ed1a 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -41,12 +41,12 @@ class Api::CheckInProcessController < Api::ApiController lookup_checkout_time = Lookup.collection_of("checkout_time") if !lookup_checkout_time.empty? - checkout_at = Time.now.utc + checkout_at = Time.now.utc.getlocal lookup_checkout_time.each do |checkout_time| arr_time = checkout_time[0].split("-") - start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p") - end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p") + start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p") + end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p") if start_time <= checkout_at && checkout_at <= end_time checkout_at = checkout_at + (checkout_time[1]).to_i.minutes end diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index 14d5c90c..8f28c365 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -2,12 +2,12 @@ class Origami::CheckInProcessController < BaseOrigamiController def check_in_process lookup_checkout_time = Lookup.collection_of("checkout_time") - checkout_at = Time.now.utc + checkout_at = Time.now.utc.getlocal if !lookup_checkout_time.empty? lookup_checkout_time.each do |checkout_time| arr_time = checkout_time[0].split("-") - start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p") - end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p") + start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p") + end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p") if start_time <= checkout_at && checkout_at <= end_time checkout_at = checkout_at + (checkout_time[1]).to_i.minutes end From 73858fc29360e8a39619f01b700d95328772b8fe Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 1 Feb 2018 18:19:35 +0630 Subject: [PATCH 2/6] change checkout time --- app/controllers/api/check_in_process_controller.rb | 2 +- app/controllers/origami/check_in_process_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 45d3ed1a..12075a50 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -47,7 +47,7 @@ class Api::CheckInProcessController < Api::ApiController arr_time = checkout_time[0].split("-") start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p") end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p") - if start_time <= checkout_at && checkout_at <= end_time + if start_time <= checkout_at.strftime("%H:%M%p") && checkout_at.strftime("%H:%M%p") <= end_time checkout_at = checkout_at + (checkout_time[1]).to_i.minutes end end diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index 8f28c365..bab40a83 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -8,7 +8,7 @@ class Origami::CheckInProcessController < BaseOrigamiController arr_time = checkout_time[0].split("-") start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p") end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p") - if start_time <= checkout_at && checkout_at <= end_time + if start_time <= checkout_at.strftime("%H:%M%p") && checkout_at.strftime("%H:%M%p") <= end_time checkout_at = checkout_at + (checkout_time[1]).to_i.minutes end end From 383aeded6088c2e4136572a2fc330572a40893eb Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 1 Feb 2018 16:16:26 +0630 Subject: [PATCH 3/6] check checkedin exist in lookups and void - sale --- .../api/check_in_process_controller.rb | 5 ++-- .../origami/check_in_process_controller.rb | 26 +++++++++---------- app/controllers/origami/void_controller.rb | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 12075a50..a033c49a 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -25,9 +25,10 @@ class Api::CheckInProcessController < Api::ApiController alert_time_min = checkout_time[1].to_i end end + render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min, :extra_minutes => extra_minutes } + else + render :json => { :status => true } end - - render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min, :extra_minutes => extra_minutes } else render :json => { :status => false, :error_message => "No current booking!" } end diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index bab40a83..67191b6e 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -12,21 +12,21 @@ class Origami::CheckInProcessController < BaseOrigamiController checkout_at = checkout_at + (checkout_time[1]).to_i.minutes end end - end - @dining_facility = DiningFacility.find(params[:dining_id]) - @dining_facility.status = "occupied" - @dining_facility.save! - - if @dining_facility.type == "Table" - type = "TableBooking" - else - type = "RoomBooking" - end - @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, - :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) - @booking.save! + @dining_facility = DiningFacility.find(params[:dining_id]) + @dining_facility.status = "occupied" + @dining_facility.save! + if @dining_facility.type == "Table" + type = "TableBooking" + else + type = "RoomBooking" + end + + @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, + :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) + @booking.save! + end respond = {:status => 'ok'} respond_to do |format| format.json { render json: respond } diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 0d368224..52b2068c 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -87,7 +87,7 @@ class Origami::VoidController < BaseOrigamiController rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate member_info = Customer.get_member_account(customer) - rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no) + rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) current_balance = SaleAudit.paymal_search(sale_id) end From 6c33040173f53d01162b27e97dc91a053af9e515 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 1 Feb 2018 16:25:11 +0630 Subject: [PATCH 4/6] remove checkin if checkin not used --- app/controllers/origami/home_controller.rb | 7 +++++++ app/controllers/origami/shifts_controller.rb | 6 ++++++ app/views/origami/home/show.html.erb | 4 +++- app/views/origami/shifts/show.html.erb | 4 +++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 536defe7..e7116553 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -84,6 +84,13 @@ class Origami::HomeController < BaseOrigamiController end end end + + #for bank integration + bank_integration = Lookup.collection_of('bank_integration') + @bank_integration = 0 + if !bank_integration[0].nil? + @bank_integration = bank_integration[0][1] + end end diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 6d0fbe02..cb2cc830 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -4,6 +4,12 @@ class Origami::ShiftsController < BaseOrigamiController def show @shift = ShiftSale.current_open_shift(current_user.id) + #for bank integration + bank_integration = Lookup.collection_of('bank_integration') + @bank_integration = 0 + if !bank_integration[0].nil? + @bank_integration = bank_integration[0][1] + end end def new diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 8440f354..a77ac31a 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -431,7 +431,9 @@ <% else %> - + <% if @bank_integration == '1' %> + + <% end %> <% end %> "> diff --git a/app/views/origami/shifts/show.html.erb b/app/views/origami/shifts/show.html.erb index f2ee019e..4ea71dec 100755 --- a/app/views/origami/shifts/show.html.erb +++ b/app/views/origami/shifts/show.html.erb @@ -31,7 +31,9 @@
- + <% if @bank_integration == '1' %> + + <% end %>
From ae4746acfcb79432c88b0ea8c57fdf21a333cc64 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 1 Feb 2018 16:34:18 +0630 Subject: [PATCH 5/6] change checkin time checked --- app/controllers/origami/home_controller.rb | 8 ++------ app/views/origami/home/show.html.erb | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index e7116553..c00b39bf 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -86,12 +86,8 @@ class Origami::HomeController < BaseOrigamiController end #for bank integration - bank_integration = Lookup.collection_of('bank_integration') - @bank_integration = 0 - if !bank_integration[0].nil? - @bank_integration = bank_integration[0][1] - end - + @checkout_time = Lookup.collection_of('checkout_time') + @checkout_alert_time = Lookup.collection_of('checkout_alert_time') end private diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index a77ac31a..0b70e159 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -431,7 +431,7 @@ <% else %> - <% if @bank_integration == '1' %> + <% if !@checkout_time.empty? && !@checkout_alert_time.empty? %> <% end %> <% end %> From f608aa8516b28ffa28ed121bf055427f51a52f2f Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 1 Feb 2018 17:00:57 +0630 Subject: [PATCH 6/6] check checkin time is available or valid time --- .../api/check_in_process_controller.rb | 27 ++++++++++------- .../origami/check_in_process_controller.rb | 29 ++++++++++--------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index a033c49a..6f32c613 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -42,6 +42,7 @@ class Api::CheckInProcessController < Api::ApiController lookup_checkout_time = Lookup.collection_of("checkout_time") if !lookup_checkout_time.empty? + today = Time.now.utc.getlocal checkout_at = Time.now.utc.getlocal lookup_checkout_time.each do |checkout_time| @@ -53,20 +54,24 @@ class Api::CheckInProcessController < Api::ApiController end end - dining_facility.status = "occupied" - dining_facility.save! + if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p") + dining_facility.status = "occupied" + dining_facility.save! - if dining_facility.type == "Table" - type = "TableBooking" + if dining_facility.type == "Table" + type = "TableBooking" + else + type = "RoomBooking" + end + + booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, + :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) + booking.save! + + render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") } else - type = "RoomBooking" + render :json => { :status => true } end - - booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, - :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) - booking.save! - - render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") } else render :json => { :status => true } end diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index 67191b6e..2c5b0b38 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -2,6 +2,7 @@ class Origami::CheckInProcessController < BaseOrigamiController def check_in_process lookup_checkout_time = Lookup.collection_of("checkout_time") + today = Time.now.utc.getlocal checkout_at = Time.now.utc.getlocal if !lookup_checkout_time.empty? lookup_checkout_time.each do |checkout_time| @@ -12,20 +13,22 @@ class Origami::CheckInProcessController < BaseOrigamiController checkout_at = checkout_at + (checkout_time[1]).to_i.minutes end end - - @dining_facility = DiningFacility.find(params[:dining_id]) - @dining_facility.status = "occupied" - @dining_facility.save! - - if @dining_facility.type == "Table" - type = "TableBooking" - else - type = "RoomBooking" - end - @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, - :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) - @booking.save! + if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p") + @dining_facility = DiningFacility.find(params[:dining_id]) + @dining_facility.status = "occupied" + @dining_facility.save! + + if @dining_facility.type == "Table" + type = "TableBooking" + else + type = "RoomBooking" + end + + @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, + :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) + @booking.save! + end end respond = {:status => 'ok'} respond_to do |format|