From 8cea60ec02361fd40518372b2616aca1e5a82255 Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 16 Mar 2018 09:42:56 +0630 Subject: [PATCH] SQA urgent issues --- .../origami/payments_controller.rb | 37 ++++++++++--------- app/controllers/origami/shifts_controller.rb | 1 + app/models/order.rb | 22 +++++------ app/pdf/order_item_pdf.rb | 2 +- app/pdf/order_item_slim_pdf.rb | 2 +- app/pdf/order_set_item_pdf.rb | 2 +- app/pdf/order_summary_pdf.rb | 3 +- app/pdf/order_summary_set_pdf.rb | 2 +- app/pdf/order_summary_slim_pdf.rb | 2 +- app/views/origami/home/index.html.erb | 2 +- .../origami/pending_order/index.html.erb | 22 ++++++++++- app/views/origami/pending_order/show.html.erb | 28 ++++++++++++-- app/views/origami/shifts/show.html.erb | 11 ++++-- app/views/reports/product_sale/index.html.erb | 2 +- config/locales/en.yml | 1 + config/locales/mm.yml | 1 + config/routes.rb | 2 +- 17 files changed, 96 insertions(+), 46 deletions(-) mode change 100644 => 100755 app/pdf/order_item_slim_pdf.rb mode change 100644 => 100755 app/pdf/order_set_item_pdf.rb mode change 100644 => 100755 app/pdf/order_summary_set_pdf.rb mode change 100644 => 100755 app/pdf/order_summary_slim_pdf.rb mode change 100644 => 100755 app/views/origami/pending_order/index.html.erb mode change 100644 => 100755 app/views/origami/pending_order/show.html.erb mode change 100644 => 100755 app/views/reports/product_sale/index.html.erb diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index c764b92f..49320273 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -104,7 +104,9 @@ class Origami::PaymentsController < BaseOrigamiController end end #end rounding adjustment - + puts "sale" + puts saleObj.to_json + sale_payment = SalePayment.new sale_payment.process_payment(saleObj, current_user.name, cash, "cash") @@ -152,12 +154,24 @@ class Origami::PaymentsController < BaseOrigamiController if customer.membership_id != nil && rebate && credit_data.nil? member_info = Customer.get_member_account(customer) - if member_info["status"] == true - rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no) - current_balance = SaleAudit.paymal_search(sale_id) - end + rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no) + current_balance = SaleAudit.paymal_search(sale_id) end + #orders print out + if params[:type] == "quick_service" + booking = Booking.find_by_sale_id(sale_id) + if booking.dining_facility_id.to_i>0 + table_id = booking.dining_facility_id + else + table_id = 0 + end + + booking.booking_orders.each do |order| + Order.pay_process_order_queue(order.order_id,table_id) + end + end + #for card sale data card_data = Array.new card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id) @@ -181,19 +195,6 @@ class Origami::PaymentsController < BaseOrigamiController filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data) render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) - - if params[:type] == "quick_service" - booking = Booking.find_by_sale_id(sale_id) - if booking.dining_facility_id.to_i>0 - table_id = booking.dining_facility_id - else - table_id = 0 - end - - booking.booking_orders.each do |order| - Order.pay_process_order_queue(order.order_id,table_id) - end - end end end end diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 19def9b6..d0b73f99 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -3,6 +3,7 @@ class Origami::ShiftsController < BaseOrigamiController end def show + @type = params[:type] @shift = ShiftSale.current_open_shift(current_user.id) #for bank integration bank_integration = Lookup.collection_of('bank_integration') diff --git a/app/models/order.rb b/app/models/order.rb index 02f4b618..25c5db4a 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -339,17 +339,17 @@ class Order < ApplicationRecord #Process order items and send to order queue def self.pay_process_order_queue(id,table_id) sidekiq = Lookup.find_by_lookup_type("sidekiq") - if !sidekiq.nil? - OrderQueueProcessorJob.perform_later(id, table_id) - else - order = Order.find(id) - if order - oqs = OrderQueueStation.new - oqs.process_order(order, table_id) - end - assign_order = AssignedOrderItem.assigned_order_item_by_job(id) - ActionCable.server.broadcast "order_queue_station_channel",order: assign_order - end + if !sidekiq.nil? + OrderQueueProcessorJob.perform_later(id, table_id) + else + order = Order.find(id) + if order + oqs = OrderQueueStation.new + oqs.process_order(order, table_id) + end + assign_order = AssignedOrderItem.assigned_order_item_by_job(id) + ActionCable.server.broadcast "order_queue_station_channel",order: assign_order + end end def check_cup_status(status) diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 379e919c..fabc8d11 100755 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -37,7 +37,7 @@ class OrderItemPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if order_item.dining.to_i > 0 + if !order_item.dining.nil? text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_item_slim_pdf.rb b/app/pdf/order_item_slim_pdf.rb old mode 100644 new mode 100755 index 09cce4d1..146b585f --- a/app/pdf/order_item_slim_pdf.rb +++ b/app/pdf/order_item_slim_pdf.rb @@ -37,7 +37,7 @@ class OrderItemSlimPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if order_item_slim.dining.to_i > 0 + if !order_item_slim.dining.nil? text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_set_item_pdf.rb b/app/pdf/order_set_item_pdf.rb old mode 100644 new mode 100755 index 6aa6efc4..9aac0d0e --- a/app/pdf/order_set_item_pdf.rb +++ b/app/pdf/order_set_item_pdf.rb @@ -37,7 +37,7 @@ class OrderSetItemPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if order_set_item.dining.to_i > 0 + if !order_set_item.dining.nil? text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 6c8dacac..17cf905c 100755 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -36,7 +36,8 @@ class OrderSummaryPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - if order[0].dining.to_i > 0 + + if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_summary_set_pdf.rb b/app/pdf/order_summary_set_pdf.rb old mode 100644 new mode 100755 index 8828ea43..14b2f796 --- a/app/pdf/order_summary_set_pdf.rb +++ b/app/pdf/order_summary_set_pdf.rb @@ -36,7 +36,7 @@ class OrderSummarySetPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - if order[0].dining.to_i > 0 + if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_summary_slim_pdf.rb b/app/pdf/order_summary_slim_pdf.rb old mode 100644 new mode 100755 index 73023278..c88061ea --- a/app/pdf/order_summary_slim_pdf.rb +++ b/app/pdf/order_summary_slim_pdf.rb @@ -36,7 +36,7 @@ class OrderSummarySlimPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - if order[0].dining.to_i > 0 + if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 3577aa48..aa000aab 100755 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -241,7 +241,7 @@ $('#cash_out').on('click',function(){ $('#close_cashier').on('click',function(e){ e.preventDefault(); // Prevent the href from redirecting directly - var linkURL = '/origami/shift/close'; + var linkURL = '/origami/shift/cashier/close'; warnBeforeRedirect(linkURL); }) diff --git a/app/views/origami/pending_order/index.html.erb b/app/views/origami/pending_order/index.html.erb old mode 100644 new mode 100755 index 8fa9a7af..2d4ba1d4 --- a/app/views/origami/pending_order/index.html.erb +++ b/app/views/origami/pending_order/index.html.erb @@ -34,7 +34,9 @@ reply <%= t("views.btn.back") %> - + <% if current_user.role != "waiter" %> + + <% end %> @@ -51,4 +53,22 @@ $('#back').on('click', function () { window.location.href = '/origami/quick_service'; }) + + $('#close_cashier').on('click',function(e){ + e.preventDefault(); // Prevent the href from redirecting directly + var linkURL = '/origami/shift/quick_service/close'; + warnBeforeRedirect(linkURL); + }); + + function warnBeforeRedirect(linkURL) { + swal({ + title: "Alert!", + text: "Are you sure you want to close cashier?", + type: "warning", + showCancelButton: true + }, function() { + // Redirect the user + window.location.href = linkURL; + }); + } diff --git a/app/views/origami/pending_order/show.html.erb b/app/views/origami/pending_order/show.html.erb old mode 100644 new mode 100755 index d7c929f7..ac164636 --- a/app/views/origami/pending_order/show.html.erb +++ b/app/views/origami/pending_order/show.html.erb @@ -1,7 +1,7 @@
-
+
PENDING ORDER @@ -148,7 +148,7 @@
-
+
<% if current_user.role != "waiter" || @status != "sale"%> @@ -167,6 +167,9 @@ <% if @status != "sale"%> <%end%> + <% if current_user.role != "waiter" %> + + <% end %>
@@ -203,12 +206,11 @@ $(document).ready(function(){ url: ajax_url, // data: 'order_id='+ order_id, success: function (result) { - console.log(result) if (!result.status) { swal("Information!", result.error_message); } else { - window.location.href = '../pending_order/'+ result.data; + location.reload(); } } }); @@ -269,5 +271,23 @@ $(document).ready(function(){ } return false; }); + + $('#close_cashier').on('click',function(e){ + e.preventDefault(); // Prevent the href from redirecting directly + var linkURL = '/origami/shift/quick_service/close'; + warnBeforeRedirect(linkURL); + }); + + function warnBeforeRedirect(linkURL) { + swal({ + title: "Alert!", + text: "Are you sure you want to close cashier?", + type: "warning", + showCancelButton: true + }, function() { + // Redirect the user + window.location.href = linkURL; + }); + } }); diff --git a/app/views/origami/shifts/show.html.erb b/app/views/origami/shifts/show.html.erb index 4ea71dec..4e42f11b 100755 --- a/app/views/origami/shifts/show.html.erb +++ b/app/views/origami/shifts/show.html.erb @@ -58,6 +58,7 @@