From 574f320dfdf96c74f87370cccb86f7d350029dec Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Tue, 22 May 2018 11:37:08 +0630 Subject: [PATCH 01/11] Export excel in Survey Report --- .../transactions/surveys_controller.rb | 1 + .../surveys/_survey_report_filter.html.erb | 41 +++++++++ app/views/transactions/surveys/index.html.erb | 34 +++----- app/views/transactions/surveys/index.xls.erb | 86 +++++++++++++++++++ 4 files changed, 141 insertions(+), 21 deletions(-) create mode 100644 app/views/transactions/surveys/_survey_report_filter.html.erb create mode 100644 app/views/transactions/surveys/index.xls.erb diff --git a/app/controllers/transactions/surveys_controller.rb b/app/controllers/transactions/surveys_controller.rb index b6c48215..4bf4ec2d 100644 --- a/app/controllers/transactions/surveys_controller.rb +++ b/app/controllers/transactions/surveys_controller.rb @@ -22,6 +22,7 @@ class Transactions::SurveysController < ApplicationController respond_to do |format| format.html # index.html.erb + format.xls format.json { render json: @surveys } end end diff --git a/app/views/transactions/surveys/_survey_report_filter.html.erb b/app/views/transactions/surveys/_survey_report_filter.html.erb new file mode 100644 index 00000000..78a988b9 --- /dev/null +++ b/app/views/transactions/surveys/_survey_report_filter.html.erb @@ -0,0 +1,41 @@ +<%= form_tag transactions_surveys_path, :method => :get, :id=>"frm_report", :class => "form" do %> +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+
+<% end %> + \ No newline at end of file diff --git a/app/views/transactions/surveys/index.html.erb b/app/views/transactions/surveys/index.html.erb index 7e750faa..cb95ad16 100644 --- a/app/views/transactions/surveys/index.html.erb +++ b/app/views/transactions/surveys/index.html.erb @@ -10,29 +10,15 @@
- <%= form_tag transactions_surveys_path, :method => :get do %> -
-
- - -
+ <%= render :partial=>'survey_report_filter', + :locals=>{ :period_type => true, :shift_name => true, :report_path =>transactions_surveys_path} %> -
- - -
+
+ + -
- - -
- -
- -
-
-
- <% end %>
@@ -116,3 +102,9 @@ + \ No newline at end of file diff --git a/app/views/transactions/surveys/index.xls.erb b/app/views/transactions/surveys/index.xls.erb new file mode 100644 index 00000000..3e31ad12 --- /dev/null +++ b/app/views/transactions/surveys/index.xls.erb @@ -0,0 +1,86 @@ +
+
+
+
+
+
+ + + + + + + + + + + + + + <% total_child = 0 %> + <% total_adult = 0 %> + <% total_male = 0 %> + <% total_female = 0 %> + <% total_local = 0 %> + <% total_customer = 0 %> + <% total_foreigner = 0 %> + <% if !@surveys.nil? %> + <% @surveys.each do |survey| %> + <% total_child = total_child.to_i + survey.child.to_i %> + <% total_adult = total_adult.to_i + survey.adult.to_i %> + <% total_male = total_male.to_i + survey.male.to_i %> + <% total_female = total_female.to_i + survey.female.to_i %> + <% total_local = total_local.to_i + survey.local.to_i %> + <% total_customer = total_customer.to_i + survey.total_customer.to_i %> + + + + + + + + + + + + + <% end %> + <% end %> + + + + + + + + + + + +
<%= t("views.right_panel.detail.dining") %><%= t("views.right_panel.detail.receipt_no") %><%= t("views.right_panel.detail.created_by") %><%= t("views.right_panel.detail.child") %><%= t("views.right_panel.detail.adult") %><%= t("views.right_panel.detail.male") %><%= t("views.right_panel.detail.female") %><%= t("views.right_panel.detail.total") %> <%= t :customer %> + <%= t("views.right_panel.detail.local") %><%= t("views.right_panel.detail.foreigner") %>
<%= survey.dining_name rescue ' '%><%= survey.receipt_no rescue '-'%><%= survey.created_by rescue ' '%><%= survey.child rescue ' '%><%= survey.adult rescue ' '%><%= survey.male rescue ' '%><%= survey.female rescue ' '%><%= survey.total_customer rescue ' '%><%= survey.local rescue ' '%> + <% if !survey.foreigner.nil? %> + <% JSON.parse(survey.foreigner).each do |foreign| %> + <% foreigner_lists = foreign.split(",") %> + <% if !foreigner_lists.empty? %> + <% foreigner_lists.each do |fgn| %> + <% unless fgn.match(/[^[:digit:]]+/) + total_foreigner = total_foreigner.to_i + fgn.to_i + end %> + <% if !fgn.scan(/\D/).empty? %> + <%= fgn %> :<% end %> <%= fgn.to_i unless fgn.match(/[^[:digit:]]+/) %>
+ <% end %> + <% end %> + <% end %> + <% end %> +
<%= t("views.right_panel.detail.total") %><%= total_child %><%= total_adult %><%= total_male %><%= total_female %><%= total_customer %><%= total_local %><%= total_foreigner %>
+
+ <%if !@orders.nil?%> + <%= paginate @surveys %> + <%end%> +
+
+
+ +
+
From f1733d9f0605c306b53c3bfe8d12ad4f6a675e59 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Tue, 22 May 2018 13:26:23 +0630 Subject: [PATCH 02/11] Pull from master --- README.md | 6 + app/assets/javascripts/addorder.js | 8 +- .../javascripts/channels/call_waiter.js | 125 ++++---- .../javascripts/channels/check_in_booking.js | 17 +- .../javascripts/channels/check_new_order.js | 62 ++-- .../channels/check_order_ready_to_delivery.js | 32 +- .../channels/check_order_send_to_kitchen.js | 30 +- app/assets/javascripts/channels/checkin.js | 4 + app/assets/javascripts/channels/order.js | 8 +- .../channels/order_queue_station.js | 133 ++++---- .../javascripts/channels/order_reservation.js | 85 ++--- .../javascripts/channels/second_display.js | 55 ++-- .../channels/second_display_view.js | 290 +++++++++--------- app/controllers/api/bill_controller.rb | 9 +- .../api/call_waiters_controller.rb | 9 +- .../api/check_in_process_controller.rb | 11 +- .../order_reservation_controller.rb | 7 +- app/controllers/crm/customers_controller.rb | 0 .../origami/addorders_controller.rb | 89 +++++- .../origami/customers_controller.rb | 0 .../origami/product_commissions_controller.rb | 70 +++-- .../origami/second_display_controller.rb | 8 +- .../origami/split_bill_controller.rb | 10 +- app/models/dining_facility.rb | 14 +- app/models/display_image.rb | 2 +- app/models/menu_category.rb | 2 +- app/models/menu_item.rb | 2 +- app/models/order.rb | 159 +++++----- app/models/order_queue_station.rb | 14 +- app/models/order_reservation.rb | 36 ++- app/models/promotion.rb | 35 ++- app/models/sale.rb | 80 ++--- app/models/sale_payment.rb | 7 +- app/pdf/receipt_bill_a5_pdf.rb | 101 +++--- app/pdf/receipt_bill_pdf.rb | 104 ++++--- .../crm/customers/_card_read_form.html.erb | 0 .../crm/customers/_crm_customer.json.jbuilder | 0 app/views/crm/customers/_form.html.erb | 0 app/views/crm/customers/_new_form.html.erb | 0 app/views/crm/customers/edit.html.erb | 0 app/views/crm/customers/edit.json.jbuilder | 0 app/views/crm/customers/index.html.erb | 0 app/views/crm/customers/index.json.jbuilder | 0 app/views/crm/customers/new.html.erb | 0 app/views/crm/customers/show.html.erb | 0 app/views/crm/customers/show.json.jbuilder | 0 app/views/oqs/edit/index.html.erb | 4 +- app/views/origami/customers/index.html.erb | 0 .../origami/dashboard/_menu.json.jbuilder | 16 +- app/views/origami/dinga/index.html.erb | 9 +- app/views/origami/paymal/index.html.erb | 7 + app/views/origami/payments/show.html.erb | 3 +- app/views/origami/pending_order/show.html.erb | 7 +- app/views/origami/sales/show.html.erb | 26 +- app/views/reports/commission/index.xls.erb | 9 + .../reports/credit_payment/index.xls.erb | 10 +- app/views/reports/dailysale/index.xls.erb | 12 +- .../reports/order_reservation/index.xls.erb | 12 +- .../reports/payment_method/index.xls.erb | 11 +- app/views/reports/product_sale/index.xls.erb | 11 +- app/views/reports/receipt_no/index.xls.erb | 12 +- app/views/reports/saleitem/index.xls.erb | 11 +- app/views/reports/shiftsale/index.xls.erb | 11 +- app/views/reports/stock_check/index.xls.erb | 9 + app/views/reports/void_sale/index.xls.erb | 12 +- .../reports/waste_and_spoilage/index.xls.erb | 11 +- ...{puma.rb.production => puma-production.rb} | 0 config/secrets.yml | 2 +- ...> 20180521041850_create_display_images.rb} | 6 +- lib/tasks/receipt.rake | 37 ++- spec/models/display_image_spec.rb | 5 + 71 files changed, 1151 insertions(+), 726 deletions(-) mode change 100755 => 100644 app/controllers/crm/customers_controller.rb mode change 100755 => 100644 app/controllers/origami/customers_controller.rb mode change 100755 => 100644 app/views/crm/customers/_card_read_form.html.erb mode change 100755 => 100644 app/views/crm/customers/_crm_customer.json.jbuilder mode change 100755 => 100644 app/views/crm/customers/_form.html.erb mode change 100755 => 100644 app/views/crm/customers/_new_form.html.erb mode change 100755 => 100644 app/views/crm/customers/edit.html.erb mode change 100755 => 100644 app/views/crm/customers/edit.json.jbuilder mode change 100755 => 100644 app/views/crm/customers/index.html.erb mode change 100755 => 100644 app/views/crm/customers/index.json.jbuilder mode change 100755 => 100644 app/views/crm/customers/new.html.erb mode change 100755 => 100644 app/views/crm/customers/show.html.erb mode change 100755 => 100644 app/views/crm/customers/show.json.jbuilder mode change 100755 => 100644 app/views/origami/customers/index.html.erb rename config/{puma.rb.production => puma-production.rb} (100%) rename db/migrate/{20180213053009_create_display_images.rb => 20180521041850_create_display_images.rb} (82%) create mode 100644 spec/models/display_image_spec.rb diff --git a/README.md b/README.md index dfebed49..4ba6d51f 100755 --- a/README.md +++ b/README.md @@ -200,6 +200,12 @@ Add Feature for Order and Reservation ** '0' means can not use order reservation and '1' means can use order reservation ** => settings/lookups => { type:order_reservation, name: OrderReservation, value:'{0 or 1}' } +For Price 0 in receipt bill + 2) settings/lookups => { type:show_price, name:Shoe Price, value:1 } + +For Price 0 in receipt bill + 2) settings/lookups => { type:order_by, name:Order By, value:name } + * ToDo list 1. Migration diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 611ffb17..5b3142e6 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -119,7 +119,6 @@ $(function() { // $(".menu_sub_category").on("click", function(){ $('.sub_category_list').addClass("hidden"); var menu_id = $(this).attr("data-id"); - console.log(menu_id); var url = "get_menu_category/"+menu_id; show_menu_item_list(url,menu_id); }); @@ -1092,7 +1091,12 @@ $(function() { if (type == true) { var table_type = $('#table_id').find("option:selected").data('type'); var table_id = $('#table_id').val(); - window.location.href = "/origami/dashboard"; + if(window.location.href.includes("modify_order")){ + var link_url = window.location.href.split("/"); + window.location.href = "/origami/quick_service/pending_order/"+link_url[link_url.length - 1]; + }else{ + window.location.href = "/origami/dashboard"; + } }else{ var table_type = $('#table_type').text(); var table_id = $('#table_id').text(); diff --git a/app/assets/javascripts/channels/call_waiter.js b/app/assets/javascripts/channels/call_waiter.js index f0a804a2..ed1fa0d3 100644 --- a/app/assets/javascripts/channels/call_waiter.js +++ b/app/assets/javascripts/channels/call_waiter.js @@ -6,68 +6,73 @@ App.call_waiter = App.cable.subscriptions.create('CallWaiterChannel', { disconnected: function() {}, received: function(data) { - table = data.table - time = data.time - // for Notificaiotn message - var element = "#notify-wrapper" - var animateEnter = ""; - var animateExit = ""; - - if (time == 'print_error') { - var colorName = "alert-danger"; - var placementFrom = "center"; - var placementAlign = "center"; - var text = " Hello
"+table ; - style ="" - }else{ - var colorName = "alert-warning"; - var placementFrom = "top"; - var placementAlign = "center"; - var text = " Calling Waiter
"+table.name ; - style ="width:180px !important;" - } - - - if (text != null || colorName != null){ - showNotification(element, colorName, text, placementFrom, placementAlign, animateEnter, animateExit); - } - - function showNotification(element, colorName, text, placementFrom, placementAlign, animateEnter, animateExit) { - if (colorName === null || colorName === '') { colorName = 'bg-black'; } - if (animateEnter === null || animateEnter === '') { animateEnter = 'animated fadeInDown'; } - if (animateExit === null || animateExit === '') { animateExit = 'animated fadeOutUp'; } - var allowDismiss = true; - - $.notify({ - message: text - }, + var hostname = location.hostname.trim(); + if(data.from == "" || hostname == data.from) { - element: element, - type: colorName, - allow_dismiss: allowDismiss, - timer: 200000000000000, - placement: { - from: placementFrom, - align: placementAlign - }, - animate: { - enter: animateEnter, - exit: animateExit - }, - template: '' - }); + table = data.table + time = data.time + + // for Notificaiotn message + var element = "#notify-wrapper" + var animateEnter = ""; + var animateExit = ""; + + if (time == 'print_error') { + var colorName = "alert-danger"; + var placementFrom = "center"; + var placementAlign = "center"; + var text = " Hello
"+table ; + style ="" + }else{ + var colorName = "alert-warning"; + var placementFrom = "top"; + var placementAlign = "center"; + var text = " Calling Waiter
"+table.name ; + style ="width:180px !important;" + } + + + if (text != null || colorName != null){ + showNotification(element, colorName, text, placementFrom, placementAlign, animateEnter, animateExit); + } + + function showNotification(element, colorName, text, placementFrom, placementAlign, animateEnter, animateExit) { + if (colorName === null || colorName === '') { colorName = 'bg-black'; } + if (animateEnter === null || animateEnter === '') { animateEnter = 'animated fadeInDown'; } + if (animateExit === null || animateExit === '') { animateExit = 'animated fadeOutUp'; } + var allowDismiss = true; + + $.notify({ + message: text + }, + { + element: element, + type: colorName, + allow_dismiss: allowDismiss, + timer: 200000000000000, + placement: { + from: placementFrom, + align: placementAlign + }, + animate: { + enter: animateEnter, + exit: animateExit + }, + template: '' + }); + } + //end Notificaiotn message + } } - //end Notificaiotn message -} }); diff --git a/app/assets/javascripts/channels/check_in_booking.js b/app/assets/javascripts/channels/check_in_booking.js index 18597f4d..410d1c53 100644 --- a/app/assets/javascripts/channels/check_in_booking.js +++ b/app/assets/javascripts/channels/check_in_booking.js @@ -5,12 +5,15 @@ App.checkin = App.cable.subscriptions.create('CheckInBookingChannel', { disconnected: function() {}, - received: function(data) { - if($('.table_'+data.table.id).hasClass('green')){ - $('.table_'+data.table.id).removeClass('green'); - $('.table_'+data.table.id).addClass('blue'); - } - $('.new_text_'+data.table.id).removeClass('hide'); - } + received: function(data) { + var hostname = location.hostname.trim(); + if(data.from == "" || hostname == data.from){ + if($('.table_'+data.table.id).hasClass('green')){ + $('.table_'+data.table.id).removeClass('green'); + $('.table_'+data.table.id).addClass('blue'); + } + $('.new_text_'+data.table.id).removeClass('hide'); + } + } }); diff --git a/app/assets/javascripts/channels/check_new_order.js b/app/assets/javascripts/channels/check_new_order.js index f4d4aa9f..9cf91522 100644 --- a/app/assets/javascripts/channels/check_new_order.js +++ b/app/assets/javascripts/channels/check_new_order.js @@ -3,38 +3,40 @@ App.check_new_order = App.cable.subscriptions.create('CheckNewOrderChannel', { disconnected: function() {}, - received: function(data) { - var order = data.data; - var shop_code = data.shop_code; - if(order.length > 0){ - var order_lists = ""; - $.each(order, function(key, value){ - if(key==0){ - order_lists = value.order_reservation_id; - }else if(key == (order.length - 1)){ - order_lists += ' and ' + value.order_reservation_id; - }else{ - order_lists += ', ' + value.order_reservation_id; + received: function(data) { + var hostname = location.hostname.trim(); + if(data.from == "" || hostname == data.from){ + var order = data.data; + var shop_code = data.shop_code; + if(order.length > 0){ + var order_lists = ""; + $.each(order, function(key, value){ + if(key==0){ + order_lists = value.order_reservation_id; + }else if(key == (order.length - 1)){ + order_lists += ' and ' + value.order_reservation_id; + }else{ + order_lists += ', ' + value.order_reservation_id; + } + }); + // alert(order_lists); + if (typeof checkNewOrderAlert !== 'undefined' && $.isFunction(checkNewOrderAlert)) { + checkNewOrderAlert(shop_code, order_lists); } - }); - - // alert(order_lists); - if (typeof checkNewOrderAlert !== 'undefined' && $.isFunction(checkNewOrderAlert)) { - checkNewOrderAlert(shop_code, order_lists); + // $("#notify_new_order_lists").text(order_lists); + // if($("#"+shop_code+"_notify_new_order").hasClass("hidden")){ + // $("#"+shop_code+"_notify_new_order").removeClass("hidden"); + // } + // $("#"+shop_code+"_notify_new_order").on('shown.bs.modal', function(e){ + // // $(document).off('focusin.modal'); + // $("#"+shop_code+"_notify_new_order").focus(); + // $("#"+shop_code+"_doemal_new_order").addClass("hidden"); + // $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden"); + // $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden"); + // }).on('hide.bs.modal', function (e) { + // $("#"+shop_code+"_notify_new_order").addClass("hidden"); + // }).modal({show: true, keyboard: false, backdrop: false}); } - // $("#notify_new_order_lists").text(order_lists); - // if($("#"+shop_code+"_notify_new_order").hasClass("hidden")){ - // $("#"+shop_code+"_notify_new_order").removeClass("hidden"); - // } - // $("#"+shop_code+"_notify_new_order").on('shown.bs.modal', function(e){ - // // $(document).off('focusin.modal'); - // $("#"+shop_code+"_notify_new_order").focus(); - // $("#"+shop_code+"_doemal_new_order").addClass("hidden"); - // $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden"); - // $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden"); - // }).on('hide.bs.modal', function (e) { - // $("#"+shop_code+"_notify_new_order").addClass("hidden"); - // }).modal({show: true, keyboard: false, backdrop: false}); } } }); diff --git a/app/assets/javascripts/channels/check_order_ready_to_delivery.js b/app/assets/javascripts/channels/check_order_ready_to_delivery.js index 3f7f53b1..54666735 100644 --- a/app/assets/javascripts/channels/check_order_ready_to_delivery.js +++ b/app/assets/javascripts/channels/check_order_ready_to_delivery.js @@ -3,20 +3,23 @@ App.check_order_ready_to_delivery = App.cable.subscriptions.create('CheckOrderRe disconnected: function() {}, - received: function(data) { - var order = data.data; - var shop_code = data.shop_code; - if(order.length > 0){ - var order_lists = ""; - $.each(order, function(key, value){ - if(key==0){ - order_lists = value.order_reservation_id; - }else if(key == (order.length - 1)){ - order_lists += ' and ' + value.order_reservation_id; - }else{ - order_lists += ', ' + value.order_reservation_id; - } - }); + received: function(data) { + var hostname = location.hostname.trim(); + if(data.from == "" || hostname == data.from) + { + var order = data.data; + var shop_code = data.shop_code; + if(order.length > 0){ + var order_lists = ""; + $.each(order, function(key, value){ + if(key==0){ + order_lists = value.order_reservation_id; + }else if(key == (order.length - 1)){ + order_lists += ' and ' + value.order_reservation_id; + }else{ + order_lists += ', ' + value.order_reservation_id; + } + }); // alert(order_lists); if (typeof checkOrderReadyToKitchenAlert !== 'undefined' && $.isFunction(checkOrderReadyToKitchenAlert)) { @@ -37,5 +40,6 @@ App.check_order_ready_to_delivery = App.cable.subscriptions.create('CheckOrderRe // }).modal({show: true, keyboard: false, backdrop: false}); } } +} }); diff --git a/app/assets/javascripts/channels/check_order_send_to_kitchen.js b/app/assets/javascripts/channels/check_order_send_to_kitchen.js index 892e0590..fee2e3f6 100644 --- a/app/assets/javascripts/channels/check_order_send_to_kitchen.js +++ b/app/assets/javascripts/channels/check_order_send_to_kitchen.js @@ -4,19 +4,22 @@ App.check_order_send_to_kitchen = App.cable.subscriptions.create('CheckOrderSend disconnected: function() {}, received: function(data) { - var order = data.data; - var shop_code = data.shop_code; - if(order.length > 0){ - var order_lists = ""; - $.each(order, function(key, value){ - if(key==0){ - order_lists = value.order_reservation_id; - }else if(key == (order.length - 1)){ - order_lists += ' and ' + value.order_reservation_id; - }else{ - order_lists += ', ' + value.order_reservation_id; - } - }); + var hostname = location.hostname.trim(); + if(data.from == "" || hostname == data.from) + { + var order = data.data; + var shop_code = data.shop_code; + if(order.length > 0){ + var order_lists = ""; + $.each(order, function(key, value){ + if(key==0){ + order_lists = value.order_reservation_id; + }else if(key == (order.length - 1)){ + order_lists += ' and ' + value.order_reservation_id; + }else{ + order_lists += ', ' + value.order_reservation_id; + } + }); // alert(order_lists); if (typeof checkOrderSendToKitchen !== 'undefined' && $.isFunction(checkOrderSendToKitchen)) { @@ -37,5 +40,6 @@ App.check_order_send_to_kitchen = App.cable.subscriptions.create('CheckOrderSend // }).modal({show: true, keyboard: false, backdrop: false}); } } +} }); diff --git a/app/assets/javascripts/channels/checkin.js b/app/assets/javascripts/channels/checkin.js index 03159170..a0712d65 100644 --- a/app/assets/javascripts/channels/checkin.js +++ b/app/assets/javascripts/channels/checkin.js @@ -6,6 +6,9 @@ App.order = App.cable.subscriptions.create('CheckinChannel', { disconnected: function() {}, received: function(data) { + var hostname = location.hostname.trim(); + if(data.from == "" || hostname == data.from) + { $.each(data.table,function(key,value){ if($('.table_'+value.table_id).hasClass('blue')){ $('.table_'+value.table_id).removeClass('blue'); @@ -22,5 +25,6 @@ App.order = App.cable.subscriptions.create('CheckinChannel', { $('.new_text_'+value.table_id).removeClass('hide'); }); } +} }); diff --git a/app/assets/javascripts/channels/order.js b/app/assets/javascripts/channels/order.js index 26c7897e..87b08c4a 100755 --- a/app/assets/javascripts/channels/order.js +++ b/app/assets/javascripts/channels/order.js @@ -3,7 +3,12 @@ App.order = App.cable.subscriptions.create('OrderChannel', { disconnected: function() {}, - received: function(data) { + received: function(data) { + var hostname = location.hostname.trim(); + console.log(hostname) + console.log(data.from) + if(data.from == "" || hostname == data.from) + { if (data.type == 'order') { $('.table_'+data.table.id).removeClass('green'); $('.table_'+data.table.id).addClass('blue'); @@ -14,6 +19,7 @@ App.order = App.cable.subscriptions.create('OrderChannel', { $('.new_text_'+data.table.id).html(''); $('.new_text_'+data.table.id).removeClass('hide') } + } } }); diff --git a/app/assets/javascripts/channels/order_queue_station.js b/app/assets/javascripts/channels/order_queue_station.js index a72a7893..ccb3b0d3 100755 --- a/app/assets/javascripts/channels/order_queue_station.js +++ b/app/assets/javascripts/channels/order_queue_station.js @@ -6,83 +6,86 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann disconnected: function() {}, received: function(data) { - var oqs_id = $('.oqs_active').attr('data-id'); - items = data.order; - for(var field in items) { - var price = parseFloat(items[field].price).toFixed(2); - if (items[field]["options"] == "[]" || items[field]["options"] == "") { - var options = ""; - }else{ - var options = items[field]["options"]; - } - //for count - test = document.getElementsByClassName("oqs_count"); + var hostname = location.hostname.trim(); + if(data.from == "" || hostname == data.from){ + var oqs_id = $('.oqs_active').attr('data-id'); + items = data.order; + for(var field in items) { + var price = parseFloat(items[field].price).toFixed(2); + if (items[field]["options"] == "[]" || items[field]["options"] == "") { + var options = ""; + }else{ + var options = items[field]["options"]; + } + //for count + test = document.getElementsByClassName("oqs_count"); - for (var i = 0; i < test.length; i++) { - oqs_count_id = $(".oqs_count"+i).attr("data-id"); - oqs_count = $(".oqs_count"+i).text(); - if ( oqs_count_id == items[field]["order_queue_station_id"]) { - oqs_count_total = +oqs_count +1 ; - $(".oqs_count"+i).text(oqs_count_total) - } - } - //end count + for (var i = 0; i < test.length; i++) { + oqs_count_id = $(".oqs_count"+i).attr("data-id"); + oqs_count = $(".oqs_count"+i).text(); + if ( oqs_count_id == items[field]["order_queue_station_id"]) { + oqs_count_total = +oqs_count +1 ; + $(".oqs_count"+i).text(oqs_count_total) + } + } + //end count - var date = new Date(items[field]["created_at"]); - // var show_date = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes(); - var show_date =date.getHours()+ ':' + date.getMinutes() +' '+(date.getHours() >= 12 ? 'PM' : 'AM'); + var date = new Date(items[field]["created_at"]); + // var show_date = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes(); + var show_date =date.getHours()+ ':' + date.getMinutes() +' '+(date.getHours() >= 12 ? 'PM' : 'AM'); - if (oqs_id == items[field]["order_queue_station_id"]) { - var table_type = (items[field]["table_type"] != null) ? items[field]["table_type"]:""; - var zone = (items[field]["zone"] != null) ? "-"+items[field]["zone"]:"No Table"; - (name === 'true') ? 'Y' :'N'; - row ='
' - +'' - +'
' - + if (oqs_id == items[field]["order_queue_station_id"]) { + var table_type = (items[field]["table_type"] != null) ? items[field]["table_type"]:""; + var zone = (items[field]["zone"] != null) ? "-"+items[field]["zone"]:"No Table"; + (name === 'true') ? 'Y' :'N'; + row ='
' + +'' + +'
' + - +'
' - +''+table_type+''+ zone+'' - +'' - +''+items[field]["order_id"]+'' - +'
' - +'

' - +''+ items[field]["item_name"] +'- ' - +' [x'+ items[field]["qty"] +'] ' - +'

' + +'
' + +''+table_type+''+ zone+'' + +'' + +''+items[field]["order_id"]+'' + +'
' + +'

' + +''+ items[field]["item_name"] +'- ' + +' [x'+ items[field]["qty"] +'] ' + +'

' - +'

'+ options +'

' + +'

'+ options +'

' - +'' - +'Order at - ' - +''+ show_date +'
' + +'' + +'Order at - ' + +''+ show_date +'
' - +'Order By - '+ items[field]["item_order_by"] +' ' - +'
' - +'
' + +'Order By - '+ items[field]["item_order_by"] +' ' + +'
' + +'
' - +' ' - +' ' - +'
' + +' ' + +' ' + +'
' - +'' - +'
'; - $('.oqs_append').append(row); - } - }//end looping + +'' + +'
'; + $('.oqs_append').append(row); + } + }//end looping - var $divs = $("div.queue_station"); - var SortListDivs = $divs.sort(function (a, b) { + var $divs = $("div.queue_station"); + var SortListDivs = $divs.sort(function (a, b) { - first = $(a).attr('data-order-no'); - next = $(b).attr('data-order-no'); + first = $(a).attr('data-order-no'); + next = $(b).attr('data-order-no'); - return parseInt(next.substring(4, 16)) - parseInt(first.substring(4, 16)); - }); - $("#oqs_container").html(SortListDivs); + return parseInt(next.substring(4, 16)) - parseInt(first.substring(4, 16)); + }); + $("#oqs_container").html(SortListDivs); + } }, }); diff --git a/app/assets/javascripts/channels/order_reservation.js b/app/assets/javascripts/channels/order_reservation.js index 468e4c31..39b31b5a 100644 --- a/app/assets/javascripts/channels/order_reservation.js +++ b/app/assets/javascripts/channels/order_reservation.js @@ -4,50 +4,53 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel' disconnected: function() {}, received: function(data) { - var shop_code = data.shop_code; - var order = data.data; - if(order.length > 0){ - $('.custom-table.'+shop_code+'_order_reserve_cable tbody').html(""); - $("."+shop_code+" > .nav-item.red > a > p.num").text(order.length); - $.each(order, function(key,value){ - var active_class = ""; - if(key==0){ - active_class = "tr-active"; - showNewOrder(order[key],shop_code); - } - var rowCount = key+1; - var date = new Date(value.created_at); - var time = timeFormat(date); - var created_at = date.getFullYear() +'-'+ (date.getMonth() >= 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() >=10?date.getDate() : '0'+date.getDate()); + var hostname = location.hostname.trim(); + if(data.from == "" || hostname == data.from){ + var shop_code = data.shop_code; + var order = data.data; + if(order.length > 0){ + $('.custom-table.'+shop_code+'_order_reserve_cable tbody').html(""); + $("."+shop_code+" > .nav-item.red > a > p.num").text(order.length); + $.each(order, function(key,value){ + var active_class = ""; + if(key==0){ + active_class = "tr-active"; + showNewOrder(order[key],shop_code); + } + var rowCount = key+1; + var date = new Date(value.created_at); + var time = timeFormat(date); + var created_at = date.getFullYear() +'-'+ (date.getMonth() >= 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() >=10?date.getDate() : '0'+date.getDate()); - var delivery_type = ""; - if(value.provider == "food2u" || value.provider == "yangondoor2door"){ - delivery_type = "DELIVERY"; - }else if(value.provider == "pick_up"){ - delivery_type = "PICK-UP"; - }else{ - delivery_type = "DIRECT DELIVERY"; - } + var delivery_type = ""; + if(value.provider == "food2u" || value.provider == "yangondoor2door"){ + delivery_type = "DELIVERY"; + }else if(value.provider == "pick_up"){ + delivery_type = "PICK-UP"; + }else{ + delivery_type = "DIRECT DELIVERY"; + } - row = '' - +''+rowCount - +'' - +''+created_at - +'' - +''+time - +'' - +''+value.grand_total - +'' - +'' - +''+ delivery_type +'' - +'' - +' '; - - $('.custom-table.'+shop_code+'_order_reserve_cable tbody').append(row); - }); + row = '' + +''+rowCount + +'' + +''+created_at + +'' + +''+time + +'' + +''+value.grand_total + +'' + +'' + +''+ delivery_type +'' + +'' + +' '; + + $('.custom-table.'+shop_code+'_order_reserve_cable tbody').append(row); + }); + } + + customTableClick(); } - - customTableClick(); } }); diff --git a/app/assets/javascripts/channels/second_display.js b/app/assets/javascripts/channels/second_display.js index 79b59cac..cfe2de8f 100644 --- a/app/assets/javascripts/channels/second_display.js +++ b/app/assets/javascripts/channels/second_display.js @@ -5,33 +5,36 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayChannel', { disconnected: function() {}, - received: function(data) { - var data_obj = data.data; - var status = data.status; - var count = 0 - var sub_total = 0 - if (data.status == "order") { - for(var i in data_obj) { + received: function(data) { + var hostname = location.hostname.trim(); + if(data.from == "" || hostname == data.from){ + var data_obj = data.data; + var status = data.status; + var count = 0 + var sub_total = 0 + if (data.status == "order") { + for(var i in data_obj) { - sub_total = sub_total + (data_obj[i].price * data_obj[i].qty) - count += 1 - row ='' - +''+count+'' - +''+data_obj[i].item_name+'' - +''+data_obj[i].qty +'' - + ''+data_obj[i].qty*data_obj[i].price +'' - +'' - $(".second_display_items").append(row); - }//end looping - }else{ - $('#s_sub_total').empty(); - $('#s_sub_total').append(data_obj.total_amount); - $('#s_total_discount').empty(); - $('#s_total_discount').append(data_obj.total_discount); - $('#s_tatal_tax').empty(); - $('#s_tatal_tax').append(data_obj.total_tax); - $('#s_grand_total').empty(); - $('#s_grand_total').append(data_obj.grand_total); + sub_total = sub_total + (data_obj[i].price * data_obj[i].qty) + count += 1 + row ='' + +''+count+'' + +''+data_obj[i].item_name+'' + +''+data_obj[i].qty +'' + + ''+data_obj[i].qty*data_obj[i].price +'' + +'' + $(".second_display_items").append(row); + }//end looping + }else{ + $('#s_sub_total').empty(); + $('#s_sub_total').append(data_obj.total_amount); + $('#s_total_discount').empty(); + $('#s_total_discount').append(data_obj.total_discount); + $('#s_tatal_tax').empty(); + $('#s_tatal_tax').append(data_obj.total_tax); + $('#s_grand_total').empty(); + $('#s_grand_total').append(data_obj.grand_total); + } } } }); diff --git a/app/assets/javascripts/channels/second_display_view.js b/app/assets/javascripts/channels/second_display_view.js index 1a1cba86..6a532f09 100644 --- a/app/assets/javascripts/channels/second_display_view.js +++ b/app/assets/javascripts/channels/second_display_view.js @@ -6,161 +6,163 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', { disconnected: function() {}, received: function(data) { - var items = data.data; - var tax = data.tax_profiles; - var status= data.status - if (status == "reload") { - jQuery('#s_reload').click(); - } - $('#second_display_slider').addClass("hidden") - $('#second_display_items').removeClass("hidden") - - - // append items - if (status == "add") { - for(var i in items) { - qty = parseInt(items[i].qty); - append = 0; - price = items[i].price; - - instance_name = items[i].instance; - if (instance_name == "undefined"){ - instance = ''; - }else{ - instance = "("+items[i].instance+")"; - } - - // d_option = items[i].options; - // if (d_option){ - // option_name = "-"+items[i].options; - // }else{ - // option_name = ''; - // } - - d_option = items[i].opt; - if (items[i].click_type != "add_icon"){ - option_name = "-"+items[i].options; - data_option = items[i].options ; - }else{ - option_name = ' '; - data_option = '[]'; - } - - var rowCount = $('.second_display_items tbody tr').length+1; - var item_row = $('.second_display_items tbody tr'); - - $(item_row).each(function(j){ - var item_code = $(item_row[j]).attr('data-code'); - var instance_code = $(item_row[j]).attr('data-instance-code'); - var r_option = $(item_row[j]).attr('data-options'); - if (item_code == items[i].item_code && instance_code == items[i].instance_code && r_option==d_option) { - if (qty > 1) { - qty = parseInt($(item_row[j]).children('#item_qty').text()) + qty; - }else{ - qty = parseInt($(item_row[j]).children('#item_qty').text()) + 1; - } - - $(item_row[j]).children('#item_qty').text(qty); - parseFloat($(item_row[j]).children('#item_price').text(parseFloat(price*qty).toFixed(2))); - append =1; - }else{ - if (qty > 1) { - qty = qty; - }else{ - qty = 1; - } - } - }); - if (append===0) { - row ="" - +''+rowCount+'' - +'' + items[i].name+ ' ' + instance + ' ' + option_name +'' - +'' + qty + '' - +'' - + parseFloat(price).toFixed(2) - +'' - +''; - $(".second_display_items tbody").append(row); - - } + var hostname = location.hostname.trim(); + if(data.from == "" || hostname == data.from){ + var items = data.data; + var tax = data.tax_profiles; + var status= data.status + if (status == "reload") { + jQuery('#s_reload').click(); } - } - if (status == "set_add") { - // var option_arr = []; - var attribute_arr = []; - var rowCount = $('.second_display_items tbody tr').length+1; - for(var i in items) { - code = items[i].code; - item_code = items[i].item_code; - name = items[i].name; - item_name = items[i].item_name; - qty = items[i].qty; + $('#second_display_slider').addClass("hidden") + $('#second_display_items').removeClass("hidden") + + + // append items + if (status == "add") { + for(var i in items) { + qty = parseInt(items[i].qty); + append = 0; price = items[i].price; - option = items[i].option; - sub_item = items[i].sub_item; - total = qty * price ; - // option_arr.push(option); - row ="" + + instance_name = items[i].instance; + if (instance_name == "undefined"){ + instance = ''; + }else{ + instance = "("+items[i].instance+")"; + } + + // d_option = items[i].options; + // if (d_option){ + // option_name = "-"+items[i].options; + // }else{ + // option_name = ''; + // } + + d_option = items[i].opt; + if (items[i].click_type != "add_icon"){ + option_name = "-"+items[i].options; + data_option = items[i].options ; + }else{ + option_name = ' '; + data_option = '[]'; + } + + var rowCount = $('.second_display_items tbody tr').length+1; + var item_row = $('.second_display_items tbody tr'); + + $(item_row).each(function(j){ + var item_code = $(item_row[j]).attr('data-code'); + var instance_code = $(item_row[j]).attr('data-instance-code'); + var r_option = $(item_row[j]).attr('data-options'); + if (item_code == items[i].item_code && instance_code == items[i].instance_code && r_option==d_option) { + if (qty > 1) { + qty = parseInt($(item_row[j]).children('#item_qty').text()) + qty; + }else{ + qty = parseInt($(item_row[j]).children('#item_qty').text()) + 1; + } + + $(item_row[j]).children('#item_qty').text(qty); + parseFloat($(item_row[j]).children('#item_price').text(parseFloat(price*qty).toFixed(2))); + append =1; + }else{ + if (qty > 1) { + qty = qty; + }else{ + qty = 1; + } + } + }); + if (append===0) { + row ="" +''+rowCount+'' - +'' + item_name+ ' ' + name + ''+option+'' + +'' + items[i].name+ ' ' + instance + ' ' + option_name +'' +'' + qty + '' +'' - + parseFloat(total).toFixed(2) + + parseFloat(price).toFixed(2) +'' +''; $(".second_display_items tbody").append(row); - rowCount = rowCount + 1; - - } - } - //end apend items - var total_price = 0; - var taxable_amount = 0; - var total_discount = 0 - var total_tax_amount = 0 - var item_row = $('.second_display_items tbody tr'); - //calculate Sub Total - $(item_row).each(function(i){ - var unit_price = parseFloat($(item_row[i]).attr('data-price')); - var qty = parseFloat($(item_row[i]).children('#item_qty').text()); - total_price += qty*unit_price; - }); - //calculate Tax Amount - for(var i in tax) { - // substract , to give after discount - var total_tax = total_price - total_discount - // include or execulive - if (tax[i].inclusive){ - rate = tax[i].rate - divided_value = (100 + rate)/rate - total_tax_amount = total_tax_amount + (total_tax / divided_value) - }else{ - total_tax_amount = total_tax_amount + (total_tax * tax[i].rate / 100) + + } } } - //end calculate Tax amount - var fixed_total_price = parseFloat(total_price).toFixed(2); - var fixed_taxable_amount = parseFloat(total_tax_amount).toFixed(2); - var fixed_grand_total = parseFloat(total_price + total_tax_amount).toFixed(2); + if (status == "set_add") { + // var option_arr = []; + var attribute_arr = []; + var rowCount = $('.second_display_items tbody tr').length+1; + for(var i in items) { + code = items[i].code; + item_code = items[i].item_code; + name = items[i].name; + item_name = items[i].item_name; + qty = items[i].qty; + price = items[i].price; + option = items[i].option; + sub_item = items[i].sub_item; + total = qty * price ; + // option_arr.push(option); + row ="" + +''+rowCount+'' + +'' + item_name+ ' ' + name + ''+option+'' + +'' + qty + '' + +'' + + parseFloat(total).toFixed(2) + +'' + +''; + $(".second_display_items tbody").append(row); + rowCount = rowCount + 1; + + } + } + //end apend items + var total_price = 0; + var taxable_amount = 0; + var total_discount = 0 + var total_tax_amount = 0 + var item_row = $('.second_display_items tbody tr'); + //calculate Sub Total + $(item_row).each(function(i){ + var unit_price = parseFloat($(item_row[i]).attr('data-price')); + var qty = parseFloat($(item_row[i]).children('#item_qty').text()); + total_price += qty*unit_price; + }); + //calculate Tax Amount + for(var i in tax) { + // substract , to give after discount + var total_tax = total_price - total_discount + // include or execulive + if (tax[i].inclusive){ + rate = tax[i].rate + divided_value = (100 + rate)/rate + total_tax_amount = total_tax_amount + (total_tax / divided_value) + }else{ + total_tax_amount = total_tax_amount + (total_tax * tax[i].rate / 100) + } + } + //end calculate Tax amount + var fixed_total_price = parseFloat(total_price).toFixed(2); + var fixed_taxable_amount = parseFloat(total_tax_amount).toFixed(2); + var fixed_grand_total = parseFloat(total_price + total_tax_amount).toFixed(2); - $('#s_sub_total').empty(); - $('#s_sub_total').append(fixed_total_price); - $('#s_tatal_tax').empty(); - $('#s_tatal_tax').append(fixed_taxable_amount); - $('#s_grand_total').empty(); - $('#s_grand_total').append(fixed_grand_total); + $('#s_sub_total').empty(); + $('#s_sub_total').append(fixed_total_price); + $('#s_tatal_tax').empty(); + $('#s_tatal_tax').append(fixed_taxable_amount); + $('#s_grand_total').empty(); + $('#s_grand_total').append(fixed_grand_total); + } } - }); diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 2fb3d621..8d8af8b2 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -47,9 +47,12 @@ class Api::BillController < Api::ApiController Promotion.promo_activate(@sale) #BillBroadcastJob.perform_later(table) - #if ENV["SERVER_MODE"] != 'cloud' - ActionCable.server.broadcast "bill_channel",table: table - #end + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "bill_channel",table: table, from: from else @status = false @error_message = "No Current Open Shift" diff --git a/app/controllers/api/call_waiters_controller.rb b/app/controllers/api/call_waiters_controller.rb index b8c11897..9c6ad974 100644 --- a/app/controllers/api/call_waiters_controller.rb +++ b/app/controllers/api/call_waiters_controller.rb @@ -6,9 +6,12 @@ class Api::CallWaitersController < ActionController::API @time = params[:time] @table = DiningFacility.find(@table_id) # CallWaiterJob.perform_later(@table,@time) - #if ENV["SERVER_MODE"] != 'cloud' - ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time - #end + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time,from: from # get printer info @shop = Shop.first unique_code = "CallWaiterPdf" diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 4bd9434d..492e345e 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -6,7 +6,16 @@ class Api::CheckInProcessController < Api::ApiController booking = dining_facility.get_current_checkout_booking if !booking.nil? - DiningFacility.check_in_booking(params[:dining_id]) + # DiningFacility.check_in_booking(params[:dining_id]) + + table = DiningFacility.find(params[:dining_id]) + #Send to background job for processing + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "check_in_booking_channel",table: table,from:from 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") diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb index a7929653..32e87a20 100644 --- a/app/controllers/api/order_reserve/order_reservation_controller.rb +++ b/app/controllers/api/order_reserve/order_reservation_controller.rb @@ -73,7 +73,12 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" } order_reservation = OrderReservation.get_pending_orders #find(order_reservation_id) - ActionCable.server.broadcast "order_reservation_channel",data: order_reservation,shop_code: shop_code + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "order_reservation_channel",data: order_reservation,shop_code: shop_code,from:from else result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is already existed!" } end diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb old mode 100755 new mode 100644 diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 63cb8736..3fc11693 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -181,6 +181,12 @@ puts params[:id] @status, @booking = @order.generate + if @status && @booking + if params[:order_source] != "quick_service" + process_order_queue(@order.order_id,@order.table_id,@order.source) + end + end + # Order.send_customer_view(@booking) if current_user.role != "waiter" && params[:create_type] == "create_pay" @@ -188,8 +194,12 @@ puts params[:id] @status, @sale = Sale.request_bill(@order,current_user,current_login_employee) # for second display - #if ENV["SERVER_MODE"] != 'cloud' - ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale" + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from #end result = {:status=> @status, :data => @sale } render :json => result.to_json @@ -240,6 +250,81 @@ puts params[:id] return false end end + + def process_order_queue(order_id,table_id,order_source) + print_status = nil + cup_status = nil + + #Send to background job for processing + order = Order.find(order_id) + sidekiq = Lookup.find_by_lookup_type("sidekiq") + + if ENV["SERVER_MODE"] != 'cloud' + cup_status = `#{"sudo service cups status"}` + print_status = check_cup_status(cup_status) + end + + if print_status + if !sidekiq.nil? + OrderQueueProcessorJob.perform_later(order_id, table_id) + else + if order + oqs = OrderQueueStation.new + oqs.process_order(order, table_id, order_source) + end + # assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id) + # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order + end + else + if ENV["SERVER_MODE"] != 'cloud' + cup_start = `#{"sudo service cups start"}` + cup_status = `#{"sudo service cups status"}` + print_status = check_cup_status(cup_status) + end + + if print_status + if !sidekiq.nil? + OrderQueueProcessorJob.perform_later(order_id, table_id) + else + if order + oqs = OrderQueueStation.new + oqs.process_order(order, table_id, order_source) + end + # assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id) + # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order + end + else + if ENV["SERVER_MODE"] != 'cloud' + from = "" + msg = ' Print Error ! Please contact to service' + ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error',from:from + end + if !sidekiq.nil? + OrderQueueProcessorJob.perform_later(order_id, table_id) + else + if order + oqs = OrderQueueStation.new + oqs.process_order(order, table_id, order_source) + end + + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id) + ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from + end + end + end + end + + def check_cup_status(status) + if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running" + return true + end + return false + end private diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb old mode 100755 new mode 100644 diff --git a/app/controllers/origami/product_commissions_controller.rb b/app/controllers/origami/product_commissions_controller.rb index 2f209a7a..31343fe5 100755 --- a/app/controllers/origami/product_commissions_controller.rb +++ b/app/controllers/origami/product_commissions_controller.rb @@ -88,41 +88,49 @@ class Origami::ProductCommissionsController < BaseOrigamiController commissioner_id = params[:commissioner_id] @sale_item = SaleItem.find(sale_item_id) @menu_item = MenuItem.find_by_item_code(@sale_item.product_code) - @commission = Commission.where('product_code = ? AND is_active = ?', @menu_item.id, true).take + # @commission = Commission.where('product_code = ? AND is_active = ?', @menu_item.item_code, true).take + + Commission.all.each do |com| + if com.product_code.include? @menu_item.item_code && com.active == true + @commission = Commission.find(com.id) + break + end + end @commissioner = Commissioner.where('id = ? AND is_active = ?', commissioner_id, true).take @product_commission = ProductCommission.where('sale_item_id = ?', @sale_item.id).take - - if !@product_commission.nil? - if @product_commission.commissioner_id == @commissioner.id - @product_commission.destroy - deselect = true - else - @product_commission.commissioner_id = @commissioner.id - deselect = false - end - else - @product_commission = ProductCommission.new - @product_commission.product_code = @menu_item.id - @product_commission.product_type = 'menu_item' # use for dummy data ToDo::need to change product type - unless @commission.nil? - @product_commission.commission_id = @commission.id - if @commission.commission_type == 'Percentage' - @product_commission.price = @sale_item.unit_price * (@commission.amount / 100.0) - @product_commission.amount = @product_commission.price * @sale_item.qty - elsif @commission.commission_type == 'Net Amount' - @product_commission.price = @commission.amount - @product_commission.amount = @product_commission.price * @sale_item.qty + if !@commission.nil? && @commissioner.commission_id == @commission.commission_id + if !@product_commission.nil? + if @product_commission.commissioner_id == @commissioner.id + @product_commission.destroy + deselect = true + else + @product_commission.commissioner_id = @commissioner.id + deselect = false end + else + @product_commission = ProductCommission.new + @product_commission.product_code = @menu_item.item_code + @product_commission.product_type = 'menu_item' # use for dummy data ToDo::need to change product type + unless @commission.nil? + @product_commission.commission_id = @commission.id + if @commission.commission_type == 'Percentage' + @product_commission.price = @sale_item.unit_price * (@commission.amount / 100.0) + @product_commission.amount = @product_commission.price * @sale_item.qty + elsif @commission.commission_type == 'Net Amount' + @product_commission.price = @commission.amount + @product_commission.amount = @product_commission.price * @sale_item.qty + end + end + @product_commission.commissioner_id = @commissioner.id + @product_commission.qty = @sale_item.qty + @product_commission.sale_id = @sale_item.sale_id + @product_commission.sale_item_id = @sale_item.sale_item_id + end + if @product_commission.save + render json: {status: true, deselect: deselect} + else + render json: {status: false, deselect: deselect} end - @product_commission.commissioner_id = @commissioner.id - @product_commission.qty = @sale_item.qty - @product_commission.sale_id = @sale_item.sale_id - @product_commission.sale_item_id = @sale_item.sale_item_id - end - if @product_commission.save - render json: {status: true, deselect: deselect} - else - render json: {status: false, deselect: deselect} end end diff --git a/app/controllers/origami/second_display_controller.rb b/app/controllers/origami/second_display_controller.rb index ac869719..5f88bdfc 100644 --- a/app/controllers/origami/second_display_controller.rb +++ b/app/controllers/origami/second_display_controller.rb @@ -13,8 +13,12 @@ class Origami::SecondDisplayController < BaseOrigamiController else tax_profiles = nil end - #if ENV["SERVER_MODE"] != 'cloud' - ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status] + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status],from:from # end end #Shop Name in Navbor diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index 2d2ca4fb..77f4589a 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -337,9 +337,13 @@ class Origami::SplitBillController < BaseOrigamiController end Promotion.promo_activate(sale) - #if ENV["SERVER_MODE"] != 'cloud' - ActionCable.server.broadcast "bill_channel",table: table - #end + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "bill_channel",table: table,from:from + render :json => { status: status } else render :json => { status: false, error_message: 'No Current Open Shift!'} diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index cff5fd60..c0843dbd 100755 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -157,15 +157,25 @@ class DiningFacility < ApplicationRecord #Send to background job for processing # CheckInBookingJob.perform_later(table) #if ENV["SERVER_MODE"] != 'cloud' - ActionCable.server.broadcast "check_in_booking_channel",table: table + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "check_in_booking_channel",table: table,from:from #end end def self.checkin_time table = DiningFacility.get_checkin_booking if table.length > 0 + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end if ENV["SERVER_MODE"] != 'cloud' - ActionCable.server.broadcast "checkin_channel",table: table + ActionCable.server.broadcast "checkin_channel",table: table,from:from end end end diff --git a/app/models/display_image.rb b/app/models/display_image.rb index 30d83566..73e88e31 100644 --- a/app/models/display_image.rb +++ b/app/models/display_image.rb @@ -1,3 +1,3 @@ class DisplayImage < ApplicationRecord - belongs_to :shop + belongs_to :shop end diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb index 21d95770..218bacb8 100755 --- a/app/models/menu_category.rb +++ b/app/models/menu_category.rb @@ -9,7 +9,7 @@ class MenuCategory < ApplicationRecord validates_presence_of :code, :name, :menu, :order_by validates_uniqueness_of :code - default_scope { order('name asc') } + default_scope { order('order_by asc') } scope :active, -> {where("is_available = 1")} def self.destroyCategory(menu_category) diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index e184cd51..03e90011 100755 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -16,7 +16,7 @@ class MenuItem < ApplicationRecord validates_presence_of :item_code, :name, :type, :min_qty,:account_id validates_uniqueness_of :item_code - default_scope { order('name asc') } + default_scope { order('item_code asc') } scope :simple_menu_item, -> { where(type: 'SimpleMenuItem') } scope :set_menu_item, -> { where(type: 'SetMenuItem') } diff --git a/app/models/order.rb b/app/models/order.rb index 8a0e52b3..9a52942e 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -71,9 +71,9 @@ class Order < ApplicationRecord BookingOrder.create({:booking_id => booking.booking_id, :order => self}) #Send order to queue one it done! - if self.source != "quick_service" - process_order_queue - end + # if self.source != "quick_service" + # process_order_queue + # end #send order to broadcast job send_order_broadcast(booking) @@ -108,9 +108,9 @@ class Order < ApplicationRecord BookingOrder.create({:booking_id => booking.booking_id, :order => self}) #Send order to queue one it done! - if self.source != "quick_service" - process_order_queue - end + # if self.source != "quick_service" + # process_order_queue + # end #send order to broadcast job send_order_broadcast(booking) @@ -283,69 +283,7 @@ class Order < ApplicationRecord # Counter number of quantityf end - #Process order items and send to order queue - def process_order_queue - print_status = nil - cup_status = nil - - #Send to background job for processing - order = Order.find(self.id) - sidekiq = Lookup.find_by_lookup_type("sidekiq") - - if ENV["SERVER_MODE"] != 'cloud' - cup_status = `#{"sudo service cups status"}` - print_status = check_cup_status(cup_status) - end - - if print_status - if !sidekiq.nil? - OrderQueueProcessorJob.perform_later(self.id, self.table_id) - else - if order - oqs = OrderQueueStation.new - oqs.process_order(order, self.table_id, self.source) - end - # assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) - # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order - end - else - if ENV["SERVER_MODE"] != 'cloud' - cup_start = `#{"sudo service cups start"}` - cup_status = `#{"sudo service cups status"}` - print_status = check_cup_status(cup_status) - end - - if print_status - if !sidekiq.nil? - OrderQueueProcessorJob.perform_later(self.id, self.table_id) - else - if order - oqs = OrderQueueStation.new - oqs.process_order(order, self.table_id, self.source) - end - # assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) - # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order - end - else - if ENV["SERVER_MODE"] != 'cloud' - - msg = ' Print Error ! Please contact to service' - ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error' - end - if !sidekiq.nil? - OrderQueueProcessorJob.perform_later(self.id, self.table_id) - else - if order - oqs = OrderQueueStation.new - oqs.process_order(order, self.table_id, self.source) - end - assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) - ActionCable.server.broadcast "order_queue_station_channel",order: assign_order - end - end - end - end - + #Process order items and send to order queue def self.pay_process_order_queue(id,table_id) # if ENV["SERVER_MODE"] != 'cloud' @@ -378,9 +316,13 @@ class Order < ApplicationRecord type = 'order' #Send to background job for processing # OrderBroadcastJob.perform_later(table,type) - #if ENV["SERVER_MODE"] != 'cloud' - ActionCable.server.broadcast "order_channel",table: table,type:type - #end + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "order_channel",table: table,type:type,from:from + end end @@ -534,11 +476,78 @@ class Order < ApplicationRecord end end end - #if ENV["SERVER_MODE"] != 'cloud' - ActionCable.server.broadcast "second_display_channel",data: @data_array,status:@status - #end + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "second_display_channel",data: @data_array,status:@status,from:from end + #Process order items and send to order queue + # def process_order_queue + # print_status = nil + # cup_status = nil + + # #Send to background job for processing + # order = Order.find(self.id) + # sidekiq = Lookup.find_by_lookup_type("sidekiq") + + # if ENV["SERVER_MODE"] != 'cloud' + # cup_status = `#{"sudo service cups status"}` + # print_status = check_cup_status(cup_status) + # end + + # if print_status + # if !sidekiq.nil? + # OrderQueueProcessorJob.perform_later(self.id, self.table_id) + # else + # if order + # oqs = OrderQueueStation.new + # oqs.process_order(order, self.table_id, self.source) + # end + # # assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) + # # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order + # end + # else + # if ENV["SERVER_MODE"] != 'cloud' + # cup_start = `#{"sudo service cups start"}` + # cup_status = `#{"sudo service cups status"}` + # print_status = check_cup_status(cup_status) + # end + + # if print_status + # if !sidekiq.nil? + # OrderQueueProcessorJob.perform_later(self.id, self.table_id) + # else + # if order + # oqs = OrderQueueStation.new + # oqs.process_order(order, self.table_id, self.source) + # end + # # assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) + # # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order + # end + # else + # if ENV["SERVER_MODE"] != 'cloud' + + # msg = ' Print Error ! Please contact to service' + # ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error' + # end + # if !sidekiq.nil? + # OrderQueueProcessorJob.perform_later(self.id, self.table_id) + # else + # if order + # oqs = OrderQueueStation.new + # oqs.process_order(order, self.table_id, self.source) + # end + # assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id) + # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order + # end + # end + # end + # end + + private def generate_custom_id diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 70b28c1f..d731c3d2 100755 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -116,7 +116,19 @@ class OrderQueueStation < ApplicationRecord order = Order.find(order_id) order_items = order.order_items - Order.pay_process_order_queue(order_id,table_id) + # Order.pay_process_order_queue(order_id,table_id) + # if order + # oqs = OrderQueueStation.new + # oqs.process_order(order, table_id) + # end + assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id) + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from + if table_id.to_i > 0 # get dining dining = DiningFacility.find(table_id) diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index 0b4ccc77..89e45021 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -317,9 +317,15 @@ class OrderReservation < ApplicationRecord end order_reservation = OrderReservation.where("status='new'") if order_reservation.length > 0 - if ENV["SERVER_MODE"] == 'cloud' - ActionCable.server.broadcast "check_new_order_channel",data: order_reservation, shop_code: shop_code - end + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + ActionCable.server.broadcast "check_new_order_channel",data: order_reservation, shop_code: shop_code,from:from + else + from = "" + end + # if ENV["SERVER_MODE"] == 'cloud' + # ActionCable.server.broadcast "check_new_order_channel",data: order_reservation, shop_code: shop_code + # end end end @@ -332,9 +338,15 @@ class OrderReservation < ApplicationRecord end order_reservation = OrderReservation.where("status='accepted' and requested_time <= '#{Time.now.utc}'") if order_reservation.length > 0 - if ENV["SERVER_MODE"] == 'cloud' - ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation, shop_code: shop_code - end + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation, shop_code: shop_code,from:from + else + from = "" + end + # if ENV["SERVER_MODE"] == 'cloud' + # ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation, shop_code: shop_code + # end end end @@ -347,9 +359,15 @@ class OrderReservation < ApplicationRecord end order_reservation = OrderReservation.where("status='send_to_kitchen' and requested_time <= '#{Time.now.utc}'") if order_reservation.length > 0 - if ENV["SERVER_MODE"] == 'cloud' - ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation, shop_code: shop_code - end + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation, shop_code: shop_code,from:from + else + from = "" + end + # if ENV["SERVER_MODE"] == 'cloud' + # ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation, shop_code: shop_code + # end end end diff --git a/app/models/promotion.rb b/app/models/promotion.rb index 028847f3..f1e19d98 100755 --- a/app/models/promotion.rb +++ b/app/models/promotion.rb @@ -136,7 +136,9 @@ class Promotion < ApplicationRecord else item = OrderItem.find_by_item_code(promo_product) end - update_existing_item(foc_qty, item, sale_id, "promotion", item.price) + source = Order.find(item.order_id).source + + update_existing_item(foc_qty, item, sale_id, "promotion", item.price,source) puts "Charged - " + charge_qty.to_s puts "FOC - " + foc_qty.to_s @@ -150,10 +152,12 @@ class Promotion < ApplicationRecord promotion_qty = foc_qty end item = OrderItem.find_by_item_instance_code(promo_product) - update_existing_item(promotion_qty, item, sale_id, "promotion", item.price) + source = Order.find(item.order_id).source + update_existing_item(promotion_qty, item, sale_id, "promotion", item.price,source) end - def self.update_existing_item(qty, item, sale_id, type, item_price) + + def self.update_existing_item(qty, item, sale_id, type, item_price,source) sale_item = SaleItem.new sale_item.product_code = item.item_code @@ -171,50 +175,54 @@ class Promotion < ApplicationRecord sale_item.sale_id = sale_id sale_item.save sale = Sale.find(sale_id) - sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount) + sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount,nil,source) end def self.give_promotion_nett_off(same, promo_product, foc_min_qty, orderitem, sale_id) puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s - + if same foc_qty = orderitem[1].to_i / foc_min_qty item = OrderItem.find_by_item_instance_code(orderitem[0]) - update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off) + source = Order.find(item.order_id).source + update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source) else foc_qty = find_second_item_qty(sale_id, promo_product.item_code) item = OrderItem.find_by_item_instance_code(promo_product.item_code) - update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off) + source = Order.find(item.order_id).source + update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source) end end def self.give_promotion_nett_price(same, promo_product, foc_min_qty, orderitem, sale_id) puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s - if same foc_qty = orderitem[1].to_i / foc_min_qty item = OrderItem.find_by_item_instance_code(orderitem[0]) # need to specify with menu item instance price = item.price.to_i - promo_product.net_price.to_i - update_existing_item(foc_qty, item, sale_id, "promotion nett price", price) + + source = Order.find(item.order_id).source + update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source) else foc_qty = find_second_item_qty(sale_id, promo_product.item_code) item = OrderItem.find_by_item_instance_code(promo_product.item_code) price = item.price - promo_product.net_price - update_existing_item(foc_qty, item, sale_id, "promotion nett price", price) + source = Order.find(item.order_id).source + update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source) end end def self.give_promotion_discount(same, promo_product, foc_min_qty, orderitem, sale_id) puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s - if same foc_qty = orderitem[1].to_i / foc_min_qty item = OrderItem.find_by_item_instance_code(orderitem[0]) # total = orderitem[1].to_i * item.price total = item.price price = calculate_discount(total, promo_product.percentage) - update_existing_item(foc_qty, item, sale_id, "promotion discount", price) + source = Order.find(item.order_id).source + update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source) else foc_qty = find_second_item_qty(sale_id, promo_product.item_code) # give total qty is 1 @@ -224,7 +232,8 @@ class Promotion < ApplicationRecord # total = item.price * foc_qty total = item.price price = calculate_discount(total, promo_product.percentage) - update_existing_item(foc_qty, item, sale_id, "promotion discount", price) + source = Order.find(item.order_id).source + update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source) end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 1441c759..7ceecebd 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -425,6 +425,7 @@ class Sale < ApplicationRecord tax_profiles = TaxProfile.all.order("order_by asc") customer = Customer.find(sale.customer_id) # #Creat new tax records + if sale.payment_status != 'foc' tax_profiles.each do |tax| # customer.tax_profiles.each do |cus_tax| @@ -456,28 +457,27 @@ class Sale < ApplicationRecord sale_tax.save end else - sale_tax = SaleTax.new(:sale => sale) - sale_tax.tax_name = tax.name - sale_tax.tax_rate = tax.rate + sale_tax = SaleTax.new(:sale => sale) + sale_tax.tax_name = tax.name + sale_tax.tax_rate = tax.rate - # substract , to give after discount - total_tax = total_taxable - total_discount - #include or execulive - if tax.inclusive - rate = tax.rate - divided_value = (100 + rate)/rate - sale_tax.tax_payable_amount = total_tax / divided_value - else - sale_tax.tax_payable_amount = total_tax * tax.rate / 100 - total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount - end - #new taxable amount is standard rule for step by step - if shop.calc_tax_order - total_taxable = total_taxable + sale_tax.tax_payable_amount - end - - sale_tax.inclusive = tax.inclusive - sale_tax.save + # substract , to give after discount + total_tax = total_taxable - total_discount + #include or execulive + if tax.inclusive + rate = tax.rate + divided_value = (100 + rate)/rate + sale_tax.tax_payable_amount = total_tax / divided_value + else + sale_tax.tax_payable_amount = total_tax * tax.rate / 100 + total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount + end + #new taxable amount is standard rule for step by step + if shop.calc_tax_order + total_taxable = total_taxable + sale_tax.tax_payable_amount + end + sale_tax.inclusive = tax.inclusive + sale_tax.save end end # end @@ -2542,32 +2542,32 @@ end if current_user.nil? query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") if !from_time.nil? && !to_time.nil? - query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) - .sum("a.qty") + query = query.where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) + .count() else - query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to) - .sum("a.qty") + query = query.where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to) + .count() end else if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") if !from_time.nil? && !to_time.nil? - query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) - .sum("a.qty") + query = query.where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) + .count() else - query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to) - .sum("a.qty") + query = query.where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to) + .count() end else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") if !from_time.nil? && !to_time.nil? - query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ? and sales.shift_sale_id=?",from,to,from_time,to_time,shift.id) - .sum("a.qty") + query = query.where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ? and sales.shift_sale_id=?",from,to,from_time,to_time,shift.id) + .count() else - query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and sales.shift_sale_id=?",from,to,shift.id) - .sum("a.qty") + query = query.where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and sales.shift_sale_id=?",from,to,shift.id) + .count() end end end @@ -2575,19 +2575,19 @@ end else if current_user.nil? query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") - .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) - .sum("a.qty") + .where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) + .count() else if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") - .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) - .sum("a.qty") + .where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) + .count() else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") - .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? and sales.shift_sale_id=?",today,shift.id) - .sum("a.qty") + .where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? and sales.shift_sale_id=?",today,shift.id) + .count() end end end @@ -2697,7 +2697,7 @@ end end def self.all_receipts - query = Sale.select("sale_payments.created_at as receipt_close_time, + query = Sale.select("sales.*,sale_payments.created_at as receipt_close_time, case when (sale_audits.action='SALEPAYMENT') then sale_audits.remark else 0 end as remark, case when (sale_taxes.tax_name='Service Charges') then sale_taxes.tax_payable_amount else 0 end as service_charges, SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount, diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 5f372581..5fbc8c24 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -609,7 +609,12 @@ class SalePayment < ApplicationRecord #Send to background job for processing # OrderBroadcastJob.perform_later(table,type) #if ENV["SERVER_MODE"] != 'cloud' - ActionCable.server.broadcast "order_channel",table: table,type:type + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "order_channel",table: table,type:type,from:from #end end end diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index 0819c94a..382633de 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -186,6 +186,51 @@ class ReceiptBillA5Pdf < Prawn::Document end def add_line_item_row(sale_items,precision,delimiter) + + y_position = cursor + move_down line_move + sub_total = 0.0 + total_qty = 0.0 + sale_items.each do |item| + # check for item not to show + + show_price = Lookup.find_by_lookup_type("show_price").value + + sub_total += item.price #(item.qty*item.unit_price) - comment for room charges + if item.status != 'Discount' && item.qty > 0 + total_qty += item.qty + end + qty = item.qty + total_price = item.price #item.qty*item.unit_price - comment for room charges + price = item.unit_price + product_name = item.product_name + + if !show_price.nil? && show_price.value.to_i>0 + item_row(item,precision,delimiter,product_name,price,qty ,total_price) + else + if item.price != 0 + item_row(item,precision,delimiter,product_name,price,qty ,total_price) + end + end + end + + stroke_horizontal_rule + + move_down line_move + y_position = cursor + bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do + text "Sub Total", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do + text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center + end + bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do + text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + end + end + + def item_row(item,precision,delimiter,product_name,price,qty ,total_price) + if precision.to_i > 0 item_name_width = (self.item_width+self.price_width) item_qty_front_width = (self.item_width+self.price_width) + 5 @@ -199,58 +244,30 @@ class ReceiptBillA5Pdf < Prawn::Document item_total_front_width = item_name_width + 5 item_total_end_width = self.total_width + 4 end + y_position = cursor - move_down line_move - sub_total = 0.0 - total_qty = 0.0 - sale_items.each do |item| - # check for item not to show - if item.price != 0 - sub_total += item.price #(item.qty*item.unit_price) - comment for room charges - if item.status != 'Discount' && item.qty > 0 - total_qty += item.qty - end - qty = item.qty - total_price = item.price #item.qty*item.unit_price - comment for room charges - price = item.unit_price - product_name = item.product_name - - y_position = cursor - - pad_top(15) { - bounding_box([0,y_position], :width =>self.item_width) do - text "#{product_name}", :size => self.item_font_size,:align => :left - end + pad_top(15) { + bounding_box([0,y_position], :width =>self.item_width) do + text "#{product_name}", :size => self.item_font_size,:align => :left + end # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - - if show_alt_name - if !(item.product_alt_name).empty? - move_down 2 - font("public/fonts/NotoSansCJKtc-Regular.ttf") do - text "(#{item.product_alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true - end + + if show_alt_name + if !(item.product_alt_name).empty? + move_down 2 + font("public/fonts/NotoSansCJKtc-Regular.ttf") do + text "(#{item.product_alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true end end - move_down line_move - } - end + end + move_down line_move + } end - stroke_horizontal_rule - - move_down line_move - y_position = cursor - bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do - text "Sub Total", :size => self.item_font_size,:align => :left - end - text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - end - def all_total(sale_data,precision,delimiter) move_down line_move item_name_width = self.item_width diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 466263c9..862a91a5 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -180,6 +180,50 @@ class ReceiptBillPdf < Prawn::Document end def add_line_item_row(sale_items,precision,delimiter) + + y_position = cursor + move_down line_move + sub_total = 0.0 + total_qty = 0.0 + sale_items.each do |item| + # check for item not to show + show_price = Lookup.find_by_lookup_type("show_price") + + sub_total += item.price #(item.qty*item.unit_price) - comment for room charges + if item.status != 'Discount' && item.qty > 0 + total_qty += item.qty + end + qty = item.qty + total_price = item.price #item.qty*item.unit_price - comment for room charges + price = item.unit_price + product_name = item.product_name + + if !show_price.nil? && show_price.value.to_i>0 + item_row(item,precision,delimiter,product_name,price,qty ,total_price) + else + if item.price != 0 + item_row(item,precision,delimiter,product_name,price,qty ,total_price) + end + end + + end + + stroke_horizontal_rule + + move_down line_move + y_position = cursor + bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do + text "Sub Total", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do + text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center + end + bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do + text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + end + end + + def item_row(item,precision,delimiter,product_name,price,qty ,total_price) if precision.to_i > 0 item_name_width = (self.item_width+self.price_width) item_qty_front_width = (self.item_width+self.price_width) + 5 @@ -194,55 +238,27 @@ class ReceiptBillPdf < Prawn::Document item_total_end_width = self.total_width + 4 end y_position = cursor - move_down line_move - sub_total = 0.0 - total_qty = 0.0 - sale_items.each do |item| - # check for item not to show - if item.price != 0 - sub_total += item.price #(item.qty*item.unit_price) - comment for room charges - if item.status != 'Discount' && item.qty > 0 - total_qty += item.qty - end - qty = item.qty - total_price = item.price #item.qty*item.unit_price - comment for room charges - price = item.unit_price - product_name = item.product_name - y_position = cursor + pad_top(15) { + bounding_box([0,y_position], :width =>self.item_width) do + text "#{product_name}", :size => self.item_font_size,:align => :left + end + # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size + text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - pad_top(15) { - bounding_box([0,y_position], :width =>self.item_width) do - text "#{product_name}", :size => self.item_font_size,:align => :left - end - # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size - text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - - if show_alt_name - if !(item.product_alt_name).empty? - move_down 2 - font("public/fonts/NotoSansCJKtc-Regular.ttf") do - text "(#{item.product_alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true - end - end + if show_alt_name + if !(item.product_alt_name).empty? + move_down 2 + font("public/fonts/NotoSansCJKtc-Regular.ttf") do + text "(#{item.product_alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true end - move_down line_move - } - + end end - end - - stroke_horizontal_rule - move_down line_move - y_position = cursor - bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do - text "Sub Total", :size => self.item_font_size,:align => :left - end - text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + } + end diff --git a/app/views/crm/customers/_card_read_form.html.erb b/app/views/crm/customers/_card_read_form.html.erb old mode 100755 new mode 100644 diff --git a/app/views/crm/customers/_crm_customer.json.jbuilder b/app/views/crm/customers/_crm_customer.json.jbuilder old mode 100755 new mode 100644 diff --git a/app/views/crm/customers/_form.html.erb b/app/views/crm/customers/_form.html.erb old mode 100755 new mode 100644 diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb old mode 100755 new mode 100644 diff --git a/app/views/crm/customers/edit.html.erb b/app/views/crm/customers/edit.html.erb old mode 100755 new mode 100644 diff --git a/app/views/crm/customers/edit.json.jbuilder b/app/views/crm/customers/edit.json.jbuilder old mode 100755 new mode 100644 diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb old mode 100755 new mode 100644 diff --git a/app/views/crm/customers/index.json.jbuilder b/app/views/crm/customers/index.json.jbuilder old mode 100755 new mode 100644 diff --git a/app/views/crm/customers/new.html.erb b/app/views/crm/customers/new.html.erb old mode 100755 new mode 100644 diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb old mode 100755 new mode 100644 diff --git a/app/views/crm/customers/show.json.jbuilder b/app/views/crm/customers/show.json.jbuilder old mode 100755 new mode 100644 diff --git a/app/views/oqs/edit/index.html.erb b/app/views/oqs/edit/index.html.erb index d9485b3a..64015e82 100644 --- a/app/views/oqs/edit/index.html.erb +++ b/app/views/oqs/edit/index.html.erb @@ -104,10 +104,12 @@ $(document).ready(function(){ $('#qty-update').on('click', function(){ var qty_weight = $("input[name='qty_weight']").val(); - if(parseInt(qty_weight) > parseInt(original_value)){ + if(parseInt(qty_weight) >= parseInt(original_value)){ swal("Alert!", "Not allowed over quantity", "warning"); return; } + + var remarks = $("textarea[name='remarks']").val(); var order_items_id = $(this).attr('data-id'); diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb old mode 100755 new mode 100644 diff --git a/app/views/origami/dashboard/_menu.json.jbuilder b/app/views/origami/dashboard/_menu.json.jbuilder index 5fe53223..8d17208c 100644 --- a/app/views/origami/dashboard/_menu.json.jbuilder +++ b/app/views/origami/dashboard/_menu.json.jbuilder @@ -5,7 +5,13 @@ json.valid_time_from menu.valid_time_from.strftime("%H:%M") json.valid_time_to menu.valid_time_to.strftime("%H:%M") if (menu.menu_categories) - json.categories menu.menu_categories do |category| + order_by = Lookup.find_by_lookup_type("order_by") + if !order_by.nil? && order_by.value == "name" + categories = MenuCategory.unscoped.where("menu_id ='#{menu.id}'").order("name asc") + else + categories = menu.menu_categories + end + json.categories categories do |category| menu_category = MenuCategory.find_by_menu_category_id(category.id) if !menu_category.nil? @@ -25,10 +31,14 @@ if (menu.menu_categories) json.parent_id category.menu_category_id json.is_available category.is_available - + if !order_by.nil? && order_by.value == "name" + menu_items = MenuItem.unscoped.where("menu_category_id = ?",category.id).order("name asc") + else + menu_items = category.menu_items + end if category.menu_items - json.items category.menu_items do |item| + json.items menu_items do |item| if item.is_available json.partial! 'origami/addorders/menu_item', item: item end diff --git a/app/views/origami/dinga/index.html.erb b/app/views/origami/dinga/index.html.erb index dba236e1..3e4a909f 100644 --- a/app/views/origami/dinga/index.html.erb +++ b/app/views/origami/dinga/index.html.erb @@ -113,6 +113,12 @@ +
+

Card Tap

+
+ +
+
@@ -256,6 +262,7 @@ getCardNo(); $("#sxModal").hide(); customer_mamber_card_no = $("#paypar_account_no").val(); + if(sale_id != 0 && customer_mamber_card_no != 0){ $.ajax({ type: "POST", @@ -429,7 +436,7 @@ }); } - $("#sxModal .btn_cancel").on('click',function(){ + $(".btn_cancel").on('click',function(){ $("#sxModal").hide(); }); diff --git a/app/views/origami/paymal/index.html.erb b/app/views/origami/paymal/index.html.erb index df5464dd..b6444384 100644 --- a/app/views/origami/paymal/index.html.erb +++ b/app/views/origami/paymal/index.html.erb @@ -108,6 +108,13 @@ + +
+

Card Tap

+
+ +
+
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 246bbcfe..ae7245a4 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -601,10 +601,11 @@ var customer_name = "<%= @customer.name %>"; $("#back").on('click', function() { localStorage.removeItem('cash'); customer_display_view(null,"reload"); + var sale_id = $('#sale_id').text(); if (cashier_type=="cashier") { window.location.href = '/origami/table/'+ dining_id; }else{ - window.location.href = '/origami/quick_service'; + window.location.href = '/origami/quick_service/pending_order/'+sale_id; } }); diff --git a/app/views/origami/pending_order/show.html.erb b/app/views/origami/pending_order/show.html.erb index 15d3aa12..e979d6d5 100644 --- a/app/views/origami/pending_order/show.html.erb +++ b/app/views/origami/pending_order/show.html.erb @@ -170,7 +170,7 @@
<% if current_user.role != "waiter" || @status != "sale"%> - + <%end%>
- <% if @sale.sale_status != 'void' && @sale.sale_status != 'waste' && @sale.sale_status != 'spoile' %> <% if current_login_employee.role == "cashier" %> Void @@ -224,6 +223,30 @@
+ + \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/reports/order_reservation/index.xls.erb b/app/views/reports/order_reservation/index.xls.erb index c674cc9b..5a3bc4ea 100755 --- a/app/views/reports/order_reservation/index.xls.erb +++ b/app/views/reports/order_reservation/index.xls.erb @@ -1,4 +1,10 @@ - + + + + + + +
@@ -129,4 +135,6 @@
- \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/reports/payment_method/index.xls.erb b/app/views/reports/payment_method/index.xls.erb index 73c8683b..73a53005 100755 --- a/app/views/reports/payment_method/index.xls.erb +++ b/app/views/reports/payment_method/index.xls.erb @@ -1,3 +1,10 @@ + + + + + + +
@@ -108,4 +115,6 @@
-
\ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/reports/product_sale/index.xls.erb b/app/views/reports/product_sale/index.xls.erb index 0ff60964..98885861 100644 --- a/app/views/reports/product_sale/index.xls.erb +++ b/app/views/reports/product_sale/index.xls.erb @@ -1,3 +1,10 @@ + + + + + + +
@@ -81,4 +88,6 @@
- \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/reports/receipt_no/index.xls.erb b/app/views/reports/receipt_no/index.xls.erb index 0b6a4dd0..ff74ef5a 100755 --- a/app/views/reports/receipt_no/index.xls.erb +++ b/app/views/reports/receipt_no/index.xls.erb @@ -1,4 +1,10 @@ - + + + + + + +
@@ -103,4 +109,6 @@
- \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/reports/saleitem/index.xls.erb b/app/views/reports/saleitem/index.xls.erb index 82b11aef..78d0aaec 100755 --- a/app/views/reports/saleitem/index.xls.erb +++ b/app/views/reports/saleitem/index.xls.erb @@ -1,3 +1,10 @@ + + + + + + +
@@ -223,4 +230,6 @@
- \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/reports/shiftsale/index.xls.erb b/app/views/reports/shiftsale/index.xls.erb index aa1d0231..46fe502d 100755 --- a/app/views/reports/shiftsale/index.xls.erb +++ b/app/views/reports/shiftsale/index.xls.erb @@ -1,3 +1,10 @@ + + + + + + +
@@ -105,4 +112,6 @@
- \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/reports/stock_check/index.xls.erb b/app/views/reports/stock_check/index.xls.erb index 4ea1f2f0..6ec88072 100755 --- a/app/views/reports/stock_check/index.xls.erb +++ b/app/views/reports/stock_check/index.xls.erb @@ -1,3 +1,10 @@ + + + + + + +
@@ -50,3 +57,5 @@
+ + \ No newline at end of file diff --git a/app/views/reports/void_sale/index.xls.erb b/app/views/reports/void_sale/index.xls.erb index e07b60b0..587ca509 100755 --- a/app/views/reports/void_sale/index.xls.erb +++ b/app/views/reports/void_sale/index.xls.erb @@ -1,4 +1,10 @@ - + + + + + + +
@@ -63,4 +69,6 @@ <% end %>
-
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/app/views/reports/waste_and_spoilage/index.xls.erb b/app/views/reports/waste_and_spoilage/index.xls.erb index 48f26650..7e71fbdc 100755 --- a/app/views/reports/waste_and_spoilage/index.xls.erb +++ b/app/views/reports/waste_and_spoilage/index.xls.erb @@ -1,3 +1,10 @@ + + + + + + +
@@ -80,4 +87,6 @@
- \ No newline at end of file + + + \ No newline at end of file diff --git a/config/puma.rb.production b/config/puma-production.rb similarity index 100% rename from config/puma.rb.production rename to config/puma-production.rb diff --git a/config/secrets.yml b/config/secrets.yml index 2768d134..aef81223 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -24,7 +24,7 @@ test: # instead read values from the environment. production: secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22 - sx_provision_url: connect.pos-myanmar.com/api #192.168.1.147:3002/api + sx_provision_url: connect.smartsales.asia/api #192.168.1.147:3002/api server_mode: application cipher_type: AES-256-CBC sx_key: Wh@t1$C2L diff --git a/db/migrate/20180213053009_create_display_images.rb b/db/migrate/20180521041850_create_display_images.rb similarity index 82% rename from db/migrate/20180213053009_create_display_images.rb rename to db/migrate/20180521041850_create_display_images.rb index f40a9179..f139d227 100644 --- a/db/migrate/20180213053009_create_display_images.rb +++ b/db/migrate/20180521041850_create_display_images.rb @@ -2,13 +2,11 @@ class CreateDisplayImages < ActiveRecord::Migration[5.1] def change create_table :display_images do |t| t.integer :shop_id + t.string :name t.binary :image t.string :created_by + t.timestamps end end - - def down - drop_table :display_images - end end diff --git a/lib/tasks/receipt.rake b/lib/tasks/receipt.rake index fce410fa..08692a0e 100644 --- a/lib/tasks/receipt.rake +++ b/lib/tasks/receipt.rake @@ -3,11 +3,11 @@ namespace :consolidate do task :receipt => :environment do # Receipt.delete_all sales = Sale.all_receipts -puts sales.to_json shop = Shop.find(1) sales.each do |sale| - puts sale.to_json - shift = ShiftSale.find(sale.shift_sale_id) + + if sale.shift_sale_id.present? + shift = ShiftSale.find(sale.shift_sale_id) receipt = Receipt.new receipt.client_code = shop.client_code receipt.client_name = shop.client_name @@ -48,6 +48,7 @@ puts sales.to_json receipt.cancle = (sale.payment_status=="void") ? false : true # void is cancel receipt.remarks = sale.remark receipt.save + end end end @@ -68,10 +69,10 @@ puts sales.to_json @item_sequence = 1 sale_count = sales.to_a.count sales.each do |sale| - if sale.qty > 0 if sale.item_instance_code !=nil + byebug menu_category = MenuCategory.find(MenuItem.find_by_item_code(sale.product_code).menu_category_id) name = menu_category.name code = menu_category.code @@ -90,7 +91,9 @@ puts sales.to_json @receipt_no = sale.receipt_no @requested_at = sale.requested_at - + if @receipt_no == '20171130-10464' + byebug + end if sale_id == sale.sale_id || count == 0 || @z ==0 @total_qty += sale.qty @total_gross_sales += sale.price @@ -109,14 +112,14 @@ puts sales.to_json receipt.receipt_date = @requested_at #requet-at receipt.transaction_date = @requested_at #before disco/after tax /after/ser_char receipt.item_sequence = @item_sequence - receipt.category_code = '' - receipt.category_name = '' + receipt.category_code = sale.product_code + receipt.category_name = sale.product_name receipt.sub_category_code = 0 receipt.sub_category_name = 0 receipt.report_group_code = 0 receipt.report_group_name = 0 - receipt.item_code = '' - receipt.item_name = '' + receipt.item_code = (sale.product_code.to_s=="NULL") ? "0" : sale.product_code + receipt.item_name = sale.product_name receipt.qty = @total_qty receipt.transaction_type = "Tender" receipt.gross_sales = @total_gross_sales @@ -158,14 +161,14 @@ puts sales.to_json receipt.receipt_date = sale.requested_at #requet-at receipt.transaction_date = sale.requested_at #before disco/after tax /after/ser_char receipt.item_sequence = @item_sequence - receipt.category_code = name - receipt.category_name = code + receipt.category_code = sale.product_code + receipt.category_name = sale.product_name receipt.sub_category_code = 0 receipt.sub_category_name = 0 receipt.report_group_code = 0 receipt.report_group_name = 0 - receipt.item_code = menu_name - receipt.item_name = menu_code + receipt.item_code = (menu_code.to_s=="NULL") ? "0" : sale.product_code + receipt.item_name = menu_name receipt.qty = sale.qty receipt.transaction_type = (sale.status==nil) ? "Sales" : sale.status receipt.gross_sales = sale.price @@ -208,14 +211,14 @@ puts sales.to_json receipt.receipt_date = @requested_at #requet-at receipt.transaction_date = @requested_at #before disco/after tax /after/ser_char receipt.item_sequence = @item_sequence - receipt.category_code = '' - receipt.category_name = '' + receipt.category_code = sale.product_code + receipt.category_name = sale.product_name receipt.sub_category_code = 0 receipt.sub_category_name = 0 receipt.report_group_code = 0 receipt.report_group_name = 0 - receipt.item_code = '' - receipt.item_name = '' + receipt.item_code = (menu_code.to_s=="NULL") ? "0" : sale.product_code + receipt.item_name = menu_name receipt.qty = @total_qty receipt.transaction_type = "Tender" receipt.gross_sales = @total_gross_sales diff --git a/spec/models/display_image_spec.rb b/spec/models/display_image_spec.rb new file mode 100644 index 00000000..1c6a0666 --- /dev/null +++ b/spec/models/display_image_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe DisplayImage, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From dbfc00435be1b3563c4bedda6bf7461d8225da83 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Wed, 23 May 2018 09:36:49 +0630 Subject: [PATCH 03/11] pull from master 23.5.2018 --- app/assets/javascripts/addorder.js | 8 +-- app/assets/stylesheets/addorder.scss | 27 +++++++--- .../api/restaurant/menu_controller.rb | 5 +- app/controllers/home_controller.rb | 50 ++++++++++--------- .../origami/dashboard_controller.rb | 36 ++++++------- .../settings/employees_controller.rb | 2 +- .../api/restaurant/menu/_menu.json.jbuilder | 2 +- .../restaurant/menu/_menu_item.json.jbuilder | 6 ++- .../api/restaurant/menu/index.json.jbuilder | 2 +- app/views/origami/addorders/detail.html.erb | 2 +- app/views/origami/payments/show.html.erb | 10 ++-- app/views/settings/employees/_form.html.erb | 1 + 12 files changed, 89 insertions(+), 62 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 5b3142e6..3be2f34d 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1434,16 +1434,16 @@ $(function() { row = '
' +'
' - +'
'+ menu_items[field].name +'
' - +"
'+ menu_items[field].name +'
' + +"
" - +"" + +JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"' style='padding:0px 5px 0px 5px'>" + +"" +add+ '' +'
' +'
' diff --git a/app/assets/stylesheets/addorder.scss b/app/assets/stylesheets/addorder.scss index d9b62131..929ffb13 100755 --- a/app/assets/stylesheets/addorder.scss +++ b/app/assets/stylesheets/addorder.scss @@ -56,24 +56,29 @@ section .content{ .nav-tabs .nav-item { border-bottom: 1px solid #fff; margin-left:2px; - + margin-right: -1.555rem; } #ul-navbar{ border-left: 1px solid #54A5AF; border-right: 1px solid #54A5AF; - + padding-right: 0px; } .nav > li > a{ color:#54A5AF; } +.nav-tabs > li > a { + color:#111 !important; +} .nav-tabs { - background-color: #eeeeee; + background-color: #ccc; } .nav-tabs .nav-link { - padding: 0.7286rem 0.2575 + padding: 0.7286rem 0.2575; + border-top-left-radius: 0rem; + border-top-right-radius: 0rem; } .nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link { - background-color: #fff; + background-color: #a1aade; border-left: 6px solid #111; color:#54A5AF; font-weight: bold; @@ -81,7 +86,7 @@ section .content{ } .sub_category_list{ background:#fff; - margin-top:8px; + margin-top:0px; } .sub_category_list > li{ list-style:none; @@ -274,4 +279,14 @@ i.logout_icon{ .set_add_icon{ display:none; +} + +.nav-tabs > li > a { + color:#111 !important; +} + + +.ls-closed section.content { + margin-left: 15px !important; + margin-right: 15px !important; } \ No newline at end of file diff --git a/app/controllers/api/restaurant/menu_controller.rb b/app/controllers/api/restaurant/menu_controller.rb index 011e4602..f6a43514 100755 --- a/app/controllers/api/restaurant/menu_controller.rb +++ b/app/controllers/api/restaurant/menu_controller.rb @@ -7,7 +7,10 @@ class Api::Restaurant::MenuController < Api::ApiController # checksum = File.readlines("public/checksums/menu_json.txt").pop.chomp all_menu = Menu.all - + @request_url = '' + if ENV["SERVER_MODE"] == "cloud" + @request_url = request.subdomain + "." + request.domain #local_url => 'http://0.0.0.0:3000' + end # to hash menu_array = [] all_menu.each do |m| diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 1aa2738c..e23da859 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -19,7 +19,7 @@ class HomeController < ApplicationController def index # @employees = Employee.all_emp_except_waiter.order("name asc") - @employees = Employee.all.order("name asc") + @employees = Employee.all.where("is_active = true").order("name asc") @login_form = LoginForm.new() render "layouts/login_dashboard", layout: false end @@ -52,29 +52,33 @@ class HomeController < ApplicationController @employee = Employee.login(@login_form.emp_id, @login_form.password) if @employee != nil - if @employee.role == "administrator" - session[:session_token] = @employee.token_session - redirect_to dashboard_path - elsif @employee.role == "cashier" - session[:session_token] = @employee.token_session - route_by_role(@employee) - elsif @employee.role == "manager" - session[:session_token] = @employee.token_session - redirect_to dashboard_path - elsif @employee.role == "supervisor" - session[:session_token] = @employee.token_session - redirect_to origami_root_path - elsif @employee.role == "waiter" - session[:session_token] = @employee.token_session - redirect_to origami_dashboard_path - elsif @employee.role == "account" - session[:session_token] = @employee.token_session - redirect_to reports_dailysale_index_path - elsif @employee.role == "kitchen" - session[:session_token] = @employee.token_session - redirect_to oqs_root_path + if @employee.is_active + if @employee.role == "administrator" + session[:session_token] = @employee.token_session + redirect_to dashboard_path + elsif @employee.role == "cashier" + session[:session_token] = @employee.token_session + route_by_role(@employee) + elsif @employee.role == "manager" + session[:session_token] = @employee.token_session + redirect_to dashboard_path + elsif @employee.role == "supervisor" + session[:session_token] = @employee.token_session + redirect_to origami_root_path + elsif @employee.role == "waiter" + session[:session_token] = @employee.token_session + redirect_to origami_dashboard_path + elsif @employee.role == "account" + session[:session_token] = @employee.token_session + redirect_to reports_dailysale_index_path + elsif @employee.role == "kitchen" + session[:session_token] = @employee.token_session + redirect_to oqs_root_path + else + render :index + end else - render :index + redirect_to root_path, :notice => "This Employee is not active" end else redirect_to root_path, :notice => "Username and Password doesn't match!" diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index 9977850f..a633c9e1 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -18,42 +18,42 @@ class Origami::DashboardController < BaseOrigamiController # .sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)') # @inventories = StockJournal.inventory_balances(today).sum(:balance) - @total_sale = Sale.total_sale(today) - @total_count = Sale.total_count(today) - @total_card = Sale.total_card_sale(today) - @total_credit = Sale.credit_payment(today) + @total_sale = Sale.total_sale(today,current_user) + @total_count = Sale.total_count(today,current_user) + @total_card = Sale.total_card_sale(today,current_user) + @total_credit = Sale.credit_payment(today,current_user) @sale_data = Array.new - @total_payment_methods = Sale.total_payment_methods(today) + @total_payment_methods = Sale.total_payment_methods(today,current_user) @total_payment_methods.each do |payment| if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" - pay = Sale.payment_sale('card', today) + pay = Sale.payment_sale('card', today, current_user) @sale_data.push({'card' => pay.payment_amount}) else - pay = Sale.payment_sale(payment.payment_method, today) + pay = Sale.payment_sale(payment.payment_method, today, current_user) @sale_data.push({payment.payment_method => pay.payment_amount}) end end - @summ_sale = Sale.summary_sale_receipt(today) - @total_customer = Sale.total_customer(today) - @total_dinein = Sale.total_dinein(today) - @total_takeaway = Sale.total_takeaway(today) - @total_other_customer = Sale.total_other_customer(today) - @total_membership = Sale.total_membership(today) + @summ_sale = Sale.summary_sale_receipt(today,current_user) + @total_customer = Sale.total_customer(today,current_user) + @total_dinein = Sale.total_dinein(today,current_user) + @total_takeaway = Sale.total_takeaway(today,current_user) + @total_other_customer = Sale.total_other_customer(today,current_user) + @total_membership = Sale.total_membership(today,current_user) - @total_order = Sale.total_order(today) - @total_accounts = Sale.total_account(today) + @total_order = Sale.total_order(today,current_user) + @total_accounts = Sale.total_account(today,current_user) @account_data = Array.new @total_accounts.each do |account| - acc = Sale.account_data(account.account_id, today) + acc = Sale.account_data(account.account_id, today,current_user) if !acc.nil? @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) end end - @top_items = Sale.top_items(today) - @total_foc_items = Sale.total_foc_items(today) + @top_items = Sale.top_items(today,current_user) + @total_foc_items = Sale.total_foc_items(today,current_user) # get printer info @print_settings = PrintSetting.get_precision_delimiter() diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb index cefb7b9c..7b558ea1 100755 --- a/app/controllers/settings/employees_controller.rb +++ b/app/controllers/settings/employees_controller.rb @@ -68,6 +68,6 @@ class Settings::EmployeesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def employee_params - params.require(:employee).permit(:name, :role, :emp_id, :password, :image_path) + params.require(:employee).permit(:name, :role, :is_active, :emp_id, :password, :image_path) end end diff --git a/app/views/api/restaurant/menu/_menu.json.jbuilder b/app/views/api/restaurant/menu/_menu.json.jbuilder index 8dcdf6fe..082b5f0a 100755 --- a/app/views/api/restaurant/menu/_menu.json.jbuilder +++ b/app/views/api/restaurant/menu/_menu.json.jbuilder @@ -17,7 +17,7 @@ if (menu.menu_categories) if category.menu_items json.items category.menu_items do |item| - json.partial! 'api/restaurant/menu/menu_item', item: item + json.partial! 'api/restaurant/menu/menu_item', item: item, request_url: request_url end end end diff --git a/app/views/api/restaurant/menu/_menu_item.json.jbuilder b/app/views/api/restaurant/menu/_menu_item.json.jbuilder index 810daf6d..56a8cb5f 100755 --- a/app/views/api/restaurant/menu/_menu_item.json.jbuilder +++ b/app/views/api/restaurant/menu/_menu_item.json.jbuilder @@ -53,7 +53,11 @@ json.id item.id json.code item.item_code json.name item.name json.alt_name item.alt_name -json.image item.image_path.url +if !request_url.nil? && request_url != '' + json.image request_url + item.image_path.url.to_s +else + json.image item.image_path.url +end json.description item.description json.information item.information json.type item.type diff --git a/app/views/api/restaurant/menu/index.json.jbuilder b/app/views/api/restaurant/menu/index.json.jbuilder index 46f35e60..a230a965 100755 --- a/app/views/api/restaurant/menu/index.json.jbuilder +++ b/app/views/api/restaurant/menu/index.json.jbuilder @@ -5,7 +5,7 @@ menu_json = json.array! @menus do |menu| json.valid_time_from menu.valid_time_from.strftime("%H:%M") json.valid_time_to menu.valid_time_to.strftime("%H:%M") - json.partial! 'api/restaurant/menu/menu', menu: menu + json.partial! 'api/restaurant/menu/menu', menu: menu, request_url: @request_url # if (@current_menu) # json.current_menu do # json.partial! 'api/restaurant/menu/menu', menu: @current_menu diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 38d30fa8..0ba7f60b 100644 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -5,7 +5,7 @@ <% type = request.path_info.include?('quick_service')%> <% modify_order = request.path_info.include?('modify_order')%> -
+
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index ae7245a4..fb4824ec 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -570,8 +570,8 @@ 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))) + // 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(); @@ -636,7 +636,7 @@ var customer_name = "<%= @customer.name %>"; $('#pay').click(function() { sub_total = $('#sub-total').text(); member = $('#membership_id').text(); - console.log(member) + // console.log(member) if (parseInt(jQuery.inArray("MPU", payment_type)) != -1 && $('.mpu').text() == 0 && sub_total != 0.0 && member) { swal("Oops","Please Pay with MPU Payment","warning"); }else if(parseInt(jQuery.inArray("Redeem", payment_type)) != -1 && $('#ppamount').text()==0 && sub_total != 0.0 && member){ @@ -1195,7 +1195,7 @@ var customer_name = "<%= @customer.name %>"; url: url, data: {}, success: function (result) { - console.log(result) + // console.log(result) if (result.status == true) { createAccessCode(code); if (type == "edit") { @@ -1330,7 +1330,7 @@ var customer_name = "<%= @customer.name %>"; url: url, data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code, success: function (result) { - console.log(result) + // console.log(result) // For Server Print - from jade if ($("#server_mode").val() == "cloud") { code2lab.printFile(result.filepath.substr(6), result.printer_url); diff --git a/app/views/settings/employees/_form.html.erb b/app/views/settings/employees/_form.html.erb index ad50e9b8..70712c7b 100755 --- a/app/views/settings/employees/_form.html.erb +++ b/app/views/settings/employees/_form.html.erb @@ -7,6 +7,7 @@
<%= f.input :name %> + <%= f.input :is_active,:input_html=>{:class=>"col-md-9"} %> <% if current_user.role == "administrator" %> <%= f.input :role, :collection => Lookup.collection_of("employee_roles"),:class=>'form-group' %> <% else %> From 40bce7f5981c643c7fb88032cc63726e9b591ade Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Wed, 23 May 2018 13:57:45 +0630 Subject: [PATCH 04/11] Add Void button in Transaction/sales --- .../transactions/sales_controller.rb | 149 +++++ app/views/transactions/sales/show.html.erb | 533 ++++++++++-------- config/routes.rb | 1 + 3 files changed, 439 insertions(+), 244 deletions(-) diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index be370371..2a823888 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -236,6 +236,155 @@ class Transactions::SalesController < ApplicationController redirect_to root_path end end + + def overall_void + sale_id = params[:sale_id] + remark = params[:remark] + order_source = params[:type] #tax profile source + access_code = params[:access_code] + 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,order_source) + end + + # update count for shift sale + if(sale.sale_status == "completed") + if sale.shift_sale_id != nil + shift = ShiftSale.find(sale.shift_sale_id) + shift.calculate(sale_id, "void") + end + else + # void before sale payment complete + if sale.shift_sale_id != nil + shift = ShiftSale.find(sale.shift_sale_id) + shift.total_void = shift.total_void + sale.grand_total + shift.save + end + end + + sale.rounding_adjustment = 0.0 + sale.payment_status = 'void' + sale.sale_status = 'void' + sale.save + + # No Need + # bookings = sale.bookings + # bookings.each do |booking| + # orders = booking.orders + # orders.each do |order| + # # order.status = 'void' + # end + # end + + if sale.bookings[0].dining_facility_id.to_i > 0 + table_avaliable = true + table_count = 0 + table = sale.bookings[0].dining_facility + table.bookings.each do |booking| + if booking.booking_status != 'moved' + if booking.sale_id + if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste' + table_avaliable = false + table_count += 1 + else + table_avaliable = true + end + else + table_avaliable = false + table_count += 1 + end + end + end + + if table_avaliable && table_count == 0 + table.status = 'available' + table.save + end + else + table = nil + end + + # FOr Sale Audit + action_by = current_user.name + if access_code != "null" && current_user.role == "cashier" + action_by = Employee.find_by_emp_id(access_code).name + end + + # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" + sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,"SALEVOID" ) + + # For Print + + member_info = nil + rebate_amount = nil + current_balance = nil + + # For Cashier by Zone + bookings = Booking.where("sale_id='#{sale_id}'") + if bookings.count > 1 + # for Multiple Booking + if bookings[0].dining_facility_id.to_i>0 + table = DiningFacility.find(bookings[0].dining_facility_id) + end + end + + if bookings[0].dining_facility_id.to_i > 0 + cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) + cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) + else + shift = ShiftSale.find(sale.shift_sale_id) + cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) + end + + + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + unique_code = "ReceiptBillPdf" + customer= Customer.find(sale.customer_id) + + #shop detail + shop_details = Shop.find(1) + # get member information + 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,sale.receipt_no) + # current_balance = SaleAudit.paymal_search(sale_id) + current_balance = 0 + end + + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + # Calculate Food and Beverage Total + item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil) + result = { + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + + # Mobile Print + render :json => result.to_json + # end + + #end print + + # update complete order items in oqs + SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr| + AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi| + aoi.delivery_status = 1 + aoi.save + end + end + end + end + private # Use callbacks to share common setup or constraints between actions. diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 049ca8c9..fd98e214 100755 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -1,4 +1,3 @@ -
-
- +
+ - - - + + + -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - <% @sale.sale_items.each do |s| %> - - - - - - - - - - <% end %> - - - - - - - - - - - <% @sale.sale_taxes.each do |r|%> - - - - - - <% end %> - - - - - - - - - - - - - <% @sale_receivables.each do |r|%> - - - - - - - <% end %> - - - - - - - - - -
<%= t("views.right_panel.detail.receipt_date") %><%= t("views.right_panel.detail.receipt_no") %><%= t :cashier %><%= t("views.right_panel.detail.sales_status") %><%= t("views.right_panel.detail.receipt_generated_at") %>
<%= @sale.receipt_date.strftime("%d-%M-%Y") %><%= @sale.receipt_no %><%= @sale.cashier_name rescue '-' %> <%= @sale.sale_status %> <%= @sale.requested_at.strftime("%m-%d-%Y %H:%M %p") %>
<%= t :sale %> <%= t("views.right_panel.detail.item_txt") %> <%= t("views.right_panel.detail.name_txt2") %><%= t("views.right_panel.detail.qty") %><%= t("views.right_panel.detail.unit_price") %><%= t("views.right_panel.detail.total_price") %><%= t("views.right_panel.detail.created_at") %><%= t("views.right_panel.detail.remark") %>
<%=s.product_name rescue ' '%><%=s.qty rescue ' '%><%= number_with_precision(s.unit_price, :precision => 2, :delimiter => ',') rescue ' '%><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %><%=s.remark rescue ' '%>
<%= t("views.right_panel.detail.total") %><%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= t("views.right_panel.detail.discount") %><%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= r.tax_name %> <%= number_with_precision(r.tax_payable_amount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= t("views.right_panel.detail.grand_total") %><%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%>
 
<%= t("views.right_panel.detail.total_pay_amount") %><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%>
<%= r.payment_method.capitalize rescue ' '%> Payment<%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%> -
<%= t("views.right_panel.detail.change") %><%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%>
- -
-
- -
-
- - - - - - - - - - - - - - - - <% @order_items.each do |order_item| %> - - - - - - - - - - - <% end %> - -
<%= t("views.right_panel.detail.order_id") %><%= t("views.right_panel.header.menu_item") %><%= t("views.right_panel.detail.qty") %><%= t("views.right_panel.detail.unit_price") %><%= t("views.right_panel.detail.option") %><%= t("views.right_panel.detail.status") %><%= t("views.right_panel.detail.waiter") %><%= t("views.right_panel.detail.created_at") %>
<%= link_to order_item.order_id, transactions_order_path(order_item.order_id) %><%= %><%= order_item.item_name %><%= order_item.qty %><%= order_item.price %><%= order_item.options %><%= order_item.order_item_status %><%= order_item.item_order_by %> <%= order_item.created_at.strftime("%d-%m-%y %I:%M %p") %>
-
-
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - <% if @customer.membership_id %> - - - - - - - - - - - - - - - <% - if @response["status"] == true %> - <% @response["data"].each do |transaction| %> - - - - - - - - - - - <% end %> - <% end %> - <% end %> - -
<%= t("views.right_panel.detail.card_no") %><%= t("views.right_panel.detail.name") %><%= t("views.right_panel.detail.company") %><%= t("views.right_panel.detail.contact_no") %><%= t("views.right_panel.detail.email") %><%= t("views.right_panel.detail.nrc_passport_no") %><%= t("views.right_panel.detail.address") %><%= t("views.right_panel.detail.dob") %>
<%= @customer.card_no rescue '-'%><%= @customer.name %><%= @customer.company rescue '-' %><%= @customer.contact_no %><%= @customer.email %><%= @customer.nrc_no %><%= @customer.address%><%= @customer.date_of_birth %>
<%= t("views.right_panel.detail.membership_transactions") %>
<%= t("views.right_panel.detail.date") %><%= t("views.right_panel.detail.redeem") %><%= t("views.right_panel.detail.rebate") %><%= t("views.right_panel.detail.balance") %><%= t("views.right_panel.detail.from_account") %><%= t("views.right_panel.detail.status") %><%= t("views.right_panel.detail.receipt_no") %>
<%= transaction["date"]%><%= transaction["redeem"]%><%= transaction["rebate"] %><%= transaction["balance"] %><%= transaction["account_status"] %><%= transaction["status"] %><%= transaction["receipt_no"] %>
-
-
- -
-
-
- - - - - - - - - - - - - <% @sale_audits.each do |audit| %> - - - - - - - - <% end %> - - -
<%= t("views.right_panel.detail.action") %><%= t("views.right_panel.detail.action_at") %><%= t("views.right_panel.detail.approved_at") %><%= t("views.right_panel.detail.remark") %>
<%= audit.action%><%= audit.action_at.strftime("%m-%d-%Y %H:%M %p")%><%= audit.approved_by%><%= audit.remark%>
-
-
+
+
+
+ + + + + + + + + <% if @sale["sale_status"] == "completed" %> + + + + + + + + + + + + <% @sale.sale_items.each do |s| %> + + + + + + + + + <% end %> + + + + + + + + + + + <% @sale.sale_taxes.each do |r|%> + + + + + + <% end %> + + + + + + + + + + + + <% @sale_receivables.each do |r|%> + + + + + + <% end %> + + + + + + +
<%= t("views.right_panel.detail.receipt_date") %><%= t("views.right_panel.detail.receipt_no") %><%= t :cashier %><%= t("views.right_panel.detail.sales_status") %><%= t("views.right_panel.detail.receipt_generated_at") %> + <%= @sale.sale_status %> <%= @sale.requested_at.strftime("%m-%d-%Y %H:%M %p") %>
<%= t :sale %> <%= t("views.right_panel.detail.item_txt") %> <%= t("views.right_panel.detail.name_txt2") %><%= t("views.right_panel.detail.qty") %><%= t("views.right_panel.detail.unit_price") %><%= t("views.right_panel.detail.total_price") %><%= t("views.right_panel.detail.created_at") %><%= t("views.right_panel.detail.remark") %>
<%=s.product_name rescue ' '%><%=s.qty rescue ' '%><%= number_with_precision(s.unit_price, :precision => 2, :delimiter => ',') rescue ' '%><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %><%=s.remark rescue ' '%>
<%= t("views.right_panel.detail.total") %><%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= t("views.right_panel.detail.discount") %><%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= r.tax_name %> <%= number_with_precision(r.tax_payable_amount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= t("views.right_panel.detail.grand_total") %><%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%>
 
<%= t("views.right_panel.detail.total_pay_amount") %><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%>
<%= r.payment_method.capitalize rescue ' '%> Payment<%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%>
<%= t("views.right_panel.detail.change") %><%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%>
+
+
+
+ + + + + + + + + + + + + + + <% @order_items.each do |order_item| %> + + + + + + + + + + + <% end %> + +
<%= t("views.right_panel.detail.order_id") %><%= t("views.right_panel.header.menu_item") %><%= t("views.right_panel.detail.qty") %><%= t("views.right_panel.detail.unit_price") %><%= t("views.right_panel.detail.option") %><%= t("views.right_panel.detail.status") %><%= t("views.right_panel.detail.waiter") %><%= t("views.right_panel.detail.created_at") %>
<%= link_to order_item.order_id, transactions_order_path(order_item.order_id) %><%= %><%= order_item.item_name %><%= order_item.qty %><%= order_item.price %><%= order_item.options %><%= order_item.order_item_status %><%= order_item.item_order_by %> <%= order_item.created_at.strftime("%d-%m-%y %I:%M %p") %>
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + <% if @customer.membership_id %> + + + + + + + + + + + + + + + <% if @response["status"] == true %> + <% @response["data"].each do |transaction| %> + + + + + + + + + + + <% end %> + <% end %> + <% end %> + +
<%= t("views.right_panel.detail.card_no") %><%= t("views.right_panel.detail.name") %><%= t("views.right_panel.detail.company") %><%= t("views.right_panel.detail.contact_no") %><%= t("views.right_panel.detail.email") %><%= t("views.right_panel.detail.nrc_passport_no") %><%= t("views.right_panel.detail.address") %><%= t("views.right_panel.detail.dob") %>
<%= @customer.card_no rescue '-'%><%= @customer.name %><%= @customer.company rescue '-' %><%= @customer.contact_no %><%= @customer.email %><%= @customer.nrc_no %><%= @customer.address%><%= @customer.date_of_birth %>
<%= t("views.right_panel.detail.membership_transactions") %>
<%= t("views.right_panel.detail.date") %><%= t("views.right_panel.detail.redeem") %><%= t("views.right_panel.detail.rebate") %><%= t("views.right_panel.detail.balance") %><%= t("views.right_panel.detail.from_account") %><%= t("views.right_panel.detail.status") %><%= t("views.right_panel.detail.receipt_no") %>
<%= transaction["date"]%><%= transaction["redeem"]%><%= transaction["rebate"] %><%= transaction["balance"] %><%= transaction["account_status"] %><%= transaction["status"] %><%= transaction["receipt_no"] %>
+
+
+ +
+
+
+ + + + + + + + + + + <% @sale_audits.each do |audit| %> + + + + + + + <% end %> + +
<%= t("views.right_panel.detail.action") %><%= t("views.right_panel.detail.action_at") %><%= t("views.right_panel.detail.approved_at") %><%= t("views.right_panel.detail.remark") %>
<%= audit.action%><%= audit.action_at.strftime("%m-%d-%Y %H:%M %p")%><%= audit.approved_by%><%= audit.remark%>
+
+
- - +
+ + + + + diff --git a/config/routes.rb b/config/routes.rb index 77e26bbb..7f776da0 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -431,6 +431,7 @@ scope "(:locale)", locale: /en|mm/ do get "/sales/:sale_id/manual_complete_sale" => "manual_sales#manual_complete_sale", :as => "manual_complete_sale" get "/sales/:sale_id/void" => "manual_sales#void", :as => "void" post "sales/:sale_id/manual_void_sale", to: "manual_sales#manual_void_sale", :as => "manual_void_sale" + post "sales/:sale_id/:type/void" => "sales#overall_void" end #--------- Reports Controller Sections ------------# From 8134e37f5fa2c572f2bb95a49388f3687c551a71 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Wed, 23 May 2018 14:00:07 +0630 Subject: [PATCH 05/11] Pull from master --- config/initializers/action_controller.rb | 2 +- db/migrate/20170403155230_create_employees.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index e0eb7455..1d8b678e 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -19,7 +19,7 @@ class ActionController::Base render :json => [{ status: false, message: 'Invalid Access!'}] end else - #check for license file + check for license file if check_license current_license(ENV["SX_PROVISION_URL"]) else diff --git a/db/migrate/20170403155230_create_employees.rb b/db/migrate/20170403155230_create_employees.rb index 4270b265..16e741d8 100755 --- a/db/migrate/20170403155230_create_employees.rb +++ b/db/migrate/20170403155230_create_employees.rb @@ -3,6 +3,7 @@ class CreateEmployees < ActiveRecord::Migration[5.1] create_table :employees do |t| t.string :name, :null => false t.string :role, :null => false, :default => "cashier" + t.boolean :is_active, :default => true t.string :emp_id, :null => false t.string :password_digest, :null => false t.string :token_session From 71b6ade2457392c2558474762ea21697911d4c67 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Wed, 23 May 2018 15:30:18 +0630 Subject: [PATCH 06/11] Edit Precision in Receipt Bill & Recceipt Bill A5 Pdf --- README.md | 2 +- app/pdf/receipt_bill_a5_pdf.rb | 31 ++++++++++++++++++------ app/pdf/receipt_bill_pdf.rb | 22 ++++++++++++----- config/initializers/action_controller.rb | 2 +- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 4ba6d51f..1d9b2e2a 100755 --- a/README.md +++ b/README.md @@ -201,7 +201,7 @@ Add Feature for Order and Reservation => settings/lookups => { type:order_reservation, name: OrderReservation, value:'{0 or 1}' } For Price 0 in receipt bill - 2) settings/lookups => { type:show_price, name:Shoe Price, value:1 } + 2) settings/lookups => { type:show_price, name:Show Price, value:1 } For Price 0 in receipt bill 2) settings/lookups => { type:order_by, name:Order By, value:name } diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index 382633de..2bee170d 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -187,6 +187,20 @@ class ReceiptBillA5Pdf < Prawn::Document def add_line_item_row(sale_items,precision,delimiter) + if precision.to_i > 0 + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = (self.item_width+self.price_width) + 5 + item_qty_end_width = self.qty_width + 4 + item_total_front_width = item_name_width + 10 + item_total_end_width = self.total_width + 9 + else + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = item_name_width + 8 + item_qty_end_width = self.qty_width + 7 + item_total_front_width = item_name_width + 5 + item_total_end_width = self.total_width + 4 + end + y_position = cursor move_down line_move sub_total = 0.0 @@ -194,7 +208,7 @@ class ReceiptBillA5Pdf < Prawn::Document sale_items.each do |item| # check for item not to show - show_price = Lookup.find_by_lookup_type("show_price").value + show_price = Lookup.find_by_lookup_type("show_price") sub_total += item.price #(item.qty*item.unit_price) - comment for room charges if item.status != 'Discount' && item.qty > 0 @@ -221,12 +235,15 @@ class ReceiptBillA5Pdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do text "Sub Total", :size => self.item_font_size,:align => :left end - bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do - text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center - end - bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do - text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - end + # bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do + # text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center + # end + # bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do + # text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + # end + text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + end def item_row(item,precision,delimiter,product_name,price,qty ,total_price) diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 862a91a5..18450f51 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -181,6 +181,20 @@ class ReceiptBillPdf < Prawn::Document def add_line_item_row(sale_items,precision,delimiter) + if precision.to_i > 0 + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = (self.item_width+self.price_width) + 5 + item_qty_end_width = self.qty_width + 4 + item_total_front_width = item_name_width + 10 + item_total_end_width = self.total_width + 9 + else + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = item_name_width + 8 + item_qty_end_width = self.qty_width + 7 + item_total_front_width = item_name_width + 5 + item_total_end_width = self.total_width + 4 + end + y_position = cursor move_down line_move sub_total = 0.0 @@ -215,12 +229,8 @@ class ReceiptBillPdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do text "Sub Total", :size => self.item_font_size,:align => :left end - bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do - text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center - end - bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do - text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - end + text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix end def item_row(item,precision,delimiter,product_name,price,qty ,total_price) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 1d8b678e..fb212f13 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -19,7 +19,7 @@ class ActionController::Base render :json => [{ status: false, message: 'Invalid Access!'}] end else - check for license file + # check for license file if check_license current_license(ENV["SX_PROVISION_URL"]) else From 85b997ddbeb32ad7781ee60248b9a583df4b8514 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 23 May 2018 16:57:41 +0630 Subject: [PATCH 07/11] change receipt no report ui and add sale taxes for dining charges --- .../api/restaurant/menu_controller.rb | 2 +- .../reports/receipt_no_controller.rb | 3 +- app/models/sale.rb | 8 ++-- app/views/reports/receipt_no/index.html.erb | 39 ++++++++++++++----- app/views/reports/receipt_no/index.xls.erb | 26 +++++++++++-- 5 files changed, 59 insertions(+), 19 deletions(-) diff --git a/app/controllers/api/restaurant/menu_controller.rb b/app/controllers/api/restaurant/menu_controller.rb index f6a43514..47a3703c 100755 --- a/app/controllers/api/restaurant/menu_controller.rb +++ b/app/controllers/api/restaurant/menu_controller.rb @@ -9,7 +9,7 @@ class Api::Restaurant::MenuController < Api::ApiController all_menu = Menu.all @request_url = '' if ENV["SERVER_MODE"] == "cloud" - @request_url = request.subdomain + "." + request.domain #local_url => 'http://0.0.0.0:3000' + @request_url = request.base_url end # to hash menu_array = [] diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 2e43da0b..19d5720a 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -27,7 +27,8 @@ authorize_resource :class => false payment_type = params[:payment_type] @sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type) @sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type) - @tax_profiles = TaxProfile.where('group_type = "cashier"').order('order_by asc').limit(2) + @tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2) + @from = from @to = to # get printer info diff --git a/app/models/sale.rb b/app/models/sale.rb index 7ceecebd..24d3f81c 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -51,7 +51,7 @@ class Sale < ApplicationRecord if !charges.nil? block_count, diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at) dining_time = booking.checkin_at.strftime('%H:%M %p').to_s + " - " + booking.checkout_at.strftime('%H:%M %p').to_s - create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time) + create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time, order_source) end return status, sale_id @@ -131,6 +131,7 @@ class Sale < ApplicationRecord if order_source.nil? order_source = order.source end + puts "compute source" compute(order_source) #Update the order items that is billed @@ -275,7 +276,7 @@ class Sale < ApplicationRecord end end - def create_saleitem_diningcharges(chargeObj, block_count, diningprice, dining_name, dining_time) + def create_saleitem_diningcharges(chargeObj, block_count, diningprice, dining_name, dining_time, order_source = nil) sale_item = SaleItem.new sale_item.product_code = chargeObj.item_code sale_item.product_name = dining_name.to_s + " ( " + dining_time.to_s + " )" @@ -291,7 +292,7 @@ class Sale < ApplicationRecord # Re-calc sale = Sale.find(self.id) - self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount) + self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount, nil, order_source) end def update_item (item) @@ -506,6 +507,7 @@ class Sale < ApplicationRecord if order_source.to_s == "emenu" order_source = "cashier" end + #Create new tax records tax_profiles.each do |tax| # customer.tax_profiles.each do |cus_tax| diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index bd06be3f..30a610d0 100755 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -47,7 +47,7 @@ <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %> <%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> <% @tax_profiles.each do |tax| %> - <%= tax.name %> + <%= tax.name %> <% end %> <%= t("views.right_panel.detail.grand_total") %> @@ -89,20 +89,39 @@ <% total_sum += result.total_amount.to_f %> <% discount_amt += result.total_discount.to_f %> <% rounding_adj += result.rounding_adjustment.to_f %> - - - + + <% tax_profile_count = @tax_profiles.length %> + <% sale_tax_count = result.sale_taxes.length %> + <% tax_count = tax_profile_count - sale_tax_count %> <%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %> <%= number_with_precision(result.total_amount, precision: precision.to_i ,delimiter: delimiter) %> - <%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) %> - <%if result.customer.customer_type == "Takeaway"%> - <%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> - <%end%> - <% result.sale_taxes.each do |tax| %> - <%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue '0' %> + + + <% if !result.sale_taxes.empty? %> + <% num = 1 + if tax_count > 0 %> + <% while num <= tax_count %> + + <%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> + + <% num += 1 + end %> + <% end %> + <% result.sale_taxes.each do |tax| %> + + <%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + + <%end%> + <% else %> + <% @tax_profiles.each do |tax| %> + <%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <% end %> <%end%> <%= number_with_precision(result.grand_total_after_rounding(), precision: precision.to_i ,delimiter: delimiter) rescue '-' %> diff --git a/app/views/reports/receipt_no/index.xls.erb b/app/views/reports/receipt_no/index.xls.erb index ff74ef5a..ac955e73 100755 --- a/app/views/reports/receipt_no/index.xls.erb +++ b/app/views/reports/receipt_no/index.xls.erb @@ -59,17 +59,35 @@ <% discount_amt += result.total_discount.to_f %> <% rounding_adj += result.rounding_adjustment.to_f %> + <% tax_profile_count = @tax_profiles.length %> + <% sale_tax_count = result.sale_taxes.length %> + <% tax_count = tax_profile_count - sale_tax_count %> <%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %> <%= result.total_amount rescue '-' %> <%= result.total_discount rescue '-' %> - <%if result.customer.customer_type == "Takeaway"%> + + <% if !result.sale_taxes.empty? %> + <% num = 1 + if tax_count > 0 %> + <% while num <= tax_count %> + 0 + <% num += 1 + end %> + <% end %> + <% result.sale_taxes.each do |tax| %> + + <%= tax.tax_payable_amount rescue '-' %> + + <%end%> + <% else %> + <% @tax_profiles.each do |tax| %> + 0 + <% end %> <%end%> <%= result.grand_total %> From 992914ee46f7434c617decba95f134e34e27b1a8 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 23 May 2018 17:23:38 +0630 Subject: [PATCH 08/11] check multiple items in split bill --- .../origami/split_bill_controller.rb | 66 ++++++++++--------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index 77f4589a..faa41926 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -161,11 +161,11 @@ class Origami::SplitBillController < BaseOrigamiController end end - puts order_id - puts order_ids.count - puts order_id_count - puts order_items.count - puts order_item_count + # puts order_id + # puts order_ids.count + # puts order_id_count + # puts order_items.count + # puts order_item_count if !order_id.nil? if order_id_count > 1 @@ -181,8 +181,8 @@ class Origami::SplitBillController < BaseOrigamiController end end - puts "updated_order_id" - puts updated_order_id + # puts "updated_order_id" + # puts updated_order_id if !updated_order_id.empty? order_ids.each do |odr_id| @@ -211,7 +211,7 @@ class Origami::SplitBillController < BaseOrigamiController end end - puts new_order_status + # puts new_order_status if new_order_status BookingOrder.find_by_order_id(odr_id).delete @@ -239,7 +239,7 @@ class Origami::SplitBillController < BaseOrigamiController end end else - puts "order_id_count < 1" + # puts "order_id_count < 1" new_order_status = true order_items.each do |order_item| orderItem = OrderItem.find(order_item["id"]) @@ -252,7 +252,7 @@ class Origami::SplitBillController < BaseOrigamiController end end - puts new_order_status + # puts new_order_status if new_order_status BookingOrder.find_by_order_id(order_id).delete @@ -337,12 +337,12 @@ class Origami::SplitBillController < BaseOrigamiController end Promotion.promo_activate(sale) - if ENV["SERVER_MODE"] == 'cloud' - from = request.subdomain + "." + request.domain - else - from = "" - end - ActionCable.server.broadcast "bill_channel",table: table,from:from + # if ENV["SERVER_MODE"] == 'cloud' + # from = request.subdomain + "." + request.domain + # else + # from = "" + # end + # ActionCable.server.broadcast "bill_channel",table: table,from:from render :json => { status: status } else @@ -379,20 +379,26 @@ class Origami::SplitBillController < BaseOrigamiController orderItem.set_menu_items = instance_item_sets.to_json end - OrderItem.processs_item(orderItem.item_code, - orderItem.item_instance_code, - orderItem.item_name, - orderItem.alt_name, - orderItem.account_id, - order_item['qty'], - orderItem.price, - orderItem.options, - set_menu_items_obj.to_json, - order_id, - orderItem.item_order_by, - orderItem.taxable) - - orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f + same_order = OrderItem.find_by_order_id(order_id) + if same_order.nil? + OrderItem.processs_item(orderItem.item_code, + orderItem.item_instance_code, + orderItem.item_name, + orderItem.alt_name, + orderItem.account_id, + order_item['qty'], + orderItem.price, + orderItem.options, + set_menu_items_obj.to_json, + order_id, + orderItem.item_order_by, + orderItem.taxable) + else + same_order.qty = same_order.qty.to_f + order_item['qty'].to_f + same_order.set_menu_items = set_menu_items_obj.to_json + same_order.save + end + orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f else orderItem.order_id = order_id end From 770ef87678a2fca991ef07b2800ce7f80854ae28 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 23 May 2018 17:28:41 +0630 Subject: [PATCH 09/11] remove action cable comment --- app/controllers/origami/split_bill_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index faa41926..c7311fd6 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -337,12 +337,12 @@ class Origami::SplitBillController < BaseOrigamiController end Promotion.promo_activate(sale) - # if ENV["SERVER_MODE"] == 'cloud' - # from = request.subdomain + "." + request.domain - # else - # from = "" - # end - # ActionCable.server.broadcast "bill_channel",table: table,from:from + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "bill_channel",table: table,from:from render :json => { status: status } else From e23982c07856cce32ef7ccf88548f3f5b0d9a3e5 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Wed, 23 May 2018 17:31:11 +0630 Subject: [PATCH 10/11] First Bill Click Alert --- app/views/origami/home/show.html.erb | 49 +++++++++++++++++----------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index e1b88f85..5f24494f 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -759,30 +759,41 @@ return false; }); }); + // Print for first bill $("#first_bill").on('click', function () { - var sale_id = $('#sale_id').val(); - var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; - var server_mode = - $.ajax({ - type: "GET", - url: ajax_url, - success: function (result) { - receipt_no = ($("#receipt_no").html()).trim(); - if((receipt_no!=undefined) && (receipt_no!="")) - createReceiptNoInFirstBillData(receipt_no,""); + swal({ + title: "Alert", + text: "Are you sure want to print First Bill?", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "Yes, print it!", + closeOnConfirm: false + }, function (isConfirm) { + if (isConfirm) { + var sale_id = $('#sale_id').val(); + var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; + var server_mode = - // For Server Print - from jade - if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); - } - - // console.log(result); - // code2lab.printBill(result.filepath, result.printer_model, result.printer_url); - location.reload(); + $.ajax({ + type: "GET", + url: ajax_url, + success: function (result) { + receipt_no = ($("#receipt_no").html()).trim(); + if((receipt_no!=undefined) && (receipt_no!="")) + createReceiptNoInFirstBillData(receipt_no,""); + + // For Server Print - from jade + if ($("#server_mode").val() == "cloud") { + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } + location.reload(); } - }); + }); + } + }); }); // click select option icon for add From ed8f9978b6d7c3583b6cffabe9dcae3d0192f98a Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 23 May 2018 17:55:17 +0630 Subject: [PATCH 11/11] remove paginate in surveys --- app/controllers/transactions/surveys_controller.rb | 10 ++-------- app/views/transactions/surveys/index.html.erb | 3 --- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/app/controllers/transactions/surveys_controller.rb b/app/controllers/transactions/surveys_controller.rb index 4bf4ec2d..829e7252 100644 --- a/app/controllers/transactions/surveys_controller.rb +++ b/app/controllers/transactions/surveys_controller.rb @@ -5,16 +5,10 @@ class Transactions::SurveysController < ApplicationController to = params[:to] if filter.nil? && from.nil? && to.nil? - surveys = Survey.all + @surveys = Survey.all else - surveys = Survey.search(filter,from,to) + @surveys = Survey.search(filter,from,to) end - - if !surveys.nil? - @surveys = Kaminari.paginate_array(surveys).page(params[:page]).per(20) - else - @surveys = [] - end @filter = filter @from = from diff --git a/app/views/transactions/surveys/index.html.erb b/app/views/transactions/surveys/index.html.erb index cb95ad16..a57d724f 100644 --- a/app/views/transactions/surveys/index.html.erb +++ b/app/views/transactions/surveys/index.html.erb @@ -93,9 +93,6 @@
- <%if !@orders.nil?%> - <%= paginate @surveys %> - <%end%>