From 6beb32348d8e2188928ee3a9d1bad5fe497d6bd8 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 22 Nov 2017 18:39:35 +0630 Subject: [PATCH] major fix taxable price for sale and other sale and oqs --- app/assets/javascripts/OQS.js | 6 +- app/assets/javascripts/application.js | 233 ------------------ .../channels/order_queue_station.js | 10 +- app/controllers/oqs/home_controller.rb | 30 +-- app/controllers/oqs/print_controller.rb | 9 +- .../origami/discounts_controller.rb | 6 +- .../origami/other_charges_controller.rb | 6 +- .../settings/dining_charges_controller.rb | 6 +- app/models/dining_charge.rb | 10 +- app/models/printer/order_queue_printer.rb | 2 +- app/models/promotion.rb | 2 +- app/models/sale.rb | 2 +- app/views/oqs/home/index.html.erb | 2 +- .../origami/other_charges/index.html.erb | 2 +- .../settings/dining_charges/_form.html.erb | 6 +- config/puma.rb | 56 ++++- config/puma.rb.production | 10 +- config/routes.rb | 2 +- 18 files changed, 105 insertions(+), 295 deletions(-) diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index e6947c18..f7d517ea 100755 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -67,7 +67,7 @@ $(document).on('turbolinks:load', function() { var date = new Date(data[field]["created_at"]); var show_date = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes(); - row ='
' + row ='
' +'
' +'
' +''+data[field]["table_type"]+'-'+ data[field]["zone"] +'' @@ -109,6 +109,7 @@ $(document).on('turbolinks:load', function() { } $(document).on('click', '.queue_station', function(event){ + var orderNo = $(this).attr('data-order-no'); var orderZone=$(this).children().children().children('.order-zone').text().trim(); var orderZoneType=$(this).children().children().children('.order-zone-type').text().trim(); // var orderItem=$(this).children().children().children('.order-item').text(); @@ -129,7 +130,7 @@ $(document).on('turbolinks:load', function() { // Call get_order_items() for Order Items by dining $.ajax({ type: 'GET', - url: '/oqs/' + orderZone, + url: '/oqs/' + orderNo, data: { 'status' : order_status }, success: function(res){ @@ -231,6 +232,7 @@ $(document).on('turbolinks:load', function() { // Print Order Summary // $('#print_order_summary').on('click',function(){ $(document).on('click', '#print_order_summary', function(event){ + var orderNo = $('.selected-item').attr('data-order-no'); var table_name=$('.selected-item').children().children().children('.order-zone').text().trim(); var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); var params = { 'table_name':table_name }; diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index acfbe88d..381d98fa 100755 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -115,236 +115,3 @@ function export_to(path) var form_params = $("#frm_report").serialize(); window.location = path+"?"+ form_params; } - -/*Oqs Js file */ - - -$(document).ready(function(){ - - $(".nav-completed").on("click", function(){ - $("#completed").removeClass('hide') - $(".oqs_append").addClass('hide') - }); - - $(".oqs_click").on("click", function(){ - $(".oqs_click").removeClass('oqs_active'); - $(".queue_station").removeClass('queue_station_box'); - $("#completed").addClass('hide'); - $(".oqs_append").removeClass('hide'); - $(this).addClass('oqs_active'); - $(".queue_station").addClass('queue_station_box'); - var oqs_id = $(this).find(".oqs-id").text(); - var url = 'oqs/get_items/'+oqs_id; - - show_details(url); - - }); //End Click - - function show_details(url){ - var oqs_append = $('.oqs_append'); - oqs_append.empty(); - var filter = $('.filter').text(); - //Start Ajax - $.ajax({ - type: "GET", - url: url, - data: {'filter':filter}, - dataType: "json", - success: function(data) { - for(var field in data) { - var price = parseFloat(data[field].price).toFixed(2); - - if (data[field]["options"] == "[]" || data[field]["options"] == "") { - var options = ""; - }else{ - var options = data.options; - } - - var date = new Date(data[field]["created_at"]); - var show_date = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes(); - - row ='
' - +'
' - +'

' - +''+data[field]["table_type"]+'- ' - +''+ data[field]["zone"] +'' - +''+ data[field]["order_id"] +'- ' - +'

' - - +'

' - +''+ data[field]["item_name"] +'- ' - +''+ data[field]["qty"] +'- ' - +'

' - - +'

'+ options +'

' - - +'

' - +'Order at' - +''+ show_date +' - ' - - +''+ data[field]["item_order_by"] +' ' - +' ' - +'

' - - +' ' - +' ' - +'
' - - +'' - - +'
'; - - - - $('.oqs_append').append(row); - } - - } - }); - //end Ajax - - } - - $(document).on('click', '.queue_station', function(event){ - var orderZone=$(this).children().children().children('.order-zone').text().trim(); - // var orderItem=$(this).children().children().children('.order-item').text(); - var assigned_item_id = $(this).children().find(".assigned-order-item").text(); - var orderQty = $(this).children().children().children('.order-qty').text(); - var orderBy = $(this).children().children().children().children('.order-by').text(); - var orderAt = $(this).children().children().children().children('.order-at').text(); - var orderCustomer = $(this).children().children('.order-customer').text(); - var order_status = $(this).children().children('.order-status').text(); - - $('#order-title').text("ORDER DETAILS - " + orderZone); - $('#order-by').text(orderBy); - $('#order-at').text(orderAt); - $('#order-customer').text(orderCustomer); - $('#order-from').text(orderZone); - // clear order items - $("#oqs-order-details-table").children("tbody").empty(); - // Call get_order_items() for Order Items by dining - $.ajax({ - type: 'GET', - url: '/oqs/' + orderZone, - data: { 'status' : order_status }, - success: function(res){ - for (i = 0; i < res.length; i++) { - var data = JSON.stringify(res[i]); - var parse_data = JSON.parse(data); - - var order_item_row = "" + - "" + parse_data.item_name + "" + - "" + parse_data.qty + "" + - ""; - $("#oqs-order-details-table").children("tbody").append(order_item_row); - } - } - }) - - // $('#order-items').text(orderItem); - // $('#order-qty').text(orderQty); - - $('.queue_station').removeClass('selected-item'); - $(this).addClass('selected-item'); - }); - - $(document).on('click', '.order-item-edit', function(event){ - var _self = $(this); // To know in ajax return - var assigned_item_id=$(this).attr('id').substr(5); - window.location.href = '/oqs/'+ assigned_item_id + "/edit" - }); - - // complete for queue item - - $(document).on('click', '.order-complete', function(event){ - //e.preventDefault(); - var _self = $(this); // To know in ajax return - var assigned_item_id=$(this).attr('id').substr(15); - var params = { 'id':assigned_item_id }; - - // Call update_delivery_status() for changed delivery and move to delivery - $.ajax({ - type: 'POST', - url: '/oqs/update_delivery', - data: params, - dataType: 'json', - success: function(data){ - for (i = 0; i < data.length; i++) { - var queue_station = $('#assigned_queue_' + data[i]).parent().parent(".queue_station"); - var station = queue_station.parent().parent().attr('id'); - - // Remove a queue card from current station - queue_station.remove(); - - // Remove a queue card from current station - queue_station.children('.card-footer').remove(); - - // Add removed queue card from station to completed - $("#completed").children('.card-columns').append(queue_station); - - // update queue item count in each station - var station_count=parseInt($("#"+station+"_count").text()) - 1; - $("#"+station+"_count").text(station_count); - } - - // update queue item count in completed station - $("#completed_count").text(parseInt($("#completed_count").text()) + data.length); - - alert("updated!"); - // Page reload - location.reload(); - } - }); - }); - - // Print Order Item - $(document).on('click', '#print_order_item', function(event){ - var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text(); - var options = $('.selected-item').children('.card-block').find('.item-options').text(); - var params = { 'options':options }; - - $.ajax({ - type: 'GET', - url: '/oqs/print/print/'+assigned_item_id, - success: function(data){ } - }); - }); - - // Print Order Summary - // $('#print_order_summary').on('click',function(){ - $(document).on('click', '#print_order_summary', function(event){ - var table_name=$('.selected-item').children().children().children('.order-zone').text().trim(); - var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); - var params = { 'table_name':table_name }; - $.ajax({ - type: 'GET', - url: '/oqs/print/print_order_summary/'+assigned_item_id, - data: params, - success: function(data){ } - }); - }); - - // Qty update for OQS Edit Controller - $('#qty-update').on('click', function(){ - var qty_weight = $("input[name='qty_weight']").val(); - var remarks = $("textarea[name='remarks']").val(); - var order_items_id = $(this).attr('data-id'); - var params = { 'order_items_id': order_items_id, 'qty_weight': qty_weight, 'remarks': remarks } - $.ajax({ - type: 'POST', - url: '/oqs/' + order_items_id, - data: params, - success: function(result){ - alert("Updated!"); - window.location.href = '/oqs'; - } - }); - }); - -}); - - - diff --git a/app/assets/javascripts/channels/order_queue_station.js b/app/assets/javascripts/channels/order_queue_station.js index 11f21727..4e169f19 100755 --- a/app/assets/javascripts/channels/order_queue_station.js +++ b/app/assets/javascripts/channels/order_queue_station.js @@ -34,7 +34,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann if (oqs_id == items[field]["order_queue_station_id"]) { - row ='
' + row ='
' +'' +'
' @@ -75,11 +75,9 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann var $divs = $("div.queue_station"); var SortListDivs = $divs.sort(function (a, b) { - first = $(a).attr('data-date'); - next = $(b).attr('data-date'); - console.log(first); - console.log("hi") - console.log(next); + 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); diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 8e92f52d..13e56c77 100755 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -44,9 +44,9 @@ class Oqs::HomeController < BaseOqsController # Get Order items def get_order_items items = [] - table_name = params[:table_id] + order_no = params[:order_no] status = params[:status] - dining = DiningFacility.find_by_name(table_name); + # dining = DiningFacility.find_by_name(table_name); # oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id) # if status == "" # AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi| @@ -60,22 +60,18 @@ class Oqs::HomeController < BaseOqsController # end # end - booking = Booking.find_by_dining_facility_id(dining.id) - BookingOrder.where("booking_id='#{ booking.booking_id }'").find_each do |bo| - order=Order.find(bo.order_id) - order.order_items.each do |oi| - items.push(oi) - end - end - - # booking_id = dining.get_new_booking - # BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo| - # order=Order.find(bo.order_id); - # order.order_items.each do |oi| - # items.push(oi) - # end + # booking = Booking.find_by_dining_facility_id(dining.id) + # BookingOrder.where("booking_id='#{ booking.booking_id }'").find_each do |bo| + # order=Order.find(bo.order_id) + # order.order_items.each do |oi| + # items.push(oi) + # end # end + OrderItem.where("order_id='#{ order_no }'").find_each do |oi| + items.push(oi) + end + render :json => items.to_json end @@ -132,7 +128,7 @@ class Oqs::HomeController < BaseOqsController .where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ") query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) .order("assigned_order_items.assigned_order_item_id desc") - .group("assigned_order_items.assigned_order_item_id") + .group("odt.order_items_id") end diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index 9551ff0b..e3001098 100755 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -40,13 +40,16 @@ class Oqs::PrintController < ApplicationController print_status = assigned_item.print_status == true ? " (Re-Print)" : "" # get dining - dining = DiningFacility.find_by_name(table_name); - booking = Booking.find_by_dining_facility_id(dining.id) + # dining = DiningFacility.find_by_name(table_name); + # booking = Booking.find_by_dining_facility_id(dining.id) + + # Get Booking ID + booking_id = BookingOrder.where("order_id='#{assigned_item.order_id}'").pluck(:booking_id)[0] # print when complete click print_settings = PrintSetting.find_by_unique_code(unique_code) order_queue_printer = Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_booking_summary(print_settings,oqs, booking.booking_id, print_status) + order_queue_printer.print_booking_summary(print_settings,oqs, booking_id, print_status) # update print status for completed same order items assigned_items.each do |ai| diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index f3bd218f..b054f77d 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -40,10 +40,10 @@ class Origami::DiscountsController < BaseOrigamiController sale_item.product_alt_name = "" sale_item.remark = "Discount" - sale_item.qty = 1 - sale_item.unit_price = di["price"] + sale_item.qty = -1 + sale_item.unit_price = di["price"] * -1 sale_item.taxable_price = di["price"] - sale_item.is_taxable = 0 + sale_item.is_taxable = 1 sale_item.account_id = origin_sale_item.account_id sale_item.price = di["price"] diff --git a/app/controllers/origami/other_charges_controller.rb b/app/controllers/origami/other_charges_controller.rb index c7e20ba6..ae3d1073 100755 --- a/app/controllers/origami/other_charges_controller.rb +++ b/app/controllers/origami/other_charges_controller.rb @@ -36,11 +36,11 @@ class Origami::OtherChargesController < BaseOrigamiController sale_item.qty = 1 sale_item.unit_price = di["price"] - sale_item.taxable_price = 0 - sale_item.is_taxable = 0 + sale_item.taxable_price = di["price"] * 1 + sale_item.is_taxable = 1 sale_item.account_id = 0 - sale_item.price = di["price"] + sale_item.price = di["price"] * 1 sale_item.save action_by = current_user.id diff --git a/app/controllers/settings/dining_charges_controller.rb b/app/controllers/settings/dining_charges_controller.rb index 72a59ce3..750b5856 100755 --- a/app/controllers/settings/dining_charges_controller.rb +++ b/app/controllers/settings/dining_charges_controller.rb @@ -57,11 +57,15 @@ class Settings::DiningChargesController < ApplicationController @dining_charge.minimum_free_time = DateTime.parse(dining_charge_params["minimum_free_time"]) @dining_charge.charge_block = DateTime.parse(dining_charge_params["charge_block"]) @dining_charge.time_rounding_block = DateTime.parse(dining_charge_params["time_rounding_block"]) + if @dining_charge.update(dining_charge_params) + @dining_charge.minimum_free_time = DateTime.parse(dining_charge_params["minimum_free_time"]) + @dining_charge.charge_block = DateTime.parse(dining_charge_params["charge_block"]) + @dining_charge.time_rounding_block = DateTime.parse(dining_charge_params["time_rounding_block"]) # @dining_charge.minimum_free_time = @dining_charge.minimum_free_time.to_datetime.advance(hours: +6, minutes: +30) # @dining_charge.charge_block = @dining_charge.charge_block.to_datetime.advance(hours: +6, minutes: +30) # @dining_charge.time_rounding_block = @dining_charge.time_rounding_block.to_datetime.advance(hours: +6, minutes: +30) - # @dining_charge.save + @dining_charge.save if @table format.html { redirect_to settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' } else diff --git a/app/models/dining_charge.rb b/app/models/dining_charge.rb index 555ba168..22c6efde 100755 --- a/app/models/dining_charge.rb +++ b/app/models/dining_charge.rb @@ -4,16 +4,16 @@ class DiningCharge < ApplicationRecord def self.amount_calculate(dining_charges_obj, checkin , checkout) # note :: the first Charge Block will cost all, the Time rounding block will included in 2nd Charge Block - if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil? + if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil? block_count = 0 price = 0 minutes = DiningCharge.time_diff(checkout, checkin) - free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.utc.localtime.strftime('%H:%M')) + free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.utc.strftime('%H:%M')) dining_minutes = minutes #- free_time # stayminutes - free minutes if dining_minutes <= free_time price = 0 else - charge_type = dining_charges_obj.charge_type + charge_type = dining_charges_obj.charge_type if charge_type == 'hr' block_count, price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr') elsif charge_type == 'day' @@ -30,7 +30,7 @@ class DiningCharge < ApplicationRecord # dining charges calculate def self.charges(chargesObj, dining_minutes, type) solid_price = 0 - charge_block = DiningCharge.convert_to_minutes(chargesObj.charge_block.utc.localtime.strftime('%H:%M')) + charge_block = DiningCharge.convert_to_minutes(chargesObj.charge_block.utc.strftime('%H:%M')) result = dining_minutes / charge_block if result.to_i < 1 @@ -40,7 +40,7 @@ class DiningCharge < ApplicationRecord solid_price = result * chargesObj.unit_price remain_value = dining_minutes % charge_block - rounding_time = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.localtime.strftime('%H:%M')) + rounding_time = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.strftime('%H:%M')) roundingblock = remain_value / rounding_time if roundingblock.to_i < 1 # no time rounding block diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index d4492739..a003cbce 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -98,7 +98,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # For Print Order Summary else - filename = "tmp/booking_summary.pdf" + filename = "tmp/booking_summary.pdf" pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name) pdf.render_file filename if oqs.print_copy diff --git a/app/models/promotion.rb b/app/models/promotion.rb index 2f7774d3..028847f3 100755 --- a/app/models/promotion.rb +++ b/app/models/promotion.rb @@ -164,7 +164,7 @@ class Promotion < ApplicationRecord sale_item.qty = qty * (-1) sale_item.unit_price = item_price # * (-1) - sale_item.taxable_price = qty * item_price # * (-1) + sale_item.taxable_price = (qty * item_price) * (-1) sale_item.price = qty * item_price * (-1) sale_item.is_taxable = 1 diff --git a/app/models/sale.rb b/app/models/sale.rb index eb776ed1..7cc0b32e 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -48,7 +48,7 @@ class Sale < ApplicationRecord # dining charges charges = DiningCharge.where('dining_facility_id=?',booking.dining_facility_id).take - if !charges.nil? + 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) diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 189be0f6..7f7f2d24 100755 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -69,7 +69,7 @@ <% @queue_completed_item.each do |qid| %> -
+
<%= qid.type %>-<%= qid.zone %> diff --git a/app/views/origami/other_charges/index.html.erb b/app/views/origami/other_charges/index.html.erb index 456d678c..5b677d3e 100755 --- a/app/views/origami/other_charges/index.html.erb +++ b/app/views/origami/other_charges/index.html.erb @@ -193,7 +193,7 @@
- +
diff --git a/app/views/settings/dining_charges/_form.html.erb b/app/views/settings/dining_charges/_form.html.erb index 30d59290..a64ceb22 100755 --- a/app/views/settings/dining_charges/_form.html.erb +++ b/app/views/settings/dining_charges/_form.html.erb @@ -15,7 +15,7 @@ access_time <% if !@dining_charge.minimum_free_time.nil?%> - + <% else %> <% end %> @@ -28,7 +28,7 @@ access_time <% if !@dining_charge.charge_block.nil?%> - + <% else %> <% end %> @@ -43,7 +43,7 @@ access_time <% if !@dining_charge.time_rounding_block.nil?%> - + <% else %> <% end %> diff --git a/config/puma.rb b/config/puma.rb index 842d1918..c8e0145e 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,10 +1,48 @@ -application_path = Rails.root #ENV.fetch("SX_PATH") {'/home/superuser/Application/production/sxrestaurant'} -directory application_path +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum, this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests, default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# environment ENV.fetch("RAILS_ENV") { "development" } -daemonize true -pidfile "#{application_path}/tmp/puma/pid" -state_path "#{application_path}/tmp/puma/state" -stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -port ENV.fetch("PORT") { 62158 } -workers 2 -preload_app! + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. If you use this option +# you need to make sure to reconnect any threads in the `on_worker_boot` +# block. +# +# preload_app! + +# The code in the `on_worker_boot` will be called if you are using +# clustered mode by specifying a number of `workers`. After each worker +# process is booted this block will be run, if you are using `preload_app!` +# option you will want to use this block to reconnect to any threads +# or connections that may have been created at application boot, Ruby +# cannot share connections between processes. +# +# on_worker_boot do +# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) +# end + +# Allow puma to be restarted by `rails restart` command. + +plugin :tmp_restart diff --git a/config/puma.rb.production b/config/puma.rb.production index 04ae9ee4..4953a9b0 100755 --- a/config/puma.rb.production +++ b/config/puma.rb.production @@ -1,9 +1,11 @@ application_path = '/home/superuser/Application/production/sxrestaurant' directory application_path -environment 'production' +environment ENV.fetch("RAILS_ENV") { "development" } daemonize true -pidfile "#{application_path}/tmp/pids/puma.pid" -state_path "#{application_path}/tmp/pids/puma.state" +pidfile "#{application_path}/tmp/puma/pid" +state_path "#{application_path}/tmp/puma/state" stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -bind 'tcp://0.0.0.0:9292' +port ENV.fetch("PORT") { 62158 } workers 2 +preload_app! + diff --git a/config/routes.rb b/config/routes.rb index 8b1aee18..1afa1ea8 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -230,7 +230,7 @@ scope "(:locale)", locale: /en|mm/ do #--------- Order Queue Station ------------# namespace :oqs do root "home#index" - get "/:table_id", to: "home#get_order_items" + get "/:order_no", to: "home#get_order_items" post 'update_delivery', to: "home#update_delivery_status"