From 06acf3acb99018aaa2b4eb69a7325e2c3b356642 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 28 Dec 2017 13:21:23 +0630 Subject: [PATCH 1/3] update ruby version --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index de22a68c..0fb5f323 100755 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -ruby '2.4.0' +ruby '2.4.1' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" From 90525b9391977cf2fad51d770b0974855880013f Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 28 Dec 2017 17:48:56 +0630 Subject: [PATCH 2/3] add extra minutes in api/check_in --- app/controllers/api/check_in_process_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 488684e7..cf34700e 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -11,6 +11,8 @@ class Api::CheckInProcessController < Api::ApiController 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") + extra_minutes = (booking.checkout_at - booking.reserved_at) / 1.minutes + lookup_checkout_time = Lookup.collection_of("checkout_alert_time") alert_time_min = 0 if !lookup_checkout_time.nil? @@ -21,7 +23,7 @@ class Api::CheckInProcessController < Api::ApiController end end - render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min } + 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 From ecb9a5f010cfa8c8bfb7db13bbb5c50ed7089900 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 28 Dec 2017 18:02:25 +0630 Subject: [PATCH 3/3] update void foc and credit for member discount --- app/controllers/origami/payments_controller.rb | 5 +++++ app/controllers/origami/void_controller.rb | 8 ++++++-- app/models/sale.rb | 1 + app/views/origami/home/show.html.erb | 6 +++--- app/views/origami/payments/show.html.erb | 14 +++++++------- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 02e0c4ef..3ab55be8 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -261,6 +261,11 @@ class Origami::PaymentsController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) + + if saleObj.discount_type == "member_discount" + saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0) + end + sale_payment = SalePayment.new sale_payment.process_payment(saleObj, @user, cash, "foc") diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 242a1c2e..ffb2bde4 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -6,7 +6,11 @@ class Origami::VoidController < BaseOrigamiController if Sale.exists?(sale_id) sale = Sale.find_by_sale_id(sale_id) - + if sale.discount_type == "member_discount" + sale.update_attributes(total_discount: 0) + sale.compute_by_sale_items(sale_id, sale.sale_items,0) + end + # update count for shift sale if(sale.sale_status == "completed") if sale.shift_sale_id != nil @@ -21,7 +25,7 @@ class Origami::VoidController < BaseOrigamiController shift.save end end - + sale.payment_status = 'void' sale.sale_status = 'void' sale.save diff --git a/app/models/sale.rb b/app/models/sale.rb index b97c529e..969deb5c 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -247,6 +247,7 @@ class Sale < ApplicationRecord #compute - invoice total def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil) + sale = Sale.find(sale_id) sales_items = sale_itemss diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 6827d8e8..bd9022d9 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -587,9 +587,9 @@ var sale_id = $('#sale_id').val(); type = $('.payment_method').val(); - - calculate_member_discount(sale_id,type); - + if (type != "Credit") { + calculate_member_discount(sale_id,type); + } var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; $.ajax({ type: "GET", diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 1010101d..c076b81b 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -425,14 +425,14 @@ var sale_id = $('#sale_id').text(); // var item_row = $('.is_card'); - // if (item_row.length < 1) { - calculate_member_discount(sale_id); - // } - - // payment - var cash = $('#cash').text(); + // payment + var cash = $('#cash').text(); var credit = $('#credit').text(); - var card = $('#card').text(); + var card = $('#card').text(); + + if (credit <= 0) { + calculate_member_discount(sale_id); + } $.ajax({type: "POST", url: "<%= origami_payment_cash_path %>",