From 213644d8ef608b230473eec62aecc13a93f8d3c1 Mon Sep 17 00:00:00 2001 From: git_code2lab Date: Fri, 15 Nov 2019 14:17:50 +0630 Subject: [PATCH 01/13] commit from production server --- .code2lab.env | 1 + Dockerfile | 21 +- Dockerfile.backup | 19 + Gemfile | 3 +- Gemfile.lock | 33 +- .../origami/dashboard_controller.rb | 3 +- .../origami/pending_order_controller.rb | 2 +- app/models/license.rb | 6 +- app/models/printer/printer_worker.rb | 2 +- app/views/settings/menus/_form.html.erb | 4 +- config/.database.yml.swp | Bin 0 -> 1024 bytes config/cable.yml | 4 +- config/initializers/license.rb | 4 +- config/redis.yml | 4 +- config/secrets.yml | 4 +- config/shops.json | 1022 +++++++++++++++++ docker-compose.yml | 60 +- docker-compose.yml.back | 31 + 18 files changed, 1154 insertions(+), 69 deletions(-) create mode 100644 Dockerfile.backup create mode 100644 config/.database.yml.swp create mode 100644 docker-compose.yml.back diff --git a/.code2lab.env b/.code2lab.env index 0a6c7f0b..3a697ccd 100644 --- a/.code2lab.env +++ b/.code2lab.env @@ -1 +1,2 @@ RAILS_ENV=production +SERVER_MODE=cloud diff --git a/Dockerfile b/Dockerfile index a3e46f4d..74c726d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,20 @@ -FROM ruby:2.4.1 -RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs +FROM ruby:2.5 +RUN apt-get update -qq && apt-get install -y build-essential libmariadb-dev libcups2-dev libpq-dev nodejs tzdata RUN mkdir /sxrestaurant RUN mkdir -p /sxrestaurant/tmp/puma -ENV RAILS_ENV staging -ENV RACK_ENV staging +ENV RAILS_ENV production +ENV RACK_ENV production WORKDIR /sxrestaurant -COPY Gemfile /sxrestaurant/Gemfile -COPY Gemfile.lock /sxrestaurant/Gemfile.lock -RUN bundle install --without development test +#RUN gem install bundler +#COPY Gemfile /sxrestaurant/Gemfile +#COPY Gemfile.lock /sxrestaurant/Gemfile.lock +#RUN bundle install --without development test RUN echo "Asia/Rangoon" > /etc/timezone RUN dpkg-reconfigure -f noninteractive tzdata +RUN date COPY . /sxrestaurant +RUN gem install bundler +#RUN bundle update --bundler +RUN bundle install --without development test RUN bundle exec rake assets:precompile -CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] \ No newline at end of file +CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] diff --git a/Dockerfile.backup b/Dockerfile.backup new file mode 100644 index 00000000..a72a1ae4 --- /dev/null +++ b/Dockerfile.backup @@ -0,0 +1,19 @@ +FROM ruby:2.5 +RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs +RUN mkdir /sxrestaurant +RUN mkdir -p /sxrestaurant/tmp/puma +ENV RAILS_ENV production +ENV RACK_ENV production +WORKDIR /sxrestaurant +#RUN gem install bundler +#COPY Gemfile /sxrestaurant/Gemfile +#COPY Gemfile.lock /sxrestaurant/Gemfile.lock +#RUN bundle install --without development test +RUN echo "Asia/Rangoon" > /etc/timezone +RUN dpkg-reconfigure -f noninteractive tzdata +COPY . /sxrestaurant +RUN gem install bundler +#RUN bundle update --bundler +RUN bundle install --without development test +RUN bundle exec rake assets:precompile +CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] diff --git a/Gemfile b/Gemfile index 1a15a61a..4a447a6e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ source 'https://rubygems.org' -ruby '2.3.1' +#ruby '2.4.1' +ruby '2.5.7' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" diff --git a/Gemfile.lock b/Gemfile.lock index c0dd2cf8..856497b0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,7 +62,7 @@ GEM builder (3.2.3) byebug (11.0.1) cancancan (1.17.0) - capistrano (3.10.1) + capistrano (3.11.2) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) @@ -99,8 +99,8 @@ GEM factory_girl_rails (4.9.0) factory_girl (~> 4.9.0) railties (>= 3.0.0) - faker (2.5.0) - i18n (~> 1.6.0) + faker (2.6.0) + i18n (>= 1.6, < 1.8) ffi (1.11.1) filterrific (5.2.1) font-awesome-rails (4.7.0.5) @@ -140,7 +140,7 @@ GEM listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - loofah (2.3.0) + loofah (2.3.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -223,23 +223,23 @@ GEM chunky_png (~> 1.0) rqrcode_core (~> 0.1.0) rqrcode_core (0.1.0) - rspec-core (3.8.2) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.5) + rspec-core (3.9.0) + rspec-support (~> 3.9.0) + rspec-expectations (3.9.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.2) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) rspec-rails (3.9.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.3) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-support (~> 3.9.0) + rspec-support (3.9.0) ruby-ole (1.2.12.2) rubyzip (1.0.0) sass (3.7.4) @@ -267,8 +267,7 @@ GEM activemodel (>= 5.0) spreadsheet (1.2.4) ruby-ole (>= 1.0) - spring (2.0.2) - activesupport (>= 4.2) + spring (2.1.0) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) @@ -371,7 +370,7 @@ DEPENDENCIES whenever RUBY VERSION - ruby 2.3.1p112 + ruby 2.4.1p111 BUNDLED WITH 2.0.2 diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index 25ea8390..22aef2e1 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -2,7 +2,8 @@ class Origami::DashboardController < BaseOrigamiController def index @shop = Shop.first - + Rails.logger.info ENV["SERVER_MODE"] + Rails.logger.info "<><><><><><><><>>" today = DateTime.now.strftime('%Y-%m-%d') @display_type = Lookup.find_by_lookup_type("display_type") diff --git a/app/controllers/origami/pending_order_controller.rb b/app/controllers/origami/pending_order_controller.rb index 4b412c17..d05388a2 100644 --- a/app/controllers/origami/pending_order_controller.rb +++ b/app/controllers/origami/pending_order_controller.rb @@ -22,7 +22,7 @@ class Origami::PendingOrderController < BaseOrigamiController else redirect_to "/origami/#{params[:type]}" and return end - elsif id.start_with?("BKI") + elsif (id.start_with?("BKI")|| id.start_with?("CBKI")) @bookings = Booking.find(id) @order = @bookings.orders.where(status: "new").first @order_items = @bookings.order_items diff --git a/app/models/license.rb b/app/models/license.rb index 9ef7d956..befb4b36 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -13,7 +13,8 @@ class License def initialize(server = "", lookup = "") #this code is hard-code to reflect server mode - Very important. - self.server_mode = ENV["SERVER_MODE"] + # self.server_mode = ENV["SERVER_MODE"] + self.server_mode = "cloud" if (server != "") self.class.base_uri server @@ -41,11 +42,12 @@ class License @params = { query: { lookup_type: self.server_mode, lookup: lookup, iv_key: aes_iv} } response = self.class.get("/subdomain", @params) @license = response.parsed_response + Rails.logger.info "License Response - " + response.parsed_response.to_s if (@license["status"] == true) assign(aes_key, aes_iv) - # Rails.logger.info "License - " + response.parsed_response.to_s + #Rails.logger.info "License - " + response.parsed_response.to_s redis = Redis.new redis.set(cache_key, Marshal.dump(@license)) diff --git a/app/models/printer/printer_worker.rb b/app/models/printer/printer_worker.rb index fee19a31..0a580e40 100755 --- a/app/models/printer/printer_worker.rb +++ b/app/models/printer/printer_worker.rb @@ -1,5 +1,5 @@ require 'net/http' -require 'cups' +#require 'cups' class Printer::PrinterWorker attr_accessor :print_settings diff --git a/app/views/settings/menus/_form.html.erb b/app/views/settings/menus/_form.html.erb index 15842333..6ad21dd5 100755 --- a/app/views/settings/menus/_form.html.erb +++ b/app/views/settings/menus/_form.html.erb @@ -7,8 +7,8 @@
<%= f.input :name,:input_html=>{:class=>"col-md-9"} %> - <%= f.input :is_active,:input_html=>{:class=>"col-md-9"} %> - <%= f.input :is_ordering,:input_html=>{:class=>"col-md-9"} %> + <%= f.input :is_active,:input_html=>{:class=>"col-md-9"}, as: :boolean %> + <%= f.input :is_ordering,:input_html=>{:class=>"col-md-9"}, as: :boolean %>
diff --git a/config/.database.yml.swp b/config/.database.yml.swp new file mode 100644 index 0000000000000000000000000000000000000000..be379f097d975bca8017d31f72bb1155cb394506 GIT binary patch literal 1024 zcmYc?$V<%2S1{5u)iY*50{eIv7)p~$^GZsQ1aUAk3v><5jdYC-bPaVaOmQdz3a2EN aBqk*mr|MPa=HON}Dl-}aqai@A5C8xTdJdle literal 0 HcmV?d00001 diff --git a/config/cable.yml b/config/cable.yml index a383c5af..36f0b961 100755 --- a/config/cable.yml +++ b/config/cable.yml @@ -1,7 +1,7 @@ redis: &redis adapter: redis - url: redis://localhost:6379/1 + url: redis://172.17.0.1:6380/1 production: *redis development: *redis -test: *redis \ No newline at end of file +test: *redis diff --git a/config/initializers/license.rb b/config/initializers/license.rb index e329f313..dd4addaa 100644 --- a/config/initializers/license.rb +++ b/config/initializers/license.rb @@ -3,4 +3,6 @@ if File.exist?("config/license.yml") config.fetch(Rails.env, {}).each do |key, value| ENV[key.upcase] = value.to_s end -end \ No newline at end of file +else + ENV["SERVER_MODE"] = "cloud" +end diff --git a/config/redis.yml b/config/redis.yml index 66b9db53..493a6027 100644 --- a/config/redis.yml +++ b/config/redis.yml @@ -9,5 +9,5 @@ test: <<: *default production: - <<: *default - url: redis://127.0.0.1:6379 \ No newline at end of file + db: 0 + url: redis://172.17.0.1:6380 diff --git a/config/secrets.yml b/config/secrets.yml index 40e0906e..ff014434 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -24,7 +24,7 @@ test: # instead read values from the environment. production: secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22 - sx_provision_url: connect.smartsales.asia/api #192.168.1.147:3002/api - server_mode: application + sx_provision_url: 52.221.188.144:9292/api #connect.smartsales.asia/api #192.168.1.147:3002/api + server_mode: cloud cipher_type: AES-256-CBC sx_key: Wh@t1$C2L diff --git a/config/shops.json b/config/shops.json index 4037179b..0c2cc02d 100644 --- a/config/shops.json +++ b/config/shops.json @@ -27,6 +27,1028 @@ "key": "DvPxzB6QjHNnfuxBz6rdOuSn0/5TkckwCu3jNv0geHY=\n", "iv": "pJ5k8JKbfti70KQoLZCm/Q==\n" } + }, + { + "lookup": "goldenpearl-191.zsai.ws", + "value": { + "key": "onqbw2wMP39fHNIYRBK8mb/BIcRKP3ozO3wybjMBFnc=\n", + "iv": "Ou74S6pvkFUZT0d2qLZUyQ==\n" + } + }, + { + "lookup": "pioneerkyitehto-585.zsai.ws", + "value": { + "key": "zNzZNd18IM4k1aJyPYrtiF4fpwbSLx8+d2myRGX6RK4=\n", + "iv": "W9V8VMfN4aDv2oRNg/C53A==\n" + } + }, + { + "lookup": "happywzyd-157.zsai.ws", + "value": { + "key": "A0fg8p3E39WHxo4/5+7AgNSI66uMK5BY3SQlXqwB+AY=\n", + "iv": "1a5sdkC/jSb47CoryMbUqA==\n" + } + }, + { + "lookup": "happymng-114.zsai.ws", + "value": { + "key": "VdUpPLn6BPLSlUeOdWMl9teG0LtrBebOW3gV0wHvqu8=\n", + "iv": "0bIcyr8GABzrwmn6v3I97g==\n" + } + }, + { + "lookup": "akssouthdagon-565.zsai.ws", + "value": { + "key": "xGGTF1AXx3GxpN1AlP1y140++aFFfhSsVmBgw2Wxugg=\n", + "iv": "NULolbNvpS9Kc2BBHHCEEA==\n" + } + }, + { + "lookup": "familykyayoo-241.zsai.ws", + "value": { + "key": "/d7bN8tLvuByN+d83J23ObUWf+JG4s4FZFhZEP2f8UE=\n", + "iv": "qvHDdwTuphSHDMDFsYFaAQ==\n" + } + }, + { + "lookup": "sqatest10-198.zsai.ws", + "value": { + "key": "433kyw1Anxpwtz0trQjnnxSQ3/y3e+qG9GYvuxeGPdk=\n", + "iv": "GFemyIhszGGjfeyfue6LTA==\n" + } + }, + { + "lookup": "c2ltest1-278.zsai.ws", + "value": { + "key": "NMUxaEDjvK4h3r2lJVJMcLWFHs82dOhSVdpCuzsnxns=\n", + "iv": "tVICjUcfFBhq0bCyuWOyZg==\n" + } + }, + { + "lookup": "democloudquickservice-216.zsai.ws", + "value": { + "key": "6lAdJO6R2vf8qWtJ5NM+vn9376qy0j7QSyuMQXcrtuU=\n", + "iv": "uG4UoSq2OCpbClV6aEipFg==\n" + } + }, + { + "lookup": "smartsalesdemo-309.zsai.ws", + "value": { + "key": "nQniNOoTdmxI+r/yJP7MveD+G1kSdbw2LmFBxN5vX7A=\n", + "iv": "D3wMEOZPkvIwAKh3EBl5XA==\n" + } + }, + { + "lookup": "mangothai-546.zsai.ws", + "value": { + "key": "gJSwTLltnU8+bckrbPpEMEEcgWn84RFJi1z4f6kQTVs=\n", + "iv": "tFy+GFIMYzp6iPsC+/SQXQ==\n" + } + }, + { + "lookup": "greatgardenbar-319.zsai.ws", + "value": { + "key": "HZzXs0aUPQfviTFeIs2WtR+El8qKqeyphDPDNNt+1PE=\n", + "iv": "ipYNucrQPHDcYg+e71Rf+w==\n" + } + }, + { + "lookup": "jackcoffeeandfood-488.zsai.ws", + "value": { + "key": "3N5gmY1DU47i3I4sTJ69iGcdDudA9/TyQarbKUeAyEs=\n", + "iv": "7PqUSe+NPc5ajpDhFPbqrg==\n" + } + }, + { + "lookup": "www.mangothai-546.zsai.ws", + "value": { + "key": "eP+zdqmu3KEmoMkqqEB5RwrYXjV1xzENrDwcryBpBj8=\n", + "iv": "YyjVeXmCndFNL/TwD3sAeQ==\n" + } + }, + { + "lookup": "tipsy-382.zsai.ws", + "value": { + "key": "G4GA0lLWEnEZkFgBRN4T29JGSCK5cFsm2iM4L6NeZ3c=\n", + "iv": "J6whsfo3z5BoYR15p1IdjA==\n" + } + }, + { + "lookup": "mrcow-482.zsai.ws", + "value": { + "key": "TbxarfeNV9Uj4vqa/DBVWRcfLBya7yZiS9RLaxS3AxY=\n", + "iv": "RYev+qd+vGoMXMy3eMXpdQ==\n" + } + }, + { + "lookup": "breadtalkhd-577.zsai.ws", + "value": { + "key": "3y/51xjhYtx92sz9ecYJFygSohJVC+5W8n9852fBPqw=\n", + "iv": "mqFO99oxmxo1nxwwfFn16A==\n" + } + }, + { + "lookup": "shwelaryk-247.zsai.ws", + "value": { + "key": "jQesmnY+UE5OruOEjKOoTE0FSqjxcG6a271H+8jhQBA=\n", + "iv": "1nrByL+LJDRFTMqeP7Dklw==\n" + } + }, + { + "lookup": "shwelarmdy-262.zsai.ws", + "value": { + "key": "DlTBmtWFoJGIQmWA6FwicNmi/Asagap8xVH841Zfbiw=\n", + "iv": "MMwY6h9BUMy0nPPFzL0pzQ==\n" + } + }, + { + "lookup": "ngwezalathty-242.zsai.ws", + "value": { + "key": "tZ//VEaYUDmF6ZwTjrPCG7vyccs5wdi6+kD12LpkSLc=\n", + "iv": "mXVGy9x+/JB45r0lTDKCZQ==\n" + } + }, + { + "lookup": "shwelarthamine-429.zsai.ws", + "value": { + "key": "O1lOMRIhdKPCiu21/+sOvLXLJ+rmaPdVbPWOzqhevII=\n", + "iv": "SyVRZ1a9dJE9LJN5D6JeZg==\n" + } + }, + { + "lookup": "shwelarmng-410.zsai.ws", + "value": { + "key": "18JjiTEj0Jz4DOf9r42Gbc3I32WUNawjLsNMAl0+Y9g=\n", + "iv": "8/dYtGXkXhyBs1/Qt0mpDA==\n" + } + }, + { + "lookup": "shwelarnorthdagon-223.zsai.ws", + "value": { + "key": "a34gWEK8M8GMPwl4/jbwTjps8xOmTiWVKQvEGdGyCOk=\n", + "iv": "l8e7p1hAI9WJBGx2Chx3TQ==\n" + } + }, + { + "lookup": "hejohejo-257.zsai.ws", + "value": { + "key": "HPWRp1gZ++HsHDB9NcVpovj2a4tTZYq/qLC99zn2v+M=\n", + "iv": "YBs001Y6Jh8ZVC8VzB/F4A==\n" + } + }, + { + "lookup": "sakurahotelandrestaurant-582.zsai.ws", + "value": { + "key": "2pFLLlwKSegBgBewu9ln+FFPZusyth+d6EdT3yfLIgE=\n", + "iv": "mBZ9dZTq716DAolwCVbS8Q==\n" + } + }, + { + "lookup": "mlmshwelar-481.zsai.ws", + "value": { + "key": "/UYiUF0Bp4XL/DCjrVsG+v1Akf0W0WcfGIeZxyELT0A=\n", + "iv": "/4VPpzDlrTdW4ylTWXyYDg==\n" + } + }, + { + "lookup": "shwelarcm-401.zsai.ws", + "value": { + "key": "NSYy2fZx7CiFLjgFvM0xad0hbNe10paWlrm/fDjDMXs=\n", + "iv": "FIn49qnkN01GCxJxYqwbxQ==\n" + } + }, + { + "lookup": "otwcyl-505.zsai.ws", + "value": { + "key": "/cJYMe6JzFApchiCwWUqlmcOug1E4+3KfuSIvdadLM0=\n", + "iv": "ZNVjjiqZ2Wj5MO4Gw3G8TQ==\n" + } + }, + { + "lookup": "otwc39mile-414.zsai.ws", + "value": { + "key": "xrK9ySdeVw1nIV2uJnPgAf0nfCRMihNjeT2dl1k2/8w=\n", + "iv": "pE03PjjMJH67rq/qw7zecQ==\n" + } + }, + { + "lookup": "shwelarhty-248.zsai.ws", + "value": { + "key": "OPTwAcfGG5dcznWCrpPDOaW9D0zDlF845skDaLKZUaw=\n", + "iv": "wlXIU3u2BwhvRjxeV823AQ==\n" + } + }, + { + "lookup": "shwelarmarketplace-403.zsai.ws", + "value": { + "key": "DYjNMG8oQCBoKUTAIyKVuWKp7ECaQcx9NGt5jEnF7e8=\n", + "iv": "EnxgXD1OFnGeAP+Uorl3YQ==\n" + } + }, + { + "lookup": "yaenanmyaeaungmyint-587.zsai.ws", + "value": { + "key": "ykEieigpIbL4ih2ZM0yw7P9T7QV5Qy5faS1U8eM/sz4=\n", + "iv": "HBljAOU1p+zs35zllBCu9g==\n" + } + }, + { + "lookup": "yuzanashwelar-557.zsai.ws", + "value": { + "key": "8uFZ2K6AQieQ8e5lDC01Jy1PmcXeDCevcYOnE5NmB8Q=\n", + "iv": "LM+wBUyWucE8/AoU5BhPfw==\n" + } + }, + { + "lookup": "yankinshwelar-579.zsai.ws", + "value": { + "key": "1QizuDDnBca59BLAKQ3nS8XDgelbe9AIhaeXqSsZTdk=\n", + "iv": "kAFDwYBU/BJ8egw1RXMa7A==\n" + } + }, + { + "lookup": "sproutspyaygarden-256.zsai.ws", + "value": { + "key": "SiU7bAEMduUlmhxNxLOfJWbk6Tf2RQdyuMtYGdRkN3k=\n", + "iv": "qhJuQQIp5x5+IgEZ1Y0+TQ==\n" + } + }, + { + "lookup": "sweetrose-406.zsai.ws", + "value": { + "key": "ODpz6U68nngygM+kfWcG+bgNkDAdT6smcPneOk8txbc=\n", + "iv": "hOsB0rPD/Dq8f0eeSbJCLw==\n" + } + }, + { + "lookup": "shwekaungkywel-307.zsai.ws", + "value": { + "key": "SjaKoPAZ9i1D4ZxZ7dBqkvxxgnq1ufGh7bMvQKB5sHU=\n", + "iv": "GSghtmz5q3ljukLDBq7cWQ==\n" + } + }, + { + "lookup": "ygnbarndagon-469.zsai.ws", + "value": { + "key": "k7aaIth74d+/V3PYscKA+5XV92XhBgJPfmiFzPl2D+o=\n", + "iv": "D7/aiLCcmEBRSFS31WSQKg==\n" + } + }, + { + "lookup": "yukimarketplace-286.zsai.ws", + "value": { + "key": "VfUWM9D1jd2tOptYTs5gVPbLZfu80qnivflz6lGcBkk=\n", + "iv": "rU05QAFPfGq+yDQxzoCOYw==\n" + } + }, + { + "lookup": "bitp3-6.zsai.ws", + "value": { + "key": "peok2nKg0Q1O6fErEWNe/EZHK85lujK2A4wKivrR/C4=\n", + "iv": "8nH0txuN6rLVQ2lUJcA6hA==\n" + } + }, + { + "lookup": "snt-591.zsai.ws", + "value": { + "key": "AZgsi9LxtS5fya3jtMPG6sZG98W06JmuyBLiP6hfViw=\n", + "iv": "YSbO5YYsVZNjeuSzEbucbg==\n" + } + }, + { + "lookup": "malaspice-500.zsai.ws", + "value": { + "key": "NO/0ZUMbEHjKd1SPVRUtLoxpsaYXIs8CwY6Rnlmyk/g=\n", + "iv": "WQhJcYBIH7Fq+7nkmS1pgg==\n" + } + }, + { + "lookup": "3point14cafe-281.zsai.ws", + "value": { + "key": "CXoqbpkmOuS+AoWLIcZ5Y9FYv1X3Q5+3cwgzQY5c1fE=\n", + "iv": "L5JlP8huflkNnFi7e8m1HA==\n" + } + }, + { + "lookup": "tinttint-320.zsai.ws", + "value": { + "key": "QV67KTU6DtDXaMJg2cUWA5+RPVVFlJKYyTAWTGwsyAw=\n", + "iv": "JEpO3EaMmh4z0qyw3BG3Vg==\n" + } + }, + { + "lookup": "hubcafeandeatery-276.zsai.ws", + "value": { + "key": "p3Tyj0UJJfUEdDQw/d9KBgGKfdhqZi/hIBjOFfQLZX4=\n", + "iv": "Qnb8/qAcK4n4NAx8RkP46g==\n" + } + }, + { + "lookup": "2019demo-416.l.zsai.ws", + "value": { + "key": "FH5+4CPbbJAsaX5peFL79HXTCuIQhB32bfA+nQ2FGso=\n", + "iv": "i8u+cLtn4BRRVc4nTOIUrQ==\n" + } + }, + { + "lookup": "aungkaungsanbahan-413.zsai.ws", + "value": { + "key": "TNhlziSLr5LDJtyc1mbZKIyiAmGzrPVC1InSgB6TXkE=\n", + "iv": "l+rjyTyM4Ak019U2UBkR9w==\n" + } + }, + { + "lookup": "r9-592.zsai.ws", + "value": { + "key": "6TPO6WGcEke5zyCzBLH2BEAI/fzCWFCeym8YHxJGobk=\n", + "iv": "cQihYFBlwaNIeSKg1Yp7GQ==\n" + } + }, + { + "lookup": "mrkaung-436.zsai.ws", + "value": { + "key": "vkKcISXI29Buqlxbww6eoh4zLGROAhj0d8z2d00BNr4=\n", + "iv": "zYTm2xFyCG2OP1UZCM9qfQ==\n" + } + }, + { + "lookup": "ninebar-558.zsai.ws", + "value": { + "key": "UYX/w2Hf1T9GV535O5JHi2M+lLAI5MuwvCbiwXWQEso=\n", + "iv": "vB5NP+VeV8r7oThoct0tJg==\n" + } + }, + { + "lookup": "skm2-470.zsai.ws", + "value": { + "key": "S7Z5sNYYaqBw9YGiuCZupAGUq2mxPijxCEoE1EgBjTE=\n", + "iv": "QcNWt5t7VhMy+NimCAXnMA==\n" + } + }, + { + "lookup": "bkkseafood-498.zsai.ws", + "value": { + "key": "gH0dupKVr/7+RYLGIhT2kyNdYU48kb9DvbS4K5d+lBo=\n", + "iv": "qCrI5Unk+LJXVXxSzZr5ig==\n" + } + }, + { + "lookup": "helloxianggou-375.zsai.ws", + "value": { + "key": "Pxkx5t6hdgCVhCVwKn7sgHy5MOTDDV3Jkl3TcFLkXi4=\n", + "iv": "H0ucjCabas5t+wn5M4L2Mg==\n" + } + }, + { + "lookup": "shwelarnnt-399.zsai.ws", + "value": { + "key": "KhvUaNhkiB2fznDh3qlx6eDO1hGiF+H5yd4og95wvrI=\n", + "iv": "V3KNkjfBjJrTrUEYtRR1FQ==\n" + } + }, + { + "lookup": "ygnmingalarktv-589.zsai.ws", + "value": { + "key": "4VGZlJG0rlpb8cyzzYniowCe2IEIFfGbACSnDFkl4IE=\n", + "iv": "wD0xJ8UgpT78g6rwpnGWpg==\n" + } + }, + { + "lookup": "skyktv-530.zsai.ws", + "value": { + "key": "Tq81jCe2bS5DwTO94LlAf63ikoVtM9SbCtsTyUAkTOY=\n", + "iv": "VN8OXicrRdo68ZfuDTIaUQ==\n" + } + }, + { + "lookup": "shwemyittar127-249.zsai.ws", + "value": { + "key": "fctlQezCvV+F2V9bADYhCREAA7Nhopx1OiAgyOsmWnc=\n", + "iv": "DpJh02YGpMGo9eIeRwoz/Q==\n" + } + }, + { + "lookup": "myanandar-485.zsai.ws", + "value": { + "key": "ngs5XR0I1DSccB5YFwAVTCDjUgTTGV//K28Lkg0S26E=\n", + "iv": "fuJ2t6/9eAErbHjxK6ESJA==\n" + } + }, + { + "lookup": "thanksbakery-584.zsai.ws", + "value": { + "key": "t1bmKQsf136B3fgG5o0r8eMaRpw0+39w3nYwCoBWWBc=\n", + "iv": "wLfChrmg7p6Bh4LGxSWIdA==\n" + } + }, + { + "lookup": "eatfinitybotahtaung-326.zsai.ws", + "value": { + "key": "lSFoJP3qHT/4D9HaDNnqkEBws5azzEVrX7EtfneNLr0=\n", + "iv": "dpr+vITpsIJGbVlnLxD4qw==\n" + } + }, + { + "lookup": "summitkorea-386.zsai.ws", + "value": { + "key": "thvWse+XVT34mNklgGQF2dcfdhCiq0o32P/xuwB/XHE=\n", + "iv": "MCOblx0L2k/i4Xx7zmzkXw==\n" + } + }, + { + "lookup": "rootkitchenandbar-569.zsai.ws", + "value": { + "key": "6Zsy5hZ1ZjiBBQ9yUV1Uc6JAzOSNJsqqYr9BcpWP0FI=\n", + "iv": "wUNQvsaXAAPXjdv6IsrS5A==\n" + } + }, + { + "lookup": "shwekyunmyay-310.zsai.ws", + "value": { + "key": "naoT5drrX06Bd6Sppuzm0SkWynd3JrwXPdYldJRpZ0g=\n", + "iv": "FbldznhPRN3vdjWMKXWJow==\n" + } + }, + { + "lookup": "r9opt-593.zsai.ws", + "value": { + "key": "FkCI9sPa6vn4cCDlT6oKQq0iEA2S/UJbHD5GggH7zrM=\n", + "iv": "cp+881vVv9xhP202DpPgsg==\n" + } + }, + { + "lookup": "optdemo-476.zsai.ws", + "value": { + "key": "LS3XHPdo1McJmHAAlKzTDLLkfhFYhVbJqBZdOPzkt28=\n", + "iv": "ToGDf/26kuIwxQXvR9AM/w==\n" + } + }, + { + "lookup": "testdemo-246.zsai.ws", + "value": { + "key": "4DjtcmNlTRJ/++sSBrIEshFp0kJLGPlduuqUjoOJuNw=\n", + "iv": "lRdIuIJTCdLjsdVeqWOMyw==\n" + } + }, + { + "lookup": "osushi-501.zsai.ws", + "value": { + "key": "S4OhABChiY/ekE46UE7K95pL4/ZXA+3PoreWQkYE6as=\n", + "iv": "Rnn316FaZgnJSUd0MeqpSw==\n" + } + }, + { + "lookup": "chathai-322.zsai.ws", + "value": { + "key": "I9TjGL73/nuaaKrQ3hUSJbt7QgES8NWxys9w2Zd0C/o=\n", + "iv": "fqQPYY1B0SDR6c6n0V7FRQ==\n" + } + }, + { + "lookup": "mrkimchikorea-499.zsai.ws", + "value": { + "key": "qA/k3CMQuNOFjYFdzJ1TLnJB8PA54u0R8Sl4GuiROI8=\n", + "iv": "UcYI4ZlYMqYhW7TubgmF4g==\n" + } + }, + { + "lookup": "mygarden-232.zsai.ws", + "value": { + "key": "K652mb5TczbANp6Fk750lX5I5oP1PztZlVqXRigQdCQ=\n", + "iv": "u78alhv81h1fYBR5MkrUzw==\n" + } + }, + { + "lookup": "pezzopizza-532.zsai.ws", + "value": { + "key": "A+LpxYd7kCIBOU+wo42eQ7qMbV6FAGCIWvh4EuP3vZU=\n", + "iv": "6duLCdCzmm7rft9bJkXOww==\n" + } + }, + { + "lookup": "pwaltawoak-374.zsai.ws", + "value": { + "key": "s5IzuXVfFa73kX+AKr2GE+2/kDZ3Vi6QDp+jCaQaFQM=\n", + "iv": "1Gkfc1iHBP6MpISpzPpAfw==\n" + } + }, + { + "lookup": "shwemingalar-534.zsai.ws", + "value": { + "key": "MhhH0Sh6FOwqqJXgivuDDVpeHDnAUzExn2z2EuxYuX8=\n", + "iv": "4QsjfQXzehd0jS6zDdTsQg==\n" + } + }, + { + "lookup": "phbakery-489.zsai.ws", + "value": { + "key": "2s48wY5Zo/cyWcNkQzn04JqqxN4Cq4+r0x03u9gU5dw=\n", + "iv": "fshavbqcLmct9/EWjQSDpg==\n" + } + }, + { + "lookup": "homek-214.zsai.ws", + "value": { + "key": "LumSI8T23KFkHzaj085VVVHmM9HlODD0Je/s6+ofQZk=\n", + "iv": "JZux8qE1YC5nm7onsx2KaQ==\n" + } + }, + { + "lookup": "nilarpabedan-458.zsai.ws", + "value": { + "key": "0VrfD1re4Fxac+6qDNaV8zopFdlmGNiNCGSDgMRgyBw=\n", + "iv": "wSf/G8SZyiWeRikqE7/3yQ==\n" + } + }, + { + "lookup": "mmdcyankin-556.zsai.ws", + "value": { + "key": "z07zwz0gsx5GB2faT8AKyz+42LIjfaOl65Gt6QJWyWk=\n", + "iv": "FqFkPDMfSVDOuTsDldxCuQ==\n" + } + }, + { + "lookup": "mmdc39miles-207.zsai.ws", + "value": { + "key": "sTunA/sPq8R2EfukoP82tGfb3iDDbD0yrI13pFJDiag=\n", + "iv": "ye9Qw+41Q4Gqh9Jh4lXwLQ==\n" + } + }, + { + "lookup": "twinbeanscafe-340.zsai.ws", + "value": { + "key": "s+pKgs8K8uRxjaHhBuqxnV2o+IrHPUK14+Yi8B5Q7FA=\n", + "iv": "Dapl2+HMlauzGQU4JYZvQA==\n" + } + }, + { + "lookup": "osaka-115.zsai.ws", + "value": { + "key": "f5t7CZknlCy5ljiBWobY80HHJG46DADJeXU0V0rdqr4=\n", + "iv": "Qd61Lxz2CVvskKOd+aK8Qg==\n" + } + }, + { + "lookup": "tpytaunggyi-477.zsai.ws", + "value": { + "key": "C8ftjJYsI82RpgX7AiVUQZyg9fuO2B19KAtKWfLhNGw=\n", + "iv": "FrUIWi2kDZsUTnft0vviww==\n" + } + }, + { + "lookup": "sandarmay-405.zsai.ws", + "value": { + "key": "ONZsJhCNVteFIgJzLO8GivIIUCdyQvYqjk6GceDPA2Y=\n", + "iv": "yTQcpSSdLYq0tRV0SkizEQ==\n" + } + }, + { + "lookup": "zieebar-594.zsai.ws", + "value": { + "key": "wY+4C+pcMyPG/Ybx90zNrMjtHWyUiuYONaUD67X6GTQ=\n", + "iv": "rpX1EeNs6Sf9ysHzen2TSA==\n" + } + }, + { + "lookup": "hlaingtharyarktv-542.zsai.ws", + "value": { + "key": "LkLaxVqx5ZglkXRxVCqURp81ih8Qzat84z4/of8nGq0=\n", + "iv": "D0NncUdflujdRS/JJbuSiA==\n" + } + }, + { + "lookup": "clbakery-404.zsai.ws", + "value": { + "key": "IlKOmz6uPc/EtfbYwrqVKhgznmRy9kEOeTyWpm0YltA=\n", + "iv": "c8anGRyowRAt6v96yp2n8A==\n" + } + }, + { + "lookup": "shwepalinism-251.zsai.ws", + "value": { + "key": "ewqCMp87P3DZ3vuvgr9MvbiIur7zJgdzpMKMa7juAtA=\n", + "iv": "7gWauvUAcGTqKZu5Mr/TOQ==\n" + } + }, + { + "lookup": "smfoodhouse-371.zsai.ws", + "value": { + "key": "ZYLcWh3oc3kfEfdvAEjBjxIT4CekhYE4LqYHTVnIN1o=\n", + "iv": "h3ZO+m+Btkwa+RgrpRbIBg==\n" + } + }, + { + "lookup": "mrchefsanchaung-288.zsai.ws", + "value": { + "key": "3/bVvNO3n/XSIZUUaJIgADzV014Xh/s7GMKZNjmLDcI=\n", + "iv": "pd2/DOZ326MAZtSOO9igEA==\n" + } + }, + { + "lookup": "skyrestaurant-531.zsai.ws", + "value": { + "key": "89mdymyGhoX2PZvQEopnstvdhhnU41/M634TAjE3y00=\n", + "iv": "Jac3ZRegr6VmguPlOVG4+A==\n" + } + }, + { + "lookup": "astonjc-155.zsai.ws", + "value": { + "key": "YOGpt7XIy/WnGB2vgNtRTeW4Cc/HC0AtYp3dzbAEAbM=\n", + "iv": "u0rGgvI8QPjOOvPcdEqZTQ==\n" + } + }, + { + "lookup": "astonhagl-239.zsai.ws", + "value": { + "key": "AA01+Z6OYCeLl6/fNYh28KaRrVEpy47E95aoXmYBAog=\n", + "iv": "7B8LIgkgbqf+E81f+IqFwg==\n" + } + }, + { + "lookup": "crystaljadesgd-231.zsai.ws", + "value": { + "key": "Ed+PWWn58o0WQ2alYNHazzlIvz8hhk17fpgdR+NeQNE=\n", + "iv": "l5iOgHah76Ds6tlKByY4pw==\n" + } + }, + { + "lookup": "fujisushi-273.zsai.ws", + "value": { + "key": "qyn1pnxDPRUf6DOatw7Pe6jdCauAseZoGA35YtSelrw=\n", + "iv": "hmjOLCD97/IR6fmwDnGqRQ==\n" + } + }, + { + "lookup": "2019demo-416.zsai.ws", + "value": { + "key": "k3G8nBREo1CSVcWvajzSzsqSQeQStjP8m03femQU+Vk=\n", + "iv": "nto3H9MXIFSQN7qtBPZ1ZA==\n" + } + }, + { + "lookup": "owa.zsai.ws", + "value": { + "key": "8kOhzJFlwwCShGFo1Az+2M5jbq41XNrG/VQuK7MMXOQ=\n", + "iv": "RsQMEy6mvuoCSM38hDg5KQ==\n" + } + }, + { + "lookup": "mail.zsai.ws", + "value": { + "key": "EQyGl7Tq9P+JxP9ByFp91UI2JnI66lzWF+XjxRRd0SY=\n", + "iv": "Qm6y7mZ+6h0sSweQcCsF7w==\n" + } + }, + { + "lookup": "ysfm-576.l.zsai.ws", + "value": { + "key": "kN95YB+bKXU0hrr1OBvqheNKMgi8wTI2i3OMW12Prc8=\n", + "iv": "KGBl0+m5LuT/zgZkd8pcIg==\n" + } + }, + { + "lookup": "ysfm-576.zsai.ws", + "value": { + "key": "uETBtnz8Us4/wt7FBF3g0j8cm0dmJ3iWGjzrEu/lL9Q=\n", + "iv": "t4sMzvXe5+TCPfjXWhJOYA==\n" + } + }, + { + "lookup": "shalteashop-421.zsai.ws", + "value": { + "key": "jiUTm9sBy4XeC1b/EYBbLRekRhEgEyYOOEv77hCv4zQ=\n", + "iv": "vD9IPx56GxlIZwyahFenGw==\n" + } + }, + { + "lookup": "thapyayyeiktkt-407.zsai.ws", + "value": { + "key": "FbO7HOCQ2dnK9GOPqfsHF16vtuMbHN67jM50EucUEdQ=\n", + "iv": "D7+j0xqLSZD72pqeGlheSA==\n" + } + }, + { + "lookup": "myomyittarthingangyun-302.zsai.ws", + "value": { + "key": "VitAok1SLjbmbcMz7FGtj8jMkg8deg5iPNvWM7bBBP4=\n", + "iv": "e3lqbtP7A7cpfCyPEWratQ==\n" + } + }, + { + "lookup": "webmail.zsai.ws", + "value": { + "key": "WPXqzXvYLPmnYge9KFewKC5vp7p3fRYF8P+TYfCtH3c=\n", + "iv": "UApU4bGToVLpUc6aBJsfnA==\n" + } + }, + { + "lookup": "excelriverview-208.zsai.ws", + "value": { + "key": "4lG/S5qW9T1eiHtHgs3/l48fN/11JSQVYDQN56iQ8Ag=\n", + "iv": "ue+ZjqBz5DKEbsw5/0Ut8g==\n" + } + }, + { + "lookup": "secure.zsai.ws", + "value": { + "key": "Gz8qSu8kl6s3WNEE62D6ykBLe006ABZyGhSWYyCBBE0=\n", + "iv": "FkEg911z+rKHZr+RULRY/A==\n" + } + }, + { + "lookup": "l.zsai.ws", + "value": { + "key": "9aJyuobKfHA73dLqJXMYBkorZuA2LrL9cqevzv/egso=\n", + "iv": "nMl+s1n80Z4+oQZiqeJsTA==\n" + } + }, + { + "lookup": "sldagon-435.zsai.ws", + "value": { + "key": "p9WNDMfWtyI6tAItA+Sx1GPshBZ7InNjZhcf3gBpjQc=\n", + "iv": "Rk3rT4U32cJvWMwr7r73kQ==\n" + } + }, + { + "lookup": "ssl.zsai.ws", + "value": { + "key": "c2EdIqsUPRhqD82NOjz/M2ixAGUdmR0QGBw47j98RPc=\n", + "iv": "zp0fQOTM3cPG6AW/OjIlcQ==\n" + } + }, + { + "lookup": "oldtownjc-361.zsai.ws", + "value": { + "key": "bKmiJ4Bwa+BxkSjtDWgVx0vMabjaWVaJk8hsANErLCo=\n", + "iv": "pNb7E/Mz65pIQxRHCtHccg==\n" + } + }, + { + "lookup": "shwemyittarhty-149.zsai.ws", + "value": { + "key": "woDDUhNRX7FtZqOTcau2L+auvbnmtuEfupG4vWTBZwg=\n", + "iv": "CF11gCUvbevfebykI8Z1dA==\n" + } + }, + { + "lookup": "eskala-359.zsai.ws", + "value": { + "key": "2rKqEIdZQ5ZmrYQB4zBdxhG8SkUDYJMz0XSKsi5t+dM=\n", + "iv": "G0pDYLhE+2FhWkysAZI64w==\n" + } + }, + { + "lookup": "tmmmdc-595.zsai.ws", + "value": { + "key": "dQrzggV0An/fNqM5cifZ6GwrJakJgzxXLRrBLMfNnm8=\n", + "iv": "MRUzTE2keAZZZDdt9QsB0g==\n" + } + }, + { + "lookup": "zandzthingangyun-409.zsai.ws", + "value": { + "key": "1GB4xozGw/WYTvy5GNkVYzcbY2iBOOsJQrE89uajyQc=\n", + "iv": "tkZvFX050Ml4T3SerrvI1g==\n" + } + }, + { + "lookup": "goldenpark-507.zsai.ws", + "value": { + "key": "Y5FX3iuiOsodILESGbeT4WtFBLQm0F9xObTiHadD6G8=\n", + "iv": "JBgqFZFdcyE2syqjOxKCyQ==\n" + } + }, + { + "lookup": "maeiporkstick-264.zsai.ws", + "value": { + "key": "7zj6IxU2GG22ar4qljaRI+ybzWZiSrrafb7yusXcYCc=\n", + "iv": "RMBd1FJxdOv8IdezT550dQ==\n" + } + }, + { + "lookup": "ygnbar-188.zsai.ws", + "value": { + "key": "qerDjCf5eC+QkvcjUP5QlQ2wRGw97CET51BjgrtfGTw=\n", + "iv": "gFfqZRL5sIDeRDDO5OAJcA==\n" + } + }, + { + "lookup": "mmdcnpt-204.zsai.ws", + "value": { + "key": "nt5CqWZVzlWGsQUkEbJkAp6jnLYEnfnTOjvH4eMClK0=\n", + "iv": "W0nQPKOyiHgl2KpRAy/lQQ==\n" + } + }, + { + "lookup": "yangonstreetfoodmarket-575.l.zsai.ws", + "value": { + "key": "M2V0rY1w1230weqa08/UxmHXzK3G+hy2iqqq5R8Srxc=\n", + "iv": "peMiS9K1MqFGI8+TTDhfRA==\n" + } + }, + { + "lookup": "m.zsai.ws", + "value": { + "key": "kDCkaCmCwQ/dzWqm8nnY5m4D8IPjLXRYVt1e+Lzsv/Y=\n", + "iv": "sAZitTycPdO3r9ebDx1KlQ==\n" + } + }, + { + "lookup": "kingbbq-597.zsai.ws", + "value": { + "key": "ym8nbah0nyEg2yOaCW5208vfPgO5aMKAErpLJ4j2LBs=\n", + "iv": "XvhpxVCJWa+oYnwhcJM91w==\n" + } + }, + { + "lookup": "tpytkt-596.zsai.ws", + "value": { + "key": "z6U3EDWGUasu/cAV1oiXLLl2jn6T/eze7FgP0ZsY1ro=\n", + "iv": "j9/M0Knt5A3hHMXasTetMA==\n" + } + }, + { + "lookup": "sproutsymg-254.zsai.ws", + "value": { + "key": "xT+Ws1UD/PHqVDisVzLZzLX2gRO6WLbQhMkI6gvXyUc=\n", + "iv": "ZAAWoV3v+tp9ucDu0MKxeg==\n" + } + }, + { + "lookup": "slt.advticket1.zsai.ws", + "value": { + "key": "OTR+gtkFToSBvc/WVBEJ+9rI8zC9zHU2OHgBeVezuJY=\n", + "iv": "dK5OHVTHbzw4yCYrLyVWfQ==\n" + } + }, + { + "lookup": "sartawkaeyaeshwelatyar-341.zsai.ws", + "value": { + "key": "Sfu2k/SrHuzDn4Ob1hiwU+6528LGJscK7//OTZ/0TSQ=\n", + "iv": "YUu9q1kbmNxKOdEYhPCqhQ==\n" + } + }, + { + "lookup": "kukupuyitkyaw-355.zsai.ws", + "value": { + "key": "FADrHpoHYsnyp5v4KqMxTZnSn3eEGUfxkYsmGxnIKKo=\n", + "iv": "1TkjUD9MomSVIKv/PDk42A==\n" + } + }, + { + "lookup": "bamboopol-243.zsai.ws", + "value": { + "key": "GdVD6WwpsHTqXgUknD6Yj64+zqMghEgYzB7THyBHx0I=\n", + "iv": "/IJkmYwknhzYZfyclwcIfw==\n" + } + }, + { + "lookup": "newkhumwai-533.zsai.ws", + "value": { + "key": "jodUZHlsVoDPsm0S0C0zZvgPO1Ba1gALc5gtdiRQfGU=\n", + "iv": "1cQKCAGtymGt4CfPThS7IA==\n" + } + }, + { + "lookup": "mrchefkamaryut-287.zsai.ws", + "value": { + "key": "g2JLcPLns8IJgaNYhEHFtwNEgNCl6UHQHy/JuBEexPw=\n", + "iv": "HF8yMiyygnhzv9rmeIwWmA==\n" + } + }, + { + "lookup": "scdemo3-171.zsai.ws", + "value": { + "key": "+AiuJAWDbd69bKqRVwrkpziHW6igQhH9Z+chUzQ39gg=\n", + "iv": "s4tvzFaa/nUJgwlP6hcAvg==\n" + } + }, + { + "lookup": "spicyhouse-567.zsai.ws", + "value": { + "key": "tIb7yWmh0jzy1y65d5U6YHoLWRSRw1Knb1XXidTnpvc=\n", + "iv": "CGRVFkzzcTwuoMqGIJRqXA==\n" + } + }, + { + "lookup": "spicy2house-568.zsai.ws", + "value": { + "key": "D9+YNX9+ifndKwHQRmTI7ebg4K91AxHA6DkzVwW4JBc=\n", + "iv": "p28aD2G8LgA7kbo0J6/w0w==\n" + } + }, + { + "lookup": "nilarsouthokkalapa-460.zsai.ws", + "value": { + "key": "4NNCZjAgzJJWxsubXTkk/r17uHwVY3/gDBX66a5HSE0=\n", + "iv": "9fezHtxuChz46oa1YJSyJg==\n" + } + }, + { + "lookup": "noodinoodle-333.zsai.ws", + "value": { + "key": "C0djTfJUjlheijJWIjLDkWFUe1C0Os5/2rgOteyBGVM=\n", + "iv": "yHDuHW/Ia42C2khyx65NzA==\n" + } + }, + { + "lookup": "ygnsquarebar-588.zsai.ws", + "value": { + "key": "DkZIDdrf9fpyqLgSAQi4UBUdu2EIdacnUeXttI6ZgpQ=\n", + "iv": "FhDyhE+gxlarl1rW/oP6Iw==\n" + } + }, + { + "lookup": "rainbowland-205.zsai.ws", + "value": { + "key": "Qyb285oJjMrBEUA5qxHcwcHgoSlawFKG7ER97IAvZso=\n", + "iv": "8wmSoFJbi3AwdKq7QtXYOw==\n" + } + }, + { + "lookup": "hotelpopular-349.zsai.ws", + "value": { + "key": "owENit+EbDj5k+7A8DuaaZ0tjr7k27OTb7rzivJr0uU=\n", + "iv": "KfRSXHL0jX8Oba4pIrAOGw==\n" + } + }, + { + "lookup": "dimsumbox-490.zsai.ws", + "value": { + "key": "sD2FU1rr6iucXie1EKfSIEKOakT4N65cmjm7b0Xtfr0=\n", + "iv": "ZYRMDynQzfr0pmQZ0R2NiA==\n" + } + }, + { + "lookup": "themomenttearoom-201.zsai.ws", + "value": { + "key": "HRdKC6hoAqa8uIyK6jjIKhHDQZOMKwYhTGntxiYvmUI=\n", + "iv": "MaCn1t24iAvHc8hQlu2WXg==\n" + } + }, + { + "lookup": "aungcafe-212.l.zsai.ws", + "value": { + "key": "AiYsb+2kRH5pKRZQzeNy144H7zL8DSKDU7RiFeLnPgg=\n", + "iv": "nN1HSpgTY3tqQSYvD/P27w==\n" + } + }, + { + "lookup": "thaismile-547.zsai.ws", + "value": { + "key": "iVzGoaEoCiJhlSIgOy8nc4QZDA6lNjXySxhb9Yv4tVk=\n", + "iv": "esdFO8156SvGT4I8la9acQ==\n" + } + }, + { + "lookup": "aungcafe-212.zsai.ws", + "value": { + "key": "NVR9U80gpR/agj3HqKngcA4aNPgKUsAndaLPOa6hpAo=\n", + "iv": "RCJswCIMSb7pQ0DFX0kKAw==\n" + } + }, + { + "lookup": "optdemo-148.zsai.ws", + "value": { + "key": "zWHZXdfoWX+E995000aNotm7F9MlDhaWZw9MRuPrFHo=\n", + "iv": "1b/EidtWf4tTjTn3DvAi3Q==\n" + } + }, + { + "lookup": "operationtesting-541.zsai.ws", + "value": { + "key": "JYhs9IwbI+HOnaOXVPnmLn34qq9hMYjqGkcR4A7d4qA=\n", + "iv": "ZbVgc2FdDPFGxJBKe5O/+g==\n" + } + }, + { + "lookup": "tpytaungyi-447.zsai.ws", + "value": { + "key": "MqPoAoQO8+gdwRD9dzrnzLdn8wtws7IYxJ0nrHoxTqc=\n", + "iv": "jufNKOmhlNSniEGuC7Vk6w==\n" + } + }, + { + "lookup": "tpytaungyi-477.zsai.ws", + "value": { + "key": "bd6U1W48JfstKf4cqnHxzsQLZ5iWIA2DwSgy18qjdwM=\n", + "iv": "V2FsbCiausDyrIF/PYgeqg==\n" + } + }, + { + "lookup": "tpy-taunggyi-477.zsai.ws", + "value": { + "key": "p1W4/Dp+KM1IW0bbDuq0GzKDHmcIgnXAZSl/HURE1K0=\n", + "iv": "rpD89r2urIbguhQR8ymUjw==\n" + } + }, + { + "lookup": "tpytaungyi447.zsai.ws", + "value": { + "key": "MdrjwSyyNPqIU+HO3rwsHHSlG6xCKC5y3pQ1ywGbX2k=\n", + "iv": "8+fEFUROBPpGp23jrRnb3Q==\n" + } } ] } diff --git a/docker-compose.yml b/docker-compose.yml index d1a961f7..ab61383d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,31 +1,33 @@ version: '3' services: - code2lab: - build: - context: . - dockerfile: ./Dockerfile - links: - - redis - volumes: - - .:/sxrestaurant - env_file: - - .code2lab.env - ports: - - '8082:62158' - environment: - - REDIS_URL=redis://redis:6379/0 - sidekiq: - build: . - command: bundle exec sidekiq -C config/sidekiq.yml - links: - - redis - volumes: - - .:/sxrestaurant - environment: - - REDIS_URL=redis://redis:6379/0 - redis: - image: redis - ports: - - '6380:6379' - volumes: - - ../data/redis:/data \ No newline at end of file + code2lab: + build: + context: . + dockerfile: ./Dockerfile + links: + - redis + volumes: + - .:/sxrestaurant + - "/etc/timezone:/etc/timezone:ro" + - "/etc/localtime:/etc/localtime:ro" + env_file: + - .code2lab.env + ports: + - '62160:62158' + environment: + - REDIS_URL=redis://172.17.0.1:6380/0 + sidekiq: + build: . + command: bundle exec sidekiq -C config/sidekiq.yml + links: + - redis + volumes: + - .:/sxrestaurant + environment: + - REDIS_URL=redis://172.17.0.1:6380/0 + redis: + image: redis + ports: + - '6380:6379' + volumes: + - ../data/redis:/data diff --git a/docker-compose.yml.back b/docker-compose.yml.back new file mode 100644 index 00000000..d1a961f7 --- /dev/null +++ b/docker-compose.yml.back @@ -0,0 +1,31 @@ +version: '3' +services: + code2lab: + build: + context: . + dockerfile: ./Dockerfile + links: + - redis + volumes: + - .:/sxrestaurant + env_file: + - .code2lab.env + ports: + - '8082:62158' + environment: + - REDIS_URL=redis://redis:6379/0 + sidekiq: + build: . + command: bundle exec sidekiq -C config/sidekiq.yml + links: + - redis + volumes: + - .:/sxrestaurant + environment: + - REDIS_URL=redis://redis:6379/0 + redis: + image: redis + ports: + - '6380:6379' + volumes: + - ../data/redis:/data \ No newline at end of file From 55f489cabbce9b8deeabde21771b16e611adfaa0 Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 18 Nov 2019 13:10:32 +0630 Subject: [PATCH 02/13] gem --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index cc6611ed..cb20745e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' -#ruby '2.4.1' -ruby '2.5.7' +ruby '2.4.1' +# ruby '2.5.7' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") From f2b4114ad5bfce9cd25e569188b9576d83ac5d25 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Tue, 19 Nov 2019 00:08:56 +0630 Subject: [PATCH 03/13] change config for local server --- .code2lab.env | 1 - .../origami/dashboard_controller.rb | 15 +- app/models/license.rb | 189 +++++++++--------- app/models/printer/printer_worker.rb | 4 +- config/cable.yml | 2 +- config/initializers/license.rb | 2 - config/redis.yml | 4 +- config/secrets.yml | 10 +- 8 files changed, 111 insertions(+), 116 deletions(-) diff --git a/.code2lab.env b/.code2lab.env index 3a697ccd..0a6c7f0b 100644 --- a/.code2lab.env +++ b/.code2lab.env @@ -1,2 +1 @@ RAILS_ENV=production -SERVER_MODE=cloud diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index 22aef2e1..7ccac407 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -2,10 +2,9 @@ class Origami::DashboardController < BaseOrigamiController def index @shop = Shop.first - Rails.logger.info ENV["SERVER_MODE"] - Rails.logger.info "<><><><><><><><>>" - today = DateTime.now.strftime('%Y-%m-%d') + today = DateTime.now.strftime('%Y-%m-%d') + @display_type = Lookup.find_by_lookup_type("display_type") @sale_data = Array.new @@ -15,7 +14,7 @@ class Origami::DashboardController < BaseOrigamiController if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay" pay = Sale.payment_sale('card', today, current_user) @sale_data.push({'card' => pay.payment_amount}) - else + else pay = Sale.payment_sale(payment.payment_method, today, current_user) @sale_data.push({payment.payment_method => pay.payment_amount}) end @@ -39,10 +38,10 @@ class Origami::DashboardController < BaseOrigamiController end else @account_data = nil - end + end @top_items = Sale.top_items(today,current_user) - @total_foc_items = Sale.total_foc_items(today,current_user) + @total_foc_items = Sale.total_foc_items(today,current_user) # get printer info @print_settings = PrintSetting.get_precision_delimiter() @@ -105,12 +104,12 @@ class Origami::DashboardController < BaseOrigamiController end def get_all_menu - @menus = Menu.active.all + @menus = Menu.active.all end def get_credit_sales credit_sales = SalePayment.get_credit_sales(params) - if !credit_sales.nil? + if !credit_sales.nil? result = {:status=> true, :data=> credit_sales } else result = {:status=> false, :message=>"There is no record." } diff --git a/app/models/license.rb b/app/models/license.rb index befb4b36..2c550a1e 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -13,28 +13,27 @@ class License def initialize(server = "", lookup = "") #this code is hard-code to reflect server mode - Very important. - # self.server_mode = ENV["SERVER_MODE"] - self.server_mode = "cloud" + self.server_mode = ENV["SERVER_MODE"] if (server != "") self.class.base_uri server end - end + end # For Cloud - def detail_with_local_cache(lookup) + def detail_with_local_cache(lookup) aes = MyAesCrypt.new - aes_key, aes_iv = aes.export_to_file(lookup) - + aes_key, aes_iv = aes.export_to_file(lookup) + ##Check from local redis - if available load local otherwise get from remote - cache_key = "#{lookup}:license:#{aes_key}:hostname" + cache_key = "#{lookup}:license:#{aes_key}:hostname" cache_license = nil ##Get redis connection from connection pool redis = Redis.new - cache_license = redis.get(cache_key) - + cache_license = redis.get(cache_key) + Rails.logger.info "Cache key - " + cache_key.to_s if cache_license.nil? ##change the d/e key @@ -48,7 +47,7 @@ class License assign(aes_key, aes_iv) #Rails.logger.info "License - " + response.parsed_response.to_s - + redis = Redis.new redis.set(cache_key, Marshal.dump(@license)) # redis.sadd("License:cache:keys", cache_key) @@ -61,36 +60,36 @@ class License return true end - else + else @license = Marshal.load(cache_license) assign(aes_key, aes_iv) - # Rails.logger.info 'API License' + # Rails.logger.info 'API License' return true end end # For Local System - def detail_with_local_file() + def detail_with_local_file() renewal_date_str = read_license("renewable_date") - if check_expiring(renewal_date_str) - # return for all ok + if check_expiring(renewal_date_str) + # return for all ok return 1 else has_license = verify_license() if has_license - # return for expiring + # return for expiring return 2 else return 0 end end - # end - end + # end + end # License Activation def license_activate (shop, license_key, db_host, db_schema, db_user, db_password) - aes = MyAesCrypt.new - aes_key, aes_iv = aes.export_key(license_key) + aes = MyAesCrypt.new + aes_key, aes_iv = aes.export_key(license_key) @params = { query: { lookup_type: self.server_mode, iv_key: aes_iv, license_key: license_key } } response = self.class.get("/activate", @params) @@ -98,21 +97,21 @@ class License if (@activate["status"]) ##Check from local redis - if available load local otherwise get from remote - cache_key = "shop:#{@activate["shop_name"]}" + cache_key = "shop:#{@activate["shop_name"]}" - cache_license = nil + cache_license = nil ##Get redis connection from connection pool redis = Redis.new - cache_license = redis.get(cache_key) + cache_license = redis.get(cache_key) Rails.logger.info "Cache key - " + cache_key.to_s - if cache_license.nil? - cache = {"shop" => @activate["shop_name"], "key" => aes_key, "iv" => @activate["iv_key"], "renewable_date" => @activate["renewable_date"] } + if cache_license.nil? + cache = {"shop" => @activate["shop_name"], "key" => aes_key, "iv" => @activate["iv_key"], "renewable_date" => @activate["renewable_date"] } redis = Redis.new redis.set(cache_key, Marshal.dump(cache)) - end + end Rails.logger.info "License - " + response.parsed_response.to_s @@ -122,21 +121,21 @@ class License sym_path = File.expand_path("~/symmetric/") response = create_symmetric_config(sym_path, db_host, db_schema, db_user, db_password) - + if(response[:status]) response = run_symmetric(sym_path) end end else response = { "status": false, "message": "Activation Failed! Please contact code2lab call center!"} - end + end return response end - def verify_license - api_token = read_license_no_decrypt("api_token") + def verify_license + api_token = read_license_no_decrypt("api_token") @params = { query: {lookup_type: "application", api_token: api_token} } - + begin response = self.class.get("/verify", @params) @varified = response.parsed_response @@ -147,7 +146,7 @@ class License end else delete_license_file - end + end rescue SocketError => e Rails.logger.debug "In SocketError No Internet connection ! " @@ -161,21 +160,21 @@ class License rescue OpenURI::HTTPError Rails.logger.debug "Can't connect server" return true - end - return false + end + return false end # Check Expired before 30 days - def check_expiring(renewal_date_str) + def check_expiring(renewal_date_str) if !renewal_date_str.empty? - renewal_date = DateTime.parse(renewal_date_str) + renewal_date = DateTime.parse(renewal_date_str) renewal_date > Date.today.advance(:days => 30) end end # Check License expired date from PROVISION SERVER - def check_expired(renewal_date_str) + def check_expired(renewal_date_str) expired_date_str = read_license("renewable_date") renewal_date = DateTime.parse(renewal_date_str) if(renewal_date_str != expired_date_str) @@ -188,32 +187,32 @@ class License return false end end - + # Check License File exists def self.check_license_file - return File.exist?("config/license.yml") + return File.exist?("config/license.yml") end # read line by key for license file - def read_license(key_name) - decrypted_line = "" + def read_license(key_name) + decrypted_line = "" key, iv = get_redis_key() - if File.exist?("config/license.yml") + if File.exist?("config/license.yml") File.open("config/license.yml").each do |line| - if line.include? (key_name) - decrypted_line_array = line.split(": ") + if line.include? (key_name) + decrypted_line_array = line.split(": ") decrypted_line = AESCrypt.decrypt_data(decode_str(decrypted_line_array[1]), decode_str(key), decode_str(iv), ENV['CIPHER_TYPE']) end end - end + end return decrypted_line end # read line by key for license file without decrypt def read_license_no_decrypt(key) decrypted_line = "" - if File.exist?("config/license.yml") + if File.exist?("config/license.yml") File.open("config/license.yml").each do |line| if line.include? (key) decrypted_line_array = line.split(": ") @@ -228,18 +227,18 @@ class License def update_license(content, new_content) key, iv = get_redis_key() - if !new_content.include? "==" + if !new_content.include? "==" crypted_str = AESCrypt.encrypt_data(new_content, decode_str(key), decode_str(iv), ENV['CIPHER_TYPE']) end - + content_str = read_license_no_decrypt(content) - if File.exist?("config/license.yml") + if File.exist?("config/license.yml") file_str = File.read("config/license.yml") new_file_str = file_str.gsub(content_str, encode_str(crypted_str)) # To write changes to the file, use: File.open("config/license.yml", "w") {|file| file.puts new_file_str } - + # File.open("config/license.yml").each do |line| # new_file_str = line.gsub(content, crypted_str) # f.put @@ -249,33 +248,33 @@ class License # Re-get keys def get_key - api_token = read_license_no_decrypt("api_token") - shop_name = read_license_no_decrypt("shop_name") + api_token = read_license_no_decrypt("api_token") + shop_name = read_license_no_decrypt("shop_name") @params = { query: {lookup_type: "application", api_token: api_token } } response = self.class.get("/get_key", @params) @data = response.parsed_response - + if (@data["status"]) ##Check from local redis - if available load local otherwise get from remote - cache_key = "shop:#{shop_name.chomp}" + cache_key = "shop:#{shop_name.chomp}" - cache_license = nil + cache_license = nil ##Get redis connection from connection pool redis = Redis.new - cache_license = redis.get(cache_key) + cache_license = redis.get(cache_key) Rails.logger.info "Cache key - " + cache_key.to_s - if cache_license.nil? - cache = {"shop" => shop_name, "key" => @data["secret_key"], "iv" => @data["iv_key"], "renewable_date" => @data["renewable_date"] } + if cache_license.nil? + cache = {"shop" => shop_name, "key" => @data["secret_key"], "iv" => @data["iv_key"], "renewable_date" => @data["renewable_date"] } redis = Redis.new redis.set(cache_key, Marshal.dump(cache)) - end + end return true - end + end return false - end + end private def get_redis_key @@ -283,18 +282,18 @@ class License key = "" shop = read_license_no_decrypt("shop_name") ##Check from local redis - if available load local otherwise get from remote - cache_key = "shop:#{shop.chomp}" + cache_key = "shop:#{shop.chomp}" - cache_shop = nil + cache_shop = nil ##Get redis connection from connection pool redis = Redis.new - cache_shop = redis.get(cache_key) + cache_shop = redis.get(cache_key) - if !cache_shop.nil? - @shop = Marshal.load(cache_shop) - key = @shop["key"] - iv = @shop["iv"] + if !cache_shop.nil? + @shop = Marshal.load(cache_shop) + key = @shop["key"] + iv = @shop["iv"] end return key, iv end @@ -309,13 +308,13 @@ class License # License File Creation def create_license_file(response_data) - if File.exist?("config/license.yml") + if File.exist?("config/license.yml") delete_license_file end begin # Licese File Creation - File.open("config/license.yml", "w") do |f| + File.open("config/license.yml", "w") do |f| f.puts("iv_key: #{response_data['iv_key']}") f.puts("shop_name: #{response_data['shop_name']}") f.puts("email: #{response_data['email']}") @@ -327,11 +326,11 @@ class License f.puts("dbusername: #{response_data['dbusername']}") f.puts("dbpassword: #{response_data['dbpassword']}") f.puts("api_token: #{response_data['api_token']}") - f.puts("app_token: #{response_data['app_token']}") + f.puts("app_token: #{response_data['app_token']}") f.puts("plan_sku: #{response_data['plan_sku']}") f.puts("renewable_date: #{response_data['renewable_date']}") f.puts("plan_name: #{response_data['plan_name']}") - end + end rescue IOError response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"} end @@ -354,15 +353,15 @@ class License f.write("group.id=sx\n") f.write("external.id=000\n") f.write("job.purge.period.time.ms=7200000\n") - f.write("job.routing.period.time.ms=5000\n") - f.write("job.push.period.time.ms=10000\n") - f.write("job.pull.period.time.ms=10000\n") - f.write("initial.load.create.first=true\n") + f.write("job.routing.period.time.ms=5000\n") + f.write("job.push.period.time.ms=10000\n") + f.write("job.pull.period.time.ms=10000\n") + f.write("initial.load.create.first=true\n") f.write("initial.load.use.extract.job.enabled=true\n") f.write("rest.api.enable=true\n") - f.close + f.close - # read from license file + # read from license file # shop_name = read_license_no_decrypt("shop_name") shop_name = "cloud" dbhost = read_license("dbhost") @@ -380,12 +379,12 @@ class License f.write("registration.url=http://#{db_host}:31415/sync/sx\n") f.write("group.id=cloud\n") f.write("external.id=001\n") - f.write("job.routing.period.time.ms=5000\n") - f.write("job.push.period.time.ms=10000\n") + f.write("job.routing.period.time.ms=5000\n") + f.write("job.push.period.time.ms=10000\n") f.write("job.pull.period.time.ms=10000\n") f.write("rest.api.enable=true\n") - # f.write("initial.load.create.first=true\n") - # f.write("initial.load.use.extract.job.enabled=true\n") + # f.write("initial.load.create.first=true\n") + # f.write("initial.load.use.extract.job.enabled=true\n") f.close rescue IOError response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"} @@ -394,12 +393,12 @@ class License end end - # Run Symmetric + # Run Symmetric def run_symmetric(sym_path) # check_sym_proc_str = `#{sym_path + "bin/sym_service status"}` # check_sym_proc_str = check_sym_proc_str.split("\n") # sym_install_status = check_sym_proc_str[0].split(": ") - + check_sym_proc_str = `#{"sudo service SymmetricDS status"}` # Check Sym Installed @@ -414,7 +413,7 @@ class License check_sym_table = system("sudo " + sym_path + "/bin/symadmin --engine sx create-sym-tables") if check_sym_table sym_sql = Rails.root + "db/sym_master.sql" - + if File.exist? (sym_sql) # Import Sym Sql to db and start sym run_sym_sql = system("sudo " + sym_path + "/bin/dbimport --engine sx " + sym_sql.to_s) @@ -429,7 +428,7 @@ class License else response = { "status": false, "message": "Activation is success but Cannot create Sym Tables. \n Please contact code2lab call center!"} end - else + else response = { "status": false, "message": "Activation is success but Symmetric not running. \n Please contact code2lab call center!"} end end @@ -437,7 +436,7 @@ class License # Check Symmetric Running def check_sym_running(status, sym_path) # Run Sym Service - # if status.include? "Server is already running" + # if status.include? "Server is already running" # return true # elsif status.include? "false" # sym_start_str = `#{sym_path + "bin/sym_service start"}` @@ -445,9 +444,9 @@ class License # return true # else # check_sym_running(sym_start_status[0]) - # end + # end # else - # return true + # return true # end if status.include? "Active: active (running)" || "Active: active (exited)" #"Server is already running" @@ -458,15 +457,15 @@ class License # Delete License File def delete_license_file - File.delete("config/license.yml") if File.exist?("config/license.yml") + File.delete("config/license.yml") if File.exist?("config/license.yml") end # Assign db info for Cloud - def assign(aes_key, aes_iv) + def assign(aes_key, aes_iv) key = Base64.decode64(aes_key) iv = Base64.decode64(aes_iv) - - if (@license["dbhost"] || @license["dbschema"] || @license["dbusername"] || @license["dbpassword"] ) + + if (@license["dbhost"] || @license["dbschema"] || @license["dbusername"] || @license["dbpassword"] ) host = Base64.decode64(@license["dbhost"]) dbschema = Base64.decode64(@license["dbschema"]) dbusername = Base64.decode64(@license["dbusername"]) @@ -475,8 +474,8 @@ class License self.dbhost = AESCrypt.decrypt_data(host, key, iv, ENV['CIPHER_TYPE']) self.dbschema = AESCrypt.decrypt_data(dbschema, key, iv, ENV['CIPHER_TYPE']) self.dbusername = AESCrypt.decrypt_data(dbusername, key, iv, ENV['CIPHER_TYPE']) - self.dbpassword = AESCrypt.decrypt_data(dbpassword, key, iv, ENV['CIPHER_TYPE']) + self.dbpassword = AESCrypt.decrypt_data(dbpassword, key, iv, ENV['CIPHER_TYPE']) end - + end end diff --git a/app/models/printer/printer_worker.rb b/app/models/printer/printer_worker.rb index 0a580e40..e0d4fc85 100755 --- a/app/models/printer/printer_worker.rb +++ b/app/models/printer/printer_worker.rb @@ -1,9 +1,9 @@ require 'net/http' -#require 'cups' +require 'cups' class Printer::PrinterWorker attr_accessor :print_settings - + def initialize(print_settings) self.print_settings = print_settings end diff --git a/config/cable.yml b/config/cable.yml index 36f0b961..e740f386 100755 --- a/config/cable.yml +++ b/config/cable.yml @@ -1,6 +1,6 @@ redis: &redis adapter: redis - url: redis://172.17.0.1:6380/1 + url: redis://localhost:6379/1 production: *redis development: *redis diff --git a/config/initializers/license.rb b/config/initializers/license.rb index 31510a0f..7eed14a6 100644 --- a/config/initializers/license.rb +++ b/config/initializers/license.rb @@ -3,6 +3,4 @@ if File.exist?("config/license.yml") config.fetch(Rails.env, {}).each do |key, value| ENV[key.upcase] = value.to_s end -else - ENV["SERVER_MODE"] = "cloud" end diff --git a/config/redis.yml b/config/redis.yml index 493a6027..b8c7b2eb 100644 --- a/config/redis.yml +++ b/config/redis.yml @@ -9,5 +9,5 @@ test: <<: *default production: - db: 0 - url: redis://172.17.0.1:6380 + <<: *default + url: redis://127.0.0.1:6379 diff --git a/config/secrets.yml b/config/secrets.yml index ff014434..069b1403 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -11,8 +11,8 @@ # if you're sharing your code publicly. development: - secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61 - sx_provision_url: connect.smartsales.asia/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api + secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61 + sx_provision_url: connect.smartsales.asia/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api server_mode: application cipher_type: AES-256-CBC sx_key: Wh@t1$C2L @@ -23,8 +23,8 @@ test: # Do not keep production secrets in the repository, # instead read values from the environment. production: - secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22 - sx_provision_url: 52.221.188.144:9292/api #connect.smartsales.asia/api #192.168.1.147:3002/api - server_mode: cloud + secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22 + sx_provision_url: connect.smartsales.asia/api #52.221.188.144:9292/api #192.168.1.147:3002/api + server_mode: application cipher_type: AES-256-CBC sx_key: Wh@t1$C2L From 2b5105672a661df11f1263171a104770ff657fef Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 19 Nov 2019 09:33:54 +0630 Subject: [PATCH 04/13] gem file --- Gemfile | 2 +- Gemfile.lock | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index cb20745e..f07c8f18 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -ruby '2.4.1' +# ruby '2.4.1' # ruby '2.5.7' git_source(:github) do |repo_name| diff --git a/Gemfile.lock b/Gemfile.lock index 858ce67d..9c92b6e0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -374,9 +374,5 @@ DEPENDENCIES web-console (>= 3.3.0) whenever -RUBY VERSION - - ruby 2.4.1p111 - BUNDLED WITH 2.0.2 From 0ed10a0c6443c76698ee5a6ae434c67245357a34 Mon Sep 17 00:00:00 2001 From: Aung Ye Kyaw Date: Tue, 19 Nov 2019 11:53:02 +0000 Subject: [PATCH 05/13] Update Gemfile for Ruby version 2.4.1 --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index cc6611ed..e0d9e933 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' -#ruby '2.4.1' -ruby '2.5.7' +ruby '2.4.1' +#ruby '2.5.7' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") From 336e32f1a67afe03b0a051e9dc73d2fb64163bf8 Mon Sep 17 00:00:00 2001 From: Nweni Date: Wed, 20 Nov 2019 09:44:49 +0630 Subject: [PATCH 06/13] fixed daliy sales report - payment method error --- app/views/reports/dailysale/index.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/reports/dailysale/index.html.erb b/app/views/reports/dailysale/index.html.erb index 592a8cca..54656079 100755 --- a/app/views/reports/dailysale/index.html.erb +++ b/app/views/reports/dailysale/index.html.erb @@ -26,12 +26,13 @@ <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%> + <% @count = 1 %> <% @payment_methods.each_slice(10) do |slice| %> <% alph = "A" %> - <% @count = 1 %> + <% slice.each do |payment_method| %> <%= alph %> From 3c5755a0288a9c91a3e30e7db980a0759a128745 Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Thu, 28 Nov 2019 17:27:28 +0630 Subject: [PATCH 07/13] fixed set items in origami --- app/views/origami/dashboard/_menu.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/origami/dashboard/_menu.json.jbuilder b/app/views/origami/dashboard/_menu.json.jbuilder index dcbff54f..703c3355 100644 --- a/app/views/origami/dashboard/_menu.json.jbuilder +++ b/app/views/origami/dashboard/_menu.json.jbuilder @@ -80,7 +80,7 @@ if (menu.menu_categories) alt_name: its.alt_name, min_selectable_qty: its.min_selectable_qty, max_selectable_qty: its.max_selectable_qty, - instances: its.menu_item_instances.map { |id| {id: id}} + instances: its.menu_item_instances.map { |i| {id: i.id} } } } From 5b88d164856b2a271bb4eb8899cb02c12f5be06b Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Thu, 28 Nov 2019 19:25:52 +0630 Subject: [PATCH 08/13] update number_formattable --- .../concerns/number_formattable.rb | 36 +++++++++++-------- .../origami/dashboard_controller.rb | 25 +++++++------ 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/app/controllers/concerns/number_formattable.rb b/app/controllers/concerns/number_formattable.rb index a7b97732..063df8ca 100644 --- a/app/controllers/concerns/number_formattable.rb +++ b/app/controllers/concerns/number_formattable.rb @@ -2,44 +2,50 @@ module NumberFormattable extend ActiveSupport::Concern def precision - @precision ||= Lookup.number_formats.find { |f| f.name.parameterize.underscore == 'precision'} + return @precision if defined? @precision + @number_formats = Lookup.number_formats if !defined? @number_formats + if @number_formats + @precision = @number_formats.find? { |x| x.name.parameterize.underscore == 'precision'}.value.to_i rescue nil + end if @precision.nil? - @print_settings ||= PrintSetting.get_precision_delimiter + @print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats if @print_settings - @precision = OpenStruct.new(value: @print_settings.precision.to_i) + @precision = @print_settings.precision.to_i else - @precision = OpenStruct.new(value: 2) + @precision = 2 end end - @precison_value ||= @precision.value.to_i end def delimiter - @delimiter ||= Lookup.number_formats.find { |f| f.name.parameterize.underscore == 'delimiter'} + return @delimiter if defined? @delimiter + @number_formats = Lookup.number_formats if !defined? @number_formats + if @number_formats + @delimiter = @number_formats.find { |f| f.name.parameterize.underscore == 'delimiter'}.value.gsub(/\\u(\h{4})/) { |m| [$1].pack("H*").unpack("n*").pack("U*") } rescue nil + end if @delimiter.nil? - @print_settings ||= PrintSetting.get_precision_delimiter + @print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats if @print_settings && @print_settings.delimiter - @delimiter = OpenStruct.new(value: ",") + @delimiter = "," else - @delimiter = OpenStruct.new(value: "") + @delimiter = "," end end - @delimiter_value ||= @delimiter.value.to_s.gsub(/\\u(\h{4})/) { |m| [$1].pack("H*").unpack("n*").pack("U*") } end def strip_insignificant_zeros - @strip_insignificant_zeros ||= Lookup.number_formats.find { |f| f.name.parameterize.underscore == 'strip_insignificant_zeros'} - if @strip_insignificant_zeros.nil? - @strip_insignificant_zeros = OpenStruct.new(value: false) + return @strip_insignificant_zeros if defined? @strip_insignificant_zeros + @number_formats = Lookup.number_formats if !defined? @number_formats + if @number_formats + @strip_insignificant_zeros = @number_formats.find { |f| f.name.parameterize.underscore == 'strip_insignificant_zeros'}.value.in? ['1', 't', 'true', 'on', 'y', 'yes'] rescue false end - @strip_insignificant_zeros_value ||= ['1', 't', 'true', 'on', 'y', 'yes'].include? @strip_insignificant_zeros.value.to_s end def number_format(number, options = {}) options[:precision] = options[:precision] || precision # options[:delimiter] = options[:delimiter] || delimiter options[:strip_insignificant_zeros] = options[:strip_insignificant_zeros] || strip_insignificant_zeros - + if options[:precision] > 0 if options[:strip_insignificant_zeros] formatted = "%.12g" % number.round(options[:precision]) diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index 00766d51..7f631334 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -2,21 +2,20 @@ class Origami::DashboardController < BaseOrigamiController def index @shop = Shop.first - - today = DateTime.now.strftime('%Y-%m-%d') - @display_type = Lookup.find_by_lookup_type("display_type") @sale_data = Array.new @total_payment_methods = Sale.total_payment_methods(current_user) + if !@total_payment_methods.nil? - @total_payment_methods.each do |payment| - pay = Sale.payment_sale(payment.payment_method, current_user) - @sale_data.push({payment.payment_method => pay.payment_amount}) - end + @total_payment_methods.each do |payment| + pay = Sale.payment_sale(payment.payment_method, current_user) + @sale_data.push({payment.payment_method => pay.payment_amount}) + end else @sale_data = nil end + @summ_sale = Sale.summary_sale_receipt(current_user) @total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to) # @total_other_customer = Sale.total_other_customer(today,current_user) @@ -25,13 +24,13 @@ class Origami::DashboardController < BaseOrigamiController @total_accounts = Account.select("accounts.id as account_id, accounts.title as title") @account_data = Array.new if !@total_accounts.nil? - @total_accounts.each do |account| - acc = Sale.account_data(account.account_id, current_user) - if !acc.nil? - @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) - end + @total_accounts.each do |account| + acc = Sale.account_data(account.account_id, current_user) + if !acc.nil? + @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) end - @total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? } + end + @total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? } else @account_data = nil end From 0ef1b4fd87d6df8cace19a59d6c9369bd9e10897 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Fri, 29 Nov 2019 14:24:35 +0630 Subject: [PATCH 09/13] fix request bill error with show_total_before_tax --- app/controllers/concerns/number_formattable.rb | 8 +++++--- app/pdf/receipt_bill_pdf.rb | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/concerns/number_formattable.rb b/app/controllers/concerns/number_formattable.rb index 063df8ca..bb022263 100644 --- a/app/controllers/concerns/number_formattable.rb +++ b/app/controllers/concerns/number_formattable.rb @@ -45,15 +45,17 @@ module NumberFormattable options[:precision] = options[:precision] || precision # options[:delimiter] = options[:delimiter] || delimiter options[:strip_insignificant_zeros] = options[:strip_insignificant_zeros] || strip_insignificant_zeros + + number = number.to_f.round(options[:precision]) if options[:precision] > 0 if options[:strip_insignificant_zeros] - formatted = "%.12g" % number.round(options[:precision]) + formatted = "%.12g" % number else - formatted = "%.#{options[:precision]}f" % number.round(options[:precision]) + formatted = "%.#{options[:precision]}f" % number end else - formatted = number.round(options[:precision]).to_i.to_s + formatted = number.to_i.to_s end if options[:delimiter] && !options[:delimiter].empty? diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 2d463b38..842b6f27 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -344,14 +344,14 @@ class ReceiptBillPdf < Prawn::Document sale_data.sale_taxes.each do |st| if (st.tax_name.include? "Service") service_tax_desc = st.tax_name - service_tax_amount = number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) + service_tax_amount = st.tax_payable_amount if incl_tax service_tax_rate = st.tax_rate.to_i end end if (st.tax_name.include? "Commercial") com_tax_desc = st.tax_name - com_tax_amount = number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) + com_tax_amount = st.tax_payable_amount if incl_tax com_tax_rate = st.tax_rate.to_i end From e3501cd43ce5fdcd600342a10644b58fa04eb1cd Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Fri, 29 Nov 2019 14:49:36 +0630 Subject: [PATCH 10/13] fix stock check error --- app/models/sale_item.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index dc03935c..3510b7c4 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -398,11 +398,12 @@ class SaleItem < ApplicationRecord stock = StockJournal.where('item_code=?', self.item_instance_code).order("id DESC").first unless stock.nil? check_item = StockCheckItem.where('item_code=?', self.item_instance_code).order("id DESC").first + + StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS) + check_item.different = check_item.different + qty + check_item.save end end - StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS) - check_item.different = check_item.different + qty - check_item.save elsif is_foc or cancel_foc qty = StockJournal.where(trans_ref: self.sale_item_id).sum("credit-debit") if stock_journal = StockJournal.where(trans_ref: self.sale_item_id, item_code: self.item_instance_code).order(id: :desc).first From 18cb9ba23cc25958864ce70f96dc06b8bff21953 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Fri, 29 Nov 2019 15:47:15 +0630 Subject: [PATCH 11/13] fix sub menu category error --- app/controllers/origami/dashboard_controller.rb | 4 ++-- app/views/origami/dashboard/_menu.json.jbuilder | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index 7f631334..43c79179 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -6,7 +6,7 @@ class Origami::DashboardController < BaseOrigamiController @sale_data = Array.new @total_payment_methods = Sale.total_payment_methods(current_user) - + if !@total_payment_methods.nil? @total_payment_methods.each do |payment| pay = Sale.payment_sale(payment.payment_method, current_user) @@ -99,7 +99,7 @@ class Origami::DashboardController < BaseOrigamiController end def get_all_menu - @menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).includes(:menu_categories => {:menu_items => {:item_sets => :menu_item_instances}}).active.all + @menus = Menu.includes(:menu_categories => :children).includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).includes(:menu_categories => {:menu_items => {:item_sets => :menu_item_instances}}).active.all @item_attributes = MenuItemAttribute.all.load @item_options = MenuItemOption.all.load end diff --git a/app/views/origami/dashboard/_menu.json.jbuilder b/app/views/origami/dashboard/_menu.json.jbuilder index 703c3355..6d1ec624 100644 --- a/app/views/origami/dashboard/_menu.json.jbuilder +++ b/app/views/origami/dashboard/_menu.json.jbuilder @@ -15,15 +15,10 @@ if (menu.menu_categories) categories = menu.menu_categories json.categories categories do |category| if category.is_available - parent_category = category.parent - if !parent_category.nil? - json.sub_category "true" - else - json.sub_category "false" - end + json.sub_category category.children.present? + valid_time = category.valid_time json.valid_time valid_time - json.id category.id json.code category.code json.order_by category.order_by From 5d10d4b6a17f176e57ac84647ab69298ed84c018 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Fri, 29 Nov 2019 17:47:16 +0630 Subject: [PATCH 12/13] fix origami dashboard --- app/models/sale.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/models/sale.rb b/app/models/sale.rb index 18be54a9..85a81950 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1583,6 +1583,8 @@ end if !from.nil? && !to.nil? query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1606,6 +1608,8 @@ end if !from.nil? && !to.nil? query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1637,6 +1641,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1654,6 +1660,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1675,6 +1683,8 @@ end if (!from.nil? && !to.nil?) query = query.merge(Sale.receipt_date_between(from, to)) + else + query = query.merge(Sale.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1692,6 +1702,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1711,6 +1723,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1738,6 +1752,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1784,6 +1800,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1802,6 +1820,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1866,6 +1886,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1884,6 +1906,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1902,6 +1926,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1921,6 +1947,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -2073,6 +2101,8 @@ def self.employee_sale(shift=nil,from=nil,to=nil,from_time=nil,to_time=nil) .paid.completed if !from.nil? && !to.nil? query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if !shift.nil? From 937f40e7c18da63e10349b5c3fd3630f3bee7379 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Mon, 2 Dec 2019 17:19:28 +0630 Subject: [PATCH 13/13] 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 details: 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