From ca360c75d66fbd9adab0c8b3b88aa60f2ed8c2bc Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 16 May 2018 18:01:47 +0630 Subject: [PATCH 1/2] update cash in and out for quick service --- .../origami/cash_ins_controller.rb | 25 ++++++++++--------- .../origami/pending_order_controller.rb | 6 +++++ app/views/origami/cash_ins/new.html.erb | 15 +++++++++-- app/views/origami/cash_outs/new.html.erb | 15 +++++++++-- .../pending_order/completed_sale.html.erb | 8 ++++++ .../origami/pending_order/index.html.erb | 12 ++++++++- app/views/origami/pending_order/show.html.erb | 10 ++++++++ config/routes.rb | 2 ++ 8 files changed, 76 insertions(+), 17 deletions(-) diff --git a/app/controllers/origami/cash_ins_controller.rb b/app/controllers/origami/cash_ins_controller.rb index 1207d486..030b56e1 100755 --- a/app/controllers/origami/cash_ins_controller.rb +++ b/app/controllers/origami/cash_ins_controller.rb @@ -8,31 +8,32 @@ class Origami::CashInsController < BaseOrigamiController amount = params[:amount] payment_method = params[:payment_method] payment_method_reference = params[:payment_method_reference] + type = params[:type] p_jour = PaymentJournal.new p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user.id) shift = ShiftSale.current_open_shift(current_user.id) current_shift = ShiftSale.current_shift - # set cashier + # set cashier if shift != nil shift = shift else open_cashier = Employee.where("role = 'cashier' AND token_session <> ''") if open_cashier.count>0 - - shift = ShiftSale.current_open_shift(open_cashier[0].id) - - if shift - shift = ShiftSale.current_open_shift(shift.id) - else - shift = ShiftSale.current_open_shift(current_shift.id) - end - else - shift = Employee.find(current_shift.employee_id).name - end + shift = ShiftSale.current_open_shift(open_cashier[0].id) + + if shift + shift = ShiftSale.current_open_shift(shift.id) + else + shift = ShiftSale.current_open_shift(current_shift.id) + end + else + shift = Employee.find(current_shift.employee_id).name + end + end shift.cash_in = shift.cash_in + amount.to_f shift.save diff --git a/app/controllers/origami/pending_order_controller.rb b/app/controllers/origami/pending_order_controller.rb index 4fa6002b..d6230993 100644 --- a/app/controllers/origami/pending_order_controller.rb +++ b/app/controllers/origami/pending_order_controller.rb @@ -62,7 +62,13 @@ class Origami::PendingOrderController < BaseOrigamiController @table_id = nil @dining = nil end + end + def cash_ins + render "origami/cash_ins/new" + end + def cash_outs + render "origami/cash_outs/new" end end diff --git a/app/views/origami/cash_ins/new.html.erb b/app/views/origami/cash_ins/new.html.erb index bda159e2..0b27a62f 100755 --- a/app/views/origami/cash_ins/new.html.erb +++ b/app/views/origami/cash_ins/new.html.erb @@ -56,6 +56,9 @@ diff --git a/app/views/origami/cash_outs/new.html.erb b/app/views/origami/cash_outs/new.html.erb index 64b3909f..32f43099 100755 --- a/app/views/origami/cash_outs/new.html.erb +++ b/app/views/origami/cash_outs/new.html.erb @@ -25,6 +25,7 @@ diff --git a/app/views/origami/pending_order/completed_sale.html.erb b/app/views/origami/pending_order/completed_sale.html.erb index 8f986f2c..507d698e 100644 --- a/app/views/origami/pending_order/completed_sale.html.erb +++ b/app/views/origami/pending_order/completed_sale.html.erb @@ -172,6 +172,8 @@ <% if current_user.role != "waiter" %> + + <% end %> @@ -201,7 +203,13 @@ $(document).ready(function(){ var linkURL = '/origami/shift/quick_service/close'; warnBeforeRedirect(linkURL); }); + $('#cash_in').on('click',function(){ + window.location.href = '/origami/quick_service/cash_ins'; + }) + $('#cash_out').on('click',function(){ + window.location.href = '/origami/quick_service/cash_outs'; + }) }); diff --git a/app/views/origami/pending_order/index.html.erb b/app/views/origami/pending_order/index.html.erb index 58e94451..673dd8e2 100644 --- a/app/views/origami/pending_order/index.html.erb +++ b/app/views/origami/pending_order/index.html.erb @@ -55,7 +55,9 @@ <% if current_user.role != "waiter" %> - <% end %> + + + <% end %> @@ -83,6 +85,14 @@ warnBeforeRedirect(linkURL); }); + $('#cash_in').on('click',function(){ + window.location.href = '/origami/quick_service/cash_ins'; + }) + + $('#cash_out').on('click',function(){ + window.location.href = '/origami/quick_service/cash_outs'; + }) + function warnBeforeRedirect(linkURL) { swal({ title: "Alert!", diff --git a/app/views/origami/pending_order/show.html.erb b/app/views/origami/pending_order/show.html.erb index 05dca72c..15d3aa12 100644 --- a/app/views/origami/pending_order/show.html.erb +++ b/app/views/origami/pending_order/show.html.erb @@ -188,6 +188,8 @@ <%end%> <% if current_user.role != "waiter" %> + <% end %> @@ -321,5 +323,13 @@ $(document).ready(function(){ window.location.href = '/oqs/'+ assigned_order_item_id + "/edit/pending"; } }); + + $('#cash_in').on('click',function(){ + window.location.href = '/origami/quick_service/cash_ins'; + }) + + $('#cash_out').on('click',function(){ + window.location.href = '/origami/quick_service/cash_outs'; + }) }); diff --git a/config/routes.rb b/config/routes.rb index 6b888e1d..77e26bbb 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -110,6 +110,8 @@ scope "(:locale)", locale: /en|mm/ do get "quick_service/modify_order/:sale_id" => "quick_service#modify_order" post 'quick_service/update_modify_order' => "quick_service#update_modify_order", :defaults => { :format => 'json' } + get "quick_service/cash_ins" => "pending_order#cash_ins" + get "quick_service/cash_outs" => "pending_order#cash_outs" resources :cash_ins, only: [:new, :create] resources :cash_outs, only: [:new, :create] From 942380afff5e4156deeeebeeae96184948dbffea Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 17 May 2018 10:40:29 +0630 Subject: [PATCH 2/2] update discount with junctionpay --- app/views/origami/payments/show.html.erb | 3 ++- config/initializers/action_controller.rb | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 020b3e94..7c99df3c 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -571,6 +571,7 @@ var customer_name = "<%= @customer.name %>"; if ($("#server_mode").val() != "cloud") { // first bill not used in cloud payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment"); console.log(payment_type) + console.log(parseInt(jQuery.inArray("MPU", payment_type))) if (member_id && member_discount) { if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){ $("#credit_payment").hide(); @@ -654,7 +655,7 @@ var customer_name = "<%= @customer.name %>"; else if(parseInt(jQuery.inArray("Alipay", payment_type)) != -1 && $('#alipaycount').text()== 0 && sub_total != 0.0 && member){ swal("Oops","Please Pay with Alipay Payment","warning"); } - else if(parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) != -1 != -1 && $('#junctionpaycount').text()==0 && sub_total != 0.0 && member){ + else if(parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) != -1 && $('#junctionpaycount').text()==0 && sub_total != 0.0 && member){ swal("Oops","Please Pay with JUNCTIONPAY Payment","warning"); } else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0 && member){ diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index e0eb7455..b84bca54 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -20,11 +20,11 @@ class ActionController::Base end else #check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - else - redirect_to activate_path - end + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end end end