From 1607cb70d349a27cba3e33652a3a22fc95d0a37e Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Mon, 2 Dec 2019 17:19:28 +0630 Subject: [PATCH 1/5] Single database for multiple shops Use ActsAsTenant as Multi-tenancy for shops See below files: - app/controllers/concern/multi_tenancy.rb - app/models/application_record.rb - app/models/shop.rb An initializer can be created to control option in ActsAsTenant. config/initializers/acts_as_tenant.rb require 'acts_as_tenant/sidekiq' ActsAsTenant.configure do |config| config.require_tenant = false # true end more detail: https://github.com/ErwinM/acts_as_tenant --- Gemfile | 3 +++ Gemfile.lock | 8 ++++++-- app/controllers/api/api_controller.rb | 2 +- app/controllers/api/bill_controller.rb | 2 +- .../api/call_waiters_controller.rb | 2 +- .../order_reservation_controller.rb | 2 +- app/controllers/api/orders_controller.rb | 2 +- .../api/payment/mobilepayment_controller.rb | 2 +- .../api/sound_effect_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- app/controllers/base_controller.rb | 3 ++- app/controllers/base_crm_controller.rb | 2 +- app/controllers/base_inventory_controller.rb | 2 +- app/controllers/base_oqs_controller.rb | 2 +- app/controllers/base_origami_controller.rb | 2 +- app/controllers/base_report_controller.rb | 4 ++-- app/controllers/base_waiter_controller.rb | 2 +- .../concerns/login_verification.rb | 12 +++++------ app/controllers/concerns/multi_tenancy.rb | 20 +++++++++++++++++++ app/controllers/crm/customers_controller.rb | 2 +- app/controllers/home_controller.rb | 2 +- .../inventory/inventory_controller.rb | 2 +- .../inventory_definitions_controller.rb | 2 +- .../inventory/stock_check_items_controller.rb | 2 +- .../inventory/stock_checks_controller.rb | 4 ++-- .../inventory/stock_journals_controller.rb | 2 +- app/controllers/oqs/edit_controller.rb | 2 +- app/controllers/origami/alipay_controller.rb | 6 +++--- .../origami/credit_payments_controller.rb | 4 ++-- .../origami/credit_sales_controller.rb | 12 +++++------ .../origami/customers_controller.rb | 2 +- .../origami/dashboard_controller.rb | 2 +- app/controllers/origami/dinga_controller.rb | 4 ++-- .../origami/gift_voucher_controller.rb | 6 +++--- app/controllers/origami/home_controller.rb | 16 +++++++-------- app/controllers/origami/jcb_controller.rb | 6 +++--- .../origami/junction_pay_controller.rb | 4 ++-- app/controllers/origami/master_controller.rb | 6 +++--- .../origami/movetable_controller.rb | 2 +- app/controllers/origami/mpu_controller.rb | 6 +++--- .../origami/order_reservation_controller.rb | 2 +- app/controllers/origami/orders_controller.rb | 4 ++-- app/controllers/origami/paymal_controller.rb | 4 ++-- .../origami/payments_controller.rb | 8 ++++---- .../origami/paypar_payments_controller.rb | 2 +- .../origami/redeem_payments_controller.rb | 2 +- .../origami/request_bills_controller.rb | 2 +- app/controllers/origami/rooms_controller.rb | 10 +++++----- app/controllers/origami/sales_controller.rb | 4 ++-- .../origami/second_display_controller.rb | 2 +- .../origami/split_bill_controller.rb | 2 +- .../origami/table_invoices_controller.rb | 4 ++-- .../origami/unionpay_controller.rb | 6 +++--- app/controllers/origami/visa_controller.rb | 6 +++--- app/controllers/origami/void_controller.rb | 2 +- app/controllers/origami/voucher_controller.rb | 2 +- .../origami/waste_spoile_controller.rb | 2 +- .../reports/product_sale_controller.rb | 2 +- .../reports/receipt_no_controller.rb | 2 +- app/controllers/settings/shops_controller.rb | 4 ++-- .../transactions/sales_controller.rb | 2 +- app/models/application_record.rb | 11 ++++++++++ app/models/kbz_pay.rb | 14 ++++++------- app/models/menu.rb | 2 +- app/models/order_queue_station.rb | 2 +- app/models/order_reservation.rb | 10 +++++----- app/models/printer/order_queue_printer.rb | 6 +++--- app/models/room.rb | 1 - app/models/sale.rb | 14 ++++++------- app/models/shop.rb | 10 +++++++--- app/uploaders/commissioner_image_uploader.rb | 12 +++++------ app/uploaders/customer_image_uploader.rb | 12 +++++------ app/uploaders/employee_image_uploader.rb | 12 +++++------ app/uploaders/menu_item_image_uploader.rb | 12 +++++------ app/uploaders/product_image_uploader.rb | 8 ++++---- app/uploaders/shop_image_uploader.rb | 12 +++++------ .../origami/dashboard/_menu.json.jbuilder | 2 +- lib/tasks/receipt.rake | 4 ++-- 78 files changed, 215 insertions(+), 173 deletions(-) create mode 100644 app/controllers/concerns/multi_tenancy.rb diff --git a/Gemfile b/Gemfile index e0d9e933..ba568b94 100644 --- a/Gemfile +++ b/Gemfile @@ -41,6 +41,9 @@ gem 'material_icons' gem 'font-awesome-rails', '~> 4.7', '>= 4.7.0.2' gem 'rack-cors' +# Multi-tenancy for shops +gem 'acts_as_tenant' + # image upload gem 'carrierwave', '~> 1.0' gem 'mini_magick' diff --git a/Gemfile.lock b/Gemfile.lock index 633b5965..bbcc1085 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -46,6 +46,9 @@ GEM i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) + acts_as_tenant (0.4.4) + rails (>= 4.0) + request_store (>= 1.0.5) aescrypt (1.0.0) airbrussh (1.4.0) sshkit (>= 1.6.1, != 1.7.0) @@ -219,6 +222,8 @@ GEM rb-inotify (0.10.0) ffi (~> 1.0) redis (3.3.5) + request_store (1.4.1) + rack (>= 1.4) roo (1.13.2) nokogiri rubyzip @@ -315,6 +320,7 @@ PLATFORMS ruby DEPENDENCIES + acts_as_tenant aescrypt axlsx (= 2.0.1) axlsx_rails @@ -374,10 +380,8 @@ DEPENDENCIES web-console (>= 3.3.0) whenever - RUBY VERSION ruby 2.4.1p111 - BUNDLED WITH 2.0.2 diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb index 0e8ea909..8a84cfa1 100755 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -1,5 +1,5 @@ class Api::ApiController < ActionController::API - include TokenVerification + include TokenVerification, MultiTenancy include ActionController::MimeResponds # before_action :lookup_domain diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 7a00666a..77fc9204 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -106,7 +106,7 @@ class Api::BillController < Api::ApiController # unique_code = "ReceiptBillPdf" # #shop detail - # shop_details = Shop.find(1) + # shop_details = Shop.current_shop # customer= Customer.find(@sale_data.customer_id) # # get member information diff --git a/app/controllers/api/call_waiters_controller.rb b/app/controllers/api/call_waiters_controller.rb index 066fa30c..5beba9a6 100644 --- a/app/controllers/api/call_waiters_controller.rb +++ b/app/controllers/api/call_waiters_controller.rb @@ -23,7 +23,7 @@ class Api::CallWaitersController < ActionController::API end ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time,from: from, shift_ids: shift_ids # get printer info - @shop = Shop.first + @shop = Shop.current_shop unique_code = "CallWaiterPdf" print_settings = PrintSetting.find_by_unique_code(unique_code) printer = Printer::ReceiptPrinter.new(print_settings) diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb index 32c2192e..cfec740d 100644 --- a/app/controllers/api/order_reserve/order_reservation_controller.rb +++ b/app/controllers/api/order_reserve/order_reservation_controller.rb @@ -70,7 +70,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation) if !order_reservation_id.nil? && flag - shop = Shop.find_by_id(1) + shop = Shop.current_shop if !shop.nil? shop_code = shop.shop_code order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio") diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index bd2c3e18..a1e9ad9e 100755 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -46,7 +46,7 @@ class Api::OrdersController < Api::ApiController @tax_profile = TaxProfile.where("lower(group_type)='cashier'") # end - @shop = Shop.first + @shop = Shop.current_shop puts "Hello world" puts @shop.to_json return @shop.to_json diff --git a/app/controllers/api/payment/mobilepayment_controller.rb b/app/controllers/api/payment/mobilepayment_controller.rb index 220cbbeb..53daa790 100644 --- a/app/controllers/api/payment/mobilepayment_controller.rb +++ b/app/controllers/api/payment/mobilepayment_controller.rb @@ -14,7 +14,7 @@ class Api::Payment::MobilepaymentController < Api::ApiController saleObj = Sale.find(sale_id) sale_items = SaleItem.get_all_sale_items(sale_id) - shop_detail = Shop.first + shop_detail = Shop.current_shop # rounding adjustment if !path.include? ("credit_payment") diff --git a/app/controllers/api/sound_effect_controller.rb b/app/controllers/api/sound_effect_controller.rb index 97dc3db5..f3126ca2 100644 --- a/app/controllers/api/sound_effect_controller.rb +++ b/app/controllers/api/sound_effect_controller.rb @@ -2,7 +2,7 @@ class Api::SoundEffectController < Api::ApiController #sound effect / alarm api for doemal side calling def sound_effect - shop = Shop.find_by_id(1) + shop = Shop.current_shop if !shop.nil? shop_code = shop.shop_code order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio") diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 66f20c55..81b4835d 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,5 @@ class ApplicationController < ActionController::Base - include LoginVerification + include LoginVerification, MultiTenancy #before_action :check_installation protect_from_forgery with: :exception diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb index 1bf5b4d4..1bb0421e 100755 --- a/app/controllers/base_controller.rb +++ b/app/controllers/base_controller.rb @@ -1,5 +1,6 @@ class BaseController < ActionController::Base + include MultiTenancy layout "installation" protect_from_forgery with: :exception - + end diff --git a/app/controllers/base_crm_controller.rb b/app/controllers/base_crm_controller.rb index 00b5cf98..08bc8138 100755 --- a/app/controllers/base_crm_controller.rb +++ b/app/controllers/base_crm_controller.rb @@ -1,5 +1,5 @@ class BaseCrmController < ActionController::Base - include LoginVerification + include LoginVerification, layout "CRM" before_action :check_user diff --git a/app/controllers/base_inventory_controller.rb b/app/controllers/base_inventory_controller.rb index 8ee82777..bd455c33 100755 --- a/app/controllers/base_inventory_controller.rb +++ b/app/controllers/base_inventory_controller.rb @@ -1,5 +1,5 @@ class BaseInventoryController < ActionController::Base - include LoginVerification + include LoginVerification, MultiTenancy layout "inventory" before_action :check_user diff --git a/app/controllers/base_oqs_controller.rb b/app/controllers/base_oqs_controller.rb index 9b337b69..6e6a9c0f 100755 --- a/app/controllers/base_oqs_controller.rb +++ b/app/controllers/base_oqs_controller.rb @@ -1,5 +1,5 @@ class BaseOqsController < ActionController::Base - include LoginVerification + include LoginVerification, MultiTenancy layout "OQS" before_action :check_user diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index 6940a129..e9cddf05 100755 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -1,5 +1,5 @@ class BaseOrigamiController < ActionController::Base - include LoginVerification + include LoginVerification, MultiTenancy layout "origami" before_action :check_user diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index 691ece34..b3d1d23a 100755 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -1,5 +1,5 @@ class BaseReportController < ActionController::Base - include LoginVerification + include LoginVerification, MultiTenancy layout "application" before_action :check_user @@ -69,7 +69,7 @@ class BaseReportController < ActionController::Base from = from.beginning_of_day to = to.end_of_day - + return from, to end diff --git a/app/controllers/base_waiter_controller.rb b/app/controllers/base_waiter_controller.rb index 580de0f9..b1d2056c 100755 --- a/app/controllers/base_waiter_controller.rb +++ b/app/controllers/base_waiter_controller.rb @@ -1,5 +1,5 @@ class BaseWaiterController < ActionController::Base - include LoginVerification + include LoginVerification, MultiTenancy layout "waiter" before_action :check_user diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb index 8eb719cb..b1102171 100755 --- a/app/controllers/concerns/login_verification.rb +++ b/app/controllers/concerns/login_verification.rb @@ -3,7 +3,7 @@ module LoginVerification included do before_action :authenticate_session_token - helper_method :current_company,:current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail + helper_method :current_company, :current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail end #this is base api base controller to need to inherit. @@ -19,7 +19,7 @@ module LoginVerification def current_shop begin - return Shop.first + return Shop.current_shop rescue return nil end @@ -41,7 +41,7 @@ module LoginVerification #Shop Name in Navbor def shop_detail - @shop = Shop.first + @shop = current_shop end #check order reservation used @@ -78,11 +78,11 @@ module LoginVerification protected # Authenticate the user with token based authentication - def authenticate - authenticate_session_token || render_unauthorized + def authenticate + authenticate_session_token || render_unauthorized end - def authenticate_session_token + def authenticate_session_token token = session[:session_token] if (token) #@current_user = User.find_by(api_key: token) diff --git a/app/controllers/concerns/multi_tenancy.rb b/app/controllers/concerns/multi_tenancy.rb new file mode 100644 index 00000000..5009e094 --- /dev/null +++ b/app/controllers/concerns/multi_tenancy.rb @@ -0,0 +1,20 @@ +module MultiTenancy + extend ActiveSupport::Concern + + included do + set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter + before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action + helper_method :current_shop if respond_to? :helper_method + end + + private + def find_shop_by_subdomain_or_frist + if request.subdomain.present? + shop_code = request.subdomain.partition('-').last + shop = Shop.find_by(shop_code: shop_code) + else + shop = Shop.first + end + set_current_tenant(shop) + end +end diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 2f846601..023b453c 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -82,7 +82,7 @@ class Crm::CustomersController < BaseCrmController @membership_types = Lookup.collection_of("member_group_type") # @taxes = TaxProfile.where(:group_type => 'cashier') - @taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") + @taxes = TaxProfile.unscope(:order).select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") .order("group_type ASC,order_by ASC") @filter = filter diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index a82a6483..18928fc3 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -91,7 +91,7 @@ class HomeController < ApplicationController def dashboard @from, @to = get_date_range_from_params - @shop = Shop.first + @shop = Shop.current_shop @orders = Sale.receipt_date_between(@from, @to).where("payment_status = 'new' and sale_status = 'bill'") @sales = Sale.receipt_date_between(@from, @to).completed diff --git a/app/controllers/inventory/inventory_controller.rb b/app/controllers/inventory/inventory_controller.rb index a0324b15..d91e4176 100755 --- a/app/controllers/inventory/inventory_controller.rb +++ b/app/controllers/inventory/inventory_controller.rb @@ -26,6 +26,6 @@ class Inventory::InventoryController < BaseInventoryController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/inventory/inventory_definitions_controller.rb b/app/controllers/inventory/inventory_definitions_controller.rb index 01ca52b3..fca0bb07 100755 --- a/app/controllers/inventory/inventory_definitions_controller.rb +++ b/app/controllers/inventory/inventory_definitions_controller.rb @@ -106,7 +106,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end private diff --git a/app/controllers/inventory/stock_check_items_controller.rb b/app/controllers/inventory/stock_check_items_controller.rb index 7a37f789..98fb0116 100755 --- a/app/controllers/inventory/stock_check_items_controller.rb +++ b/app/controllers/inventory/stock_check_items_controller.rb @@ -64,7 +64,7 @@ class Inventory::StockCheckItemsController < BaseInventoryController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end private diff --git a/app/controllers/inventory/stock_checks_controller.rb b/app/controllers/inventory/stock_checks_controller.rb index b7f7369d..05f7c70f 100755 --- a/app/controllers/inventory/stock_checks_controller.rb +++ b/app/controllers/inventory/stock_checks_controller.rb @@ -41,7 +41,7 @@ class Inventory::StockChecksController < BaseInventoryController member_info = nil unique_code = 'StockCheckPdf' - shop_details = current_shop + shop_details = Shop.current_shop checker = Employee.find(stockcheck.check_by) print_settings = PrintSetting.find_by_unique_code(unique_code) if !print_settings.nil? @@ -66,7 +66,7 @@ class Inventory::StockChecksController < BaseInventoryController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = current_shop + @shop = Shop.current_shop end # before_action :set_stock_check, only: [:show, :edit, :update, :destroy] diff --git a/app/controllers/inventory/stock_journals_controller.rb b/app/controllers/inventory/stock_journals_controller.rb index 11db2efd..9a737da0 100755 --- a/app/controllers/inventory/stock_journals_controller.rb +++ b/app/controllers/inventory/stock_journals_controller.rb @@ -64,7 +64,7 @@ class StockJournalsController < ApplicationController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end private diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb index c6e130ec..e2499fbb 100644 --- a/app/controllers/oqs/edit_controller.rb +++ b/app/controllers/oqs/edit_controller.rb @@ -85,6 +85,6 @@ class Oqs::EditController < BaseOqsController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/alipay_controller.rb b/app/controllers/origami/alipay_controller.rb index 8c5f4884..3578724f 100644 --- a/app/controllers/origami/alipay_controller.rb +++ b/app/controllers/origami/alipay_controller.rb @@ -11,7 +11,7 @@ class Origami::AlipayController < BaseOrigamiController end total = 0 @alipaycount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_alipay = 0 @member_discount = 0 @@ -64,7 +64,7 @@ class Origami::AlipayController < BaseOrigamiController ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -88,6 +88,6 @@ class Origami::AlipayController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/credit_payments_controller.rb b/app/controllers/origami/credit_payments_controller.rb index 05faf4f7..3e9f2bd3 100755 --- a/app/controllers/origami/credit_payments_controller.rb +++ b/app/controllers/origami/credit_payments_controller.rb @@ -9,7 +9,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController @creditcount = 0 others = 0 - @shop = Shop.first + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else @@ -32,7 +32,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController sale_id = params[:sale_id] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj diff --git a/app/controllers/origami/credit_sales_controller.rb b/app/controllers/origami/credit_sales_controller.rb index 8f43edda..587b22dd 100644 --- a/app/controllers/origami/credit_sales_controller.rb +++ b/app/controllers/origami/credit_sales_controller.rb @@ -3,11 +3,11 @@ class Origami::CreditSalesController < BaseOrigamiController @cashier_type = 'cashier' @webview = false if check_mobile - @webview = true + @webview = true end - - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @@ -15,7 +15,7 @@ class Origami::CreditSalesController < BaseOrigamiController @sale = Sale.find_by_sale_id(params[:sale_id]) @sale_payment = SalePayment.select("SUM(payment_amount) as payment_amount") .where("sale_id = ? and payment_method=?", @sale.sale_id, "creditnote") - + @sale_taxes = [] sale_taxes = SaleTax.where("sale_id = ?", @sale.sale_id) if !sale_taxes.empty? @@ -24,5 +24,5 @@ class Origami::CreditSalesController < BaseOrigamiController end end end - + end diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 97f35339..b77137a9 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -87,7 +87,7 @@ class Origami::CustomersController < BaseOrigamiController @count_customer = Customer.count_customer # @taxes = TaxProfile.where(:group_type => 'cashier') - @taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") + @taxes = TaxProfile.unscope(:order).select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") .order("group_type ASC,order_by ASC") # if flash["errors"] # @crm_customer.valid? diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index 43c79179..4ff6e8b3 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -1,7 +1,7 @@ class Origami::DashboardController < BaseOrigamiController def index - @shop = Shop.first + @shop = Shop.current_shop @display_type = Lookup.find_by_lookup_type("display_type") @sale_data = Array.new diff --git a/app/controllers/origami/dinga_controller.rb b/app/controllers/origami/dinga_controller.rb index 01e35004..9754b81d 100644 --- a/app/controllers/origami/dinga_controller.rb +++ b/app/controllers/origami/dinga_controller.rb @@ -6,7 +6,7 @@ class Origami::DingaController < BaseOrigamiController @membership_rebate_balance=0 @sale_data = Sale.find_by_sale_id(@sale_id) @receipt_no = @sale_data.receipt_no - @shop = Shop.first + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(@sale_data.grand_total) else @@ -77,7 +77,7 @@ def create account_no = params[:account_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj # new_total = Sale.get_rounding_adjustment(saleObj.grand_total) diff --git a/app/controllers/origami/gift_voucher_controller.rb b/app/controllers/origami/gift_voucher_controller.rb index 572e248e..7ad78065 100644 --- a/app/controllers/origami/gift_voucher_controller.rb +++ b/app/controllers/origami/gift_voucher_controller.rb @@ -6,7 +6,7 @@ class Origami::GiftVoucherController < BaseOrigamiController sale_data = Sale.find_by_sale_id(@sale_id) total = 0 @gift_vouchercount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_gift_voucher = 0 @member_discount = 0 @@ -48,7 +48,7 @@ class Origami::GiftVoucherController < BaseOrigamiController ref_no = params[:reference_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -66,6 +66,6 @@ class Origami::GiftVoucherController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index fe074210..30a6ce92 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -4,8 +4,8 @@ class Origami::HomeController < BaseOrigamiController def index @webview = check_mobile - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @@ -21,8 +21,8 @@ class Origami::HomeController < BaseOrigamiController @print_settings = PrintSetting.get_precision_delimiter() @webview = check_mobile - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @@ -126,7 +126,7 @@ class Origami::HomeController < BaseOrigamiController lookup_edit_order = Lookup.collection_of('edit_order') if !lookup_edit_order.empty? lookup_edit_order.each do |edit_order| - if edit_order[0].downcase == "editorderorigami" + if edit_order[0].downcase == "editorderorigami" if edit_order[1] == '0' && (current_login_employee.role == 'cashier' || current_login_employee.role == 'waiter') @edit_order_origami = false end @@ -139,14 +139,14 @@ class Origami::HomeController < BaseOrigamiController lookup_changable_tax = Lookup.collection_of('changable_tax') if !lookup_changable_tax.empty? lookup_changable_tax.each do |changable_tax| - if changable_tax[0].downcase == "change" - if changable_tax[1] == '0' + if changable_tax[0].downcase == "change" + if changable_tax[1] == '0' @changable_tax = false end end end end - + end def check_emp_access_code diff --git a/app/controllers/origami/jcb_controller.rb b/app/controllers/origami/jcb_controller.rb index 1f979adc..3a64b8a0 100644 --- a/app/controllers/origami/jcb_controller.rb +++ b/app/controllers/origami/jcb_controller.rb @@ -12,7 +12,7 @@ class Origami::JcbController < BaseOrigamiController end total = 0 @jcbcount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_jcb = 0 @member_discount= 0 @@ -66,7 +66,7 @@ class Origami::JcbController < BaseOrigamiController ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -89,6 +89,6 @@ class Origami::JcbController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/junction_pay_controller.rb b/app/controllers/origami/junction_pay_controller.rb index c77c2655..1b416c6a 100644 --- a/app/controllers/origami/junction_pay_controller.rb +++ b/app/controllers/origami/junction_pay_controller.rb @@ -11,7 +11,7 @@ class Origami::JunctionPayController < BaseOrigamiController @cashier_id = current_user.emp_id @payment_method_setting_nav = PaymentMethodSetting.all - @shop = Shop.first + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else @@ -52,7 +52,7 @@ class Origami::JunctionPayController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj diff --git a/app/controllers/origami/master_controller.rb b/app/controllers/origami/master_controller.rb index 15edb703..f36b86f0 100644 --- a/app/controllers/origami/master_controller.rb +++ b/app/controllers/origami/master_controller.rb @@ -12,7 +12,7 @@ class Origami::MasterController < BaseOrigamiController end total = 0 @mastercount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_master = 0 @member_discount = 0 @@ -63,7 +63,7 @@ class Origami::MasterController < BaseOrigamiController ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -87,6 +87,6 @@ class Origami::MasterController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb index 41c58941..86680c6e 100755 --- a/app/controllers/origami/movetable_controller.rb +++ b/app/controllers/origami/movetable_controller.rb @@ -105,7 +105,7 @@ class Origami::MovetableController < BaseOrigamiController # @type = (DiningFacility.find(change_to)).type # @moved_by = @current_user.name # @date = DateTime.now - # @shop = Shop.first + # @shop = Shop.current_shop # unique_code = "MoveTablePdf" # pdf_no = PrintSetting.where(:unique_code => unique_code).count # #print_settings = PrintSetting.find_by_unique_code(unique_code) diff --git a/app/controllers/origami/mpu_controller.rb b/app/controllers/origami/mpu_controller.rb index 220219c3..1a7743c1 100644 --- a/app/controllers/origami/mpu_controller.rb +++ b/app/controllers/origami/mpu_controller.rb @@ -11,7 +11,7 @@ class Origami::MpuController < BaseOrigamiController end total = 0 @mpucount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_mpu = 0 @member_discount = 0 @@ -64,7 +64,7 @@ class Origami::MpuController < BaseOrigamiController ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -87,6 +87,6 @@ class Origami::MpuController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb index 3fdeee25..508bf483 100644 --- a/app/controllers/origami/order_reservation_controller.rb +++ b/app/controllers/origami/order_reservation_controller.rb @@ -4,7 +4,7 @@ class Origami::OrderReservationController < BaseOrigamiController @order = OrderReservation.latest_order #.active @count_on_order = OrderReservation.get_count_on_order @count_on_completed = OrderReservation.get_count_on_completed - @shop = Shop.find_by_id(1) + @shop = Shop.current_shop @receipt_bill = check_receipt_bill end diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index 5f34d9a3..2a7c9aa3 100755 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -5,8 +5,8 @@ class Origami::OrdersController < BaseOrigamiController @webview = true end - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @order = Order.find(params[:order_id]) diff --git a/app/controllers/origami/paymal_controller.rb b/app/controllers/origami/paymal_controller.rb index 36c19327..cfabd2b5 100644 --- a/app/controllers/origami/paymal_controller.rb +++ b/app/controllers/origami/paymal_controller.rb @@ -6,7 +6,7 @@ class Origami::PaymalController < BaseOrigamiController @membership_rebate_balance=0 sale_data = Sale.find_by_sale_id(@sale_id) @receipt_no = sale_data.receipt_no - @shop = Shop.first + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else @@ -75,7 +75,7 @@ def create puts params.to_json if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index c6c61602..401e231b 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -59,7 +59,7 @@ class Origami::PaymentsController < BaseOrigamiController end #shop detail - ## shop_detail = Shop.first + ## shop_detail = Shop.current_shop # customer= Customer.where('customer_id=' +.customer_id) customer = Customer.find(sale_data.customer_id) # rounding adjustment @@ -141,7 +141,7 @@ class Origami::PaymentsController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) sale_items = SaleItem.get_all_sale_items(sale_id) - #shop_detail = Shop.first + #shop_detail = Shop.current_shop # rounding adjustment if !path.include? ("credit_payment") if shop_detail.is_rounding_adj @@ -577,7 +577,7 @@ class Origami::PaymentsController < BaseOrigamiController customer= Customer.find(saleObj.customer_id) #shop detail - #shop_detail = Shop.first + #shop_detail = Shop.current_shop # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate @@ -686,7 +686,7 @@ class Origami::PaymentsController < BaseOrigamiController customer= Customer.find(saleObj.customer_id) #shop detail - #shop_detail = Shop.first + #shop_detail = Shop.current_shop printer = PrintSetting.all unique_code="ReceiptBillPdf" diff --git a/app/controllers/origami/paypar_payments_controller.rb b/app/controllers/origami/paypar_payments_controller.rb index fbcd348c..f2fb3c7b 100755 --- a/app/controllers/origami/paypar_payments_controller.rb +++ b/app/controllers/origami/paypar_payments_controller.rb @@ -7,7 +7,7 @@ class Origami::PayparPaymentsController < BaseOrigamiController payment_method = "paypar" if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment if shop_details.is_rounding_adj diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb index c0edf879..0d1836c0 100755 --- a/app/controllers/origami/redeem_payments_controller.rb +++ b/app/controllers/origami/redeem_payments_controller.rb @@ -6,7 +6,7 @@ class Origami::RedeemPaymentsController < BaseOrigamiController @membership_rebate_balance=0 sale_data = Sale.find_by_sale_id(@sale_id) - @shop = Shop.first + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 6d36f319..69a316f5 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -90,7 +90,7 @@ class Origami::RequestBillsController < ApplicationController # Not Use for these printed bill cannot give customer # unique_code = "ReceiptBillPdf" # #shop detail - # shop_details = Shop.find(1) + # shop_details = Shop.current_shop # # customer= Customer.where('customer_id=' +.customer_id) # customer= Customer.find(@sale_data.customer_id) # # get member information diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 80eb5641..c94c5c18 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -1,7 +1,7 @@ class Origami::RoomsController < BaseOrigamiController def index - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @shift = ShiftSale.current_open_shift(current_user.id) @@ -17,8 +17,8 @@ class Origami::RoomsController < BaseOrigamiController @webview = true end - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @@ -29,7 +29,7 @@ class Origami::RoomsController < BaseOrigamiController @status_sale = "" @sale_array = Array.new - @shop = Shop.first + @shop = Shop.current_shop @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb index d2af3258..98bbd288 100755 --- a/app/controllers/origami/sales_controller.rb +++ b/app/controllers/origami/sales_controller.rb @@ -5,8 +5,8 @@ class Origami::SalesController < BaseOrigamiController @webview = true end - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") diff --git a/app/controllers/origami/second_display_controller.rb b/app/controllers/origami/second_display_controller.rb index 21c0674d..392b85e6 100644 --- a/app/controllers/origami/second_display_controller.rb +++ b/app/controllers/origami/second_display_controller.rb @@ -27,7 +27,7 @@ class Origami::SecondDisplayController < BaseOrigamiController #Shop Name in Navbor # helper_method :shop_detail # def shop_detail - # @shop = Shop.first + # @shop = Shop.current_shop # end diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index fb6db35f..12a232a6 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -413,7 +413,7 @@ class Origami::SplitBillController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb index 7082e44c..e3f9f0ab 100755 --- a/app/controllers/origami/table_invoices_controller.rb +++ b/app/controllers/origami/table_invoices_controller.rb @@ -1,7 +1,7 @@ class Origami::TableInvoicesController < BaseOrigamiController def index @table = DiningFacility.find(params[:table_id]) - shop = Shop.first + shop = Shop.current_shop puts "table bookig lenght" @sale_array = Array.new @table.bookings.each do |booking| @@ -34,7 +34,7 @@ class Origami::TableInvoicesController < BaseOrigamiController @table = DiningFacility.find(params[:table_id]) @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all - shop = Shop.first + shop = Shop.current_shop @sale_array = Array.new @table.bookings.each do |booking| if booking.sale_id.nil? diff --git a/app/controllers/origami/unionpay_controller.rb b/app/controllers/origami/unionpay_controller.rb index b351d40a..23587ca0 100644 --- a/app/controllers/origami/unionpay_controller.rb +++ b/app/controllers/origami/unionpay_controller.rb @@ -11,7 +11,7 @@ class Origami::UnionpayController < BaseOrigamiController end total = 0 @unionpaycount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_unionpay = 0 @member_discount = 0 @@ -61,7 +61,7 @@ class Origami::UnionpayController < BaseOrigamiController ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -85,6 +85,6 @@ class Origami::UnionpayController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/visa_controller.rb b/app/controllers/origami/visa_controller.rb index c50339e4..6eb11be5 100644 --- a/app/controllers/origami/visa_controller.rb +++ b/app/controllers/origami/visa_controller.rb @@ -11,7 +11,7 @@ class Origami::VisaController < BaseOrigamiController end total = 0 @visacount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_visa = 0 @member_discount = 0 @@ -61,7 +61,7 @@ class Origami::VisaController < BaseOrigamiController ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -85,6 +85,6 @@ class Origami::VisaController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 5352b7c3..7fb54825 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -116,7 +116,7 @@ class Origami::VoidController < BaseOrigamiController customer= Customer.find(sale.customer_id) #shop detail - shop_details = current_shop + shop_details = Shop.current_shop # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate diff --git a/app/controllers/origami/voucher_controller.rb b/app/controllers/origami/voucher_controller.rb index e512a48b..1b79cb49 100755 --- a/app/controllers/origami/voucher_controller.rb +++ b/app/controllers/origami/voucher_controller.rb @@ -8,7 +8,7 @@ class Origami::VoucherController < BaseOrigamiController @vouchercount = 0 others = 0 - @shop = Shop.first + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb index 6a68a2b9..ba0846ee 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -89,7 +89,7 @@ class Origami::WasteSpoileController < BaseOrigamiController customer= Customer.find(sale.customer_id) #shop detail - shop_details = current_shop + shop_details = Shop.current_shop # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate diff --git a/app/controllers/reports/product_sale_controller.rb b/app/controllers/reports/product_sale_controller.rb index 9791545e..61f17396 100644 --- a/app/controllers/reports/product_sale_controller.rb +++ b/app/controllers/reports/product_sale_controller.rb @@ -22,6 +22,6 @@ class Reports::ProductSaleController < BaseReportController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index eeff4bf0..1136bc31 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -183,7 +183,7 @@ authorize_resource :class => false customer= Customer.find(saleObj.customer_id) #shop detail - #shop_detail = Shop.first + #shop_detail = Shop.current_shop # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate diff --git a/app/controllers/settings/shops_controller.rb b/app/controllers/settings/shops_controller.rb index 598e4f9b..9e902dad 100644 --- a/app/controllers/settings/shops_controller.rb +++ b/app/controllers/settings/shops_controller.rb @@ -59,11 +59,11 @@ class Settings::ShopsController < ApplicationController File.delete(delete_path) end end - save_path = Rails.root.join("public/#{current_shop.shop_code}_#{a.original_filename}") + save_path = Rails.root.join("public/#{Shop.current_shop.shop_code}_#{a.original_filename}") File.open(save_path, 'wb') do |f| f.write a.read end - audio_name = "#{current_shop.shop_code}_#{a.original_filename}" + audio_name = "#{Shop.current_shop.shop_code}_#{a.original_filename}" @settings_shop.display_images.where(:name => "order_audio").destroy_all @display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :name => "order_audio", :image => audio_name) else diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 83efc401..661b42e9 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -346,7 +346,7 @@ class Transactions::SalesController < ApplicationController customer= Customer.find(sale.customer_id) #shop detail - shop_details = Shop.find_by_id(1) + shop_details = Shop.current_shop # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 10a4cba8..590cdf8d 100755 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,14 @@ class ApplicationRecord < ActiveRecord::Base self.abstract_class = true + + def self.inherited(subclass) + super + + return unless subclass.superclass == self + return unless subclass.column_names.include? 'shop_id' + + subclass.class_eval do + acts_as_tenant(:shop) + end + end end diff --git a/app/models/kbz_pay.rb b/app/models/kbz_pay.rb index 5893e048..523a7fc5 100644 --- a/app/models/kbz_pay.rb +++ b/app/models/kbz_pay.rb @@ -3,13 +3,13 @@ class KbzPay KBZ_PAY = 'KBZPay' def self.pay(amount, receipt_no, url, key, app_id, code) - shop = Shop.first + shop = Shop.current_shop prefix = shop.shop_code receipt_no = "#{prefix}#{receipt_no}" datetime = DateTime.now.strftime("%d%m%Y%H%M") kbz_app_id = app_id - kbz_merch_code = code + kbz_merch_code = code kbz_api_key = key kbz_provider_url = "#{url}/precreate" @@ -58,17 +58,17 @@ class KbzPay # Rails.logger.debug result['Response'] return false, result['Response'] end - + end def self.query(receipt_no, current_user, url, key, app_id, code) - shop = Shop.first + shop = Shop.current_shop prefix = shop.shop_code receipt_no = "#{prefix}#{receipt_no}" amount = 0 datetime = DateTime.now.strftime("%d%m%Y%H%M") kbz_app_id = app_id - kbz_merch_code = code + kbz_merch_code = code kbz_api_key = key kbz_provider_url = "#{url}/queryorder" @@ -122,7 +122,7 @@ class KbzPay # return true, "successfully paid by KBZ PAY" elsif result['Response']['trade_status'] == "PAY_FAILED" - + # return false, "pay failed by KBZ PAY" elsif result['Response']['trade_status'] == "WAIT_PAY" # return false , "Waiting to pay by KBZ PAY" @@ -135,4 +135,4 @@ class KbzPay return amount end -end \ No newline at end of file +end diff --git a/app/models/menu.rb b/app/models/menu.rb index a825cc7b..1dd0aaed 100755 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -141,7 +141,7 @@ class Menu < ApplicationRecord end else # Menu by Menu Import - @shop = Shop.first + @shop = Shop.current_shop shop_code = "" if !@shop.nil? if @shop.shop_code diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 147ebdc4..6d8830f8 100755 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -297,7 +297,7 @@ class OrderQueueStation < ApplicationRecord @type = (DiningFacility.find(change_to)).type @moved_by = current_user @date = DateTime.now - @shop = Shop.first + @shop = Shop.current_shop unique_code = "MoveTablePdf" # pdf_no = PrintSetting.where(:unique_code => unique_code).count print_settings = PrintSetting.find_by_unique_code(unique_code) diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index 8de88ee2..60c33d2e 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -157,7 +157,7 @@ class OrderReservation < ApplicationRecord def self.update_doemal_payment(order,current_user,receipt_bill) if(Sale.exists?(order.sale_id)) saleObj = Sale.find(order.sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment if shop_details.is_rounding_adj a = saleObj.grand_total % 25 # Modulus @@ -194,7 +194,7 @@ class OrderReservation < ApplicationRecord shift = ShiftSale.find(saleObj.shift_sale_id) cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) - shop_detail = Shop.first + shop_detail = Shop.current_shop order_reservation = OrderReservation.get_order_reservation_info(saleObj.sale_id) if !cashier_terminal.nil? # Calculate Food and Beverage Total @@ -400,7 +400,7 @@ class OrderReservation < ApplicationRecord end def self.check_new_order - shop = Shop.find_by_id(1) + shop = Shop.current_shop if !shop.shop_code.nil? shop_code = shop.shop_code else @@ -418,7 +418,7 @@ class OrderReservation < ApplicationRecord end def self.check_order_send_to_kitchen - shop = Shop.find_by_id(1) + shop = Shop.current_shop if !shop.shop_code.nil? shop_code = shop.shop_code else @@ -436,7 +436,7 @@ class OrderReservation < ApplicationRecord end def self.check_order_ready_to_delivery - shop = Shop.find_by_id(1) + shop = Shop.current_shop if !shop.shop_code.nil? shop_code = shop.shop_code else diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index ed14d884..5d72773c 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -38,7 +38,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # end - shop = Shop.first + shop = Shop.current_shop directory_name = 'public/orders_'+shop.shop_code Dir.mkdir(directory_name) unless File.exists?(directory_name) @@ -80,7 +80,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker print_setting = PrintSetting.all.order("id ASC") order=print_query('order_summary', order_id) - shop = Shop.first + shop = Shop.current_shop directory_name = 'public/orders_'+shop.shop_code Dir.mkdir(directory_name) unless File.exists?(directory_name) @@ -192,7 +192,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker order=print_query('booking_summary', booking_id) - shop = Shop.first + shop = Shop.current_shop directory_name = 'public/orders_'+shop.shop_code Dir.mkdir(directory_name) unless File.exists?(directory_name) diff --git a/app/models/room.rb b/app/models/room.rb index 87f232e9..63c548ec 100755 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -1,4 +1,3 @@ class Room < DiningFacility - has_many :bookings, :foreign_key => 'dining_facility_id' end diff --git a/app/models/sale.rb b/app/models/sale.rb index 85a81950..59d3683b 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -440,7 +440,7 @@ class Sale < ApplicationRecord #compute - invoice total def compute_by_sale_items(total_discount, discount_type=nil, order_source=nil, tax_type=nil, type=nil) - shop = Shop.first + shop = Shop.current_shop #Computation Fields subtotal_price = 0 @@ -507,7 +507,7 @@ class Sale < ApplicationRecord # Tax Re-Calculte def compute_tax(total_taxable, total_discount = 0, order_source = nil, tax_type=nil) - shop = Shop.first + shop = Shop.current_shop #if tax is not apply create new record # SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax| @@ -627,7 +627,7 @@ class Sale < ApplicationRecord # Tax Calculate def apply_tax(total_taxable, order_source = nil, tax_type = nil) - shop = Shop.first + shop = Shop.current_shop #if tax is not apply create new record # SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax| @@ -645,7 +645,7 @@ class Sale < ApplicationRecord order_source = "cashier" end - # tax_data = TaxProfile.unscoped.where("group_type=?",order_source).pluck(:id) + # tax_data = TaxProfile.unscope(:order).where("group_type=?",order_source).pluck(:id) # customer = Customer.find(self.customer_id).tax_profiles tax_profiles = unique_tax_profiles(order_source, self.customer_id) @@ -710,7 +710,7 @@ class Sale < ApplicationRecord end def adjust_rounding - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment if shop_details.is_rounding_adj new_total = Sale.get_rounding_adjustment(self.grand_total) @@ -726,7 +726,7 @@ class Sale < ApplicationRecord #Generate new Receipt No when it is not assigned def generate_receipt_no #shop_code and client_code - shop_details = Shop.first + shop_details = Shop.current_shop #Date-Shift- if self.receipt_no.nil? prefix = DateTime.now().utc @@ -1239,7 +1239,7 @@ end #product sale report query def self.get_menu_item_query(order_by) - query = MenuItem.unscoped.select("acc.id as account_id, + query = MenuItem.unscope(:order).select("acc.id as account_id, acc.title as account_name, mii.item_instance_code as item_code, " + "(CASE WHEN si.qty IS NOT NULL THEN SUM(si.qty) ELSE 0 END) as total_item," + diff --git a/app/models/shop.rb b/app/models/shop.rb index 75c30dd7..41110515 100755 --- a/app/models/shop.rb +++ b/app/models/shop.rb @@ -1,13 +1,17 @@ class Shop < ApplicationRecord - #ShopDetail = Shop.find_by_id(1) + #ShopDetail = Shop.current_shop # Shop Image Uploader - mount_uploader :logo, ShopImageUploader + mount_uploader :logo, ShopImageUploader - has_many :display_images + has_many :display_images accepts_nested_attributes_for :display_images def file_data=(input_data) self.data = input_data.read end + + def self.current_shop + ActsAsTenant.current_tenant + end end diff --git a/app/uploaders/commissioner_image_uploader.rb b/app/uploaders/commissioner_image_uploader.rb index 9b65e4a8..42e90a16 100644 --- a/app/uploaders/commissioner_image_uploader.rb +++ b/app/uploaders/commissioner_image_uploader.rb @@ -20,11 +20,11 @@ class CommissionerImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.first.shop_code.nil? - "#{original_filename}" if original_filename.present? + if Shop.current_shop.shop_code.nil? + "#{original_filename}" if original_filename.present? else - "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? - end + "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present? + end end # def cache_dir @@ -62,6 +62,6 @@ class CommissionerImageUploader < CarrierWave::Uploader::Base # Avoid using model.id or version_name here, see uploader/store.rb for details. # def filename # "something.jpg" if original_filename - # end + # end -end \ No newline at end of file +end diff --git a/app/uploaders/customer_image_uploader.rb b/app/uploaders/customer_image_uploader.rb index be1326d6..77a133af 100644 --- a/app/uploaders/customer_image_uploader.rb +++ b/app/uploaders/customer_image_uploader.rb @@ -20,11 +20,11 @@ class CustomerImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.first.shop_code.nil? - "#{original_filename}" if original_filename.present? + if Shop.current_shop.shop_code.nil? + "#{original_filename}" if original_filename.present? else - "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? - end + "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present? + end end # def cache_dir @@ -62,6 +62,6 @@ class CustomerImageUploader < CarrierWave::Uploader::Base # Avoid using model.id or version_name here, see uploader/store.rb for details. # def filename # "something.jpg" if original_filename - # end + # end -end \ No newline at end of file +end diff --git a/app/uploaders/employee_image_uploader.rb b/app/uploaders/employee_image_uploader.rb index 17c9d120..62aa3e15 100644 --- a/app/uploaders/employee_image_uploader.rb +++ b/app/uploaders/employee_image_uploader.rb @@ -20,11 +20,11 @@ class EmployeeImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.first.shop_code.nil? - "#{original_filename}" if original_filename.present? + if Shop.current_shop.shop_code.nil? + "#{original_filename}" if original_filename.present? else - "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? - end + "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present? + end end # def cache_dir @@ -62,6 +62,6 @@ class EmployeeImageUploader < CarrierWave::Uploader::Base # Avoid using model.id or version_name here, see uploader/store.rb for details. # def filename # "something.jpg" if original_filename - # end + # end -end \ No newline at end of file +end diff --git a/app/uploaders/menu_item_image_uploader.rb b/app/uploaders/menu_item_image_uploader.rb index 7a4b2039..5f23cafc 100755 --- a/app/uploaders/menu_item_image_uploader.rb +++ b/app/uploaders/menu_item_image_uploader.rb @@ -15,16 +15,16 @@ class MenuItemImageUploader < CarrierWave::Uploader::Base # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: def store_dir - "image/menu_images/#{Shop.first.shop_code}" + "image/menu_images/#{Shop.current_shop.shop_code}" # "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end def filename - if Shop.first.shop_code.nil? - "#{original_filename}" if original_filename.present? + if Shop.current_shop.shop_code.nil? + "#{original_filename}" if original_filename.present? else - "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? - end + "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present? + end end # def cache_dir @@ -42,7 +42,7 @@ class MenuItemImageUploader < CarrierWave::Uploader::Base # Process files as they are uploaded: # process scale: [200, 300] process :resize_to_fit => [400, 250]#[200, 150] - + # # def scale(width, height) # # do something diff --git a/app/uploaders/product_image_uploader.rb b/app/uploaders/product_image_uploader.rb index c39d867d..35fde675 100755 --- a/app/uploaders/product_image_uploader.rb +++ b/app/uploaders/product_image_uploader.rb @@ -20,11 +20,11 @@ class ProductImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.first.shop_code.nil? - "#{original_filename}" if original_filename.present? + if Shop.current_shop.shop_code.nil? + "#{original_filename}" if original_filename.present? else - "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? - end + "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present? + end end # def cache_dir diff --git a/app/uploaders/shop_image_uploader.rb b/app/uploaders/shop_image_uploader.rb index 394704c3..c27fb65c 100644 --- a/app/uploaders/shop_image_uploader.rb +++ b/app/uploaders/shop_image_uploader.rb @@ -20,11 +20,11 @@ class ShopImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.first.shop_code.nil? - "#{original_filename}" if original_filename.present? + if Shop.current_shop.shop_code.nil? + "#{original_filename}" if original_filename.present? else - "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? - end + "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present? + end end # def cache_dir @@ -62,6 +62,6 @@ class ShopImageUploader < CarrierWave::Uploader::Base # Avoid using model.id or version_name here, see uploader/store.rb for details. # def filename # "something.jpg" if original_filename - # end + # end -end \ No newline at end of file +end diff --git a/app/views/origami/dashboard/_menu.json.jbuilder b/app/views/origami/dashboard/_menu.json.jbuilder index 6d1ec624..372d521c 100644 --- a/app/views/origami/dashboard/_menu.json.jbuilder +++ b/app/views/origami/dashboard/_menu.json.jbuilder @@ -8,7 +8,7 @@ json.valid_time_to menu.valid_time_to.strftime("%H:%M") if (menu.menu_categories) 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") + # categories = MenuCategory.unscope(:order).where("menu_id ='#{menu.id}'").order("name asc") # else # categories = menu.menu_categories # end diff --git a/lib/tasks/receipt.rake b/lib/tasks/receipt.rake index 180b0de4..af50f3f3 100644 --- a/lib/tasks/receipt.rake +++ b/lib/tasks/receipt.rake @@ -3,7 +3,7 @@ namespace :consolidate do task :receipt => :environment do # Receipt.delete_all sales = Sale.all_receipts - shop = Shop.first #current_shop + shop = Shop.current_shop #Shop.current_shop sales.each do |sale| if sale.shift_sale_id.present? @@ -57,7 +57,7 @@ namespace :consolidate do ReceiptDetail.delete_all sales = Sale.all_receipt_details - shop = Shop.first #current_shop + shop = Shop.current_shop #Shop.current_shop sale_id = '' count = 0 From 108415ed3f80df5e4a01be29a930b4216f483687 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Tue, 3 Dec 2019 10:02:49 +0630 Subject: [PATCH 2/5] update dine-in pay bill --- .../origami/payments_controller.rb | 4 +-- app/models/sale_payment.rb | 27 +++++-------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 401e231b..b6c3e5be 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -176,14 +176,14 @@ class Origami::PaymentsController < BaseOrigamiController # For Cashier by Zone # bookings = Booking.where("sale_id='#{sale_id}'") - bookings = Booking.find_by_sale_id(sale_id) + bookings = saleObj.bookings[0] shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) else if bookings.dining_facility_id.to_i > 0 - table = DiningFacility.find(bookings.dining_facility_id) + table = bookings.dining_facility cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index e0ad2383..c48b4a6b 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -87,7 +87,7 @@ class SalePayment < ApplicationRecord amount_due = amount_due - payment.payment_amount end end - if (amount_due >= 0) + if (amount_due > 0) payment_status = false membership_data = nil #route to payment type @@ -780,27 +780,14 @@ class SalePayment < ApplicationRecord def table_update_status(sale_obj) status = true sale_count = 0 - booking = Booking.find_by_sale_id(sale_obj.id) - if booking + if booking = sale_obj.bookings[0] if booking.dining_facility_id.to_i > 0 - table = DiningFacility.find(booking.dining_facility_id) - bookings = table.bookings - bookings.each do |tablebooking| - if tablebooking.booking_status != 'moved' - if tablebooking.sale_id - if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' && tablebooking.sale.sale_status != 'spoile' && tablebooking.sale.sale_status != 'waste' - status = false - sale_count += 1 - else - status = true - end - else - status = false - sale_count += 1 - end - end + table = booking.dining_facility + if Booking.left_joins(:sale).where(dining_facility_id: booking.dining_facility_id).where.not(booking_status: 'moved').where("sales.sale_status NOT IN ('completed', 'void', 'spoile', 'waste') OR sales.sale_status IS NULL").exists? + status = false end - if status && sale_count == 0 + + if status table.update_attributes(status: "available") # table.status = "available" # table.save From c8c39b06361511312a9f39354a4094c2801525f2 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Tue, 3 Dec 2019 16:15:48 +0630 Subject: [PATCH 3/5] update origami/home/index --- app/controllers/origami/home_controller.rb | 8 ++-- app/models/dining_facility.rb | 38 +++--------------- app/models/lookup.rb | 17 ++++---- app/models/sale.rb | 2 +- app/models/sale_payment.rb | 45 +++++++++------------- app/views/origami/home/index.html.erb | 8 ++-- 6 files changed, 41 insertions(+), 77 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 30a6ce92..910fedf9 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -4,8 +4,8 @@ class Origami::HomeController < BaseOrigamiController def index @webview = check_mobile - @tables = Table.unscope(:order).all.active.order('status desc') - @rooms = Room.unscope(:order).all.active.order('status desc') + @tables = Table.unscope(:order).includes(:zone).all.active.order('status desc') + @rooms = Room.unscope(:order).includes(:zone).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @@ -21,8 +21,8 @@ class Origami::HomeController < BaseOrigamiController @print_settings = PrintSetting.get_precision_delimiter() @webview = check_mobile - @tables = Table.unscope(:order).all.active.order('status desc') - @rooms = Room.unscope(:order).all.active.order('status desc') + @tables = Table.unscope(:order).includes(:zone).all.active.order('status desc') + @rooms = Room.unscope(:order).includes(:zone).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index e5f35e03..d759ba73 100755 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -33,50 +33,22 @@ class DiningFacility < ApplicationRecord def get_current_booking checkin_time_lookup = Lookup.get_checkin_time_limit - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and (CASE WHEN checkin_at > '#{DateTime.now.utc}' THEN checkin_at >= '#{DateTime.now.utc}' ELSE checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' END) and checkout_by is null").limit(1) #and checkout_at is null - # booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_by is null").limit(1) #and checkout_at is null - if booking.count > 0 then - return booking[0] - else - return nil - end + Booking.where(dining_facility_id: self.id, booking_status: 'assign', checkout_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago).first #and checkout_at is null end def get_moved_booking checkin_time_lookup = Lookup.get_checkin_time_limit - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) - - if booking.count > 0 then - return booking[0] - else - return nil - end + Booking.where(dining_facility_id: self.id, booking_status: 'moved', checkout_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago).first end def get_new_booking # query for new - # if status - # to ask when req bill booking_status? - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and sale_id is null and checkout_at is null").limit(1) - # else - # booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and sale_id not null").limit(1) - # end - - if booking.count > 0 then - return booking[0].booking_id - else - return nil - end + Booking.where(dining_facility_id: self.id, booking_status: 'assign', sale_id: nil, checkout_at: nil).first end def get_current_checkout_booking checkin_time_lookup = Lookup.get_checkin_time_limit - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null").limit(1) - if booking.count > 0 then - return booking[0] - else - return nil - end + Booking.where(dining_facility_id: self.id, booking_status: 'assign', checkout_at: nil).where.not(reserved_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago).first end def get_checkout_booking @@ -119,7 +91,7 @@ class DiningFacility < ApplicationRecord def self.get_checkin_booking checkin_time_lookup = Lookup.get_checkin_time_limit - bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null") + bookings = Booking.where(booking_status: 'assign', checkout_at: nil).where.not(reserved_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago) arr_booking = Array.new if bookings lookup_checkout_time = Lookup.collection_of("checkout_alert_time") diff --git a/app/models/lookup.rb b/app/models/lookup.rb index 5b45822c..ac7bd6da 100755 --- a/app/models/lookup.rb +++ b/app/models/lookup.rb @@ -4,6 +4,8 @@ class Lookup < ApplicationRecord scope :number_formats, -> { where(lookup_type: 'number_format')} + TIME_LIMIT = 5 + def available_types {'Employee Roles' => 'employee_roles', 'Dining Facilities Status' => 'dining_facilities_status', @@ -23,15 +25,13 @@ class Lookup < ApplicationRecord # Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] } # end + def self.time_limit + TIME_LIMIT + end + def self.get_checkin_time_limit - time_limit = 5 - - lookup = Lookup.find_by_lookup_type('checkin_time_limit') - if !lookup.nil? - time_limit = lookup.value.to_i - end - - return time_limit + return RequestStore[:checkin_time_limit] if RequestStore[:checkin_time_limit] + RequestStore[:checkin_time_limit] = Lookup.find_by_lookup_type('checkin_time_limit').value.to_i rescue time_limit end def self.sync_url @@ -58,7 +58,6 @@ class Lookup < ApplicationRecord def self.collection_of(type) Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] } - end def self.create_shift_sale_lookup diff --git a/app/models/sale.rb b/app/models/sale.rb index 59d3683b..c7a05189 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -2025,7 +2025,7 @@ end query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id") .joins("join orders as orders on orders.order_id = sale_orders.order_id") query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' #{type}") - query = query.where("DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? ",DateTime.now.strftime('%Y-%m-%d')) + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) .group("sales.sale_id") end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index c48b4a6b..631ede89 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -960,37 +960,30 @@ class SalePayment < ApplicationRecord #credit payment query def self.get_credit_sales(params) - receipt_no = "" - customer = "" - if !params["receipt_no"].blank? - receipt_no = " and s.receipt_no LIKE '%#{params["receipt_no"]}%'" + payments = SalePayment.select("sale_payments.sale_id, sale_payments.sale_payment_id, sale_payments.payment_method, sale_payments.payment_amount") + .select("SUM(sale_payments.payment_amount) OVER (PARTITION BY sale_payments.sale_id) total_payment_amount") + + credit_sales = Sale.select("sales.sale_id, sales.receipt_no, sales.receipt_date as sale_date, sales.cashier_name") + .select("sale_payments.sale_payment_id, sale_payments.payment_amount").select("customers.name as customer_name") + .joins("JOIN (#{payments.to_sql}) AS sale_payments ON sale_payments.sale_id = sales.sale_id").joins(:customer).joins(:orders) + .completed.paid.where("sale_payments.payment_method = 'creditnote' AND sales.grand_total > sale_payments.total_payment_amount - sale_payments.payment_amount") + .group(:receipt_no) + .order(:receipt_date).order(:receipt_no) + + if params["receipt_no"].present? + credit_sales = credit_sales.where("sales.receipt_no LIKE ?", "%#{params["receipt_no"]}%") end - if !params["customer_id"].blank? - customer = " and s.customer_id = '#{params["customer_id"]}'" + if params["customer_id"].present? + credit_sales = credit_sales.where("sales.customer_id = ?", params["customer_id"]) end - order_source_query = "(select orders.source FROM orders JOIN sale_orders so ON so.order_id=orders.order_id WHERE so.sale_id=s.sale_id GROUP BY so.sale_id)" - - query = SalePayment.select("s.receipt_no, sale_payments.sale_payment_id, - sale_payments.payment_method, - SUM(sale_payments.payment_amount) as payment_amount, - s.receipt_date as sale_date, - s.sale_id, - s.cashier_name as cashier_name, c.name as customer_name") - .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") - .joins("INNER JOIN customers c ON c.customer_id = s.customer_id") - - if params[:type].nil? - query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") - elsif params[:type] == "cashier" - query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND #{order_source_query}='#{params[:type]}' OR #{order_source_query}='emenu' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") - else - query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND #{order_source_query}='#{params[:type]}' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") + if params[:type].present? + sources = [] + sources << params[:type] + sources << 'emenu' if params[:type] == 'cashier' + credit_sales = credit_sales.where("orders.source IN (?)", sources) end - query = query.group("s.receipt_no") - .order("s.receipt_date ASC, s.receipt_no ASC") - return query end def self.get_credit_amount_due_left(sale_id) diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index ba4da374..39c33749 100755 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -65,7 +65,7 @@ <% end %>
Table <%= table.name %> ( <%= table.seater %> Seat )
- <%= table.zone.name %> + <%= table.zone.name %>
<% end %> @@ -160,7 +160,7 @@ <%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %> <%= t("views.right_panel.detail.receipt_no") %> <%= t :cashier %> <%= t("views.right_panel.detail.name") %> - <%= t :customer %> <%= t("views.right_panel.detail.name") %> + <%= t :customer %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.credit_amount") %> @@ -338,8 +338,8 @@ function warnBeforeRedirect(linkURL,occupied_count) { text = "Are you sure you want to close cashier?"; } swal({ - title: "Alert!", - text: text, + title: "Alert!", + text: text, type: "warning", showCancelButton: true, html: true From 37380f6bfb24c0ad4b8421e27fdbb440a826fe92 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Tue, 3 Dec 2019 19:37:59 +0630 Subject: [PATCH 4/5] Fix json rendering error --- app/controllers/api/api_controller.rb | 10 +++++++++- app/controllers/application_controller.rb | 4 ++-- app/controllers/base_controller.rb | 5 +++-- app/controllers/base_crm_controller.rb | 4 +++- app/controllers/base_inventory_controller.rb | 4 +++- app/controllers/base_oqs_controller.rb | 4 +++- app/controllers/base_origami_controller.rb | 4 +++- app/controllers/base_report_controller.rb | 4 +++- app/controllers/base_waiter_controller.rb | 4 +++- app/controllers/concerns/multi_tenancy.rb | 1 - 10 files changed, 32 insertions(+), 12 deletions(-) diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb index 8a84cfa1..0cf85065 100755 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -1,11 +1,19 @@ class Api::ApiController < ActionController::API - include TokenVerification, MultiTenancy + include MultiTenancy + include TokenVerification include ActionController::MimeResponds + include ActionView::Rendering # before_action :lookup_domain helper_method :current_token, :current_login_employee, :get_cashier private + # ActionView::Rendering override render_to_body breaks render :json, + # resulting in an ActionView::MissingTemplate error. + def render_to_body(options) + _render_to_body_with_renderer(options) || super + end + #this is base api base controller to need to inherit. #all token authentication must be done here #response format must be set to JSON diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 81b4835d..8f537383 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,6 @@ class ApplicationController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification #before_action :check_installation protect_from_forgery with: :exception @@ -17,5 +18,4 @@ class ApplicationController < ActionController::Base flash[:warning] = exception.message redirect_to root_path end - end diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb index 1bb0421e..22cbf130 100755 --- a/app/controllers/base_controller.rb +++ b/app/controllers/base_controller.rb @@ -1,6 +1,7 @@ class BaseController < ActionController::Base include MultiTenancy - layout "installation" - protect_from_forgery with: :exception + layout "installation" + + protect_from_forgery with: :exception end diff --git a/app/controllers/base_crm_controller.rb b/app/controllers/base_crm_controller.rb index 08bc8138..577c387e 100755 --- a/app/controllers/base_crm_controller.rb +++ b/app/controllers/base_crm_controller.rb @@ -1,5 +1,7 @@ class BaseCrmController < ActionController::Base - include LoginVerification, + include MultiTenancy + include LoginVerification + layout "CRM" before_action :check_user diff --git a/app/controllers/base_inventory_controller.rb b/app/controllers/base_inventory_controller.rb index bd455c33..45fa8954 100755 --- a/app/controllers/base_inventory_controller.rb +++ b/app/controllers/base_inventory_controller.rb @@ -1,5 +1,7 @@ class BaseInventoryController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "inventory" before_action :check_user diff --git a/app/controllers/base_oqs_controller.rb b/app/controllers/base_oqs_controller.rb index 6e6a9c0f..6b01383d 100755 --- a/app/controllers/base_oqs_controller.rb +++ b/app/controllers/base_oqs_controller.rb @@ -1,5 +1,7 @@ class BaseOqsController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "OQS" before_action :check_user diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index e9cddf05..e3daff76 100755 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -1,5 +1,7 @@ class BaseOrigamiController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "origami" before_action :check_user diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index b3d1d23a..a4c7c3c3 100755 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -1,5 +1,7 @@ class BaseReportController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "application" before_action :check_user diff --git a/app/controllers/base_waiter_controller.rb b/app/controllers/base_waiter_controller.rb index b1d2056c..0962b3f0 100755 --- a/app/controllers/base_waiter_controller.rb +++ b/app/controllers/base_waiter_controller.rb @@ -1,5 +1,7 @@ class BaseWaiterController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "waiter" before_action :check_user diff --git a/app/controllers/concerns/multi_tenancy.rb b/app/controllers/concerns/multi_tenancy.rb index 5009e094..cb7c8aae 100644 --- a/app/controllers/concerns/multi_tenancy.rb +++ b/app/controllers/concerns/multi_tenancy.rb @@ -4,7 +4,6 @@ module MultiTenancy included do set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action - helper_method :current_shop if respond_to? :helper_method end private From ca92a0791976f25644e6aa286169663505db4d72 Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 3 Dec 2019 20:19:42 +0630 Subject: [PATCH 5/5] shop code missing --- app/controllers/foodcourt/void_controller.rb | 10 ++++----- .../origami/addorders_controller.rb | 5 +++-- app/controllers/origami/home_controller.rb | 4 ++-- app/models/sale.rb | 8 +++---- config/puma.rb | 22 +++++++++---------- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/app/controllers/foodcourt/void_controller.rb b/app/controllers/foodcourt/void_controller.rb index 92aba110..6d7dd34c 100755 --- a/app/controllers/foodcourt/void_controller.rb +++ b/app/controllers/foodcourt/void_controller.rb @@ -73,7 +73,7 @@ class Foodcourt::VoidController < BaseFoodcourtController # FOr Sale Audit action_by = current_user.name if access_code != "null" && current_user.role == "cashier" - action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name + action_by = Employee.find_by_emp_id_and_shop_code(access_code,Shop.current_shop.shop_code).name end # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" @@ -116,7 +116,7 @@ class Foodcourt::VoidController < BaseFoodcourtController customer= Customer.find(sale.customer_id) # get member information - rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + 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) @@ -124,7 +124,7 @@ class Foodcourt::VoidController < BaseFoodcourtController current_balance = 0 end - printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") + printer = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'") unique_code="ReceiptBillPdf" if !printer.empty? @@ -139,13 +139,13 @@ class Foodcourt::VoidController < BaseFoodcourtController end end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_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) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 9670ee23..f4381fb4 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -6,7 +6,7 @@ class Origami::AddordersController < BaseOrigamiController if check_mobile @webview = true end - + @shop = Shop.current_shop @tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") @rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") @all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc') @@ -19,6 +19,7 @@ class Origami::AddordersController < BaseOrigamiController if check_mobile @webview = true end + @shop = Shop.current_shop display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code) if !display_type.nil? && display_type.value.to_i ==2 @display_type = display_type.value @@ -224,7 +225,7 @@ class Origami::AddordersController < BaseOrigamiController def process_order_queue(order_id,table_id,order_source) print_status = nil cup_status = nil - + @shop = Shop.current_shop #Send to background job for processing order = Order.find(order_id) sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",@shop.shop_code) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 349dd27f..9d57e765 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -4,7 +4,7 @@ class Origami::HomeController < BaseOrigamiController def index @webview = check_mobile - + @shop = Shop.current_shop @tables = Table.unscope(:order).all.active.order('status desc') @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @@ -21,7 +21,7 @@ class Origami::HomeController < BaseOrigamiController # get printer info @print_settings = PrintSetting.get_precision_delimiter() @webview = check_mobile - + @shop = Shop.current_shop @tables = Table.unscope(:order).all.active.order('status desc') @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") diff --git a/app/models/sale.rb b/app/models/sale.rb index 66ed469a..a92d3b4d 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -2057,13 +2057,13 @@ end query = query.where("bookings.booking_status = 'assign' AND orders.status = 'new' AND orders.source =? ","#{type}") .group("bookings.booking_id") end - def self.completed_sale(type,shop_code) + def self.completed_sale(type) if type == "cashier" type = "and orders.source = 'emenu' or orders.source = 'cashier'" else type = "and orders.source = '#{type}'" end - query = Sale.where("sales.shop_code='#{shop_code}'") + query = Sale.where("sales.shop_code='#{Shop.current_shop.shop_code}'") query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id") .joins("join orders as orders on orders.order_id = sale_orders.order_id") query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' #{type}") @@ -2456,7 +2456,7 @@ private def update_stock_journal if self.sale_status == "void" && self.sale_status_before_last_save != "void" self.sale_items.each do |item| - found, inventory_definition = InventoryDefinition.find_product_in_inventory(item,self.shop_code) + found, inventory_definition = InventoryDefinition.find_product_in_inventory(item) if found stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first unless stock.nil? @@ -2469,7 +2469,7 @@ private end elsif self.sale_status == "waste" || self.sale_status == "spoile" || (self.payment_status == "foc" && self.payment_status_was != "foc") self.bookings.first.order_items.each do |item| - found, inventory_definition = InventoryDefinition.find_product_in_inventory(item,self.shop_code) + found, inventory_definition = InventoryDefinition.find_product_in_inventory(item) if found if stock_journal = StockJournal.find_by_trans_ref(item.order_items_id) if self.payment_status == "foc" && self.payment_status_was != "foc" diff --git a/config/puma.rb b/config/puma.rb index d24425ae..f0013d25 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,11 +1,11 @@ -application_path="#{File.expand_path("../..", __FILE__)}" -directory application_path -#environment ENV.fetch("RAILS_ENV") { "production" } -environment "production" -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! -threads 1,1 +# application_path="#{File.expand_path("../..", __FILE__)}" +# directory application_path +# #environment ENV.fetch("RAILS_ENV") { "production" } +# environment "production" +# 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! +# threads 1,1