From 213644d8ef608b230473eec62aecc13a93f8d3c1 Mon Sep 17 00:00:00 2001 From: git_code2lab Date: Fri, 15 Nov 2019 14:17:50 +0630 Subject: [PATCH 01/54] 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/54] 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 74e29f7c3959aa667d114ba35f30a0bf15514378 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Mon, 18 Nov 2019 14:00:52 +0630 Subject: [PATCH 03/54] remove def total_account from sale --- Gemfile.lock | 4 ++-- app/controllers/home_controller.rb | 7 ++++--- .../origami/dashboard_controller.rb | 3 ++- app/models/sale.rb | 21 ------------------- 4 files changed, 8 insertions(+), 27 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 49926b1c..a1fd1f6d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -375,8 +375,8 @@ DEPENDENCIES web-console (>= 3.3.0) whenever - RUBY VERSION - ruby 2.6.3p62 + ruby 2.4.1p111 + BUNDLED WITH 2.0.2 diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index d9c67962..4d8c715a 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -134,7 +134,7 @@ class HomeController < ApplicationController end @inventories = StockJournal.inventory_balances(today,@from,@to,@from_time,@to_time).sum(:balance) - @total_trans = Sale.total_trans(today,current_user,@from,@to,@from_time,@to_time) + @total_trans = Sale.total_trans(today,current_user,@from,@to,@from_time,@to_time) @total_card = Sale.total_card_sale(today,current_user,@from,@to,@from_time,@to_time) @total_credit = Sale.credit_payment(today,current_user,@from,@to,@from_time,@to_time) @@ -157,15 +157,16 @@ class HomeController < ApplicationController # @total_other_customer = Sale.total_other_customer(today,current_user) @total_order = Sale.total_order(today,current_user,@from,@to,@from_time,@to_time) - @total_accounts = Sale.total_account(today,current_user,@from,@to,@from_time,@to_time) + @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, today,current_user,@from,@to,@from_time,@to_time) - if !acc.nil? + if !acc.nil? && acc.cnt_acc > 0 @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) end end + @total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? } end @top_items = Sale.top_items(today,current_user,@from,@to,@from_time,@to_time) diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index 1daa652b..a1aa2064 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -27,7 +27,7 @@ class Origami::DashboardController < BaseOrigamiController # @total_other_customer = Sale.total_other_customer(today,current_user) @total_order = Sale.total_order(today,current_user) - @total_accounts = Sale.total_account(today,current_user) + @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| @@ -36,6 +36,7 @@ class Origami::DashboardController < BaseOrigamiController @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) end end + @total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? } else @account_data = nil end diff --git a/app/models/sale.rb b/app/models/sale.rb index fe43ea69..999a18fd 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1878,27 +1878,6 @@ end query = query.first end - def self.total_account(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil) - query = Sale.select("distinct b.id as account_id, b.title as title") - .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") - .joins("JOIN accounts as b ON b.id = a.account_id") - .where('sales.sale_status = "completed"') - if (!from.nil? && !to.nil?) && (from != "" && to!="") - query = query.date_between(from, to) - if !from_time.nil? && !to_time.nil? - query = query.time_between(from_time, to_time) - end - else - query = query.date_on(today) - end - if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') - if shift = ShiftSale.current_open_shift(current_user.id) - query = query.where("sales.shift_sale_id = ?", shift.id) - end - end - return query - end - def self.account_data(account_id, today, current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil) query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") From 8638a53f12e8a1376b84d6d52dc0518c07db4287 Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Mon, 18 Nov 2019 15:48:35 +0630 Subject: [PATCH 04/54] fixed foc --- app/models/inventory_definition.rb | 9 +++++---- app/models/order_item.rb | 21 ++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/models/inventory_definition.rb b/app/models/inventory_definition.rb index f2ed207d..82545456 100755 --- a/app/models/inventory_definition.rb +++ b/app/models/inventory_definition.rb @@ -23,8 +23,8 @@ class InventoryDefinition < ApplicationRecord end end - def self.find_product_in_inventory(item,instance_code) - # unless instance_code.empty? + def self.find_product_in_inventory(item) + # unless instance_code.nil? # instance_code = instance_code.to_s # instance_code[0] = "" # instance_code = instance_code.chomp("]") @@ -33,8 +33,9 @@ class InventoryDefinition < ApplicationRecord # end # # if prod = InventoryDefinition.where("item_code IN(#{instance_code})") - # puts "found prodcut+++++++++++++++++++++++++++++++++++===" - # puts prod.to_json + # if stock_check_item = StockCheckItem.where("item_code IN(#{instance_code})") + # return true, prod + # end # end if product = InventoryDefinition.find_by_item_code(item.item_instance_code) diff --git a/app/models/order_item.rb b/app/models/order_item.rb index 005bfe67..0b1c77d2 100755 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -125,18 +125,17 @@ class OrderItem < ApplicationRecord end def update_stock_journal - if self.set_menu_items.present? - puts "set menu itemsssssssss???????????????????????????????" - puts items = JSON.parse(self.set_menu_items) - instance_code = Array.new - count = 0 - items.each { |i| - instance_code.push(i["item_instance_code"]) - } - print instance_code - end + # if self.set_menu_items.present? + # items = JSON.parse(self.set_menu_items) + # instance_code = Array.new + # count = 0 + # items.each { |i| + # instance_code.push(i["item_instance_code"]) + # } + # end + if self.qty != self.qty_before_last_save - found, inventory_definition = InventoryDefinition.find_product_in_inventory(self,instance_code) + found, inventory_definition = InventoryDefinition.find_product_in_inventory(self) if found InventoryDefinition.check_balance(self, inventory_definition) end From f2b4114ad5bfce9cd25e569188b9576d83ac5d25 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Tue, 19 Nov 2019 00:08:56 +0630 Subject: [PATCH 05/54] 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 06/54] 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 07/54] 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 08/54] 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 a36e170d94ec26ab20adb0a095cb0149729a4429 Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Wed, 20 Nov 2019 15:14:09 +0630 Subject: [PATCH 09/54] inventory for set items --- .../origami/sale_edit_controller.rb | 4 +- app/models/inventory_definition.rb | 28 +--- app/models/order_item.rb | 40 +---- app/models/sale.rb | 6 +- app/models/sale_item.rb | 143 ++++++++++++++---- 5 files changed, 130 insertions(+), 91 deletions(-) diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index 7f456f35..363791a8 100755 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -163,7 +163,7 @@ class Origami::SaleEditController < BaseOrigamiController # end # end - sale.compute_by_sale_items(saleObj.total_discount, nil, order_source) + # sale.compute_by_sale_items(saleObj.total_discount, nil, order_source) FOR WHAT???? ProductCommission.edit_product_commission(saleitemObj) end @@ -195,7 +195,7 @@ class Origami::SaleEditController < BaseOrigamiController end remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}" sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"ITEMCANCELVOID" ) - + saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source) ProductCommission.remove_product_commission(saleitemObj) end diff --git a/app/models/inventory_definition.rb b/app/models/inventory_definition.rb index 82545456..fb247805 100755 --- a/app/models/inventory_definition.rb +++ b/app/models/inventory_definition.rb @@ -24,20 +24,6 @@ class InventoryDefinition < ApplicationRecord end def self.find_product_in_inventory(item) - # unless instance_code.nil? - # instance_code = instance_code.to_s - # instance_code[0] = "" - # instance_code = instance_code.chomp("]") - # else - # instance_code = '"0"' - # end - # - # if prod = InventoryDefinition.where("item_code IN(#{instance_code})") - # if stock_check_item = StockCheckItem.where("item_code IN(#{instance_code})") - # return true, prod - # end - # end - if product = InventoryDefinition.find_by_item_code(item.item_instance_code) if stock_check_item = StockCheckItem.find_by_item_code(item.item_instance_code) return true, product @@ -46,13 +32,12 @@ class InventoryDefinition < ApplicationRecord end def self.check_balance(item, inventory_definition) # item => saleItemOBj - stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first - unless stock.nil? - modify_balance(item, stock, inventory_definition) - else - puts "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OUT OF STOCK >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - StockJournal.add_to_journal(item.item_instance_code, item.qty, 0, "out of stock", inventory_definition, item.id, StockJournal::SALES_TRANS) - end + stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first + unless stock.nil? + modify_balance(item, stock, inventory_definition) + else + StockJournal.add_to_journal(item.item_instance_code, item.qty, 0, "out of stock", inventory_definition, item.id, StockJournal::SALES_TRANS) + end end def self.modify_balance(item, stock, inventory_definition) #saleitemObj @@ -77,6 +62,7 @@ class InventoryDefinition < ApplicationRecord elsif item.is_a? SaleItem trans_type = StockJournal::SALES_TRANS end + # StockJournal.add_to_journal(instance_code, qty, stock.balance, remark, inventory_definition, item.id, trans_type) StockJournal.add_to_journal(item.item_instance_code, qty, stock.balance, remark, inventory_definition, item.id, trans_type) check_item.different = check_item.different - qty check_item.save diff --git a/app/models/order_item.rb b/app/models/order_item.rb index 0b1c77d2..3e75ecba 100755 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -125,41 +125,13 @@ class OrderItem < ApplicationRecord end def update_stock_journal - # if self.set_menu_items.present? - # items = JSON.parse(self.set_menu_items) - # instance_code = Array.new - # count = 0 - # items.each { |i| - # instance_code.push(i["item_instance_code"]) - # } - # end - - if self.qty != self.qty_before_last_save - found, inventory_definition = InventoryDefinition.find_product_in_inventory(self) - if found - InventoryDefinition.check_balance(self, inventory_definition) + unless MenuItemInstance.where("item_instance_name <> ''").pluck(:item_instance_code).include?(self.item_instance_code) + if self.qty != self.qty_before_last_save + found, inventory_definition = InventoryDefinition.find_product_in_inventory(self) + if found + InventoryDefinition.check_balance(self, inventory_definition) + end end end - # if self.qty > self.qty_was - # credit = 0 - # debit = self.qty.to_i - self.qty_was.to_i - # else - # credit = self.qty_was.to_i - self.qty.to_i - # debit = 0 - # end - # if credit != debit - # defination = InventoryDefinition.find_by_item_code(self.item_instance_code) - # stock = StockJournal.where('item_code = ?', self.item_instance_code).order("id DESC").first - # journal = StockJournal.create( - # item_code: self.item_instance_code, - # credit: credit, - # debit: debit, - # balance: stock.balance - debit + credit, - # inventory_definition_id: defination.id, - # remark: 'ok', - # trans_ref: self.order.id, - # trans_type: StockJournal::SALES_TRANS - # ) - # end end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 999a18fd..a0273619 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -2468,7 +2468,11 @@ private found, inventory_definition = InventoryDefinition.find_product_in_inventory(item) if found if stock_journal = StockJournal.find_by_trans_ref(item.order_items_id) - stock_journal.update(remark: self.sale_status) + if self.payment_status == "foc" && self.payment_status_was != "foc" + stock_journal.update(remark: self.payment_status) + else + stock_journal.update(remark: self.sale_status) + end end end end diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 8473da78..65f3a4d5 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -13,6 +13,7 @@ class SaleItem < ApplicationRecord before_validation :round_to_precision after_update :update_stock_journal + after_save :update_stock_journal_set_item # Add Sale Items def self.add_sale_items(sale_items) @@ -304,40 +305,42 @@ class SaleItem < ApplicationRecord end def update_stock_journal - is_void = self.status == "void" && self.status_before_last_save != "void" - cancel_void = self.status_before_last_save == "void" && self.status.nil? - is_edit = self.qty >= 0 && self.qty != self.qty_before_last_save - is_foc = self.status == "foc" && self.status_before_last_save != "foc" - cancel_foc = self.status_before_last_save == "foc" + unless MenuItemInstance.where("item_instance_name <> ''").pluck(:item_instance_code).include?(self.item_instance_code) + is_void = self.status == "void" && self.status_before_last_save != "void" + cancel_void = self.status_before_last_save == "void" && self.status.nil? + is_edit = self.qty >= 0 && self.qty != self.qty_before_last_save + is_foc = self.status == "foc" && self.status_before_last_save != "foc" + cancel_foc = self.status_before_last_save == "foc" - if is_void or cancel_void or is_edit or is_foc or cancel_foc - found, inventory_definition = InventoryDefinition.find_product_in_inventory(self) - if found - 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 - if is_void or cancel_void or is_edit - if is_void - qty = -self.qty - remark = "void" - elsif cancel_void - qty = self.qty - remark = "cancel void" - elsif is_edit - qty = self.qty - self.qty_before_last_save - remark = "edit" - 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 - else is_foc or cancel_foc - qty = StockJournal.where(trans_ref: self.sale_item_id).sum("credit-debit") - if order_item_id = self.sale.bookings.first.order_items.where(item_instance_code: self.item_instance_code, qty: self.qty + qty).select(:order_items_id).first.order_items_id - if stock_journal = StockJournal.find_by_trans_ref(order_item_id) - if is_foc - stock_journal.update(remark: "foc") - elsif cancel_foc - stock_journal.update(remark: "cancel_foc") + if is_void or cancel_void or is_edit or is_foc or cancel_foc + found, inventory_definition = InventoryDefinition.find_product_in_inventory(self) + if found + 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 + if is_void or cancel_void or is_edit + if is_void + qty = -self.qty + remark = "void" + elsif cancel_void + qty = self.qty + remark = "cancel void" + elsif is_edit + qty = self.qty - self.qty_before_last_save + remark = "edit" + 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 + else is_foc or cancel_foc + qty = StockJournal.where(trans_ref: self.sale_item_id).sum("credit-debit") + if order_item_id = self.sale.bookings.first.order_items.where(item_instance_code: self.item_instance_code, qty: self.qty + qty).select(:order_items_id).first.order_items_id + if stock_journal = StockJournal.find_by_trans_ref(order_item_id) + if is_foc + stock_journal.update(remark: "foc") + elsif cancel_foc + stock_journal.update(remark: "cancel_foc") + end end end end @@ -346,4 +349,78 @@ class SaleItem < ApplicationRecord end end end + + def update_stock_journal_set_item + is_void = self.status == "void" && self.status_before_last_save != "void" && self.qty > 0 + cancel_void = self.status_before_last_save == "void" && self.status.nil? + is_edit = self.qty >= 0 && self.qty != self.qty_before_last_save + is_foc = self.status == "foc" && self.status_before_last_save != "foc" + cancel_foc = self.status_before_last_save == "foc" + is_waste = self.status == "waste" + is_spoile = self.status == "spoile" + + if MenuItemInstance.where("item_instance_name <> ''").pluck(:item_instance_code).include?(self.item_instance_code) + if self.qty == 1 && self.qty != self.qty_before_last_save + found, inventory_definition = InventoryDefinition.find_product_in_inventory(self) + if found + 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 + if self.qty.to_i >= 0 + qty = self.qty - self.qty_was + if stock.balance.to_i >= qty + puts ">> stock is greater than order qty" + remark = "ok" + else + puts " << stock is less than order qty" + remark = "out of stock" + 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 + else + StockJournal.add_to_journal(self.item_instance_code, self.qty, 0, "out of stock", inventory_definition, self.id, StockJournal::SALES_TRANS) + end + end + elsif is_void or cancel_void or is_edit + if is_void + qty = -self.qty + remark = "void" + elsif cancel_void + qty = self.qty + remark = "cancel void" + elsif is_edit + qty = self.qty - self.qty_before_last_save + remark = "edit" + end + found, inventory_definition = InventoryDefinition.find_product_in_inventory(self) + if found + 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 + 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 + if is_foc + stock_journal.update(remark: "foc") + elsif cancel_foc + stock_journal.update(remark: "cancel_foc") + end + end + elsif is_waste or is_spoile + found, inventory_definition = InventoryDefinition.find_product_in_inventory(self) + if found + if stock_journal = StockJournal.where(trans_ref: self.sale_item_id, item_code: self.item_instance_code) + stock_journal.update(remark: self.status) + end + end + end + end + end end From ba340292ab59bd2f30ea1c5152ca11cd939b08f2 Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Mon, 25 Nov 2019 13:13:31 +0630 Subject: [PATCH 10/54] fixed no tax --- app/models/sale.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index a0273619..bbd76c25 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -527,7 +527,7 @@ class Sale < ApplicationRecord tax_profiles = unique_tax_profiles(order_source, self.customer_id) # #Creat new tax records - if self.payment_status != 'foc' + if self.payment_status != 'foc' && tax_type.to_s != "no_tax" tax_profiles.each do |tax| sale_tax = SaleTax.new(:sale => self) sale_tax.tax_name = tax.name @@ -552,6 +552,15 @@ class Sale < ApplicationRecord sale_tax.inclusive = tax.inclusive sale_tax.save end + elsif tax_type.to_s == "no_tax" + tax_profiles.each do |tax| + sale_tax = SaleTax.new(:sale => self) + sale_tax.tax_name = tax.name + sale_tax.tax_rate = 0 + sale_tax.tax_payable_amount = 0 + sale_tax.inclusive = tax.inclusive + sale_tax.save + end end self.tax_type = tax_incl_exec self.total_tax = total_tax_amount From ecd1bb79313c16868d90c4c19cafcfee19192725 Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Mon, 25 Nov 2019 16:24:04 +0630 Subject: [PATCH 11/54] fixed service charges & commercial tax --- app/models/sale.rb | 54 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index bbd76c25..ad981c57 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -527,7 +527,7 @@ class Sale < ApplicationRecord tax_profiles = unique_tax_profiles(order_source, self.customer_id) # #Creat new tax records - if self.payment_status != 'foc' && tax_type.to_s != "no_tax" + if self.payment_status != 'foc' && tax_type.to_s == "all" tax_profiles.each do |tax| sale_tax = SaleTax.new(:sale => self) sale_tax.tax_name = tax.name @@ -561,6 +561,58 @@ class Sale < ApplicationRecord sale_tax.inclusive = tax.inclusive sale_tax.save end + elsif tax_type.to_s == "Commercial Tax" + tax_profiles.each do |tax| + if tax.name == tax_type.to_s + sale_tax = SaleTax.new(:sale => self) + sale_tax.tax_name = tax.name + sale_tax.tax_rate = tax.rate + # substract , to give after discount + total_tax = total_taxable - total_discount + #include or execulive + if tax.inclusive + tax_incl_exec = "inclusive" + rate = tax.rate + divided_value = (100 + rate)/rate + sale_tax.tax_payable_amount = total_tax / divided_value + else + sale_tax.tax_payable_amount = total_tax * tax.rate / 100 + total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount + end + #new taxable amount is standard rule for step by step + if shop.calc_tax_order + total_taxable = total_taxable + sale_tax.tax_payable_amount + end + sale_tax.inclusive = tax.inclusive + sale_tax.save + end + end + elsif tax_type.to_s == "Service Charges" + tax_profiles.each do |tax| + if tax.name == tax_type.to_s + sale_tax = SaleTax.new(:sale => self) + sale_tax.tax_name = tax.name + sale_tax.tax_rate = tax.rate + # substract , to give after discount + total_tax = total_taxable - total_discount + #include or execulive + if tax.inclusive + tax_incl_exec = "inclusive" + rate = tax.rate + divided_value = (100 + rate)/rate + sale_tax.tax_payable_amount = total_tax / divided_value + else + sale_tax.tax_payable_amount = total_tax * tax.rate / 100 + total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount + end + #new taxable amount is standard rule for step by step + if shop.calc_tax_order + total_taxable = total_taxable + sale_tax.tax_payable_amount + end + sale_tax.inclusive = tax.inclusive + sale_tax.save + end + end end self.tax_type = tax_incl_exec self.total_tax = total_tax_amount From 3c1cc737b59d183c78b65ec5c4055bdb08c6c5ef Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Mon, 25 Nov 2019 23:17:53 +0630 Subject: [PATCH 12/54] improve receipt/details reports and implement number formatting 1) eager load reports for receipt/details 2) introduce number_format lookups to replace print_settings for number formatting 3) implement NumberFormattable concern, reference number_format lookups or print_settings if not exist, to get number format settings and number formatting 4) replace rails NumberHelper.number_with_precision with NumberFormattable.number_format hopefully to reduce overhead, formatting numbers for huge lists of data --- README.md | 9 + app/controllers/application_controller.rb | 6 +- app/controllers/base_origami_controller.rb | 18 +- app/controllers/base_report_controller.rb | 20 +- .../concerns/number_formattable.rb | 57 +++++ app/controllers/home_controller.rb | 29 +-- .../reports/receipt_no_detail_controller.rb | 13 +- app/helpers/application_helper.rb | 5 +- app/models/lookup.rb | 2 + app/models/sale.rb | 226 ++++++------------ app/models/sale_audit.rb | 2 +- app/models/sale_item.rb | 3 +- app/models/sale_tax.rb | 2 +- app/pdf/check_in_out_pdf.rb | 2 +- app/pdf/close_cashier_customise_pdf.rb | 146 ++++++----- app/pdf/close_cashier_pdf.rb | 121 +++++----- app/pdf/close_cashier_pdf_v1.rb | 113 ++++----- app/pdf/move_table_pdf.rb | 6 +- app/pdf/move_table_star_pdf.rb | 6 +- app/pdf/order_item_customise_pdf.rb | 8 +- app/pdf/order_item_pdf.rb | 8 +- app/pdf/order_item_slim_customise_pdf.rb | 32 +-- app/pdf/order_item_slim_pdf.rb | 34 +-- app/pdf/order_item_star_pdf.rb | 8 +- app/pdf/order_set_item_customise_pdf.rb | 30 +-- app/pdf/order_set_item_pdf.rb | 30 +-- app/pdf/order_summary_customise_pdf.rb | 8 +- app/pdf/order_summary_pdf.rb | 52 ++-- app/pdf/order_summary_set_customise_pdf.rb | 38 +-- app/pdf/order_summary_set_pdf.rb | 48 ++-- app/pdf/order_summary_slim_customise_pdf.rb | 46 ++-- app/pdf/order_summary_slim_pdf.rb | 44 ++-- app/pdf/receipt_bill_a5_pdf.rb | 155 ++++++------ app/pdf/receipt_bill_order_pdf.rb | 83 +++---- app/pdf/receipt_bill_pdf.rb | 73 +++--- app/pdf/receipt_bill_star_pdf.rb | 65 +++-- app/pdf/sale_items_pdf.rb | 13 +- app/pdf/sale_items_star_pdf.rb | 13 +- app/views/home/dashboard.html.erb | 24 +- app/views/origami/dashboard/index.html.erb | 20 +- app/views/origami/discounts/index.html.erb | 124 ++-------- app/views/origami/home/show.html.erb | 154 ++++++------ app/views/origami/payments/show.html.erb | 96 ++++---- .../origami/table_invoices/show.html.erb | 72 +++--- app/views/reports/commission/index.html.erb | 26 +- .../reports/credit_payment/index.html.erb | 20 +- app/views/reports/dailysale/index.html.erb | 94 ++++---- app/views/reports/dailysale/index.xls.erb | 14 +- .../reports/hourly_saleitem/index.html.erb | 18 +- .../reports/hourly_saleitem/index.xls.erb | 18 +- .../reports/order_reservation/index.html.erb | 123 +++++----- .../reports/payment_method/index.html.erb | 50 ++-- .../reports/payment_method/index.xls.erb | 74 +++--- app/views/reports/product_sale/index.html.erb | 43 ++-- app/views/reports/receipt_no/index.html.erb | 40 ++-- app/views/reports/receipt_no/index.xls.erb | 39 ++- .../reports/receipt_no_detail/index.html.erb | 82 +++---- app/views/reports/saleitem/index.html.erb | 44 ++-- app/views/reports/saleitem/index.xls.erb | 88 +++---- .../reports/saleitem/indexbackup.html.erb | 106 ++++---- app/views/reports/shiftsale/index.html.erb | 32 +-- app/views/reports/staff_meal/index.html.erb | 38 +-- app/views/reports/staff_meal/index.xls.erb | 38 +-- app/views/reports/stock_check/index.html.erb | 20 +- app/views/reports/stock_check/index.xls.erb | 2 +- app/views/reports/void_sale/index.html.erb | 28 +-- .../reports/waste_and_spoilage/index.html.erb | 20 +- .../order_reservations/index.html.erb | 31 +-- .../order_reservations/show.html.erb | 59 ++--- app/views/transactions/sales/show.html.erb | 18 +- db/seeds.rb | 7 +- 71 files changed, 1338 insertions(+), 1898 deletions(-) create mode 100644 app/controllers/concerns/number_formattable.rb diff --git a/README.md b/README.md index 77a25926..54474f5e 100755 --- a/README.md +++ b/README.md @@ -279,6 +279,15 @@ For Food Court Settings On/Off ** '0' means can not use food court and '1' means can use food court ** => settings/lookups => { type:food_court, name: FoodCourt, value:'{0 or 1}' } +For Number Formats + Precision + => settings/lookups => { lookup_type: number_format, name: precision, value: {0..2} } + Delimiter + => settings/lookups => { lookup_type: number_format, name: delimiter, value: { ',', '\u0020', '', ... } + Strip insignificant zeros + => settings/lookups => { lookup_type: number_format, name: strip_insignificant_zeros, + value: {true: => ['1', 't', 'true', 'on', 'y', 'yes'], false: => ['0', 'f', 'false', 'off', 'n', 'no', ...] } + /* Customer Types in lookups */ 1) settings/lookups => { type:customer_type, name: Dinein, value:Dinein } 2) settings/lookups => { type:customer_type, name: Takeaway, value: Takeaway } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f1d5f79a..66f20c55 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,6 @@ class ApplicationController < ActionController::Base include LoginVerification - + #before_action :check_installation protect_from_forgery with: :exception @@ -17,7 +17,5 @@ class ApplicationController < ActionController::Base flash[:warning] = exception.message redirect_to root_path end + end - - - diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index dc93b2de..6940a129 100755 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -5,7 +5,7 @@ class BaseOrigamiController < ActionController::Base before_action :check_user #before_action :check_installation - protect_from_forgery with: :exception + protect_from_forgery with: :exception helper_method :current_token @@ -15,16 +15,16 @@ class BaseOrigamiController < ActionController::Base redirect_to origami_dashboard_path end - def check_user - if check_mobile + def check_user + if check_mobile if current_user.nil? return render status: 401, json: { - message: "User using other device!" + message: "User using other device!" }.to_json end - else + else if current_user.nil? - redirect_to root_path + redirect_to root_path end end end @@ -41,13 +41,13 @@ class BaseOrigamiController < ActionController::Base #check webview def check_mobile status = false - authenticate_with_http_token do |token, options| + authenticate_with_http_token do |token, options| if token session[:webview] = true session[:session_token] = token - end + end end - + if session[:webview] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i status = true end diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index 0875fda5..8cb3d00d 100755 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -1,11 +1,11 @@ class BaseReportController < ActionController::Base include LoginVerification - layout "application" + layout "application" - before_action :check_user + before_action :check_user - #before_action :check_installation - protect_from_forgery with: :exception + #before_action :check_installation + protect_from_forgery with: :exception rescue_from CanCan::AccessDenied do |exception| flash[:warning] = exception.message @@ -29,7 +29,7 @@ class BaseReportController < ActionController::Base period_type = params[:period_type] period = params[:period] from = params[:from] - to = params[:to] + to = params[:to] day_ref = Time.now.utc.getlocal if from.present? && to.present? @@ -39,10 +39,10 @@ class BaseReportController < ActionController::Base f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) from = f_time.beginning_of_day.utc.getlocal - to = t_time.end_of_day.utc.getlocal + to = t_time.end_of_day.utc.getlocal + + else - else - case period.to_i when PERIOD["today"] @@ -77,10 +77,10 @@ class BaseReportController < ActionController::Base when PERIOD["last_year"] from = (day_ref - 1.year).beginning_of_year.utc to = (day_ref - 1.year).end_of_year.utc - end + end end - return from, to + return from, to end def check_user diff --git a/app/controllers/concerns/number_formattable.rb b/app/controllers/concerns/number_formattable.rb new file mode 100644 index 00000000..a27c551c --- /dev/null +++ b/app/controllers/concerns/number_formattable.rb @@ -0,0 +1,57 @@ +module NumberFormattable + extend ActiveSupport::Concern + + def precision + @precision ||= Lookup.number_formats.find { |f| f.name.parameterize.underscore == 'precision'} + if @precision + @precision.value.to_i + else + @print_settings ||= PrintSetting.get_precision_delimiter + if @print_settings + @print_settings.precision.to_i + end + end || 2 + end + + def delimiter + @delimiter ||= Lookup.number_formats.find { |f| f.name.parameterize.underscore == 'delimiter'} + if @delimiter + @delimiter_value ||= @delimiter.value.to_s.gsub(/\\u(\h{4})/) { |m| [$1].pack("H*").unpack("n*").pack("U*") } + else + @print_settings ||= PrintSetting.get_precision_delimiter + if @print_settings + "," if @print_settings.delimiter + end + end || "" + end + + def strip_insignificant_zeros + @strip_insignificant_zeros ||= Lookup.number_formats.find { |f| f.name.parameterize.underscore == 'strip_insignificant_zeros'} + if @strip_insignificant_zeros + ['1', 't', 'true', 'on', 'y', 'yes'].include? @strip_insignificant_zeros.value.to_s + end || false + 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]) + else + formatted = "%.#{options[:precision]}f" % number.round(options[:precision]) + end + else + formatted = number.to_i.to_s + end + + if options[:delimiter] && + formatted = formatted.gsub(/(\d)(?=\d{3}+(\.\d*)?$)/, "\\1#{options[:delimiter]}") + end + + return formatted + end + +end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 4d8c715a..3353a3a5 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -94,27 +94,24 @@ class HomeController < ApplicationController @shop = Shop.first today = DateTime.now.strftime('%Y-%m-%d') + @orders = Sale.where("payment_status = 'new' and sale_status = 'bill'") + @sales = Sale.completed + if !@from.nil? && !@to.nil? + @orders = @orders.date_between(@from, @to) + @sales = @sales.date_between(@from, @to) if !@from_time.nil? && @to_time.nil? - @orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count() - else - @orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count() + @orders = @orders.time_between(@from_time, @to_time) + @sales = @sales.time_between(@from_time, @to_time) end else - @orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count() + @orders = @orders.date_on(today) + @sales = @sales.date_on(today) end - if !@from.nil? && !@to.nil? - if !@from_time.nil? && @to_time.nil? - @sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count() - else - @sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count() - end - else - @sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count() - end - @top_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"top").sum('i.qty') - @bottom_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"bottom").sum('i.qty') - @hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time).sum(:grand_total) + + @top_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"top") + @bottom_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"bottom") + @hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time) # .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p') # .sum(:grand_total) logger.debug 'hourly_sales<>><><><<<<<<>><<<><><><><><><><><><<>><' diff --git a/app/controllers/reports/receipt_no_detail_controller.rb b/app/controllers/reports/receipt_no_detail_controller.rb index d7b018d7..b6e8bb16 100755 --- a/app/controllers/reports/receipt_no_detail_controller.rb +++ b/app/controllers/reports/receipt_no_detail_controller.rb @@ -1,4 +1,4 @@ -class Reports::ReceiptNoDetailController < BaseReportController +class Reports::ReceiptNoDetailController < BaseReportController authorize_resource :class => false def index @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]] @@ -9,11 +9,10 @@ authorize_resource :class => false @shift = '' if params[:shift_name].to_i != 0 - @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) @shift_sale = ShiftSale.find(params[:shift_name]) - if to.blank? + if to.blank? @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at) else if @shift_sale.shift_closed_at.blank? @@ -25,7 +24,7 @@ authorize_resource :class => false end payment_type = params[:payment_type] - @sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type) + @sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type) @from = from @to = to @@ -62,10 +61,10 @@ authorize_resource :class => false end out = {:status => 'ok', :message => date_arr} - + respond_to do |format| format.json { render json: out } end end - -end \ No newline at end of file + +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 27024d75..16e44953 100755 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,4 +1,6 @@ module ApplicationHelper + include NumberFormattable + def flash_class(level) case level when :notice then "alert alert-info fade-in" @@ -6,5 +8,6 @@ module ApplicationHelper when :error then "alert alert-error fade-in" when :alert then "alert alert-error fade-in" end - end + end + end diff --git a/app/models/lookup.rb b/app/models/lookup.rb index b446d4e8..5b45822c 100755 --- a/app/models/lookup.rb +++ b/app/models/lookup.rb @@ -2,6 +2,8 @@ class Lookup < ApplicationRecord has_many :accounts + scope :number_formats, -> { where(lookup_type: 'number_format')} + def available_types {'Employee Roles' => 'employee_roles', 'Dining Facilities Status' => 'dining_facilities_status', diff --git a/app/models/sale.rb b/app/models/sale.rb index a0273619..1074122b 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1,4 +1,5 @@ class Sale < ApplicationRecord + include NumberFormattable self.primary_key = "sale_id" #primary key - need to be unique generated for multiple shops @@ -7,12 +8,15 @@ class Sale < ApplicationRecord belongs_to :cashier, foreign_key: "cashier_id", class_name: "Employee" belongs_to :customer, :optional => true belongs_to :shift_sale + has_one :survey, foreign_key: "receipt_no" + has_many :sale_audits has_many :sale_items has_many :sale_discount_items has_many :sale_discounts has_many :sale_taxes has_many :sale_payments has_many :sale_orders + has_many :sale_payments_for_credits, through: :sale_audits has_many :orders, through: :sale_orders has_many :order_items, through: :sale_orders has_many :bookings @@ -28,7 +32,7 @@ class Sale < ApplicationRecord scope :date_on, -> (date) { where("DATE(CONVERT_TZ(receipt_date, '+00:00', ?)) = ?", Time.zone.formatted_offset, date) } scope :date_between, -> (from, to) { where("DATE(CONVERT_TZ(receipt_date, '+00:00', ?)) BETWEEN ? AND ?", Time.zone.formatted_offset, from, to) } scope :time_between, -> (from, to) { where("TIME(CONVERT_TZ(receipt_date, '+00:00', ?)) BETWEEN ? AND ?", Time.zone.formatted_offset, from, to) } - scope :along_with_sale_payments_except_void, -> { joins("LEFT JOIN sale_payments on sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND DATE(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30')) = DATE(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'))") } + scope :along_with_sale_payments_except_void, -> { joins("LEFT JOIN sale_payments on sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND DATE(CONVERT_TZ(sale_payments.created_at,'+00:00', '#{Time.zone.formatted_offset}')) = DATE(CONVERT_TZ(sales.receipt_date,'+00:00', '#{Time.zone.formatted_offset}'))") } def qty_of(item_instance_code) order_items.select(:order_items_id, :item_instance_code, 'SUM(qty) as qty').where(item_instance_code: item_instance_code).group(:item_instance_code).first @@ -542,15 +546,20 @@ class Sale < ApplicationRecord divided_value = (100 + rate)/rate sale_tax.tax_payable_amount = total_tax / divided_value else - sale_tax.tax_payable_amount = total_tax * tax.rate / 100 + sale_tax.tax_payable_amount = total_tax * tax.rate / 100 + end + + sale_tax.inclusive = tax.inclusive + sale_tax.save + + if !tax.inclusive total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount end + #new taxable amount is standard rule for step by step if shop.calc_tax_order total_taxable = total_taxable + sale_tax.tax_payable_amount end - sale_tax.inclusive = tax.inclusive - sale_tax.save end end self.tax_type = tax_incl_exec @@ -598,6 +607,12 @@ class Sale < ApplicationRecord sale_tax.tax_payable_amount = total_tax / divided_value else sale_tax.tax_payable_amount = total_tax * tax.rate / 100 + end + + sale_tax.inclusive = tax.inclusive + sale_tax.save + + if !tax.inclusive total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount end @@ -605,9 +620,6 @@ class Sale < ApplicationRecord if shop.calc_tax_order total_taxable = total_taxable + sale_tax.tax_payable_amount end - - sale_tax.inclusive = tax.inclusive - sale_tax.save end self.tax_type = tax_incl_exec self.total_tax = total_tax_amount @@ -1197,7 +1209,7 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty payment_type = " and sale_payments.payment_method = '#{payment_type}'" end - query = Sale.all.select("sales.*,sale_payments.*,df.name,df.type") + query = Sale.includes(:sale_items).select("sales.*,sale_payments.*,df.name,df.type") .where("sale_status= 'completed' and sale_payments.payment_amount != 0 #{payment_type}") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") .joins("join bookings on bookings.sale_id = sales.sale_id") @@ -1215,17 +1227,16 @@ end def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,payment_type) ## => left join -> show all sales although no orders - if payment_type.blank? - payment_type = '' - else - payment_type = " and sale_payments.payment_method = '#{payment_type}'" - end - query = Sale.select("sales.*,bookings.dining_facility_id as table_id") - .where("sale_status= 'completed' and sale_payments.payment_amount != 0 #{payment_type}") - .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") - .joins("join bookings on bookings.sale_id = sales.sale_id") - .group("sales.sale_id") + query = Sale.includes([:customer, :survey, :sale_payments]) + .includes(:bookings => :dining_facility) + .select("sales.*, SUM(sale_payments.payment_amount) AS payments_for_credits_amount") + .joins(:bookings) + .left_joins(:sale_payments_for_credits) + .completed + .where.not(total_amount: 0) + .group(:sale_id) + .order(:receipt_date) if shift.present? query = query.where("sales.shift_sale_id in (?)", shift.to_a) elsif shift_sale_range.present? @@ -1233,6 +1244,9 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay else query = query.where("sales.receipt_date between ? and ?",from,to) end + + ActiveRecord::Associations::Preloader.new.preload(query, :sale_items, SaleItem.where.not(price: 0)) + return query end @@ -1503,101 +1517,53 @@ end end def self.top_bottom_products(today,current_user,from,to,from_time,to_time,type) - if (!from.nil? && !to.nil?) && (from != "" && to!="") - if current_user.nil? - query = Sale.top_bottom(today,nil,from,to,from_time,to_time) + query = Sale.joins("JOIN sale_items ON sale_items.sale_id = sales.sale_id") + .completed + .where("qty > 0 AND price > 0") + .group("SUBSTRING_INDEX(product_name, ' - ', 1)") - if type == "top" - query = query.group('i.product_name') - .order("SUM(i.qty) DESC").limit(20) - elsif type == "bottom" - query = query.group('i.product_name') - .order("SUM(i.qty) ASC").limit(20) - end - else - if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor' - query = Sale.top_bottom(today,nil,from,to,from_time,to_time) - if type == "top" - query = query.group('i.product_name') - .order("SUM(i.qty) DESC").limit(20) - elsif type == "bottom" - query = query.group('i.product_name') - .order("SUM(i.qty) ASC").limit(20) - end - else - shift = ShiftSale.current_open_shift(current_user.id) - if !shift.nil? - query = Sale.top_bottom(today,shift,from,to,from_time,to_time) - if type == "top" - query = query.group('i.product_name') - .order("SUM(i.qty) DESC").limit(20) - elsif type == "bottom" - query = query.group('i.product_name') - .order("SUM(i.qty) ASC").limit(20) - end - end - end + if !from.nil? && !to.nil? + query = query.date_between(from, to) + if !from_time.nil? && !to_time.nil? + query = query.time_between(from_time, to_time) end else - if current_user.nil? - query = Sale.top_bottom(today).group('i.product_name') - - if type == "top" - query = query.order("SUM(i.qty) DESC").limit(20) - elsif type == "bottom" - query = query.order("SUM(i.qty) ASC").limit(20) - end - else - if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor' - query = Sale.top_bottom(today).group('i.product_name') - if type == "top" - query = query.order("SUM(i.qty) DESC").limit(20) - elsif type == "bottom" - query = query.order("SUM(i.qty) ASC").limit(20) - end - else - shift = ShiftSale.current_open_shift(current_user.id) - if !shift.nil? - query = Sale.top_bottom(today,shift).group('i.product_name') - if type == "top" - query = query.order("SUM(i.qty) DESC").limit(20) - elsif type == "bottom" - query = query.order("SUM(i.qty) ASC").limit(20) - end - end - end + query = query.date_on(today) + end + if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') + if shift = ShiftSale.current_open_shift(current_user.id) + query = query.where("shift_sale_id='#{shift.id}'") end end + + if type == "top" + query = query.order("SUM(qty) DESC") + else + query = query.order("SUM(qty) ASC") + end + + query.limit(20).sum('qty') end def self.hourly_sales(today,current_user,from,to,from_time,to_time) - if (!from.nil? && !to.nil?) && (from != "" && to!="") - if current_user.nil? - query = Sale.hourly_sale_data(today,nil,from,to,from_time,to_time) - else - if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor' - query = Sale.hourly_sale_data(today,nil,from,to,from_time,to_time) - else - shift = ShiftSale.current_open_shift(current_user.id) - if !shift.nil? - query = Sale.hourly_sale_data(today,shift,from,to,from_time,to_time) - end - end + query = Sale.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')") + .order('receipt_date').completed + + if !from.nil? && !to.nil? + query = query.date_between(from, to) + if !from_time.nil? && !to_time.nil? + query = query.time_between(from_time, to_time) end else - if current_user.nil? - query = Sale.hourly_sale_data(today) - else - if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor' - query = Sale.hourly_sale_data(today) - else - shift = ShiftSale.current_open_shift(current_user.id) - if !shift.nil? - query = Sale.hourly_sale_data(today,shift) - end - end + query = query.date_on(today) + end + + if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') + if shift = ShiftSale.current_open_shift(current_user.id) + query = query.where("shift_sale_id='#{shift.id}'") end end + query.sum(:grand_total) end def self.employee_sales(today,current_user,from,to,from_time,to_time) @@ -2074,60 +2040,6 @@ def unique_tax_profiles(order_source, customer_id) return tax_data end -def self.top_bottom(today,shift=nil,from=nil,to=nil,from_time=nil,to_time=nil) - if !from.nil? && !to.nil? - query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," + - " i.price as unit_price,i.product_name") - .joins("JOIN sale_items i ON i.sale_id = sales.sale_id") - if !from_time.nil? && !to_time.nil? - query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+ - " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}' and sale_status= 'completed'") - else - query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+ - " and sale_status= 'completed'") - end - if !shift.nil? - query = query.where("shift_sale_id='#{shift.id}'") - end - else - query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," + - " i.price as unit_price,i.product_name") - .joins("JOIN sale_items i ON i.sale_id = sales.sale_id") - .where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+ - " and sale_status= 'completed'") - if !shift.nil? - query = query.where("shift_sale_id='#{shift.id}'") - end - end - return query -end - -def self.hourly_sale_data(today,shift=nil,from=nil,to=nil,from_time=nil,to_time=nil) - if !from.nil? && !to.nil? - query = Sale.select("grand_total") - if !from_time.nil? && !to_time.nil? - query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time) - else - query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to) - end - if !shift.nil? - query = query.where("shift_sale_id='#{shift.id}'") - end - query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')") - .order('receipt_date') - else - query = Sale.select("grand_total") - .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today) - if !shift.nil? - query = query.where("shift_sale_id='#{shift.id}'") - end - query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')") - .order('receipt_date') - end - - return query -end - def self.employee_sale(today,shift=nil,from=nil,to=nil,from_time=nil,to_time=nil) query = Sale.joins(:cashier) .joins(:sale_payments) @@ -2291,7 +2203,7 @@ end def grand_total_round print_settings = PrintSetting.get_precision_delimiter() if !print_settings.nil? - self.grand_total =self.grand_total.round(print_settings.precision.to_i) + self.grand_total =self.grand_total.round(precision) end end @@ -2438,8 +2350,6 @@ private def round_to_precision if (self.total_amount != self.total_amount_was || self.total_discount != self.total_discount_was || self.total_tax != self.total_tax_was) if (self.total_amount % 1 > 0 || self.total_discount % 1 > 0 || self.total_tax % 1 > 0) - precision = PrintSetting.get_precision_delimiter().precision.to_i - self.total_amount = self.total_amount.round(precision) self.total_discount = self.total_discount.round(precision) self.total_tax = self.total_tax.round(precision) diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb index 1488cad1..14b952af 100755 --- a/app/models/sale_audit.rb +++ b/app/models/sale_audit.rb @@ -6,7 +6,7 @@ class SaleAudit < ApplicationRecord belongs_to :sale - belongs_to :credit_payment, -> { where "SUBSTRING_INDEX(sale_audits.remark,'||',1) = sale_payments.sale_payment_id" }, foreign_key: "sale_id", primary_key: "sale_id", class_name: "SalePayment" + belongs_to :sale_payments_for_credit, -> { where "SUBSTRING_INDEX(sale_audits.remark,'||',1) = sale_payments.sale_payment_id" }, foreign_key: "sale_id", primary_key: "sale_id", class_name: "SalePayment" def self.sync_sale_audit_records(sale_audits) if !sale_audits.nil? diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 65f3a4d5..dc03935c 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -1,4 +1,5 @@ class SaleItem < ApplicationRecord + include NumberFormattable self.primary_key = "sale_item_id" #primary key - need to be unique generated for multiple shops @@ -294,8 +295,6 @@ class SaleItem < ApplicationRecord if self.unit_price != self.unit_price_was || self.price != self.price_was if unit_price_fraction > 0 || price_fraction > 0 if ['Discount', 'promotion'].include?(self.status) - precision = PrintSetting.get_precision_delimiter().precision.to_i - self.unit_price = self.unit_price.round(precision) self.price = (self.unit_price * self.qty).round(precision) self.taxable_price = self.price diff --git a/app/models/sale_tax.rb b/app/models/sale_tax.rb index 2e35d2b5..801c3bf7 100755 --- a/app/models/sale_tax.rb +++ b/app/models/sale_tax.rb @@ -1,4 +1,5 @@ class SaleTax < ApplicationRecord + include NumberFormattable self.primary_key = "sale_tax_id" #primary key - need to be unique generated for multiple shops @@ -44,7 +45,6 @@ class SaleTax < ApplicationRecord def round_to_precision if self.tax_payable_amount != self.tax_payable_amount_was if self.tax_payable_amount % 1 > 0 - precision = PrintSetting.get_precision_delimiter().precision.to_i self.tax_payable_amount = self.tax_payable_amount.round(precision) end end diff --git a/app/pdf/check_in_out_pdf.rb b/app/pdf/check_in_out_pdf.rb index 08b9eba8..dfc40c2c 100644 --- a/app/pdf/check_in_out_pdf.rb +++ b/app/pdf/check_in_out_pdf.rb @@ -1,5 +1,5 @@ class CheckInOutPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size, :item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,booking, table) self.page_width = print_settings.page_width diff --git a/app/pdf/close_cashier_customise_pdf.rb b/app/pdf/close_cashier_customise_pdf.rb index 2b05394d..34c4288d 100644 --- a/app/pdf/close_cashier_customise_pdf.rb +++ b/app/pdf/close_cashier_customise_pdf.rb @@ -1,5 +1,5 @@ class CloseCashierCustomisePdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) @@ -39,22 +39,11 @@ class CloseCashierCustomisePdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - #precision checked - if printer_settings.precision.to_i > 2 - printer_settings.precision = 2 - end - #check delimiter - if printer_settings.delimiter - delimiter = "," - else - delimiter = "" - end - header( shop_details) stroke_horizontal_rule - shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) + shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) end def header (shop_details) @@ -103,13 +92,13 @@ class CloseCashierCustomisePdf < Prawn::Document bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left end - + y_position = cursor bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do text "Opening Float : ", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do - text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left + text "#{ number_format(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left end y_position = cursor @@ -117,8 +106,8 @@ class CloseCashierCustomisePdf < Prawn::Document text "Closing Float : ", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do - text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left - # text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}" + text "#{ number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left + # text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}" end @@ -135,7 +124,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Received Amount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end @@ -144,7 +133,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Cash In :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{number_format(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -152,7 +141,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Cash Out :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{number_format(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end move_down -5 @@ -165,7 +154,7 @@ class CloseCashierCustomisePdf < Prawn::Document total_discount_account = total_discount_account.to_f + amount.total_price.to_f end - #end total amount by Account + #end total amount by Account #start total FOC amount @total_foc = 0 @@ -173,7 +162,7 @@ class CloseCashierCustomisePdf < Prawn::Document @total_foc = other.foc_amount.round(2) end - #end total FOC amount + #end total FOC amount total_grand_total = shift_sale.grand_total + @total_foc.to_f + shift_sale.total_void.to_f - total_discount_account.to_f # @total_grand_total = @shift_sale.grand_total + @overall + @total_foc + @shift_sale.total_void y_position = cursor @@ -181,21 +170,21 @@ class CloseCashierCustomisePdf < Prawn::Document text "Grand Total :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(total_grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{number_format(total_grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end #start total amount by Account Like Food / Beverage /.. total_discount_by_account.each do |amount| - + y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right + text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right end end - #end total amount by Account + #end total amount by Account y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do @@ -205,8 +194,8 @@ class CloseCashierCustomisePdf < Prawn::Document @total_foc = 0 end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right - end + text "(#{ number_format(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right + end y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do @@ -218,7 +207,7 @@ class CloseCashierCustomisePdf < Prawn::Document move_down -5 stroke_horizontal_rule - move_down 7 + move_down 7 @total_foc = 0 y_position = cursor @@ -226,7 +215,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Cash Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -234,9 +223,9 @@ class CloseCashierCustomisePdf < Prawn::Document text "Credit Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right + text "#{number_format(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right end - #start other payment details + #start other payment details if shift_sale.other_sales > 0 other_payment.each do |other| @total_foc = other.foc_amount.round(2) @@ -246,7 +235,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "MPU Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -256,7 +245,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "VISA Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{number_format(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -266,7 +255,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Master Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -276,7 +265,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "JCB Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -286,7 +275,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -296,7 +285,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Alipay Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -306,7 +295,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "JunctionPay Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -316,7 +305,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Dinga Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -326,7 +315,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Redeem Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -336,7 +325,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Paymal Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -346,7 +335,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end end @@ -356,7 +345,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Other Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -365,8 +354,8 @@ class CloseCashierCustomisePdf < Prawn::Document text "Rounding Adjustments :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right - + text "#{ number_format(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + end y_position = cursor @@ -374,14 +363,14 @@ class CloseCashierCustomisePdf < Prawn::Document text "Gross Sale :", :style => :bold, :size => self.header_font_size - 1, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right + text "#{ number_format(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right end - # end other payment details + # end other payment details move_down -5 stroke_horizontal_rule move_down 7 - + # start Dinein and Takeaway y_position = cursor @@ -392,7 +381,7 @@ class CloseCashierCustomisePdf < Prawn::Document total_dinein = 0 end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(total_dinein, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(total_dinein, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -401,11 +390,11 @@ class CloseCashierCustomisePdf < Prawn::Document end if total_takeway.nil? total_takeway = 0 - end - bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(total_takeway, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end - + bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do + text "#{ number_format(total_takeway, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + end + # stop Dinein and Takeaway move_down -5 @@ -419,7 +408,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -428,7 +417,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Total Taxes :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -436,7 +425,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right + text "#{number_format(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right end if total_credit_payments && total_credit_payments.to_f > 0 @@ -445,7 +434,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Total Credit Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end #end for service charges and commercial tax @@ -463,16 +452,16 @@ class CloseCashierCustomisePdf < Prawn::Document move_down 7 #start total amount by Account Like Food / Beverage /.. # total_discount_by_account.each do |amount| - + # y_position = cursor # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do # text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right # end # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - # text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right + # text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right # end # end - #end total amount by Account + #end total amount by Account # y_position = cursor # bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do @@ -481,19 +470,19 @@ class CloseCashierCustomisePdf < Prawn::Document # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do # text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right # end - + #start total amount by Account Like Food / Beverage /.. - total_amount_by_account.each do |amount| + total_amount_by_account.each do |amount| y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right + text "#{number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right end end - #end total amount by Account + #end total amount by Account #start total other charges amount if total_other_charges.present? @@ -502,9 +491,9 @@ class CloseCashierCustomisePdf < Prawn::Document text "Total Other Charges :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(total_other_charges, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(total_other_charges, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end - end + end #end total other charges amount move_down -5 @@ -513,32 +502,32 @@ class CloseCashierCustomisePdf < Prawn::Document #start total over all discount if total_member_discount[0].member_discount.present? - @member_discount = total_member_discount[0].member_discount rescue 0.0 + @member_discount = total_member_discount[0].member_discount rescue 0.0 @overall = shift_sale.total_discounts - @member_discount - + y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total Member Discount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end - else - @overall = shift_sale.total_discounts + else + @overall = shift_sale.total_discounts end - + if @overall > 0 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total Discount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "-#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right - end + text "-#{ number_format(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + end move_down -5 stroke_horizontal_rule move_down 7 - end + end #end total over all discount if total_waste.to_f > 0 @@ -547,7 +536,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Total Waste :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "(#{ number_with_precision(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right + text "(#{ number_format(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right end end @@ -557,7 +546,7 @@ class CloseCashierCustomisePdf < Prawn::Document text "Total Spoile :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "(#{ number_with_precision(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right + text "(#{ number_format(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right end end @@ -591,4 +580,3 @@ class CloseCashierCustomisePdf < Prawn::Document move_down 5 end end - diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index d4564291..976c3d93 100755 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -1,5 +1,5 @@ class CloseCashierPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width def initialize(printer_settings, shift_sale, sale_items, total_other_charges_info, acc_cate_count, menu_cate_count, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) @@ -39,25 +39,14 @@ class CloseCashierPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - #precision checked - if printer_settings.precision.to_i > 2 - printer_settings.precision = 2 - end - #check delimiter - if printer_settings.delimiter - delimiter = "," - else - delimiter = "" - end - header( shop_details) stroke_horizontal_rule - shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments) + shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments) if !sale_items.nil? or !sale_items.blank? - sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges_info) + sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges_info) end end @@ -107,13 +96,13 @@ class CloseCashierPdf < Prawn::Document bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left end - + y_position = cursor bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do text "Opening Float : ", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do - text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left + text "#{ number_format(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left end y_position = cursor @@ -121,8 +110,8 @@ class CloseCashierPdf < Prawn::Document text "Closing Float : ", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do - text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left - # text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}" + text "#{ number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left + # text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}" end @@ -139,7 +128,7 @@ class CloseCashierPdf < Prawn::Document text "Received Amount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end @@ -148,7 +137,7 @@ class CloseCashierPdf < Prawn::Document text "Cash In:", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{number_format(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -156,7 +145,7 @@ class CloseCashierPdf < Prawn::Document text "Cash Out:", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{number_format(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end move_down -5 @@ -169,7 +158,7 @@ class CloseCashierPdf < Prawn::Document text "Cash Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -177,10 +166,10 @@ class CloseCashierPdf < Prawn::Document text "Credit Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right + text "#{number_format(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right end - #start other payment details + #start other payment details if shift_sale.other_sales > 0 other_payment.each do |other| @total_foc = other.foc_amount.round(2) @@ -190,7 +179,7 @@ class CloseCashierPdf < Prawn::Document text "MPU Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -200,7 +189,7 @@ class CloseCashierPdf < Prawn::Document text "VISA Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{number_format(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -210,7 +199,7 @@ class CloseCashierPdf < Prawn::Document text "Master Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -220,7 +209,7 @@ class CloseCashierPdf < Prawn::Document text "JCB Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -230,7 +219,7 @@ class CloseCashierPdf < Prawn::Document text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -240,7 +229,7 @@ class CloseCashierPdf < Prawn::Document text "Alipay Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -250,7 +239,7 @@ class CloseCashierPdf < Prawn::Document text "KBZ Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.kbzpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.kbzpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -260,7 +249,7 @@ class CloseCashierPdf < Prawn::Document text "JunctionPay Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -270,7 +259,7 @@ class CloseCashierPdf < Prawn::Document text "Dinga Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -280,7 +269,7 @@ class CloseCashierPdf < Prawn::Document text "Redeem Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -290,7 +279,7 @@ class CloseCashierPdf < Prawn::Document text "Paymal Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -300,7 +289,7 @@ class CloseCashierPdf < Prawn::Document text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end end @@ -310,7 +299,7 @@ class CloseCashierPdf < Prawn::Document text "Other Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -319,7 +308,7 @@ class CloseCashierPdf < Prawn::Document text "Rounding Adjustments :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -327,10 +316,10 @@ class CloseCashierPdf < Prawn::Document text "Total :", :style => :bold, :size => self.header_font_size - 1, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right + text "#{ number_format(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right end - # end other payment details + # end other payment details move_down -5 stroke_horizontal_rule move_down 7 @@ -342,7 +331,7 @@ class CloseCashierPdf < Prawn::Document text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -351,7 +340,7 @@ class CloseCashierPdf < Prawn::Document text "Total Taxes :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -359,7 +348,7 @@ class CloseCashierPdf < Prawn::Document text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right + text "#{number_format(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right end if total_credit_payments && total_credit_payments.to_f > 0 @@ -368,7 +357,7 @@ class CloseCashierPdf < Prawn::Document text "Total Credit Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end #end for service charges and commercial tax @@ -386,30 +375,30 @@ class CloseCashierPdf < Prawn::Document move_down 7 #start total amount by Account Like Food / Beverage /.. total_discount_by_account.each do |amount| - + y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right + text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right end end - #end total amount by Account + #end total amount by Account if total_member_discount[0].member_discount.present? - @member_discount = total_member_discount[0].member_discount rescue 0.0 + @member_discount = total_member_discount[0].member_discount rescue 0.0 @overall = shift_sale.total_discounts - @member_discount - + y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total Member Discount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end - else - @overall = shift_sale.total_discounts + else + @overall = shift_sale.total_discounts end y_position = cursor @@ -417,18 +406,18 @@ class CloseCashierPdf < Prawn::Document text "Total Discount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right - end + text "#{ number_format(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + end y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total FOC :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right - end + text "(#{ number_format(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right + end - y_position = cursor + y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total Void :", :size => self.item_font_size, :align => :right end @@ -441,7 +430,7 @@ class CloseCashierPdf < Prawn::Document text "Total Waste :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "(#{ number_with_precision(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right + text "(#{ number_format(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right end y_position = cursor @@ -449,7 +438,7 @@ class CloseCashierPdf < Prawn::Document text "Total Spoile :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "(#{ number_with_precision(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right + text "(#{ number_format(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right end # y_position = cursor @@ -459,19 +448,19 @@ class CloseCashierPdf < Prawn::Document # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do # text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right # end - + move_down -5 stroke_horizontal_rule move_down 7 #start total amount by Account Like Food / Beverage /.. - total_amount_by_account.each do |amount| + total_amount_by_account.each do |amount| y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right + text "#{number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right end end @@ -482,7 +471,7 @@ class CloseCashierPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do text "#{total_other_charges}", :size => self.item_font_size, :align => :right end - #end total amount by Account + #end total amount by Account y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do @@ -532,7 +521,7 @@ class CloseCashierPdf < Prawn::Document sale_items.each do |item| if !arr.include?(item['menu_category_id']) - + if flag == true move_down 5 stroke_horizontal_rule @@ -567,7 +556,7 @@ class CloseCashierPdf < Prawn::Document # text_box "#{item['grand_total'].to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix # } add_item_line(item['product_name'], item['unit_price'].to_i, item['total_item'].to_i, item['grand_total'].to_i) - + if item['total_item'].to_i > 0 or item['status_type'] == 'foc' or item['status_type'] == 'void' total_qty += item['total_item'].to_i total_items += item['total_item'].to_i @@ -657,4 +646,4 @@ class CloseCashierPdf < Prawn::Document text_box "#{sub_total.to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } end -end \ No newline at end of file +end diff --git a/app/pdf/close_cashier_pdf_v1.rb b/app/pdf/close_cashier_pdf_v1.rb index 687f0aa8..c241c047 100644 --- a/app/pdf/close_cashier_pdf_v1.rb +++ b/app/pdf/close_cashier_pdf_v1.rb @@ -1,5 +1,5 @@ class CloseCashierPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width def initialize(printer_settings, shift_sale, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) @@ -39,22 +39,11 @@ class CloseCashierPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - #precision checked - if printer_settings.precision.to_i > 2 - printer_settings.precision = 2 - end - #check delimiter - if printer_settings.delimiter - delimiter = "," - else - delimiter = "" - end - header( shop_details) stroke_horizontal_rule - shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments) + shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments) end @@ -104,13 +93,13 @@ class CloseCashierPdf < Prawn::Document bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left end - + y_position = cursor bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do text "Opening Float : ", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do - text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left + text "#{ number_format(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left end y_position = cursor @@ -118,8 +107,8 @@ class CloseCashierPdf < Prawn::Document text "Closing Float : ", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do - text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left - # text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}" + text "#{ number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left + # text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}" end @@ -136,7 +125,7 @@ class CloseCashierPdf < Prawn::Document text "Received Amount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end @@ -145,7 +134,7 @@ class CloseCashierPdf < Prawn::Document text "Cash In:", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{number_format(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -153,7 +142,7 @@ class CloseCashierPdf < Prawn::Document text "Cash Out:", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{number_format(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end move_down -5 @@ -166,7 +155,7 @@ class CloseCashierPdf < Prawn::Document text "Cash Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -174,10 +163,10 @@ class CloseCashierPdf < Prawn::Document text "Credit Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right + text "#{number_format(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right end - #start other payment details + #start other payment details if shift_sale.other_sales > 0 other_payment.each do |other| @total_foc = other.foc_amount.round(2) @@ -187,7 +176,7 @@ class CloseCashierPdf < Prawn::Document text "MPU Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -197,7 +186,7 @@ class CloseCashierPdf < Prawn::Document text "VISA Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{number_format(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -207,7 +196,7 @@ class CloseCashierPdf < Prawn::Document text "Master Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -217,7 +206,7 @@ class CloseCashierPdf < Prawn::Document text "JCB Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -227,7 +216,7 @@ class CloseCashierPdf < Prawn::Document text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -237,7 +226,7 @@ class CloseCashierPdf < Prawn::Document text "Alipay Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -247,7 +236,7 @@ class CloseCashierPdf < Prawn::Document text "JunctionPay Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -257,7 +246,7 @@ class CloseCashierPdf < Prawn::Document text "Dinga Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -267,7 +256,7 @@ class CloseCashierPdf < Prawn::Document text "Redeem Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -277,7 +266,7 @@ class CloseCashierPdf < Prawn::Document text "Paymal Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -287,7 +276,7 @@ class CloseCashierPdf < Prawn::Document text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end end @@ -297,7 +286,7 @@ class CloseCashierPdf < Prawn::Document text "Other Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -306,7 +295,7 @@ class CloseCashierPdf < Prawn::Document text "Rounding Adjustments :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -314,10 +303,10 @@ class CloseCashierPdf < Prawn::Document text "Total :", :style => :bold, :size => self.header_font_size - 1, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right + text "#{ number_format(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right end - # end other payment details + # end other payment details move_down -5 stroke_horizontal_rule move_down 7 @@ -329,7 +318,7 @@ class CloseCashierPdf < Prawn::Document text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -338,7 +327,7 @@ class CloseCashierPdf < Prawn::Document text "Total Taxes :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -346,7 +335,7 @@ class CloseCashierPdf < Prawn::Document text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right + text "#{number_format(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right end if total_credit_payments && total_credit_payments.to_f > 0 @@ -355,7 +344,7 @@ class CloseCashierPdf < Prawn::Document text "Total Credit Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end #end for service charges and commercial tax @@ -373,30 +362,30 @@ class CloseCashierPdf < Prawn::Document move_down 7 #start total amount by Account Like Food / Beverage /.. total_discount_by_account.each do |amount| - + y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right + text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right end end - #end total amount by Account + #end total amount by Account if total_member_discount[0].member_discount.present? - @member_discount = total_member_discount[0].member_discount rescue 0.0 + @member_discount = total_member_discount[0].member_discount rescue 0.0 @overall = shift_sale.total_discounts - @member_discount - + y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total Member Discount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + text "#{ number_format(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end - else - @overall = shift_sale.total_discounts + else + @overall = shift_sale.total_discounts end y_position = cursor @@ -404,18 +393,18 @@ class CloseCashierPdf < Prawn::Document text "Total Discount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right - end + text "#{ number_format(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + end y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total FOC :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right - end + text "(#{ number_format(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right + end - y_position = cursor + y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total Void :", :size => self.item_font_size, :align => :right end @@ -428,7 +417,7 @@ class CloseCashierPdf < Prawn::Document text "Total Waste :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "(#{ number_with_precision(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right + text "(#{ number_format(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right end y_position = cursor @@ -436,7 +425,7 @@ class CloseCashierPdf < Prawn::Document text "Total Spoile :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "(#{ number_with_precision(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right + text "(#{ number_format(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right end # y_position = cursor @@ -446,19 +435,19 @@ class CloseCashierPdf < Prawn::Document # bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do # text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right # end - + move_down -5 stroke_horizontal_rule move_down 7 #start total amount by Account Like Food / Beverage /.. - total_amount_by_account.each do |amount| + total_amount_by_account.each do |amount| y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right + text "#{number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right end end @@ -469,7 +458,7 @@ class CloseCashierPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do text "#{total_other_charges}", :size => self.item_font_size, :align => :right end - #end total amount by Account + #end total amount by Account y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do @@ -502,4 +491,4 @@ class CloseCashierPdf < Prawn::Document end -end \ No newline at end of file +end diff --git a/app/pdf/move_table_pdf.rb b/app/pdf/move_table_pdf.rb index 5d44b393..dc55eedc 100644 --- a/app/pdf/move_table_pdf.rb +++ b/app/pdf/move_table_pdf.rb @@ -1,5 +1,5 @@ class MoveTablePdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(printer_settings,to,from,shop_detail,date,type,moved_by,order_items) self.page_width = printer_settings.page_width @@ -39,7 +39,7 @@ class MoveTablePdf < Prawn::Document stroke_horizontal_rule move_down 5 - add_lining_item(order_items, printer_settings.precision) + add_lining_item(order_items, precision) move_down 5 stroke_horizontal_rule @@ -98,7 +98,7 @@ class MoveTablePdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width) do - text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left + text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left end bounding_box([0,y_position], :width => self.item_width) do diff --git a/app/pdf/move_table_star_pdf.rb b/app/pdf/move_table_star_pdf.rb index 0467cbab..88ea4ef1 100644 --- a/app/pdf/move_table_star_pdf.rb +++ b/app/pdf/move_table_star_pdf.rb @@ -1,5 +1,5 @@ class MoveTableStarPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(printer_settings,to,from,shop_detail,date,type,moved_by,order_items) self.page_width = printer_settings.page_width @@ -38,7 +38,7 @@ class MoveTableStarPdf < Prawn::Document stroke_horizontal_rule move_down 5 - add_lining_item(order_items, printer_settings.precision) + add_lining_item(order_items, precision) move_down 5 stroke_horizontal_rule @@ -97,7 +97,7 @@ class MoveTableStarPdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width) do - text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left + text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left end bounding_box([0,y_position], :width => self.item_width) do diff --git a/app/pdf/order_item_customise_pdf.rb b/app/pdf/order_item_customise_pdf.rb index b509a01a..32be1928 100644 --- a/app/pdf/order_item_customise_pdf.rb +++ b/app/pdf/order_item_customise_pdf.rb @@ -1,5 +1,5 @@ class OrderItemCustomisePdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty) self.page_width = print_settings.page_width @@ -47,7 +47,7 @@ class OrderItemCustomisePdf < Prawn::Document order_info(order_item.order_id, order_item.order_by,order_item.order_at) # order items - order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty) + order_items(order_item, options, alt_name, precision, before_updated_qty) end # Write Order Information to PDF @@ -107,7 +107,7 @@ class OrderItemCustomisePdf < Prawn::Document end bounding_box([self.item_width - 10,y_position], :width => self.qty_width) do - text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right + text "[#{number_format(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right end bounding_box([0,y_position], :width => self.item_width) do @@ -146,7 +146,7 @@ class OrderItemCustomisePdf < Prawn::Document # add option y_position = cursor bounding_box([0,y_position], :width => self.page_width) do - text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end end end diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index ed079aeb..d4a05aa2 100755 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -1,5 +1,5 @@ class OrderItemPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty) @@ -48,7 +48,7 @@ class OrderItemPdf < Prawn::Document order_info(order_item.order_id, order_item.order_by,order_item.order_at) # order items - order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty) + order_items(order_item, options, alt_name, precision, before_updated_qty) end # Write Order Information to PDF @@ -108,7 +108,7 @@ class OrderItemPdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width) do - text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text "[#{number_format(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end bounding_box([0,y_position], :width => self.item_width) do @@ -147,7 +147,7 @@ class OrderItemPdf < Prawn::Document # add option y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end end end diff --git a/app/pdf/order_item_slim_customise_pdf.rb b/app/pdf/order_item_slim_customise_pdf.rb index c4b1e5c5..f759cbec 100644 --- a/app/pdf/order_item_slim_customise_pdf.rb +++ b/app/pdf/order_item_slim_customise_pdf.rb @@ -1,5 +1,5 @@ class OrderItemSlimCustomisePdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :item_slim_font_size def initialize(print_settings,order_item_slim, print_status, options, alt_name, before_updated_qty) self.page_width = print_settings.page_width @@ -11,9 +11,9 @@ class OrderItemSlimCustomisePdf < Prawn::Document self.qty_width = 40 self.total_width = 40 # No Need for item self.item_width = self.page_width - (self.qty_width - self.margin) - self.item_height = 15 + self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=90 + self.label_width=90 self.item_slim_font_size=8 super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) @@ -29,17 +29,17 @@ class OrderItemSlimCustomisePdf < Prawn::Document }) font "#{print_settings.font}" - fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" - #font "public/fonts/Chinese.ttf" + # font "public/fonts/padauk.ttf" + #font "public/fonts/Chinese.ttf" if !order_item_slim.dining.nil? text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 end - + stroke_horizontal_rule move_down 1 @@ -47,35 +47,35 @@ class OrderItemSlimCustomisePdf < Prawn::Document order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at) # order items slim - order_items_slim(order_item_slim, options, alt_name, print_settings.precision, before_updated_qty) + order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty) end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) #booking ID booking_id = get_booking_id(order_no) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Booking: #{booking_id}", :size => self.item_slim_font_size,:align => :left + text "Booking: #{booking_id}", :size => self.item_slim_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left + text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderBy: #{order_by} ", :size => self.item_slim_font_size,:align => :left + text "OrderBy: #{order_by} ", :size => self.item_slim_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_slim_font_size,:align => :left + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_slim_font_size,:align => :left end stroke_horizontal_rule @@ -88,7 +88,7 @@ class OrderItemSlimCustomisePdf < Prawn::Document def order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty) y_position = cursor - #Add Order Item + #Add Order Item add_order_items_slim(order_item_slim, options, alt_name, precision) dash(1, :space => 1, :phase => 1) @@ -108,7 +108,7 @@ class OrderItemSlimCustomisePdf < Prawn::Document end bounding_box([self.item_width - 5,y_position], :width => self.qty_width) do - text "[#{number_with_precision(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right + text "[#{number_format(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right end bounding_box([0,y_position], :width => self.item_width) do @@ -146,7 +146,7 @@ class OrderItemSlimCustomisePdf < Prawn::Document # add option y_position = cursor bounding_box([0,y_position], :width => self.page_width) do - text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end end end diff --git a/app/pdf/order_item_slim_pdf.rb b/app/pdf/order_item_slim_pdf.rb index 3e39644f..a32c1a26 100755 --- a/app/pdf/order_item_slim_pdf.rb +++ b/app/pdf/order_item_slim_pdf.rb @@ -1,7 +1,7 @@ class OrderItemSlimPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width - + def initialize(print_settings,order_item_slim, print_status, options, alt_name, before_updated_qty) self.page_width = print_settings.page_width self.page_height = print_settings.page_height @@ -12,9 +12,9 @@ class OrderItemSlimPdf < Prawn::Document self.qty_width = 40 self.total_width = 40 # No Need for item self.item_width = self.page_width - (self.qty_width - self.margin) - self.item_height = 15 + self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=90 + self.label_width=90 super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # super(:margin => [10, 5, 30, 5], :page_size => [200,400]) @@ -29,17 +29,17 @@ class OrderItemSlimPdf < Prawn::Document }) font "#{print_settings.font}" - fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" - #font "public/fonts/Chinese.ttf" + # font "public/fonts/padauk.ttf" + #font "public/fonts/Chinese.ttf" if !order_item_slim.dining.nil? text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 end - + stroke_horizontal_rule move_down 1 @@ -47,35 +47,35 @@ class OrderItemSlimPdf < Prawn::Document order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at) # order items slim - order_items_slim(order_item_slim, options, alt_name, print_settings.precision, before_updated_qty) + order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty) end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) #booking ID booking_id = get_booking_id(order_no) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left + text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left end stroke_horizontal_rule @@ -87,7 +87,7 @@ class OrderItemSlimPdf < Prawn::Document def order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty) y_position = cursor - #Add Order Item + #Add Order Item add_order_items_slim(order_item_slim, options, alt_name, precision) puts options puts '............PDF OPTIONS...............' @@ -108,7 +108,7 @@ class OrderItemSlimPdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width) do - text "[#{number_with_precision(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text "[#{number_format(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end bounding_box([0,y_position], :width => self.item_width) do @@ -146,7 +146,7 @@ class OrderItemSlimPdf < Prawn::Document # add option y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end end end diff --git a/app/pdf/order_item_star_pdf.rb b/app/pdf/order_item_star_pdf.rb index 2686efd7..0703c8a2 100644 --- a/app/pdf/order_item_star_pdf.rb +++ b/app/pdf/order_item_star_pdf.rb @@ -1,5 +1,5 @@ class OrderItemStarPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty) @@ -48,7 +48,7 @@ class OrderItemStarPdf < Prawn::Document order_info(order_item.order_id, order_item.order_by,order_item.order_at) # order items - order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty) + order_items(order_item, options, alt_name, precision, before_updated_qty) end # Write Order Information to PDF @@ -108,7 +108,7 @@ class OrderItemStarPdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width) do - text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text "[#{number_format(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end bounding_box([0,y_position], :width => self.item_width) do @@ -147,7 +147,7 @@ class OrderItemStarPdf < Prawn::Document # add option y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end end end diff --git a/app/pdf/order_set_item_customise_pdf.rb b/app/pdf/order_set_item_customise_pdf.rb index 2e1d0a2c..f684e275 100644 --- a/app/pdf/order_set_item_customise_pdf.rb +++ b/app/pdf/order_set_item_customise_pdf.rb @@ -1,5 +1,5 @@ class OrderSetItemCustomisePdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order_set_item, print_status, options, alt_name, before_updated_qty) self.page_width = print_settings.page_width @@ -12,9 +12,9 @@ class OrderSetItemCustomisePdf < Prawn::Document self.qty_width = 40 self.total_width = 40 # No Need for item self.item_width = self.page_width - (self.qty_width - self.margin) - self.item_height = 15 + self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=90 + self.label_width=90 super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # super(:margin => [10, 5, 30, 5], :page_size => [200,400]) @@ -29,11 +29,11 @@ class OrderSetItemCustomisePdf < Prawn::Document }) font "#{print_settings.font}" - fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" - #font "public/fonts/Chinese.ttf" + # font "public/fonts/padauk.ttf" + #font "public/fonts/Chinese.ttf" if !order_set_item.dining.nil? text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else @@ -46,35 +46,35 @@ class OrderSetItemCustomisePdf < Prawn::Document order_info(order_set_item.order_id, order_set_item.order_by,order_set_item.order_at) # order items - order_set_items(order_set_item, options, alt_name, print_settings.precision, before_updated_qty) + order_set_items(order_set_item, options, alt_name, precision, before_updated_qty) end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) #booking ID booking_id = get_booking_id(order_no) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Booking: #{booking_id}", :size => self.order_no_font_size,:align => :left + text "Booking: #{booking_id}", :size => self.order_no_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left + text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderBy: #{order_by} ", :size => self.order_no_font_size,:align => :left + text "OrderBy: #{order_by} ", :size => self.order_no_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.order_no_font_size,:align => :left + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.order_no_font_size,:align => :left end stroke_horizontal_rule @@ -86,7 +86,7 @@ class OrderSetItemCustomisePdf < Prawn::Document def order_set_items(order_set_item, options, alt_name, precision, before_updated_qty) y_position = cursor - #Add Order Item + #Add Order Item add_order_set_items(order_set_item, options, alt_name, precision) dash(1, :space => 1, :phase => 1) @@ -106,7 +106,7 @@ class OrderSetItemCustomisePdf < Prawn::Document end bounding_box([self.item_width - 5,y_position], :width => self.qty_width) do - text "[#{number_with_precision(order_set_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right + text "[#{number_format(order_set_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right end bounding_box([0,y_position], :width => self.item_width) do @@ -161,7 +161,7 @@ class OrderSetItemCustomisePdf < Prawn::Document # add option y_position = cursor bounding_box([0,y_position], :width => self.page_width) do - text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end end end diff --git a/app/pdf/order_set_item_pdf.rb b/app/pdf/order_set_item_pdf.rb index 09cdc6db..cb57c870 100755 --- a/app/pdf/order_set_item_pdf.rb +++ b/app/pdf/order_set_item_pdf.rb @@ -1,5 +1,5 @@ class OrderSetItemPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order_set_item, print_status, options, alt_name, before_updated_qty) self.page_width = print_settings.page_width @@ -11,9 +11,9 @@ class OrderSetItemPdf < Prawn::Document self.qty_width = 40 self.total_width = 40 # No Need for item self.item_width = self.page_width - (self.qty_width - self.margin) - self.item_height = 15 + self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=90 + self.label_width=90 super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # super(:margin => [10, 5, 30, 5], :page_size => [200,400]) @@ -28,11 +28,11 @@ class OrderSetItemPdf < Prawn::Document }) font "#{print_settings.font}" - fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" - #font "public/fonts/Chinese.ttf" + # font "public/fonts/padauk.ttf" + #font "public/fonts/Chinese.ttf" if !order_set_item.dining.nil? text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else @@ -45,35 +45,35 @@ class OrderSetItemPdf < Prawn::Document order_info(order_set_item.order_id, order_set_item.order_by,order_set_item.order_at) # order items - order_set_items(order_set_item, options, alt_name, print_settings.precision, before_updated_qty) + order_set_items(order_set_item, options, alt_name, precision, before_updated_qty) end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) #booking ID booking_id = get_booking_id(order_no) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left end move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left + text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left end move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left end move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left end stroke_horizontal_rule @@ -85,7 +85,7 @@ class OrderSetItemPdf < Prawn::Document def order_set_items(order_set_item, options, alt_name, precision, before_updated_qty) y_position = cursor - #Add Order Item + #Add Order Item add_order_set_items(order_set_item, options, alt_name, precision) dash(1, :space => 1, :phase => 1) @@ -105,7 +105,7 @@ class OrderSetItemPdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width) do - text "[#{number_with_precision(order_set_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text "[#{number_format(order_set_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end bounding_box([0,y_position], :width => self.item_width) do @@ -160,7 +160,7 @@ class OrderSetItemPdf < Prawn::Document # add option y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end end end diff --git a/app/pdf/order_summary_customise_pdf.rb b/app/pdf/order_summary_customise_pdf.rb index 8ffedca0..bce29877 100644 --- a/app/pdf/order_summary_customise_pdf.rb +++ b/app/pdf/order_summary_customise_pdf.rb @@ -1,5 +1,5 @@ class OrderSummaryCustomisePdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty) self.page_width = print_settings.page_width @@ -48,9 +48,9 @@ class OrderSummaryCustomisePdf < Prawn::Document # order items if order_items == nil - order_items(order, alt_name, print_settings.precision) + order_items(order, alt_name, precision) else - order_items(order_items, alt_name, print_settings.precision) + order_items(order_items, alt_name, precision) end end @@ -113,7 +113,7 @@ class OrderSummaryCustomisePdf < Prawn::Document end bounding_box([self.item_width - 10,y_position], :width => self.qty_width) do - text " [#{number_with_precision(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text " [#{number_format(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end bounding_box([0,y_position], :width => self.item_width) do diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index fd446131..f3d25ff1 100755 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -1,5 +1,5 @@ class OrderSummaryPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty) self.page_width = print_settings.page_width @@ -11,9 +11,9 @@ class OrderSummaryPdf < Prawn::Document self.qty_width = 40 self.total_width = 40 # No Need for item self.item_width = self.page_width - (self.qty_width - self.margin) - self.item_height = 15 + self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=90 + self.label_width=90 super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) @@ -27,18 +27,18 @@ class OrderSummaryPdf < Prawn::Document }) font "#{print_settings.font}" - fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - + if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 end - + stroke_horizontal_rule move_down 5 @@ -47,38 +47,38 @@ class OrderSummaryPdf < Prawn::Document # order items if order_items == nil - order_items(order, alt_name, print_settings.precision) + order_items(order, alt_name, precision) else - order_items(order_items, alt_name, print_settings.precision) + order_items(order_items, alt_name, precision) end end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) #booking ID booking_id = get_booking_id(order_no) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left - end - - move_down 5 - y_position = cursor - bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left end move_down 5 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left end move_down 5 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + end + + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left end stroke_horizontal_rule @@ -103,7 +103,7 @@ class OrderSummaryPdf < Prawn::Document #Add Order Item add_order_items(order_item, alt_name, precision) - + end # Add order items under order info @@ -113,7 +113,7 @@ class OrderSummaryPdf < Prawn::Document move_down 5 order_item.each do|odi| - # check for item not to show + # check for item not to show # if odi.price != 0 y_position = cursor @@ -123,14 +123,14 @@ class OrderSummaryPdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width) do - text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left + text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left end bounding_box([0,y_position], :width => self.item_width) do text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left end - + if alt_name if !(odi.alt_name).empty? move_down 4 @@ -138,15 +138,15 @@ class OrderSummaryPdf < Prawn::Document text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true # end end - + end # add option options = odi.options == "[]"? "" : odi.options - + if options != "" move_down 5 - + y_position = cursor bounding_box([0,y_position], :width => self.item_width) do text "#{options}", :size => self.item_font_size,:align => :left @@ -161,7 +161,7 @@ class OrderSummaryPdf < Prawn::Document stroke_horizontal_line 0, (self.page_width - self.margin) move_down 5 # end - end + end end def get_booking_id(order_no) diff --git a/app/pdf/order_summary_set_customise_pdf.rb b/app/pdf/order_summary_set_customise_pdf.rb index 0e33d314..70c116fc 100644 --- a/app/pdf/order_summary_set_customise_pdf.rb +++ b/app/pdf/order_summary_set_customise_pdf.rb @@ -1,5 +1,5 @@ class OrderSummarySetCustomisePdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty) self.page_width = print_settings.page_width @@ -12,9 +12,9 @@ class OrderSummarySetCustomisePdf < Prawn::Document self.qty_width = 40 self.total_width = 40 # No Need for item self.item_width = self.page_width - (self.qty_width - self.margin) - self.item_height = 15 + self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=90 + self.label_width=90 super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) @@ -38,7 +38,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 end - + stroke_horizontal_rule move_down 5 @@ -47,38 +47,38 @@ class OrderSummarySetCustomisePdf < Prawn::Document # order items if order_items == nil - order_items(order, alt_name, print_settings.precision) + order_items(order, alt_name, precision) else - order_items(order_items, alt_name, print_settings.precision) + order_items(order_items, alt_name, precision) end end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) #booking ID booking_id = get_booking_id(order_no) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Booking: #{booking_id}", :size => self.order_no_font_size,:align => :left + text "Booking: #{booking_id}", :size => self.order_no_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left + text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderBy: #{order_by} ", :size => self.order_no_font_size,:align => :left + text "OrderBy: #{order_by} ", :size => self.order_no_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.order_no_font_size,:align => :left + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.order_no_font_size,:align => :left end stroke_horizontal_rule @@ -92,7 +92,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document #Add Order Item add_order_items(order_item, alt_name, precision) - + end # Add order items under order info @@ -102,7 +102,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document move_down 5 order_item.each do|odi| - # check for item not to show + # check for item not to show # if odi.price != 0 y_position = cursor @@ -112,14 +112,14 @@ class OrderSummarySetCustomisePdf < Prawn::Document end bounding_box([self.item_width - 5,y_position], :width => self.qty_width) do - text "[#{number_with_precision(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text "[#{number_format(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end bounding_box([0,y_position], :width => self.item_width) do text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left end - + if alt_name if !(odi.alt_name).empty? move_down 4 @@ -127,7 +127,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true # end end - + end #add set menu items @@ -148,10 +148,10 @@ class OrderSummarySetCustomisePdf < Prawn::Document # add option options = odi.options == "[]"? "" : odi.options - + if options != "" move_down 5 - + y_position = cursor bounding_box([0,y_position], :width => self.item_width) do text "#{options}", :size => self.item_font_size,:align => :left @@ -166,7 +166,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document stroke_horizontal_line 0, (self.page_width - self.margin) move_down 5 # end - end + end end def get_booking_id(order_no) diff --git a/app/pdf/order_summary_set_pdf.rb b/app/pdf/order_summary_set_pdf.rb index 5e27f82b..dd65f0d2 100755 --- a/app/pdf/order_summary_set_pdf.rb +++ b/app/pdf/order_summary_set_pdf.rb @@ -1,5 +1,5 @@ class OrderSummarySetPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty) self.page_width = print_settings.page_width @@ -11,9 +11,9 @@ class OrderSummarySetPdf < Prawn::Document self.qty_width = 40 self.total_width = 40 # No Need for item self.item_width = self.page_width - (self.qty_width - self.margin) - self.item_height = 15 + self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=90 + self.label_width=90 super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) @@ -37,7 +37,7 @@ class OrderSummarySetPdf < Prawn::Document else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 end - + stroke_horizontal_rule move_down 5 @@ -46,38 +46,38 @@ class OrderSummarySetPdf < Prawn::Document # order items if order_items == nil - order_items(order, alt_name, print_settings.precision) + order_items(order, alt_name, precision) else - order_items(order_items, alt_name, print_settings.precision) + order_items(order_items, alt_name, precision) end end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) #booking ID booking_id = get_booking_id(order_no) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left - end - - move_down 5 - y_position = cursor - bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left end move_down 5 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left end move_down 5 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + end + + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left end stroke_horizontal_rule @@ -102,7 +102,7 @@ class OrderSummarySetPdf < Prawn::Document #Add Order Item add_order_items(order_item, alt_name, precision) - + end # Add order items under order info @@ -112,7 +112,7 @@ class OrderSummarySetPdf < Prawn::Document move_down 5 order_item.each do|odi| - # check for item not to show + # check for item not to show # if odi.price != 0 y_position = cursor @@ -122,14 +122,14 @@ class OrderSummarySetPdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width) do - text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left + text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left end bounding_box([0,y_position], :width => self.item_width) do text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left end - + if alt_name if !(odi.alt_name).empty? move_down 4 @@ -137,7 +137,7 @@ class OrderSummarySetPdf < Prawn::Document text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true # end end - + end #add set menu items @@ -158,10 +158,10 @@ class OrderSummarySetPdf < Prawn::Document # add option options = odi.options == "[]"? "" : odi.options - + if options != "" move_down 5 - + y_position = cursor bounding_box([0,y_position], :width => self.item_width) do text "#{options}", :size => self.item_font_size,:align => :left @@ -176,7 +176,7 @@ class OrderSummarySetPdf < Prawn::Document stroke_horizontal_line 0, (self.page_width - self.margin) move_down 5 # end - end + end end def get_booking_id(order_no) diff --git a/app/pdf/order_summary_slim_customise_pdf.rb b/app/pdf/order_summary_slim_customise_pdf.rb index c641b0c8..e8bd21f2 100644 --- a/app/pdf/order_summary_slim_customise_pdf.rb +++ b/app/pdf/order_summary_slim_customise_pdf.rb @@ -1,5 +1,5 @@ class OrderSummarySlimCustomisePdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:item_slim_font_size def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty) self.page_width = print_settings.page_width @@ -11,10 +11,10 @@ class OrderSummarySlimCustomisePdf < Prawn::Document self.qty_width = 40 self.total_width = 40 # No Need for item self.item_width = self.page_width - (self.qty_width - self.margin) - self.item_height = 15 + self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=90 - self.item_slim_font_size=8 + self.label_width=90 + self.item_slim_font_size=8 super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) @@ -38,7 +38,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 end - + stroke_horizontal_rule move_down 1 @@ -47,38 +47,38 @@ class OrderSummarySlimCustomisePdf < Prawn::Document # order items if order_items == nil - order_items(order, alt_name, print_settings.precision) + order_items(order, alt_name, precision) else - order_items(order_items, alt_name, print_settings.precision) + order_items(order_items, alt_name, precision) end end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) #booking ID booking_id = get_booking_id(order_no) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Booking: #{booking_id}", :size => self.item_slim_font_size,:align => :left - end - - move_down 1 - y_position = cursor - bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left + text "Booking: #{booking_id}", :size => self.item_slim_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderBy: #{order_by} ", :size => self.item_slim_font_size,:align => :left + text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_slim_font_size,:align => :left + text "OrderBy: #{order_by} ", :size => self.item_slim_font_size,:align => :left + end + + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_slim_font_size,:align => :left end stroke_horizontal_rule @@ -95,7 +95,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document #Add Order Item add_order_items(order_item, alt_name, precision) - + end # Add order items under order info @@ -105,7 +105,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document move_down 1 order_item.each do|odi| - # check for item not to show + # check for item not to show # if odi.price != 0 y_position = cursor @@ -115,14 +115,14 @@ class OrderSummarySlimCustomisePdf < Prawn::Document end bounding_box([self.item_width - 5,y_position], :width => self.qty_width) do - text "[#{number_with_precision(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + text "[#{number_format(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left end bounding_box([0,y_position], :width => self.item_width) do text "#{odi.item_name}", :size => self.item_font_size,:align => :left end - + if alt_name if !(odi.alt_name).empty? move_down 1 @@ -134,7 +134,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document # add option options = odi.options == "[]"? "" : odi.options - + if options != "" move_down 1 @@ -152,7 +152,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document stroke_horizontal_line 0, (self.page_width - self.margin) move_down 1 # end - end + end end def get_booking_id(order_no) diff --git a/app/pdf/order_summary_slim_pdf.rb b/app/pdf/order_summary_slim_pdf.rb index 1b78cf23..2cbe14d8 100755 --- a/app/pdf/order_summary_slim_pdf.rb +++ b/app/pdf/order_summary_slim_pdf.rb @@ -1,5 +1,5 @@ class OrderSummarySlimPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty) self.page_width = print_settings.page_width @@ -11,9 +11,9 @@ class OrderSummarySlimPdf < Prawn::Document self.qty_width = 40 self.total_width = 40 # No Need for item self.item_width = self.page_width - (self.qty_width - self.margin) - self.item_height = 15 + self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=90 + self.label_width=90 super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) @@ -37,7 +37,7 @@ class OrderSummarySlimPdf < Prawn::Document else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 end - + stroke_horizontal_rule move_down 1 @@ -46,38 +46,38 @@ class OrderSummarySlimPdf < Prawn::Document # order items if order_items == nil - order_items(order, alt_name, print_settings.precision) + order_items(order, alt_name, precision) else - order_items(order_items, alt_name, print_settings.precision) + order_items(order_items, alt_name, precision) end end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) #booking ID booking_id = get_booking_id(order_no) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left - end - - move_down 1 - y_position = cursor - bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left end move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + end + + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left end stroke_horizontal_rule @@ -102,7 +102,7 @@ class OrderSummarySlimPdf < Prawn::Document #Add Order Item add_order_items(order_item, alt_name, precision) - + end # Add order items under order info @@ -112,7 +112,7 @@ class OrderSummarySlimPdf < Prawn::Document move_down 1 order_item.each do|odi| - # check for item not to show + # check for item not to show # if odi.price != 0 y_position = cursor @@ -122,14 +122,14 @@ class OrderSummarySlimPdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width) do - text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left + text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left end bounding_box([0,y_position], :width => self.item_width) do text "#{odi.item_name}", :size => self.item_font_size,:align => :left end - + if alt_name if !(odi.alt_name).empty? move_down 1 @@ -141,7 +141,7 @@ class OrderSummarySlimPdf < Prawn::Document # add option options = odi.options == "[]"? "" : odi.options - + if options != "" move_down 1 @@ -159,7 +159,7 @@ class OrderSummarySlimPdf < Prawn::Document stroke_horizontal_line 0, (self.page_width - self.margin) move_down 1 # end - end + end end def get_booking_id(order_no) diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index 02443c0c..fbbf51e2 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -1,5 +1,5 @@ class ReceiptBillA5Pdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) @@ -26,11 +26,6 @@ class ReceiptBillA5Pdf < Prawn::Document #setting page margin and width super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) - #precision checked - if printer_settings.precision.to_i > 2 - printer_settings.precision = 2 - end - # db font setup if printer_settings.font != "" font_families.update("#{printer_settings.font}" => { @@ -46,23 +41,17 @@ class ReceiptBillA5Pdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - if printer_settings.delimiter - delimiter = "," - else - delimiter = "" - end - header(shop_details) stroke_horizontal_rule cashier_info(sale_data, customer_name, latest_order_no) - line_items(sale_items,printer_settings.precision,delimiter) - all_total(sale_data,printer_settings.precision,delimiter) + line_items(sale_items,precision,delimiter) + all_total(sale_data,precision,delimiter) if member_info != nil - member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance) + member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance) end customer(customer_name) @@ -77,21 +66,21 @@ class ReceiptBillA5Pdf < Prawn::Document card_balance_data(card_balance_amount) end #end card blanace amount - + if discount_price_by_accounts.length > 0 && shop_details.show_account_info - discount_account(discount_price_by_accounts,printer_settings.precision,delimiter) + discount_account(discount_price_by_accounts,precision,delimiter) end if shop_details.show_account_info - items_account(item_price_by_accounts,printer_settings.precision,delimiter) + items_account(item_price_by_accounts,precision,delimiter) if other_charges_amount - show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter) + show_other_charges_amount(other_charges_amount,precision,delimiter) end end #start for individual payment if !sale_data.equal_persons.nil? - individual_payment(sale_data, printer_settings.precision, delimiter) + individual_payment(sale_data, precision, delimiter) end #end for individual payment @@ -100,7 +89,7 @@ class ReceiptBillA5Pdf < Prawn::Document if shop_details.note && !shop_details.note.nil? shop_note(printed_status) end - + footer(printed_status) end @@ -130,7 +119,7 @@ class ReceiptBillA5Pdf < Prawn::Document text "OrderNo : #{ latest_order_no }", :size => self.header_font_size+2,:align => :left end move_down line_move - + # move_down 2 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do @@ -154,7 +143,7 @@ class ReceiptBillA5Pdf < Prawn::Document bounding_box([self.item_description_width, y_position], :width =>self.item_description_width, :height => self.item_height) do text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left - end + end bounding_box([self.item_description_width - 2,y_position], :width =>self.item_description_width, :height => self.item_height) do text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right end @@ -172,7 +161,7 @@ class ReceiptBillA5Pdf < Prawn::Document # bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do - # text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } + # text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } # - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" , # :size => self.item_font_size,:align => :right # end @@ -209,7 +198,7 @@ class ReceiptBillA5Pdf < Prawn::Document end def add_line_item_row(sale_items,precision,delimiter) - + if precision.to_i > 0 item_name_width = (self.item_width+self.price_width) item_qty_front_width = (self.item_width+self.price_width) + 5 @@ -229,17 +218,17 @@ class ReceiptBillA5Pdf < Prawn::Document sub_total = 0.0 total_qty = 0.0 sale_items.each do |item| - # check for item not to show + # check for item not to show show_price = Lookup.find_by_lookup_type("show_price") sub_total += item.price #(item.qty*item.unit_price) - comment for room charges if item.status != 'Discount' && item.qty > 0 if !show_price.nil? && show_price.value.to_i > 0 && item.price == 0 - total_qty += item.qty + total_qty += item.qty else if item.price != 0 - total_qty += item.qty + total_qty += item.qty end end end @@ -265,14 +254,14 @@ class ReceiptBillA5Pdf < Prawn::Document text "Sub Total", :size => self.item_font_size,:align => :left end # bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do - # text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center + # text "#{number_format(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center # end # bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do - # text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + # text "#{number_format(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right # end - text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - + text_box "#{number_format(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_format(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + end def item_row(item,precision,delimiter,product_name,price,qty ,total_price) @@ -297,10 +286,10 @@ class ReceiptBillA5Pdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_width) do text "#{product_name}", :size => self.item_font_size,:align => :left end - # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size - text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size + text_box "#{number_format(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_format(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix if show_alt_name if !(item.product_alt_name).empty? @@ -328,7 +317,7 @@ class ReceiptBillA5Pdf < Prawn::Document text "#{ dis_type }", :size => self.item_font_size,:align => :left end bounding_box([self.description_width,y_position], :width =>self.label_width) do - text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right + text "( #{number_format(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right end if sale_data.sale_taxes.length > 0 @@ -344,7 +333,7 @@ class ReceiptBillA5Pdf < Prawn::Document text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left end bounding_box([self.description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end else @@ -370,7 +359,7 @@ class ReceiptBillA5Pdf < Prawn::Document end bounding_box([self.description_width,y_position], :width =>self.label_width) do text "#{sale_data.rounding_adjustment}", :size => self.item_font_size,:align => :right - end + end end move_down line_move @@ -380,15 +369,15 @@ class ReceiptBillA5Pdf < Prawn::Document text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left end bounding_box([self.description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right + text "#{number_format(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right end move_down line_move - + sale_payment(sale_data,precision,delimiter) - + end - def sale_payment(sale_data,precision,delimiter) + def sale_payment(sale_data,precision,delimiter) stroke_horizontal_rule # move_down 10 sql = "SELECT SUM(payment_amount) @@ -419,28 +408,28 @@ class ReceiptBillA5Pdf < Prawn::Document text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left end end - + bounding_box([self.description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down line_move end - if sale_data.amount_received > 0 + if sale_data.amount_received > 0 y_position = cursor move_down line_move bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do text "Change Amount", :size => self.item_font_size,:align => :left end bounding_box([self.description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end #move_down line_move - end + end end # show member information def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance) - if rebate_amount != nil + if rebate_amount != nil if rebate_amount["status"] == true stroke_horizontal_rule total = 0 @@ -467,10 +456,10 @@ class ReceiptBillA5Pdf < Prawn::Document text "Rebate Earn", :size => self.item_font_size,:align => :left end bounding_box([self.description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - - end + + end # Total Rebate Amount if birthday if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebatebonusAccount" && res["status"]== "Rebate" rebate_balance = rebate_balance + res["deposit"] @@ -480,9 +469,9 @@ class ReceiptBillA5Pdf < Prawn::Document text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left end bounding_box([self.description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - end + end #end Total rebate if birthday end @@ -492,7 +481,7 @@ class ReceiptBillA5Pdf < Prawn::Document text "Redeem Amount", :size => self.item_font_size,:align => :left end bounding_box([self.description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + text "#{number_format(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end if current_balance != nil @@ -502,10 +491,10 @@ class ReceiptBillA5Pdf < Prawn::Document text "Old Balance", :size => self.item_font_size,:align => :left end bounding_box([self.description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + text "#{number_format(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end - + end end @@ -515,7 +504,7 @@ class ReceiptBillA5Pdf < Prawn::Document if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" total_balance = total_balance + res["balance"] - + end end move_down line_move @@ -524,10 +513,10 @@ class ReceiptBillA5Pdf < Prawn::Document text "Total Balance", :size => self.item_font_size,:align => :left end bounding_box([self.description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end - + end def customer(customer_name) @@ -554,8 +543,8 @@ class ReceiptBillA5Pdf < Prawn::Document text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left end bounding_box([self.description_width,y_position], :width =>self.label_width) do - text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right - end + text "(" + "#{ number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right + end move_down line_move end end @@ -570,8 +559,8 @@ class ReceiptBillA5Pdf < Prawn::Document text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width =>self.description_width) do - text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right - end + text "#{number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end move_down line_move end end @@ -582,9 +571,9 @@ class ReceiptBillA5Pdf < Prawn::Document text "Other Charges", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width =>self.item_description_width) do - text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - move_down line_move + move_down line_move end #individual payment per person @@ -604,7 +593,7 @@ class ReceiptBillA5Pdf < Prawn::Document bounding_box([self.label_width,y_position], :width =>self.item_description_width) do move_down 15 - text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + text "#{number_format(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end @@ -623,17 +612,17 @@ class ReceiptBillA5Pdf < Prawn::Document JOIN sale_audits sa ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id where sa.sale_id='#{sale_data.sale_id}')) = 0 - THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment| + THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment| if payment.payment_method == "creditnote" y_position = cursor stroke_horizontal_rule - + bounding_box([self.label_width,y_position], :width =>self.description_width) do move_down 70 stroke_horizontal_rule end - + bounding_box([self.label_width,y_position], :width =>self.description_width) do move_down 73 text "Approved By" , :size => self.item_font_size,:align => :center @@ -650,8 +639,8 @@ class ReceiptBillA5Pdf < Prawn::Document move_down 70 stroke_horizontal_rule end - - if sale_data.payment_status == "foc" + + if sale_data.payment_status == "foc" bounding_box([self.label_width,y_position], :width =>self.description_width) do move_down 73 text "Acknowledged By" , :size => self.item_font_size,:align => :center @@ -661,10 +650,10 @@ class ReceiptBillA5Pdf < Prawn::Document move_down 73 text "Approved By" , :size => self.item_font_size,:align => :center end - end - - end - + end + + end + end def shop_note(shop) @@ -674,8 +663,8 @@ class ReceiptBillA5Pdf < Prawn::Document move_down line_move y_position = cursor - - text "#{shop.note}", :size => self.item_font_size,:align => :left + + text "#{shop.note}", :size => self.item_font_size,:align => :left move_down line_move end @@ -688,10 +677,10 @@ class ReceiptBillA5Pdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.item_description_width) do text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :right - end + end move_down line_move end @@ -729,7 +718,7 @@ class ReceiptBillA5Pdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width) do text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right end @@ -753,4 +742,4 @@ class ReceiptBillA5Pdf < Prawn::Document end return status end -end \ No newline at end of file +end diff --git a/app/pdf/receipt_bill_order_pdf.rb b/app/pdf/receipt_bill_order_pdf.rb index e66cb37e..0f2e1fc6 100644 --- a/app/pdf/receipt_bill_order_pdf.rb +++ b/app/pdf/receipt_bill_order_pdf.rb @@ -1,5 +1,5 @@ class ReceiptBillOrderPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move @@ -27,11 +27,6 @@ class ReceiptBillOrderPdf < Prawn::Document #setting page margin and width super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) - #precision checked - if printer_settings.precision.to_i > 2 - printer_settings.precision = 2 - end - # db font setup if printer_settings.font != "" font_families.update("#{printer_settings.font}" => { @@ -47,19 +42,13 @@ class ReceiptBillOrderPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - if printer_settings.delimiter - delimiter = "," - else - delimiter = "" - end - header(shop_details) stroke_horizontal_rule cashier_info(sale_data, customer_name, latest_order_no,order_reservation) - line_items(sale_items,printer_settings.precision,delimiter,order_reservation) - all_total(sale_data,printer_settings.precision,delimiter,order_reservation) + line_items(sale_items,precision,delimiter,order_reservation) + all_total(sale_data,precision,delimiter,order_reservation) footer(printed_status) end @@ -78,13 +67,13 @@ class ReceiptBillOrderPdf < Prawn::Document def cashier_info(sale_data, customer_name, latest_order_no,order_reservation) move_down line_move - + # move_down 2 - + y_position = cursor bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do text "Order Date " , :size => self.item_font_size, :align => :left - end + end bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do text "#{order_reservation.created_at.strftime('%d-%m-%Y %H:%M %p')}", :size => self.item_font_size,:align => :right end @@ -92,7 +81,7 @@ class ReceiptBillOrderPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do text "Requested Date Time " , :size => self.item_font_size, :align => :left - end + end bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do text "#{order_reservation.requested_time.strftime('%d-%m-%Y %H:%M %p')}", :size => self.item_font_size,:align => :right end @@ -100,7 +89,7 @@ class ReceiptBillOrderPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do text "Payment Type" , :size => self.item_font_size, :align => :left - end + end bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do text "#{order_reservation.payment_type}", :size => self.item_font_size,:align => :right end @@ -108,7 +97,7 @@ class ReceiptBillOrderPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do text "#{customer_name} " , :size => self.item_font_size, :align => :left - end + end bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do text "Online Order", :size => self.item_font_size,:align => :right end @@ -167,14 +156,14 @@ class ReceiptBillOrderPdf < Prawn::Document total_qty = 0.0 show_price = Lookup.find_by_lookup_type("show_price") sale_items.each do |item| - # check for item not to show + # check for item not to show if item.status != 'Discount' && item.qty > 0 if !show_price.nil? && show_price.value.to_i > 0 && item.price == 0 - total_qty += item.qty + total_qty += item.qty else if item.price != 0 - total_qty += item.qty + total_qty += item.qty end end end @@ -191,7 +180,7 @@ class ReceiptBillOrderPdf < Prawn::Document qty = item.qty total_price = item.price #item.qty*item.unit_price - comment for room charges price = item.unit_price - + # end if !show_price.nil? && show_price.value.to_i>0 item_row(item,precision,delimiter,product_name,price,qty ,total_price) @@ -209,8 +198,8 @@ class ReceiptBillOrderPdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do text "Sub Total", :size => self.item_font_size,:align => :left end - text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(order_reservation.total_amount, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_format(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_format(order_reservation.total_amount, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix if !order_reservation.delivery_type.nil? && order_reservation.delivery_fee.to_f > 0 y_position = cursor @@ -219,27 +208,27 @@ class ReceiptBillOrderPdf < Prawn::Document end bounding_box([self.description_width - 48,y_position], :width =>self.label_width, :height => self.item_height) do - text "#{number_with_precision(order_reservation.delivery_fee, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - end + text "#{number_format(order_reservation.delivery_fee, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + end end if order_reservation.total_tax > 0 y_position = cursor bounding_box([0, y_position], :width =>self.item_description_width , :height => self.item_height) do text "Tax " , :size => self.item_font_size, :align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do - text "#{number_with_precision(order_reservation.total_tax, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - end - end + text "#{number_format(order_reservation.total_tax, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + end + end y_position = cursor bounding_box([0, y_position], :width =>self.item_description_width , :height => self.item_height) do text "Convenience Charges " , :size => self.item_font_size, :align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do - text "#{number_with_precision(order_reservation.convenience_charge, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + text "#{number_format(order_reservation.convenience_charge, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end if order_reservation.discount_amount > 0 @@ -249,9 +238,9 @@ class ReceiptBillOrderPdf < Prawn::Document end bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do - text "#{number_with_precision(order_reservation.discount_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - end - end + text "#{number_format(order_reservation.discount_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + end + end end #Change items rows @@ -277,10 +266,10 @@ class ReceiptBillOrderPdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_width) do text "#{product_name}", :size => self.item_font_size,:align => :left end - # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size - text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size + text_box "#{number_format(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_format(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix if show_alt_name if !(item.product_alt_name).empty? @@ -309,11 +298,11 @@ class ReceiptBillOrderPdf < Prawn::Document end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(order_reservation.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right - end + text "#{number_format(order_reservation.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right + end move_down line_move - # sale_payment(sale_data,precision,delimiter) + # sale_payment(sale_data,precision,delimiter) end #Change Footer @@ -326,10 +315,10 @@ class ReceiptBillOrderPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width) do text "#{printed_status}",:style => :bold, :size => header_font_size - 1,:align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size - 1,:align => :left - end + end move_down line_move end @@ -351,4 +340,4 @@ class ReceiptBillOrderPdf < Prawn::Document end return status end -end \ No newline at end of file +end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 2a99e9f9..2d463b38 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,7 +1,7 @@ # require 'prawn/qrcode' require 'prawn/measurement_extensions' class ReceiptBillPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move @@ -29,11 +29,6 @@ class ReceiptBillPdf < Prawn::Document #setting page margin and width super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) - #precision checked - if printer_settings.precision.to_i > 2 - printer_settings.precision = 2 - end - # db font setup if printer_settings.font != "" font_families.update("#{printer_settings.font}" => { @@ -49,23 +44,17 @@ class ReceiptBillPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - if printer_settings.delimiter - delimiter = "," - else - delimiter = "" - end - header(shop_details) stroke_horizontal_rule cashier_info(sale_data, customer_name, latest_order_no) - line_items(sale_items,printer_settings.precision,delimiter) - all_total(sale_data,printer_settings.precision,delimiter) + line_items(sale_items,precision,delimiter) + all_total(sale_data,precision,delimiter) if member_info != nil - member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance) + member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance) end customer(customer_name) @@ -82,19 +71,19 @@ class ReceiptBillPdf < Prawn::Document #end card blanace amount if discount_price_by_accounts.length > 0 && shop_details.show_account_info - discount_account(discount_price_by_accounts,printer_settings.precision,delimiter) + discount_account(discount_price_by_accounts,precision,delimiter) end if shop_details.show_account_info - items_account(item_price_by_accounts,printer_settings.precision,delimiter) + items_account(item_price_by_accounts,precision,delimiter) if other_charges_amount - show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter) + show_other_charges_amount(other_charges_amount,precision,delimiter) end end #start for individual payment if !sale_data.equal_persons.nil? - individual_payment(sale_data,sale_data.equal_persons, printer_settings.precision, delimiter) + individual_payment(sale_data,sale_data.equal_persons, precision, delimiter) end #end for individual payment @@ -273,8 +262,8 @@ class ReceiptBillPdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do text "Sub Total", :size => self.item_font_size,:align => :left end - text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(@sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_format(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_format(@sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix end def item_row(item,precision,delimiter,product_name,price,qty ,total_price) @@ -298,9 +287,9 @@ class ReceiptBillPdf < Prawn::Document text "#{product_name}", :size => self.item_font_size,:align => :left end # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size - text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_format(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_format(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix if show_alt_name if !(item.product_alt_name).empty? @@ -330,7 +319,7 @@ class ReceiptBillPdf < Prawn::Document text "#{ dis_type }", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right + text "( #{number_format(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right end service_tax_desc = "" @@ -355,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_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) + service_tax_amount = number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) 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_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) + com_tax_amount = number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) if incl_tax com_tax_rate = st.tax_rate.to_i end @@ -374,7 +363,7 @@ class ReceiptBillPdf < Prawn::Document text "#{ service_tax_desc } (#{incl_tax} #{ service_tax_rate }%)", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(service_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(service_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down line_move y_position = cursor @@ -391,7 +380,7 @@ class ReceiptBillPdf < Prawn::Document text "#{ com_tax_desc } (#{incl_tax} #{ com_tax_rate.to_i }%)", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(com_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(com_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end else sale_data.sale_taxes.each do |st| @@ -402,7 +391,7 @@ class ReceiptBillPdf < Prawn::Document text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end end @@ -439,7 +428,7 @@ class ReceiptBillPdf < Prawn::Document text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right + text "#{number_format(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right end move_down line_move @@ -480,7 +469,7 @@ class ReceiptBillPdf < Prawn::Document end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down line_move end @@ -491,7 +480,7 @@ class ReceiptBillPdf < Prawn::Document text "Change Amount", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end # move_down line_move end @@ -526,7 +515,7 @@ class ReceiptBillPdf < Prawn::Document text "Rebate Earn", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end @@ -539,7 +528,7 @@ class ReceiptBillPdf < Prawn::Document text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end #end Total rebate if birthday @@ -551,7 +540,7 @@ class ReceiptBillPdf < Prawn::Document text "Redeem Amount", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + text "#{number_format(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end if current_balance != nil @@ -561,7 +550,7 @@ class ReceiptBillPdf < Prawn::Document text "Old Balance", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + text "#{number_format(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end @@ -583,7 +572,7 @@ class ReceiptBillPdf < Prawn::Document text "Total Balance", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end @@ -615,7 +604,7 @@ class ReceiptBillPdf < Prawn::Document text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right + text "(" + "#{ number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right end move_down line_move end @@ -631,7 +620,7 @@ class ReceiptBillPdf < Prawn::Document text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width =>self.item_description_width) do - text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down line_move end @@ -643,7 +632,7 @@ class ReceiptBillPdf < Prawn::Document text "Other Charges", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width =>self.item_description_width) do - text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down line_move end @@ -666,7 +655,7 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.label_width,y_position], :width =>self.item_description_width) do move_down 15 - text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + text "#{number_format(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end diff --git a/app/pdf/receipt_bill_star_pdf.rb b/app/pdf/receipt_bill_star_pdf.rb index 0b1f8ce2..d9a14d4a 100644 --- a/app/pdf/receipt_bill_star_pdf.rb +++ b/app/pdf/receipt_bill_star_pdf.rb @@ -1,5 +1,5 @@ class ReceiptBillStarPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move @@ -28,11 +28,6 @@ class ReceiptBillStarPdf < Prawn::Document #setting page margin and width super(:margin => [self.margin_top, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) - #precision checked - if printer_settings.precision.to_i > 2 - printer_settings.precision = 2 - end - # db font setup if printer_settings.font != "" font_families.update("#{printer_settings.font}" => { @@ -48,23 +43,17 @@ class ReceiptBillStarPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - if printer_settings.delimiter - delimiter = "," - else - delimiter = "" - end - header(shop_details) stroke_horizontal_rule cashier_info(sale_data, customer_name, latest_order_no) - line_items(sale_items,printer_settings.precision,delimiter) - all_total(sale_data,printer_settings.precision,delimiter) + line_items(sale_items,precision,delimiter) + all_total(sale_data,precision,delimiter) if member_info != nil - member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance) + member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance) end customer(customer_name) @@ -81,19 +70,19 @@ class ReceiptBillStarPdf < Prawn::Document #end card blanace amount if discount_price_by_accounts.length > 0 && shop_details.show_account_info - discount_account(discount_price_by_accounts,printer_settings.precision,delimiter) + discount_account(discount_price_by_accounts,precision,delimiter) end if shop_details.show_account_info - items_account(item_price_by_accounts,printer_settings.precision,delimiter) + items_account(item_price_by_accounts,precision,delimiter) if other_charges_amount - show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter) + show_other_charges_amount(other_charges_amount,precision,delimiter) end end #start for individual payment if !sale_data.equal_persons.nil? - individual_payment(sale_data,sale_data.equal_persons, printer_settings.precision, delimiter) + individual_payment(sale_data,sale_data.equal_persons, precision, delimiter) end #end for individual payment @@ -268,8 +257,8 @@ class ReceiptBillStarPdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do text "Sub Total", :size => self.item_font_size,:align => :left end - text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_format(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_format(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix end def item_row(item,precision,delimiter,product_name,price,qty ,total_price) @@ -293,9 +282,9 @@ class ReceiptBillStarPdf < Prawn::Document text "#{product_name}", :size => self.item_font_size,:align => :left end # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size - text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_format(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_format(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix if show_alt_name if !(item.product_alt_name).empty? @@ -325,7 +314,7 @@ class ReceiptBillStarPdf < Prawn::Document text "#{ dis_type }", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right + text "( #{number_format(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right end if sale_data.sale_taxes.length > 0 @@ -342,7 +331,7 @@ class ReceiptBillStarPdf < Prawn::Document text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end else @@ -378,7 +367,7 @@ class ReceiptBillStarPdf < Prawn::Document text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right + text "#{number_format(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right end move_down line_move @@ -419,7 +408,7 @@ class ReceiptBillStarPdf < Prawn::Document end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down line_move end @@ -430,7 +419,7 @@ class ReceiptBillStarPdf < Prawn::Document text "Change Amount", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end # move_down line_move end @@ -465,7 +454,7 @@ class ReceiptBillStarPdf < Prawn::Document text "Rebate Earn", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end @@ -478,7 +467,7 @@ class ReceiptBillStarPdf < Prawn::Document text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end #end Total rebate if birthday @@ -490,7 +479,7 @@ class ReceiptBillStarPdf < Prawn::Document text "Redeem Amount", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + text "#{number_format(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end if current_balance != nil @@ -500,7 +489,7 @@ class ReceiptBillStarPdf < Prawn::Document text "Old Balance", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + text "#{number_format(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end @@ -522,7 +511,7 @@ class ReceiptBillStarPdf < Prawn::Document text "Total Balance", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end @@ -554,7 +543,7 @@ class ReceiptBillStarPdf < Prawn::Document text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right + text "(" + "#{ number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right end move_down line_move end @@ -570,7 +559,7 @@ class ReceiptBillStarPdf < Prawn::Document text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width =>self.item_description_width) do - text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down line_move end @@ -582,7 +571,7 @@ class ReceiptBillStarPdf < Prawn::Document text "Other Charges", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width =>self.item_description_width) do - text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_format(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down line_move end @@ -605,7 +594,7 @@ class ReceiptBillStarPdf < Prawn::Document bounding_box([self.label_width,y_position], :width =>self.item_description_width) do move_down 15 - text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + text "#{number_format(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end diff --git a/app/pdf/sale_items_pdf.rb b/app/pdf/sale_items_pdf.rb index 657b7fe1..af76c427 100644 --- a/app/pdf/sale_items_pdf.rb +++ b/app/pdf/sale_items_pdf.rb @@ -1,5 +1,5 @@ class SaleItemsPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, total_other_charges) @@ -41,17 +41,6 @@ class SaleItemsPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - #precision checked - if printer_settings.precision.to_i > 2 - printer_settings.precision = 2 - end - #check delimiter - if printer_settings.delimiter - delimiter = "," - else - delimiter = "" - end - header( shop_details) stroke_horizontal_rule diff --git a/app/pdf/sale_items_star_pdf.rb b/app/pdf/sale_items_star_pdf.rb index 6860b341..a1181e13 100644 --- a/app/pdf/sale_items_star_pdf.rb +++ b/app/pdf/sale_items_star_pdf.rb @@ -1,5 +1,5 @@ class SaleItemsStarPdf < Prawn::Document - include ActionView::Helpers::NumberHelper + include NumberFormattable attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, total_other_charges) @@ -41,17 +41,6 @@ class SaleItemsStarPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - #precision checked - if printer_settings.precision.to_i > 2 - printer_settings.precision = 2 - end - #check delimiter - if printer_settings.delimiter - delimiter = "," - else - delimiter = "" - end - header( shop_details) stroke_horizontal_rule diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 0f9890d7..5c2eeb8d 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -3,18 +3,6 @@

<%= t :date_time %> : <%= Time.zone.now.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %>

- <% if @print_settings.precision.to_i > 0 - precision = @print_settings.precision - else - precision = 0 - end - #check delimiter - if @print_settings.delimiter - delimiter = "," - else - delimiter = "" - end - %>
@@ -211,19 +199,19 @@ <% revenue = @summ_sale.total_amount - @summ_sale.total_discount%> <%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : - <%= number_with_precision( revenue, precision: precision.to_i ,delimiter: delimiter) %> + <%= number_format( revenue, precision: precision.to_i ,delimiter: delimiter) %> <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : - <%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> + <%= number_format( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %> <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : - <%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> + <%= number_format( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %> <%= t("views.right_panel.detail.total_sale") %> : - <%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%> + <%= number_format( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%> @@ -240,7 +228,7 @@ @@ -253,7 +241,7 @@ <% end %> diff --git a/app/views/origami/dashboard/index.html.erb b/app/views/origami/dashboard/index.html.erb index 204ac3d4..713ba6a5 100644 --- a/app/views/origami/dashboard/index.html.erb +++ b/app/views/origami/dashboard/index.html.erb @@ -6,18 +6,6 @@

<%= t :date_time %> : <%= Time.zone.now.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %>

- <% if @print_settings.precision.to_i > 0 - precision = @print_settings.precision - else - precision = 0 - end - #check delimiter - if @print_settings.delimiter - delimiter = "," - else - delimiter = "" - end - %>
@@ -91,19 +79,19 @@
<% revenue = @summ_sale.total_amount - @summ_sale.total_discount%> - + - + - + - +
<% @sale_data.each do |data| %> <% pay_mth = payment.payment_method %> - <%= number_with_precision(data[""+pay_mth+""], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> + <%= number_format(data[""+pay_mth+""], precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %> <% end %>
<%= t("views.right_panel.detail.other_payment") %> : - <%= number_with_precision(total_card["card"], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> + <%= number_format(total_card["card"], precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %>
<%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : <%= number_with_precision( revenue, precision: precision.to_i ,delimiter: delimiter) %><%= number_format( revenue, precision: precision.to_i ,delimiter: delimiter) %>
<%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : <%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %><%= number_format( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %>
<%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : <%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%><%= number_format( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%>
<%= t("views.right_panel.detail.total") %> <%= t :sale %> : <%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%><%= number_format( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%>
diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index abeeb442..5d24c9d1 100755 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -2,20 +2,6 @@ - <% if !@print_settings.nil? %> - <% if @print_settings.precision.to_i > 0 - precision = @print_settings.precision - else - precision = 0 - end - #check delimiter - if @print_settings.delimiter - delimiter = "," - else - delimiter = "" - end - %> - <% end %>
@@ -96,7 +82,7 @@
- +
@@ -57,14 +43,14 @@
- <% @tables.each do |table| %> + <% @tables.each do |table| %> <% if table.status == 'occupied' %> <% if table.get_booking.nil? %> <% if table.get_checkout_booking.nil? %>
- <% else %> + <% else %>
- <% end %> + <% end %>
<%= table.name %>
<%= table.zone.name %> @@ -72,12 +58,12 @@
- <% else %> + <% else %> <% if table.get_checkout_booking.nil? %>
- <% else %> + <% else %>
- <% end %> + <% end %>
<%= table.name %>
<%= table.zone.name %> @@ -111,7 +97,7 @@ <% end %>
<%= room.name %>
- <%= room.zone.name %> + <%= room.zone.name %> billed
@@ -123,7 +109,7 @@ <% end %>
<%= room.name %>
- <%= room.zone.name %> + <%= room.zone.name %> new
@@ -132,8 +118,8 @@
<%= room.name %>
- <%= room.zone.name %> - + <%= room.zone.name %> +
<% end %> @@ -160,8 +146,8 @@ <% else %> <% order_status = order.status %> <% end %> - <%= order.order_id %> - <% if !order_status.empty? %>| <%= order_status %> + <%= order.order_id %> + <% if !order_status.empty? %>| <%= order_status %> <% end %>
@@ -193,7 +179,7 @@
- + @@ -245,7 +231,7 @@ <% else %> ORDER DETAILS | Table <%= @dining.name rescue "" %> <% end %> - +
@@ -335,8 +321,8 @@ <% end %> <% if !order_item.set_menu_items.nil? && order_item.set_menu_items != '[]' - JSON.parse(order_item.set_menu_items).each do |item_instance| - set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f %> + JSON.parse(order_item.set_menu_items).each do |item_instance| + set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f %>
<%= item_instance["item_instance_name"] %> @@ -345,17 +331,17 @@
<%= set_item_option %> <% end %> <% end %> -
- <% end + + <% end sub_total += set_item_prices end %>
- + <% end %> <% end %> - <% end %> + <% end %>
Sub Total:<%= number_with_precision(sub_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %><%= number_format(sub_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %> <%= t("views.right_panel.detail.receipt_no") %> <%= t :cashier %> <%= t("views.right_panel.detail.name") %> <%= t :customer %> <%= t("views.right_panel.detail.name") %> <%= t :customer %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.credit_amount") %>
<%= order_item.qty %> <%= (order_item.qty*order_item.price).to_f + set_item_prices %>
@@ -364,7 +350,7 @@ - + <%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%> @@ -373,7 +359,7 @@ <%end%> - + <% if @status_sale == "sale" %> @@ -396,15 +382,15 @@ <% end %> - + - + - + <% end %> @@ -431,10 +417,10 @@ <% end %> <% end %> - <% if !order_item.set_menu_items.nil? - JSON.parse(order_item.set_menu_items).each do |item_instance| + <% if !order_item.set_menu_items.nil? + JSON.parse(order_item.set_menu_items).each do |item_instance| set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f - %> + %>
<%= item_instance["item_instance_name"] %> <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %> @@ -444,8 +430,8 @@ <% end %> <% end %> - - <% end + + <% end sub_total += set_item_prices end %> @@ -456,7 +442,7 @@ end %>
Sub Total:<%= number_with_precision(sub_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %><%= number_format(sub_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
Discount:(<%= number_with_precision(@obj_sale.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>)(<%= number_format(@obj_sale.total_discount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>)
<%= number_with_precision(@obj_sale.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%><%= number_format(@obj_sale.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%>
Rounding Adj:<%= number_with_precision(@obj_sale.rounding_adjustment, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%><%= number_format(@obj_sale.rounding_adjustment, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%>
Grand Total:<%= number_with_precision(@obj_sale.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %><%= number_format(@obj_sale.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
--> - + <% end %> <% if @sale_array.size > 1 %> @@ -496,7 +482,7 @@ - <% if @dining.status != "available" %> + <% if @dining.status != "available" %> <% if @status_order == 'order' && @status_sale != 'sale' %> <%if !@order_items.empty? %> @@ -526,7 +512,7 @@ <% if current_login_employee.role == "cashier" %> - Edit + Edit Void <% else %> @@ -545,19 +531,19 @@ <% end %> <% if current_login_employee.role != "waiter" %> - + <%if @membership.discount && @obj_sale.customer.membership_id %> <%else%> - <%end%> - + <%end%> + <% end %> <% end %> @@ -583,7 +569,7 @@
- + <% @payment_methods.each_with_index do |pay, pay_index| %> <%if (pay_index+1)%3 == 0 %>
@@ -625,7 +611,7 @@
- +
@@ -638,7 +624,7 @@ - @@ -690,7 +676,7 @@ count += 1 %> - <%= count %> + <%= count %> <%= order_item.item_name %> <% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %> @@ -701,10 +687,10 @@ <% end %> <% end %> - <% if !order_item.set_menu_items.nil? - JSON.parse(order_item.set_menu_items).each do |item_instance| + <% if !order_item.set_menu_items.nil? + JSON.parse(order_item.set_menu_items).each do |item_instance| set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f - %> + %>
<%= item_instance["item_instance_name"] %> <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %> @@ -714,8 +700,8 @@ <% end %> <% end %> - - <% end + + <% end sub_total += set_item_prices end %> @@ -823,7 +809,7 @@ if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){ receipt_no = ($("#receipt_no").html()).trim(); } - + discount="<%= @membership.discount%>" if ($("#server_mode").val() != "cloud") { // first bill not used in cloud if (discount) { @@ -887,7 +873,7 @@ } else { var sale_id = "<%= @dining.id %>"; } - //var table_id = $('.tables').attr("data-id"); + //var table_id = $('.tables').attr("data-id"); window.location.href = '/origami/' + sale_id +"/"+cashier_type+ "/surveys" }); @@ -989,22 +975,22 @@ } location.reload(); } - }); + }); } - }); + }); }); - // click select option icon for add - $(document).on('click', '.payment_btn', function(event){ + // click select option icon for add + $(document).on('click', '.payment_btn', function(event){ active = $(this).hasClass('selected-payment'); value = $(this).data('value'); type = $(this).data('type'); group = $(this).data('group'); payments = $(".payment_btn"); - if (active) { + if (active) { $(this).removeClass('selected-payment'); - }else{ + }else{ $(this).addClass('selected-payment'); } }); //End selecct attribute buttom @@ -1026,7 +1012,7 @@ if(!location.pathname.includes("credit_payment")){ calculate_member_discount(sale_id,"Cash",tax_type); } - } + } } var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; $.ajax({ @@ -1045,7 +1031,7 @@ } location.reload(); } - }); + }); }); function calculate_member_discount(sale_id,type,tax_type) { @@ -1060,10 +1046,10 @@ url: "/origami/" + sale_id + "/member_discount", data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':'cashier','tax_type':tax_type }, async: false, - success:function(result){ + success:function(result){ } }); - + } $('#pay').on('click', function () { @@ -1137,11 +1123,11 @@ } }); } - else { + else { location.reload(); } } - }); + }); }else{ swal("Opps","There is no orders!","warning"); } @@ -1151,7 +1137,7 @@ $('#split_bills').click(function(){ var dining_id = "<%= @dining.id %>"; window.location.href = '/origami/table/' + dining_id + "/" + cashier_type +"/split_bills"; - }); + }); $('#move').on('click', function () { if($('#move').is(":visible")) { @@ -1236,7 +1222,7 @@ }else{ swal("Opps","You are not authorized for void","warning") } - + }); $('#commissions').on('click', function () { @@ -1285,7 +1271,7 @@ } }); } - }); + }); }else{ swal("Opps","You are not authorized for void","warning") } @@ -1303,7 +1289,7 @@ window.location.href = '/origami/addorders/' + dining_id; }); - /* check in process */ + /* check in process */ $('#check_in').on('click',function(){ var dining_id = "<%= @dining.id %>"; @@ -1394,7 +1380,7 @@ } }); } - }); + }); } function check_emp_access_code(access_code,type) { @@ -1460,11 +1446,11 @@ type: "POST", url: "/origami/payment/"+cashier_type+"/change_tax", data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: tax_type}, - success:function(data){ + success:function(data){ if(data.status){ localStorage.setItem("tax_type", tax_type); window.location.href = '/origami/table/'+dining_id; - } + } } }); }else{ diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index a40f7f58..a7737724 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -2,20 +2,6 @@ - <% if !@print_settings.nil? %> - <% if @print_settings.precision.to_i > 0 - precision = @print_settings.precision - else - precision = 0 - end - #check delimiter - if @print_settings.delimiter - delimiter = "," - else - delimiter = "" - end - %> - <% end %>
@@ -78,9 +64,9 @@ <% sub_total += sale_item.price%> <%= count %> - <%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%> + <%=sale_item.product_name%>@<%=number_format( sale_item.unit_price, precision: precision.to_i )%> <%=sale_item.qty%> - <%=(number_with_precision(sale_item.price, precision: precision.to_i ))%> + <%=(number_format(sale_item.price, precision: precision.to_i ))%> <%end %> @@ -93,7 +79,7 @@ Sub Total - <%=number_with_precision(sub_total, precision: precision.to_i)%> + <%=number_format(sub_total, precision: precision.to_i)%> <%if @sale_data.discount_type == 'member_discount'%> @@ -101,7 +87,7 @@ <%else%> (Discount) <%end%> - (<%= number_with_precision(@sale_data.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>) + (<%= number_format(@sale_data.total_discount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>) @@ -122,20 +108,20 @@ <% end %> - <%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%> + <%= number_format(@sale_data.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%> Rounding Adj: - <%= number_with_precision(@sale_data.rounding_adjustment, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%> + <%= number_format(@sale_data.rounding_adjustment, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%> Grand Total - <%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%> + <%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%> <%if @balance > 0%> <%= @accountable_type %> - <%=number_with_precision(@balance, precision: precision.to_i )%> + <%=number_format(@balance, precision: precision.to_i )%> <% end %> <% if !@individual_total[0].nil? %> @@ -149,7 +135,7 @@ Amount Due (per person) - <%= number_with_precision(@individual_total[0]['per_person_amount'], precision: precision.to_i )%> + <%= number_format(@individual_total[0]['per_person_amount'], precision: precision.to_i )%> <% end %> @@ -171,16 +157,16 @@ <% if @sale_payment.nil? %> - <%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %> + <%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %> <% else %> - <%= number_with_precision(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%> + <%= number_format(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%> <% end %> @@ -190,13 +176,13 @@
Cash
- <%= number_with_precision(@cash, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %> + <%= number_format(@cash, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% if @sale_payment.nil? && @cashier_type != "food_court" %>
Credit
-
<%= number_with_precision(@credit, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@credit, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %> @@ -205,21 +191,21 @@
Other Payments (KBZ Pay)
- <%= number_with_precision(@kbz_pay_amount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %> + <%= number_format(@kbz_pay_amount, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
<% elsif @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0 && @unionpaycount == 0.0 && @alipaycount == 0.0 && @paymalcount == 0.0 && @junctionpaycount == 0.0 && @dingacount == 0.0 && @giftvouchercount == 0.0 %>
Other Payments
- <%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %> + <%= number_format(@other, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
<% else %>
Other Payments
- <%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %> + <%= number_format(@other_payment, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
<% end %> @@ -231,9 +217,9 @@
MPU
<% if @other != 0.0 %> -
<%= number_with_precision(@other, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@other, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %> -
<%= number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(0, precision: precision.to_i ) %>
<% end %>
@@ -242,9 +228,9 @@
Redeem
<% if @ppamount != 0.0 %> -
<%= number_with_precision(@ppamount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@ppamount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %> -
<%= number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(0, precision: precision.to_i ) %>
<% end %>
@@ -253,9 +239,9 @@
VISA
<% if @visacount != 0.0 %> -
<%= number_with_precision(@visacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@visacount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %> -
<%= number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(0, precision: precision.to_i ) %>
<% end %> @@ -264,9 +250,9 @@
JCB
<% if @jcbcount != 0.0 %> -
<%= number_with_precision(@jcbcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@jcbcount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %> -
<%= number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(0, precision: precision.to_i ) %>
<% end %> @@ -275,9 +261,9 @@
MASTER
<% if @mastercount != 0.0 %> -
<%= number_with_precision(@mastercount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@mastercount, precision: precision.to_i) rescue number_format(0, precision: precision.to_i ) %>
<% else %> -
<%= number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(0, precision: precision.to_i ) %>
<% end %> @@ -287,9 +273,9 @@
UNIONPAY
<% if @unionpaycount != 0.0 %> -
<%= number_with_precision(@unionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@unionpaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %> -
<%= number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(0, precision: precision.to_i ) %>
<% end %> @@ -298,9 +284,9 @@
Alipay
<% if @alipaycount != 0.0 %> -
<%= number_with_precision(@alipaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@alipaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %> -
<%= number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(0, precision: precision.to_i ) %>
<% end %> @@ -309,9 +295,9 @@
PAYMAL
<% if @paymalcount != 0.0 %> -
<%= number_with_precision(@paymalcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@paymalcount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %> -
<%= number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(0, precision: precision.to_i ) %>
<% end %> @@ -319,9 +305,9 @@
DINGA
<% if @dingacount != 0.0 %> -
<%= number_with_precision(@dingacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@dingacount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %> -
<%= number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(0, precision: precision.to_i ) %>
<% end %> @@ -330,9 +316,9 @@
JUNCTION PAY
<% if @junctionpaycount != 0.0 %> -
<%= number_with_precision(@junctionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@junctionpaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %> -
<%= number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(0, precision: precision.to_i ) %>
<% end %> @@ -341,15 +327,15 @@
GIFT VOUCHER
<% if @giftvouchercount != 0.0 %> -
<%= number_with_precision(@giftvouchercount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@giftvouchercount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
<% else %> -
<%= number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(0, precision: precision.to_i ) %>
<% end %>
Balance
-
<%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
<%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
diff --git a/app/views/origami/table_invoices/show.html.erb b/app/views/origami/table_invoices/show.html.erb index 84efbc66..76c65057 100644 --- a/app/views/origami/table_invoices/show.html.erb +++ b/app/views/origami/table_invoices/show.html.erb @@ -1,19 +1,5 @@
-<% if !@print_settings.nil? %> - <% if @print_settings.precision.to_i > 0 - precision = @print_settings.precision - else - precision = 0 - end - #check delimiter - if @print_settings.delimiter - delimiter = "," - else - delimiter = "" - end - %> -<% end %>
@@ -89,7 +75,7 @@ <%= count %> <%= sale_item.product_name %> <%= sale_item.qty %> - <%= number_with_precision(sale_item.price, precision: precision.to_i ) %> + <%= number_format(sale_item.price, precision: precision.to_i ) %> <% # end @@ -108,7 +94,7 @@ <%= count %> <%= order_item.item_name %> <%= order_item.qty %> - <%= number_with_precision(order_item.qty*order_item.price, precision: precision.to_i ) %> + <%= number_format(order_item.qty*order_item.price, precision: precision.to_i ) %> <% end @@ -124,7 +110,7 @@ - + <%if @sale.discount_type == 'member_discount'%> @@ -132,19 +118,19 @@ <%else%> <%end%> - + - + - + - +
Sub Total:<%= number_with_precision(sub_total, precision: precision.to_i ) %><%= number_format(sub_total, precision: precision.to_i ) %>
Discount:(<%= number_with_precision(@sale.total_discount, precision: precision.to_i ) rescue 0%>)(<%= number_format(@sale.total_discount, precision: precision.to_i ) rescue 0%>)
Tax:<%= number_with_precision(@sale.total_tax, precision: precision.to_i ) rescue 0%><%= number_format(@sale.total_tax, precision: precision.to_i ) rescue 0%>
Rounding Adj:<%= number_with_precision(@sale.rounding_adjustment, precision: precision.to_i ) rescue 0%><%= number_format(@sale.rounding_adjustment, precision: precision.to_i ) rescue 0%>
Grand Total:<%= number_with_precision(@sale.grand_total, precision: precision.to_i ) rescue 0%><%= number_format(@sale.grand_total, precision: precision.to_i ) rescue 0%>
@@ -163,7 +149,7 @@ <%else%> - <%end%> + <%end%> <% end %> @@ -173,7 +159,7 @@ <% else %> +
+
+
+ + + + + + + + + + + + <% if type && !modify_order%> + + <% end %> + " id="server_mode"> + + + + diff --git a/app/views/foodcourt/addorders/get_all_product.json.jbuilder b/app/views/foodcourt/addorders/get_all_product.json.jbuilder new file mode 100755 index 00000000..01921c59 --- /dev/null +++ b/app/views/foodcourt/addorders/get_all_product.json.jbuilder @@ -0,0 +1,4 @@ + +json.array! @product, :id, :item_code, :name, :alt_name,:image_path, + :description,:information,:taxable,:unit_price, :created_at, + :updated_at, :created_by \ No newline at end of file diff --git a/app/views/foodcourt/addorders/get_item_instance.json.jbuilder b/app/views/foodcourt/addorders/get_item_instance.json.jbuilder new file mode 100644 index 00000000..c95f782d --- /dev/null +++ b/app/views/foodcourt/addorders/get_item_instance.json.jbuilder @@ -0,0 +1,39 @@ +if(@instance) + menu_item = MenuItem.find(@instance.menu_item_id) + # Format for option json + opt_format = [] + # Format for attributes json + menu_item.item_options.each do|opt| + menu_opt = MenuItemOption.find(opt) + if opt_format.count == 0 + opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] }) + next + end + + opt_format.each do |of| + if menu_opt.option_type.in? opt_format.map {|k| k[:type]} + if menu_opt.option_type == of[:type] + of[:values].push(menu_opt.name) + end + else + new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] } + opt_format.push(new_opt) + break + end + end + end + + json.success true + json.id @instance.id + json.name @instance.item_instance_name + json.code @instance.item_instance_code + + json.item_id @instance.menu_item_id + json.attributes @instance.item_attributes + json.price @instance.price + json.is_default @instance.is_default + + json.options opt_format +else + json.success false +end diff --git a/app/views/foodcourt/addorders/get_menu.json.jbuilder b/app/views/foodcourt/addorders/get_menu.json.jbuilder new file mode 100644 index 00000000..bbe18fff --- /dev/null +++ b/app/views/foodcourt/addorders/get_menu.json.jbuilder @@ -0,0 +1 @@ +json.array! @menu_category \ No newline at end of file diff --git a/app/views/foodcourt/addorders/get_menu_category.json.jbuilder b/app/views/foodcourt/addorders/get_menu_category.json.jbuilder new file mode 100755 index 00000000..d5822d3d --- /dev/null +++ b/app/views/foodcourt/addorders/get_menu_category.json.jbuilder @@ -0,0 +1,8 @@ +if @menu.menu_items + json.menu_items @menu.menu_items do |item| + if item.is_available + json.partial! 'foodcourt/addorders/menu_item', item: item + end + + end +end diff --git a/app/views/foodcourt/addorders/get_menu_sub_category.json.jbuilder b/app/views/foodcourt/addorders/get_menu_sub_category.json.jbuilder new file mode 100644 index 00000000..d391e4c5 --- /dev/null +++ b/app/views/foodcourt/addorders/get_menu_sub_category.json.jbuilder @@ -0,0 +1,9 @@ +if @sub_menu + json.sub_category @sub_menu.each do |sub_cat| + json.id sub_cat.id + json.code sub_cat.code + json.name sub_cat.name + json.menu_id sub_cat.menu_id + json.menu_category_id sub_cat.menu_category_id + end +end diff --git a/app/views/foodcourt/cash_ins/new.html.erb b/app/views/foodcourt/cash_ins/new.html.erb new file mode 100755 index 00000000..7bc17066 --- /dev/null +++ b/app/views/foodcourt/cash_ins/new.html.erb @@ -0,0 +1,101 @@ +
+
+
+

<%= t :cash_in %>

+
+ + + + + + + + + + + + + + + + + + + + + +
<%= t :payment_reference %> + + +
<%= t("views.right_panel.detail.remark") %> + + +
<%= t :payment_method %> + + + + + +
<%= t :reference_number %> + + +
<%= t("views.right_panel.detail.amount") %> + + +
+
+
+
+
+ + +
+ +
+
+
+ + diff --git a/app/views/foodcourt/cash_mgmt/create.html.erb b/app/views/foodcourt/cash_mgmt/create.html.erb new file mode 100755 index 00000000..1b4805a2 --- /dev/null +++ b/app/views/foodcourt/cash_mgmt/create.html.erb @@ -0,0 +1,2 @@ +

CashMgmt#create

+

Find me in app/views/cash_mgmt/create.html.erb

diff --git a/app/views/foodcourt/cash_mgmt/index.html.erb b/app/views/foodcourt/cash_mgmt/index.html.erb new file mode 100755 index 00000000..88195969 --- /dev/null +++ b/app/views/foodcourt/cash_mgmt/index.html.erb @@ -0,0 +1,2 @@ +

CashMgmt#index

+

Find me in app/views/cash_mgmt/index.html.erb

\ No newline at end of file diff --git a/app/views/foodcourt/cash_mgmt/new.html.erb b/app/views/foodcourt/cash_mgmt/new.html.erb new file mode 100755 index 00000000..b06a8d2d --- /dev/null +++ b/app/views/foodcourt/cash_mgmt/new.html.erb @@ -0,0 +1,3 @@ +

CashMgmt#new

+

Find me in app/views/cash_mgmt/new.html.erb

+ diff --git a/app/views/foodcourt/cash_outs/new.html.erb b/app/views/foodcourt/cash_outs/new.html.erb new file mode 100755 index 00000000..14a9ec97 --- /dev/null +++ b/app/views/foodcourt/cash_outs/new.html.erb @@ -0,0 +1,53 @@ +
+
+
+

<%= t :cash_out %>

+ + + + + + + + + + + + + +
<%= t :payment_reference %>
<%= t("views.right_panel.detail.remark") %>
<%= t("views.right_panel.detail.amount") %>
+
+
+

+ + +
+
+
+ diff --git a/app/views/foodcourt/customers/index.html.erb b/app/views/foodcourt/customers/index.html.erb new file mode 100644 index 00000000..82d72d07 --- /dev/null +++ b/app/views/foodcourt/customers/index.html.erb @@ -0,0 +1,715 @@ + +
+
+
+
+
+
+ <% path ="/foodcourt/#{@sale_id}/#{@cashier_type}/customers/#{@page}" %> + <%= form_tag path, :id => "filter_form", :method => :get do %> +
+
+ + + +
+ + + + + + + + +
+ <% end %> +
+
+ +
+
+
+
+ <%= paginate @crm_customers %> +
+
+ + + + + + + + + + + + + + + + + <% if @crm_customers.count > 0 %> + <% @i = 0 %> + <% @crm_customers.each do |crm_customer| %> + + + + + + + + + + + + + + <% end %> + <%else%> + + <% end %> + +
<%= t("views.right_panel.detail.sr_no") %><%= t :customer %> <%= t("views.right_panel.detail.type") %><%= t("views.right_panel.detail.name") %><%= t("views.right_panel.detail.card_no") %><%= t("views.right_panel.detail.membership_type") %><%= t("views.right_panel.detail.contact_no") %><%= t("views.right_panel.detail.email") %>
+ + <% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %> + <%= @i += 1 %> + <%else%> + - + <% end %> + <%= crm_customer.customer_type rescue '-' %><%= crm_customer.name %><%= crm_customer.card_no rescue '-' %> + <% if !@membership_types.nil? %> + <% @membership_types.each do |member_type| %> + <% if member_type[1] == crm_customer.membership_type %> + <%= member_type[0] %> + <% end %> + <% end %> + <% end %> + <%= crm_customer.contact_no %><%= crm_customer.email %>

There are no record for your search

+
+
+
+
+ + + + <%if !@dining_facility.nil?%> + + + + <% elsif @cashier_type == 'quick_service' || @cashier_type == "food_court" %> + + + + <%else%> + + + + <%end%> + +
+
+
+
+ +
+ <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> + + <%= f.error_notification %> + <%= f.hidden_field :id, :class => "form-control col-md-6 " %> +
+
+
+
+ +
+ +
+
+
+
+
+
+   +   +   + +
+
+
"> +
+ <%= f.input :name, :class => "form-control name", :required => true %> + + <% flash.each do |name, msg| %> + <% str="[\"#{msg['name']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end -%> +
+
+
"> +
+ <%= f.input :contact_no, :class => "form-control contact_no" ,:required => true%> + + <% flash.each do |name, msg| %> + <% str="[\"#{msg['contact_no']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end %> +
+
+ +
"> +
+ <%= f.input :email, :class => "form-control email" ,:required => true%> + + <% flash.each do |name, msg| %> + <% str="[\"#{msg['email']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end %> +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+ + <%= f.file_field :image_path, :class => "img-thumbnail" %> +
+
+
+
+
+
+ + +
+
+
+
+ <%= f.input :nrc_no,:label => "NRC No", :class => "form-control nrc_no" %> +
+
+
+
+ <%= f.input :company, :class => "form-control col-md-6 company"%> + + <% flash.each do |name, msg| %> + <% str="[\"#{msg['company']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end -%> +
+
+
+
+ + <%= f.text_field :date_of_birth, :value=>"01-01-1990",:class=>"datepicker form-control col-md-12"%> +
+
+
+
+ <%= f.input :address, :class => "form-control address" %> +
+
+
+
+ + +
+
+ +
+
+ <%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control tax_profiles" %> +
+
+ +
"> +
+ <%= f.input :card_no, :class => "form-control card_no"%> + <% flash.each do |name, msg| %> + <% str="[\"#{msg['card_no']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end %> +
+
+ +
+
+ +
+ +
+
+
+
+ +
+
+ + +
+
+
+
+ + <%= f.submit t("views.btn.submit"),:class => 'btn bg-blue btn-md waves-effect', :id => 'submit_customer' %> + +
+
+
+
+ <% end %> +
+
+
+
+
+
+
+
+ +
+

Card Tap

+
+ +
+
+ + diff --git a/app/views/foodcourt/dashboard/_menu.json.jbuilder b/app/views/foodcourt/dashboard/_menu.json.jbuilder new file mode 100644 index 00000000..9c9f1963 --- /dev/null +++ b/app/views/foodcourt/dashboard/_menu.json.jbuilder @@ -0,0 +1,112 @@ +json.id menu.id +json.name menu.name +json.is_ordering menu.is_ordering +json.is_active menu.is_active +json.valid_time_from menu.valid_time_from.strftime("%H:%M") +json.valid_time_to menu.valid_time_to.strftime("%H:%M") + +if (menu.menu_categories) + order_by = Lookup.find_by_lookup_type("order_by") + # if !order_by.nil? && order_by.value == "name" + # categories = MenuCategory.unscoped.where("menu_id ='#{menu.id}'").order("name asc") + # else + # categories = menu.menu_categories + # end + 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 + valid_time = category.valid_time + json.valid_time valid_time + + json.id category.id + json.code category.code + json.order_by category.order_by + json.name category.name + json.alt_name category.alt_name + json.order_by category.order_by + json.parent_id category.menu_category_id + json.is_available category.is_available + + if !order_by.nil? && order_by.value == "name" + menu_items = category.menu_items.sort_by(&:name) + else + menu_items = category.menu_items + end + + if category.menu_items + json.items menu_items do |item| + if item.is_available + # Format for attributes json + attr_format = [] + # Format for attributes json + if item.item_attributes.count > 0 + item_attributes = @item_attributes.select{ |x| item.item_attributes.include?(x.id.to_s) } + attr_format = item_attributes.group_by {|att| att.attribute_type }.map { |type, values| {type: type, values: values.map(&:name)} } + end + + # Format for option json + opt_format = [] + # Format for attributes json + if item.item_options.count > 0 + item_options = @item_options.select{ |x| item.item_options.include?(x.id.to_s) } + opt_format = item_options.group_by {|opt| opt.option_type }.map { |type, values| {type: type, values: values.map(&:name)} } + end + + #Menu Item Information + json.id item.id + json.code item.item_code + json.name item.name + json.alt_name item.alt_name + json.image item.image_path.url + json.description item.description + json.information item.information + json.type item.type + json.account_id item.account_id + json.min_qty item.min_qty + json.is_available item.is_available + json.is_sub_item item.is_sub_item + json.unit item.unit + + # Item Sets of Menu Item + json.item_sets item.item_sets.map { |its| + { id: its.id, + name: its.name, + alt_name: its.alt_name, + min_selectable_qty: its.min_selectable_qty, + max_selectable_qty: its.max_selectable_qty, + instances: its.menu_item_instances.pluck(:id).map { |id| {id: id}} + } + } + + json.attributes attr_format + json.options opt_format + + json.instances item.menu_item_instances do |is| + if is.is_available + # Convert id to name for attributes + instance_attr = @item_attributes.select{ |x| item.item_attributes.include?(x.id) }.pluck(:name) + + json.id is.id + json.code is.item_instance_code + json.name is.item_instance_name + json.price is.price + json.is_available is.is_available + json.is_default is.is_default + json.is_on_promotion is.is_on_promotion + json.promotion_price is.promotion_price + json.values instance_attr + end + end + + end + end + end + end + end +end diff --git a/app/views/foodcourt/dashboard/get_all_menu.json.jbuilder b/app/views/foodcourt/dashboard/get_all_menu.json.jbuilder new file mode 100644 index 00000000..cce593ff --- /dev/null +++ b/app/views/foodcourt/dashboard/get_all_menu.json.jbuilder @@ -0,0 +1,18 @@ +menu_json = json.array! @menus do |menu| + + if !menu.is_ordering + json.id menu.id + json.name menu.name + json.valid_days menu.valid_days + json.valid_time_from menu.valid_time_from.strftime("%H:%M") + json.valid_time_to menu.valid_time_to.strftime("%H:%M") + + json.partial! 'foodcourt/dashboard/menu', menu: menu + # if (@current_menu) + # json.current_menu do + # json.partial! 'api/restaurant/menu/menu', menu: @current_menu + # end + # end + end + +end diff --git a/app/views/foodcourt/dashboard/index.html.erb b/app/views/foodcourt/dashboard/index.html.erb new file mode 100644 index 00000000..1caab8e6 --- /dev/null +++ b/app/views/foodcourt/dashboard/index.html.erb @@ -0,0 +1,281 @@ +
+ +
+ +

<%= t :date_time %> : <%= Time.zone.now.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %>

+
+ <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> + + +
+ <% if @quick_service == '1' %> +
+
+
+ arrow_forward +
+
<%= t :quick_service %>
+
+
+ <% end %> + <% if @food_court == '1' %> +
+
+
+ arrow_forward +
+
<%= @food_court_name %>
+
+
+ <% end %> + <% if @dinein_cashier == '1' %> +
+
+
+ arrow_forward +
+
<%= t :dine_in_cashier %>
+
+
+ <% end %> + <% if @reservation == '1' %> +
+
+
+ arrow_forward +
+
<%= t :reservation %>
+
+
+ <% end %> + <% if @order_reservation == '1' %> +
+
+
+ arrow_forward +
+
<%= t :order_reservation %>
+
+
+ <% end %> +
+ + <% if !@current_user.nil? && @current_user.role != 'waiter' && @setting_flag %> + +
+ + <% if !@summ_sale.nil? %> + +
+
+
+
<%= t :sale %>
+ + + + + + + <% revenue = @summ_sale.total_amount - @summ_sale.total_discount%> + + + + + + + + + + + + + + + +
<%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.receipt") %> : <%= @summ_sale.total_receipt %>
<%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : <%= number_with_precision( revenue, precision: precision.to_i ,delimiter: delimiter) %>
<%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : <%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %>
<%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : <%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%>
<%= t("views.right_panel.detail.total") %> <%= t :sale %> : <%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%>
+ + <% if !(@total_payment_methods.nil?) %> + <% @total_payment_methods.each do |payment| %> + <% if !@sale_data[0].empty? %> + <% if payment.payment_method != 'mpu' && payment.payment_method != 'visa' && payment.payment_method != 'master' && payment.payment_method != 'jcb' %> + + <% if payment.payment_method == 'paypar' %> + + <% else %> + + <% end %> + + + <% end %> + <% end %> + <% end %> + + <% total_card = @sale_data.select { |hash| hash["card"]!=nil }.first %> + <% if !total_card.nil? %> + + + + + <% end %> + + <% end %> +
Redeem Sale : <%= payment.payment_method.to_s.capitalize %> Sale : + <% @sale_data.each do |data| %> + <% pay_mth = payment.payment_method %> + <%= data[""+pay_mth+""] %> + <% end %> +
<%= t("views.right_panel.detail.other_payment") %> : + <%= total_card["card"].to_f %> +
+
+
+
+ <% end %> +
+
+
+
<%= t :customer %>
+ + <% if !@total_customer.nil? %> + + + + + <% end %> + <% if !@total_dinein.nil? %> + + + + + <% end %> + <% if !@total_takeaway.nil? %> + + + + + <% end %> + + <% if !@total_membership.nil? %> + + + + + <% end %> +
<%= t("views.right_panel.detail.total") %> <%= t :customer %> : <%= @total_customer %>
<%= t("views.right_panel.detail.dine_in") %> : <%= @total_dinein %>
<%= t("views.right_panel.detail.takeaway") %> : <%= @total_takeaway %>
<%= t("views.right_panel.detail.membership") %> : <%= @total_membership %>
+
+
+
+
+
+
+
<%= t("views.right_panel.detail.order") %>
+ + <% if !@total_order.nil? %> + + + + + <% end %> + + <% if !@total_accounts.nil? %> + <% @total_accounts.each do |account| %> + + + + + <% end %> + <% end %> + <% if !@top_items.nil? %> + + + + + <% end %> + <% if !@total_foc_items.nil? %> + + + + + <% end %> +
<%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.order") %> : <%= @total_order.total_order %>
<%= account.title %> (Account) : + <% @account_data.each do |data| %> + <% acc = account.title %> + <%= data[""+acc+""] %> <% if !data[''+acc+''].nil? %> ( <%= data[''+acc+'_amount'] %> ) <% end %> + <% end %> +
<%= t :top %> <%= t("views.right_panel.detail.item") %> : <%= @top_items.item_name %> +
(<%= @top_items.item_total_price %>)
<%= t("views.right_panel.detail.total") %> <%= t("views.btn.foc") %> <%= t("views.right_panel.detail.item") %> : <%= @total_foc_items.to_int %>
+
+
+
+
+ <% end %> +
+ + " id="server_mode"> + diff --git a/app/views/foodcourt/discounts/index.html.erb b/app/views/foodcourt/discounts/index.html.erb new file mode 100755 index 00000000..5ca020a3 --- /dev/null +++ b/app/views/foodcourt/discounts/index.html.erb @@ -0,0 +1,919 @@ +
+ + <% if !@print_settings.nil? %> + <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> + <% end %> +
+ +
+ +
+ +
+
+
+ <%if !@table.nil?%> + + + <%else%> + + + <%end%> + + +

Receipt No: <%=@sale_data.receipt_no rescue ' '%>

+ +
+
+

Date: <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+ + + + + + + + + + + <% sub_total = 0 %> + <% @sale_data.sale_items.each do |sale_item| %> + <% sub_total += sale_item.qty * sale_item.unit_price %> + <% if sale_item.price > 0 && sale_item.status.blank? %> + > + + + + + <% elsif sale_item.price < 0 && sale_item.status == "Discount" %> + > + + + + + <% end %> + <% end %> + +
ItemsQTYPrice
+ + + <%=sale_item.product_name%>@<%=sale_item.unit_price%> + + <%=sale_item.qty%> + + <%=(sale_item.qty*sale_item.unit_price)%> +
+ + + <%=sale_item.product_name%>@<%=sale_item.unit_price%> + + <%=sale_item.qty.abs%> + + <%=(sale_item.qty*sale_item.unit_price)%> +
+
+
+ +
+
+
+ + + +
+ +
+
+
Discount Control
+
+
+
+
+
+
+ + +
+
+
+ <% @accounts.each do |acc| %> + + <% end %> +
+
+
+
+ +
+
+
+
+
+
+
5%
+
+
+
+
1
+
2
+
3
+
+
+
+ +
+
+
10%
+
+
+
+
4
+
5
+
6
+
+
+
+ +
+
+
15%
+
+
+
+
7
+
8
+
9
+
+
+
+ +
+
+
20%
+
+
+
+
0
+
.
+
00
+
+
+
+ +
+
+
30%
+
+
+
+
+
DEL
+
CLR
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+ + +
+ +
+ +
+ + + + + <% if @member_discount%> + + <%end %> +
+
+
+
+ + diff --git a/app/views/foodcourt/orders/app_order_by_booking.html.erb b/app/views/foodcourt/orders/app_order_by_booking.html.erb new file mode 100644 index 00000000..e531e024 --- /dev/null +++ b/app/views/foodcourt/orders/app_order_by_booking.html.erb @@ -0,0 +1,39 @@ +
+ +
+
+
+
+
+
+
+ ORDER DETAILS + Booking Id : +
+
+
+
+ + + + + + + + + + + +
#ItemsQTY
+
+ +
+
+
+
+
diff --git a/app/views/foodcourt/orders/app_orders.html.erb b/app/views/foodcourt/orders/app_orders.html.erb new file mode 100644 index 00000000..5356333f --- /dev/null +++ b/app/views/foodcourt/orders/app_orders.html.erb @@ -0,0 +1,17 @@ +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/views/foodcourt/orders/show.html.erb b/app/views/foodcourt/orders/show.html.erb new file mode 100755 index 00000000..53fdb437 --- /dev/null +++ b/app/views/foodcourt/orders/show.html.erb @@ -0,0 +1,391 @@ + +
+ +
+ + + + +
+
+ +
+
+ <% @complete.each do |sale| %> +
+
+ <%= sale.receipt_no %><%= sale.sale_status %> +
+
+ <% end %> +
+
+ + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> + <% if table.get_booking.nil? %> + <% if table.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= table.name %>
+ <%= table.zone.name %> + billed +
+
+
+ <% else %> + <% if table.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= table.name %>
+ <%= table.zone.name %> + new +
+
+ <% end %> + <% else %> +
+
+ <%= table.name %>
+ <%= table.zone.name %> + new +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> + <% if room.get_booking.nil? %> +
+
+ <%= room.name %>
+ <%= room.zone.name %> + billed +
+
+ <% else %> +
+
+ <%= room.name %>
+ <%= room.zone.name %> + new +
+
+ <% end %> + <% else %> +
+
+ <%= room.name %>
+ <%= room.zone.name %> + +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @orders.each do |order| %> +
text-white" data-id = "<%= order.order_id %>"> +
+ <% + order_status = "" + sale_order = SaleOrder.find_by_order_id(order) + if sale_order + unless sale_order.sale_id.nil? + sale = Sale.find(sale_order.sale_id) + order_status = sale.sale_status + if order_status == 'new' + order_status = order.status + end + end + else + order_status = order.status + end + %> + <%= order.order_id %> <% if !order_status.empty? %>| <%= order_status %> <% end %> +
+
+ <% end %> +
+
+ + +
+
+
+
+ +
+
+ +
+
+
+ + + + + + + + + +
<%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %><%= t("views.right_panel.detail.receipt_no") %> <%= t :cashier %> <%= t("views.right_panel.detail.name") %> <%= t :customer %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.credit_amount") %>
+
+
+
+ +
+
+ +
+ + +
+
+
+
ORDERS DETAILS
+
+
+
+
+ Order No: <%= @order.order_id %> + +
+
+ Date: <%= @order.created_at.utc.getlocal.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> +
+
+
+
+ Customer : +
+ +
+
"> +
+ + + + + + + + + + <% + sub_total = 0 + @order.order_items.each do |sale_item| + sub_total = sub_total + sale_item.price + %> + <% unless sale_item.price <= 0 %> + + + + + + <% + end + end + %> + +
ItemsQTYPrice
+ <%= sale_item.item_name %> + <% if !sale_item.set_menu_items.nil? + sale_item.set_menu_items.each do |item_instance| %> +
<%= item_instance %> + <% end + end %> +
<%= sale_item.qty %><%= sale_item.price %>
+
+
+ +
+
+
+ + +
+ + <% if !@split_bill.nil? && @split_bill == '1' %> + + <% end %> + <% if @sale_status != 'completed' %> + + <% end %> + +
+
+
+ + + + + + diff --git a/app/views/foodcourt/other_charges/index.html.erb b/app/views/foodcourt/other_charges/index.html.erb new file mode 100755 index 00000000..0a446619 --- /dev/null +++ b/app/views/foodcourt/other_charges/index.html.erb @@ -0,0 +1,406 @@ +
+
+ +
+ +
+ +
+
+
+ +

Receipt No: <%=@sale_data.receipt_no rescue ' '%>

+ +
+
+

Date: <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+ + + + + + + + + + <% sub_total = 0 %> + <% @sale_data.sale_items.each do |sale_item| %> + <% + sub_total += sale_item.qty*sale_item.unit_price + unless sale_item.price == 0 + %> + > + + + + + <% + end + end + %> + +
ItemsQTYPrice
+ + <%=sale_item.product_name%>@<%=sale_item.unit_price%> + + <%=sale_item.qty%> + + <%=(sale_item.qty*sale_item.unit_price)%> +
+
+
+ +
+
+
+ + + +
+ +
+
+
Other Charges Control
+
+
+
+
+
+
+ +
+
+
+ +
+
+ + Is Taxable +
+
+
+
+ +
+ +
+
+
+
+
+
3000
+
+
+
+
1
+
2
+
3
+
+
+
+ +
+
+
5000
+
+
+
+
4
+
5
+
6
+
+
+
+ +
+
+
10000
+
+
+
+
7
+
8
+
9
+
+
+
+ +
+
+
15000
+
+
+
+
0
+
.
+
00
+
+
+
+ +
+
+
20000
+
+
+
+
+
DEL
+
CLR
+
+
+
+
+
+ +
+
+ + +
+
+
+
+
+
+ + +
+ +
+ <%if !@table.nil?%> + + <%else%> + + <%end%> + +
+
+
+
+ diff --git a/app/views/foodcourt/paymal/create.json.jbuilder b/app/views/foodcourt/paymal/create.json.jbuilder new file mode 100644 index 00000000..f352b148 --- /dev/null +++ b/app/views/foodcourt/paymal/create.json.jbuilder @@ -0,0 +1,2 @@ +json.set! :status, @out[0] +json.set! :message, @out[1] \ No newline at end of file diff --git a/app/views/foodcourt/paymal/index.html.erb b/app/views/foodcourt/paymal/index.html.erb new file mode 100644 index 00000000..17d99db0 --- /dev/null +++ b/app/views/foodcourt/paymal/index.html.erb @@ -0,0 +1,404 @@ +
+ +
+
+
+
+ + + +
+
+ + <%@payment_prices = @payment_prices +@rounding_adj%> + +
+
+
+ <% if @payparcount > 0 %> +
+
+ + +
+
+
+ <% end %> +
+
+ + +
+
+
+
+
+ +
0.0
+
+
+
+
+
+ +
+ +
+
+
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+ +
+
+ + +
+
+ +
+
+ +
+

Card Tap

+
+ +
+
+
+ + + + + diff --git a/app/views/foodcourt/payments/create.json.jbuilder b/app/views/foodcourt/payments/create.json.jbuilder new file mode 100755 index 00000000..f1dd8cad --- /dev/null +++ b/app/views/foodcourt/payments/create.json.jbuilder @@ -0,0 +1,2 @@ +json.status true + diff --git a/app/views/foodcourt/payments/show.html.erb b/app/views/foodcourt/payments/show.html.erb new file mode 100755 index 00000000..f3439910 --- /dev/null +++ b/app/views/foodcourt/payments/show.html.erb @@ -0,0 +1,1788 @@ +
+ + <% if !@print_settings.nil? %> + <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> + <% end %> + +
+
+
+
+
+
+
Receipt No : <%=@sale_data.receipt_no rescue ' '%>
+
Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %>
+
+
+
Table No : <%=@table_no%>
+ +
Sale ID : <% if @sale_data %><%=@sale_data.sale_id %><% end %>
+
+ +
+
+ Customer : + <% if @cashier_type == 'quick_service' || @cashier_type == 'food_court' %> + + <% else %> + <%= @sale_data.customer.name%> + <% end %> + +
+
Checkin Time : <%if !@checkin_time.nil?%><%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %> + <%end%>
+
+
+
+ +
+
+
+ + + + + + + + + +
#ItemsQTYPrice
+
+
+
+ +
+ + + <% sub_total = 0 + count = 0 + %> + <% @sale_data.sale_items.each do |sale_item| + count += 1 + %> + + <% sub_total += sale_item.price%> + + + + + + + <%end %> + +
<%= count %><%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%><%=sale_item.qty%><%=(number_with_precision(sale_item.price, precision: precision.to_i ))%>
+
+
+
+ + + + +
+
+ +
+
+
+
+
Amount Due <% if !@sale_payment.nil? %>( Credit )<% end %>
+
+ + + + <% if @sale_payment.nil? %> + <%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %> + <% else %> + <%= number_with_precision(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%> + <% end %> + + +
+
+ +
+
Cash
+
+ <%= number_with_precision(@cash, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %> +
+
+ <% if @sale_payment.nil? && @cashier_type != "food_court" %> +
+
Credit
+
<%= number_with_precision(@credit, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
+ <% else %> + + <% end %> +
+
Other Payments
+
+ <%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %> +
+
+
+
+
+ +
+
+
MPU
+ <% if @other != 0.0 %> +
<%= number_with_precision(@other, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
Redeem
+ <% if @ppamount != 0.0 %> +
<%= number_with_precision(@ppamount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
VISA
+ <% if @visacount != 0.0 %> +
<%= number_with_precision(@visacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
JCB
+ <% if @jcbcount != 0.0 %> +
<%= number_with_precision(@jcbcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
MASTER
+ <% if @mastercount != 0.0 %> +
<%= number_with_precision(@mastercount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + + +
+
+
UNIONPAY
+ <% if @unionpaycount != 0.0 %> +
<%= number_with_precision(@unionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
Alipay
+ <% if @alipaycount != 0.0 %> +
<%= number_with_precision(@alipaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
PAYMAL
+ <% if @paymalcount != 0.0 %> +
<%= number_with_precision(@paymalcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ +
+
+
DINGA
+ <% if @dingacount != 0.0 %> +
<%= number_with_precision(@dingacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
JUNCTION PAY
+ <% if @junctionpaycount != 0.0 %> +
<%= number_with_precision(@junctionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
GIFT VOUCHER
+ <% if @giftvouchercount != 0.0 %> +
<%= number_with_precision(@giftvouchercount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ +
+
Balance
+
<%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
+ +
+
+ + +
+
+
+ + + <% if current_login_employee.role == "cashier" %> + <% if @other_payment <= 0 && @sale_payment.nil? %> + <%if @sale_data.total_discount == 0 %> + FOC + <% end %> + <%end %> + <% if @sale_payment.nil? %> + Void + <% if @other_payment <= 0 %> + <%if @sale_data.total_discount == 0 %> + Waste + Spoile + <% end %> + <% end %> + <% end %> + <% else %> + <% if @other_payment <= 0 && @sale_payment.nil?%> + <%if @sale_data.total_discount == 0 %> + + + <% end %> + <% end %> + <% end %> + <% end %> + +<% if (@cashier_type=="quick_service" || @cashier_type=="food_court") && @sale_payment.nil? %> +
+ + + + <% if current_login_employee.role == "cashier" %> + Edit + <% else %> + +
+ <% end %> + <% end %> + <% end %> +
+
+
+ +
+ +
+ +
+
+
+
+
+ +
+ +
+ +
+
+
+ +
+
+ + + + + + + +
+
+

Card Tap

+
+
+ +
+
+ + + + + diff --git a/app/views/foodcourt/paypar_payments/create.json.jbuilder b/app/views/foodcourt/paypar_payments/create.json.jbuilder new file mode 100755 index 00000000..f352b148 --- /dev/null +++ b/app/views/foodcourt/paypar_payments/create.json.jbuilder @@ -0,0 +1,2 @@ +json.set! :status, @out[0] +json.set! :message, @out[1] \ No newline at end of file diff --git a/app/views/foodcourt/paypar_payments/index.html.erb b/app/views/foodcourt/paypar_payments/index.html.erb new file mode 100755 index 00000000..4e74da85 --- /dev/null +++ b/app/views/foodcourt/paypar_payments/index.html.erb @@ -0,0 +1,21 @@ +
+ +
+
+ <% if @membership_id!=0 %> +
+
Redim Amount
+
+ <% end %> +
+
+
+ +
+ +
+ diff --git a/app/views/foodcourt/request_bills/print.json.jbuilder b/app/views/foodcourt/request_bills/print.json.jbuilder new file mode 100755 index 00000000..332a9cec --- /dev/null +++ b/app/views/foodcourt/request_bills/print.json.jbuilder @@ -0,0 +1,7 @@ +if @status == true + #show invoice number and stuff + json.status @status +else + json.status @status + json.error_message @error_message +end diff --git a/app/views/foodcourt/reservation/index.html.erb b/app/views/foodcourt/reservation/index.html.erb new file mode 100644 index 00000000..1575b1e5 --- /dev/null +++ b/app/views/foodcourt/reservation/index.html.erb @@ -0,0 +1,149 @@ +<%= stylesheet_link_tag 'reservation', media: 'all', 'data-turbolinks-track': 'reload' %> +<%= javascript_include_tag 'reservation', 'data-turbolinks-track': 'reload' %> +
+
+
+
+
+
<%= t :make_reservation %>
+
+
+
+
+
+ +
+
+
+
+
+   + +
+
+ +
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+
+
+
+ + +
+
+
+ +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+
+
diff --git a/app/views/foodcourt/sale_edit/apply_void.json.jbuilder b/app/views/foodcourt/sale_edit/apply_void.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/sale_edit/apply_void.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/sale_edit/cancel_all_void.json.jbuilder b/app/views/foodcourt/sale_edit/cancel_all_void.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/sale_edit/cancel_all_void.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/sale_edit/edit.html.erb b/app/views/foodcourt/sale_edit/edit.html.erb new file mode 100755 index 00000000..e1a8dd85 --- /dev/null +++ b/app/views/foodcourt/sale_edit/edit.html.erb @@ -0,0 +1,427 @@ +
+
+ +
+
+
+
INVOICE DETAILS
+
+
+
+
+

Receipt No: + <%= @saleobj.receipt_no rescue '' %> +

+
+
+

Date: + <%= @saleobj.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %> +

+
+
+
+
+

Customer :

+
+ +
+
+ + + + + + + + + + + + + <% + count = 0 + sub_total = 0 + @saleobj.sale_items.each do |sale_item| + count += 1 + sub_total = sub_total + sale_item.price + %> + + <% + # Can't check for discount + unless sale_item.price == 0 + %> + + + + <% if sale_item.status != 'void' && sale_item.status != 'edit' && sale_item.status != 'foc' %> + + + + + + <% elsif sale_item.qty.to_i < 0 || sale_item.status == 'edit' %> + + + + + <% else %> + + + + <% end %> + + <% + end + end + %> + +
#ItemsQTY + Price + Action
<%= count %> + <%= sale_item.product_name %> + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ + +
+ + + + +
+
+
+ + + + diff --git a/app/views/foodcourt/sale_edit/item_void.json.jbuilder b/app/views/foodcourt/sale_edit/item_void.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/sale_edit/item_void.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/sale_edit/item_void_cancel.json.jbuilder b/app/views/foodcourt/sale_edit/item_void_cancel.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/sale_edit/item_void_cancel.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/sales/add_to_existing_invoice.json.jbuilder b/app/views/foodcourt/sales/add_to_existing_invoice.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/sales/add_to_existing_invoice.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/sales/show.html.erb b/app/views/foodcourt/sales/show.html.erb new file mode 100755 index 00000000..fd74df43 --- /dev/null +++ b/app/views/foodcourt/sales/show.html.erb @@ -0,0 +1,565 @@ +
+
+ +
+ + + + "> + +
+
+ +
+
+ <% @complete.each do |sale| %> +
+
+ <%= sale.receipt_no %><%= sale.sale_status %> +
+
+ <% end %> +
+
+ + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> + <% if table.get_booking.nil? %> + <% if table.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= table.name %>
+ <%= table.zone.name %> + + billed +
+
+
+ <% else %> + <% if table.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= table.name %>
+ <%= table.zone.name %> + + new +
+
+ <% end %> + <% else %> +
+
+ <%= table.name %>
+ <%= table.zone.name %> + new +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> + <% if room.get_booking.nil? %> +
+
+ <%= room.name %>
+ <%= room.zone.name %> + + billed +
+
+ <% else %> +
+
+ <%= room.name %>
+ <%= room.zone.name %> + + new +
+
+ <% end %> + <% else %> +
+
+ <%= room.name %>
+ <%= room.zone.name %> + +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @orders.each do |order| %> +
text-white" data-id="<%= order.order_id %>"> +
+ <% + order_status = "" + sale_order = SaleOrder.find_by_order_id(order) + if sale_order + unless sale_order.sale_id.nil? + sale = Sale.find(sale_order.sale_id) + order_status = sale.sale_status + if order_status == 'new' + order_status = order.status + end + end + else + order_status = order.status + end + %> + <%= order.order_id %> <% if !order_status.empty? %>| <%= order_status %> <% end %> +
+
+ <% end %> +
+
+ + +
+
+
+
+ +
+
+ +
+
+
+ + + + + + + + + +
<%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %><%= t("views.right_panel.detail.receipt_no") %> <%= t :cashier %> <%= t("views.right_panel.detail.name") %> <%= t :customer %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.credit_amount") %>
+
+
+
+ +
+
+ +
+ + + +
+
+
+
INVOICE DETAILS | Table <%= @dining.name rescue "" %>
+
+
+
+
+ Receipt No: + <%= @sale.receipt_no rescue '' %> + +
+
+ Date: <%= @sale.created_at.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> +
+
+
+
+ Customer : <%= @sale.customer.name rescue "-" %> + +
+ +
+
+
+ + + + + + + + + + <% + sub_total = 0 + @sale.sale_items.each do |sale_item| + sub_total = sub_total + sale_item.price + %> + + <% #unless sale_item.price <= 0 %> + + + + + + <% + + #end + end + + %> + +
ItemsQTYPrice
<%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
+
+
+ +
+
+
+ + +
+ + <% if @sale.sale_status != 'void' && @sale.sale_status != 'waste' && @sale.sale_status != 'spoile' %> + <% if current_login_employee.role == "cashier" %> + <% if @sale.payment_status != 'foc' %> + Void + <% end %> + Re.Print + <% else %> + <% if @sale.payment_status != 'foc' %> + + <% end %> + + <% end %> + <% end %> + +
+
+ + +
+ + + + + + + + + diff --git a/app/views/foodcourt/second_display/_second_display.html.erb b/app/views/foodcourt/second_display/_second_display.html.erb new file mode 100644 index 00000000..c09d6c4c --- /dev/null +++ b/app/views/foodcourt/second_display/_second_display.html.erb @@ -0,0 +1,67 @@ +
+
+ +
+
+
+
+ + + + + + + + + + + + + +
#ItemsQTYPrice
+
+
+
+ +
+ +
+
+
+
+ <% @display_images.each do |p| %> + <%= image_tag "#{p.image}", :alt => "rss feed"%> + <% break %> + <% end %> +
+
+
+
+ diff --git a/app/views/foodcourt/second_display/_slider.html.erb b/app/views/foodcourt/second_display/_slider.html.erb new file mode 100644 index 00000000..71f463b7 --- /dev/null +++ b/app/views/foodcourt/second_display/_slider.html.erb @@ -0,0 +1,20 @@ +<%= stylesheet_link_tag 'wow_style', media: 'all', 'data-turbolinks-track': 'reload' %> +<%= javascript_include_tag 'wowslider', 'data-turbolinks-track': 'reload' %> +<%= javascript_include_tag 'wow_script', 'data-turbolinks-track': 'reload' %> +
+
+
+
+
    + <% @display_images.each do |p| %> +
  • + <%= image_tag "#{p.image}", :alt => "rss feed"%> +
  • + <% end %> +
+
+
+
+
+
+ diff --git a/app/views/foodcourt/second_display/index.html.erb b/app/views/foodcourt/second_display/index.html.erb new file mode 100644 index 00000000..5b4ad7f0 --- /dev/null +++ b/app/views/foodcourt/second_display/index.html.erb @@ -0,0 +1,20 @@ +
+ +
+ <%= render 'slider' %> +
+ + +
+ diff --git a/app/views/foodcourt/shifts/create.json.jbuilder b/app/views/foodcourt/shifts/create.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/shifts/create.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/shifts/edit.html.erb b/app/views/foodcourt/shifts/edit.html.erb new file mode 100755 index 00000000..60d5c6d8 --- /dev/null +++ b/app/views/foodcourt/shifts/edit.html.erb @@ -0,0 +1 @@ +

Close Cashier

diff --git a/app/views/foodcourt/shifts/index.html.erb b/app/views/foodcourt/shifts/index.html.erb new file mode 100755 index 00000000..ebec0301 --- /dev/null +++ b/app/views/foodcourt/shifts/index.html.erb @@ -0,0 +1,2 @@ +

Origami::Shifts#index

+

Find me in app/views/origami/shifts/index.html.erb

diff --git a/app/views/foodcourt/shifts/new.html.erb b/app/views/foodcourt/shifts/new.html.erb new file mode 100755 index 00000000..eb02d644 --- /dev/null +++ b/app/views/foodcourt/shifts/new.html.erb @@ -0,0 +1,126 @@ +
+

Open Cashier

+
+
+
+ + + + + + <% @float.each do |float| %> + + + + + <% end %> + + + + +
Cashier Terminal + + +
<%= float.name %>
Total
+ +
+
+
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Clr
+
Calculate
+
Open Cashier
+
+
+ +
+
+
+
+ diff --git a/app/views/foodcourt/shifts/sale_summary.html.erb b/app/views/foodcourt/shifts/sale_summary.html.erb new file mode 100755 index 00000000..321a3941 --- /dev/null +++ b/app/views/foodcourt/shifts/sale_summary.html.erb @@ -0,0 +1,201 @@ +
+ +
+

Sales Summary Quick View

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Cashier Cashier Terminal Opening Date Opening float Received Amount Cast In Cast Out Total Receipt Dining Count Takeaway Count Total Void
<%= @shift.employee.name%><%=@shift.cashier_terminal.name%><%= @shift.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') %> + <%=@shift.opening_balance %><%=@shift.closing_balance %><%=@shift.cash_in %><%=@shift.cash_out %><%= @shift.total_receipt %><%= @shift.dining_count %><%= @shift.takeaway_count %>(<%= @shift.total_void.round(2) %>)
+ + <% @total_amount_by_account.each do |amount| %> + + + + + + <%end%> + + + + + + + <% @total_discount_by_account.each do |amount| %> + + + + + + <%end%> + + <% if !@total_member_discount[0].member_discount.nil? + @member_discount = @total_member_discount[0].member_discount rescue 0.0 + @overall = @shift.total_discounts - @member_discount + %> + + + + + + <%else @overall = @shift.total_discounts %> + + <%end%> + + + + + + + + + + + + <% @sale_taxes.each do |tax| %> + + + + + + <%end%> + + + + + + + + + + + + + + + +
Total <%= amount.account_name %> Amount<%= amount.total_price.round(2) %>
Net Sales<%=@shift.nett_sales %>
Total <%= amount.account_name %> Discount<%= amount.total_price.round(2) %>
Total Member Discount<%= @member_discount %>
Total Overall Discount<%= @overall %>
Total Discount<%= @shift.total_discounts %>
<%= tax.tax_name %> <%= tax.st_amount.round(2) %>
Total Tax <%=@shift.total_taxes %>
Rounding Adj <%= @shift.total_rounding.round(2) %>
Grand Total <%= @shift.grand_total.round(2) %>
+
+ + + + + + + + + + + + <% @total_amount = 0 + + @other_payment.each do |other| %> + + + + + + + + + + <% @total_amount = @total_amount+other.mpu_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.visa_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.master_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.jcb_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.foc_amount rescue 0.0 %> + + <%end%> + + + + + + + + + + + + +
Cash Payment <%=@shift.cash_sales %>
Credit Payment <%=@shift.credit_sales %>
Other Payment Detail
MPU Payment <%=other.mpu_amount.round(2) rescue 0.0 %>
VISA Payment <%=other.visa_amount.round(2) rescue 0.0 %>
JCB Payment <%=other.master_amount.round(2) rescue 0.0 %>
Master Payment <%=other.jcb_amount.round(2) rescue 0.0 %>
Reedem Payment <%=other.paypar_amount.round(2) rescue 0.0 %>
FOC <%=other.foc_amount.round(2) rescue 0.0 %>
Total Other Payment <%=@shift.other_sales %>
Total Payment <%= @total_amount+@shift.cash_sales+@shift.credit_sales %>
+
+
+ +
+


+ + +
+
+ + diff --git a/app/views/foodcourt/shifts/show.html.erb b/app/views/foodcourt/shifts/show.html.erb new file mode 100755 index 00000000..e2f2275c --- /dev/null +++ b/app/views/foodcourt/shifts/show.html.erb @@ -0,0 +1,282 @@ +
+ + +
+
+

<%= t :close_cashier %>

+
+ + + + + + + + + + +
<%= t :shift_started_at %><%= @shift.shift_started_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %>
<%= t :cashier_name %><%= @shift.employee.name rescue ''%>
+
+
+
+ <%= t :closing_balance %> +
+
+ +
+

+
+
+ + + <% if @bank_integration == '1' && @cashier_type!="ordering" %> + + <% end %> +
+
+ + +
+ diff --git a/app/views/foodcourt/shifts/update_shift.json.jbuilder b/app/views/foodcourt/shifts/update_shift.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/shifts/update_shift.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/surveys/_form.html.erb b/app/views/foodcourt/surveys/_form.html.erb new file mode 100755 index 00000000..c0ed9f59 --- /dev/null +++ b/app/views/foodcourt/surveys/_form.html.erb @@ -0,0 +1,534 @@ +
+
+
+
+ <%= simple_form_for(@survey, :url => foodcourt_create_surveys_path) do |f| %> + <%= f.error_notification %> +
+ <% if !@survey_data.nil? %> +
+
+
+ <%= f.input :child, input_html: { value: @survey_data.child, class: 'col-md-10', :onChange => "total_customer();", :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyChild(this.value);" }%> +
+
+
+
+ <%= f.input :adult, input_html: { value: @survey_data.adult, class: 'col-md-10', :onChange => "total_customer();", :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyAdult(this.value);" }%> +
+
+
+
+
+
+ <%= f.input :male , input_html: { value: @survey_data.male, class: 'col-md-10', :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyMale(this.value);" }%> +
+
+
+
+ <%= f.input :female , input_html: { value: @survey_data.female, class: 'col-md-10', :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyFemale(this.value);" }%> +
+
+
+ <%= f.input :total_customer, input_html: { value:@survey_data.total_customer , :readonly => true, class: 'col-md-11'} %> + <%= f.input :local , input_html: { value: @survey_data.local, class: 'col-md-11', :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyLocal(this.value);" }%> + + +
+ Foreigner +
+
+
+ + + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ <% else %> +
+
+
+ <%= f.input :child , input_html: { class: 'col-md-10' ,min:'1', :onChange => "total_customer();", :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyChild(this.value);" }%> +
+
+
+
+ <%= f.input :adult , input_html: { class: 'col-md-10' ,min:'1', :onChange => "total_customer();", :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyAdult(this.value);" }%> +
+
+
+
+
+
+ <%= f.input :male , input_html: { min:'1',class: 'col-md-10' , :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyMale(this.value);" }%> +
+
+
+
+ <%= f.input :female , input_html: { min:'1',class: 'col-md-10' , :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyFemale(this.value);" }%> +
+
+
+ <%= f.input :total_customer, input_html: { :readonly => true,min:'1', class: 'col-md-11'} %> + <%= f.input :local , input_html: { min:'1',class: 'col-md-11', :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyLocal(this.value);" }%> + +
+ Foreigner +
+
+
+ + + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ <% end %> + + <%if !@dining_facility.nil? %> + + + <%= f.input :dining_name, :as => :hidden, :input_html => { :value => @dining_facility.name } %> + <%else%> + + + <%= f.input :dining_name, :as => :hidden, :input_html => { :value => 0 } %> + <%end%> + + + + <% if !@survey_data.nil? %> + /> + <% else %> + + <% end %> + + + <%= f.input :created_by, :as => :hidden, :input_html => { :value => current_login_employee.name } %> + <%= f.input :receipt_no, :as => :hidden, :input_html => { :value => @receipt_no} %> + <%= f.input :total_amount, :as => :hidden, :input_html => { :value => @grand_total } %> +
+
+ <%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %> +
+ <% end %> +
+
+
+
+
+
+
+
+
+
+
1
+
2
+
3
+
+
+
+ +
+
+
+
4
+
5
+
6
+
+
+
+ +
+
+
+
7
+
8
+
9
+
+
+
+ +
+
+
+
0
+
.
+
00
+
+
+
+ +
+
+
+
+
DEL
+
CLR
+
+
+
+
+
+
+
+
+ +
+ +
+ +
+ +
+ + diff --git a/app/views/foodcourt/surveys/_survey.json.jbuilder b/app/views/foodcourt/surveys/_survey.json.jbuilder new file mode 100755 index 00000000..1a0e4aa8 --- /dev/null +++ b/app/views/foodcourt/surveys/_survey.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! settings_account, :id, :title, :account_type, :created_at, :updated_at +json.url settings_account_url(settings_account, format: :json) diff --git a/app/views/foodcourt/surveys/edit.html.erb b/app/views/foodcourt/surveys/edit.html.erb new file mode 100755 index 00000000..96fca006 --- /dev/null +++ b/app/views/foodcourt/surveys/edit.html.erb @@ -0,0 +1,12 @@ + + + <%= render 'form', settings_account: @settings_account %> diff --git a/app/views/foodcourt/surveys/index.html.erb b/app/views/foodcourt/surveys/index.html.erb new file mode 100755 index 00000000..c3d9cdfa --- /dev/null +++ b/app/views/foodcourt/surveys/index.html.erb @@ -0,0 +1,91 @@ + + +
+
+
+ + + + + + + + + + + + + + + <% @settings_accounts.each do |account| %> + + + + + + + + + + <% end %> + +
<%= t("views.right_panel.detail.title") %><%= t("views.right_panel.detail.account_type") %><%= t("views.right_panel.detail.discount") %><%= t("views.right_panel.detail.point") %><%= t("views.right_panel.detail.bonus") %><%= t("views.right_panel.detail.rebate") %><%= t("views.right_panel.detail.actions") %>
<%= account.title %><%= account.account_type == 1 ? "Expense" : "Income"%><%= account.discount %><%= account.point %><%= account.bonus %><%= account.rebate %> + <%= link_to t("views.btn.show"), settings_account_path(account),:class => 'btn btn-info btn-sm waves-effect' %> + <%= link_to t("views.btn.edit"), edit_settings_account_path(account),:class => 'btn btn-primary btn-sm waves-effect' %> +
+
+
+
+
+
+
view_headline <%= t("views.right_panel.header.page_detail") %>
+

+ 1) <%= t("views.right_panel.detail.title") %> - <%= t("views.right_panel.detail.title_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.account_txt") %>
+ 2) <%= t("views.right_panel.detail.account_type") %> - <%= t("views.right_panel.detail.account_type_txt") %>
+ 3) <%= t("views.right_panel.detail.discount") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.discount_txt") %>
+ 4) <%= t("views.right_panel.detail.point") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.point_txt") %>
+ 5) <%= t("views.right_panel.detail.bonus") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.bonus_txt") %>
+ 6) <%= t("views.right_panel.detail.rebate") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.rebate_txt") %>
+ 7) <%= t("views.right_panel.detail.actions") %> - <%= t("views.right_panel.detail.actions_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+

+
list <%= t("views.right_panel.header.button_lists") %>
+

+ 1) <%= t("views.right_panel.button.new") %> - <%= t("views.right_panel.detail.new_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+ 2) <%= t("views.right_panel.button.show") %> - <%= t("views.right_panel.detail.show_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+ 2) <%= t("views.right_panel.button.edit") %> - <%= t("views.right_panel.detail.edit_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+

+
list <%= t("views.right_panel.header.link_lists") %>
+

+ 1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %>
+ 2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.dashboard_txt") %>
+

+
+
+
+
+ +
+
+ + diff --git a/app/views/foodcourt/surveys/index.json.jbuilder b/app/views/foodcourt/surveys/index.json.jbuilder new file mode 100755 index 00000000..10158c29 --- /dev/null +++ b/app/views/foodcourt/surveys/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @settings_accounts, partial: 'settings_accounts/settings_account', as: :settings_account diff --git a/app/views/foodcourt/surveys/new.html.erb b/app/views/foodcourt/surveys/new.html.erb new file mode 100755 index 00000000..ee4d9a57 --- /dev/null +++ b/app/views/foodcourt/surveys/new.html.erb @@ -0,0 +1,3 @@ + + + <%= render 'form', survey: @survey %> diff --git a/app/views/foodcourt/surveys/show.html.erb b/app/views/foodcourt/surveys/show.html.erb new file mode 100755 index 00000000..4c28f27c --- /dev/null +++ b/app/views/foodcourt/surveys/show.html.erb @@ -0,0 +1,84 @@ + + + +
+ +
+
+
+
+

Account

+ + + + + + + + + + + + + + + + + + + + + + + + + +
<%= t("views.right_panel.detail.title") %><%= t("views.right_panel.detail.account_type") %><%= t("views.right_panel.detail.can_get_points") %><%= t("views.right_panel.detail.can_rebate") %><%= t("views.right_panel.detail.actions") %>
<%= @settings_account.title %><%= @settings_account.account_type %><%= @settings_account.point %><%= @settings_account.rebate %><%= link_to t("views.btn.edit"), edit_settings_account_path(@settings_account),:class => 'btn btn-primary btn-sm waves-effect' %> + + + +
+
+
+
+ +
+
+
+
view_headline <%= t("views.right_panel.header.page_detail") %>
+

+ 1) <%= t("views.right_panel.detail.title") %> - <%= t("views.right_panel.detail.title_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.account_txt") %>
+ 2) <%= t("views.right_panel.detail.account_type") %> - <%= t("views.right_panel.detail.account_type_txt") %>
+ 3) <%= t("views.right_panel.detail.can_get_points") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.point_txt") %>
+ 4) <%= t("views.right_panel.detail.can_rebate") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.rebate_txt") %>
+ 5) <%= t("views.right_panel.detail.actions") %> - <%= t("views.right_panel.detail.actions_txt2") %> <%= t("views.right_panel.detail.account_txt") %>
+

+
list <%= t("views.right_panel.header.button_lists") %>
+

+ 1) <%= t("views.right_panel.button.edit") %> - <%= t("views.right_panel.detail.edit_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+ 2) <%= t("views.right_panel.button.delete") %> - <%= t("views.right_panel.detail.delete_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+

+
list <%= t("views.right_panel.header.link_lists") %>
+

+ 1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %>
+ 2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+

+
+
+
+
+ diff --git a/app/views/foodcourt/surveys/show.json.jbuilder b/app/views/foodcourt/surveys/show.json.jbuilder new file mode 100755 index 00000000..e9673454 --- /dev/null +++ b/app/views/foodcourt/surveys/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "settings_accounts/settings_account", settings_account: @settings_account diff --git a/app/views/layouts/CRM.html.erb b/app/views/layouts/CRM.html.erb index 955abc98..f41f96f3 100755 --- a/app/views/layouts/CRM.html.erb +++ b/app/views/layouts/CRM.html.erb @@ -36,32 +36,36 @@
<%= render 'layouts/header' %> -
- <%= render 'layouts/left_sidebar' %> - <%= render 'layouts/right_sidebar' %> +
+ <%if current_login_employee.role == "foodcourt_cashier" %> + <%= render 'layouts/foodcourt_left_sidebar' %> + <% else %> + <%= render 'layouts/left_sidebar' %> + <%end%> + <%= render 'layouts/right_sidebar' %>
-
+
<% flash.each do |type, message| %> <% if !flash["errors"]%> - <% + <% if type == "notice" color = "alert-success" end if type == "error" color = "alert-danger" - end + end %> <% if flash["error"] || flash["notice"]%> <% end %> - <% end %> - <% end %> - <%= yield %> + <% end %> + <% end %> + <%= yield %>
- \ No newline at end of file + diff --git a/app/views/layouts/_foodcourt_left_sidebar.html.erb b/app/views/layouts/_foodcourt_left_sidebar.html.erb new file mode 100644 index 00000000..520a3251 --- /dev/null +++ b/app/views/layouts/_foodcourt_left_sidebar.html.erb @@ -0,0 +1,54 @@ + + + - - + <% if current_login_employee.role !='foodcourt_cashier' %> + + <% end %> + + + + + +
+ +<%end%> + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index d03889f7..cd405859 100755 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -4,7 +4,7 @@ - + SmartSales : Restaurant <%= csrf_meta_tags %> @@ -12,10 +12,10 @@ <%= stylesheet_link_tag 'application', media: 'all' %> - <%= javascript_include_tag 'application' %> + <%= javascript_include_tag 'application' %> - +
@@ -37,27 +37,32 @@
<%= render 'layouts/header' %> -
- <%= render 'layouts/left_sidebar' %> - <%= render 'layouts/right_sidebar' %> +
+ <%if current_login_employee.role == "foodcourt_cashier" %> + <%= render 'layouts/foodcourt_left_sidebar' %> + <% else %> + <%= render 'layouts/left_sidebar' %> + <%end%> + + <%= render 'layouts/right_sidebar' %>
-
+
<% flash.each do |type, message| %> - <% if type == "notice" + <% if type == "notice" color = "alert-success" elsif type == "error" color = "alert-danger" else color = "bg-black" end %> - + - <% end %> - <%= yield %> -
+ <% end %> + <%= yield %> +
- \ No newline at end of file + diff --git a/app/views/layouts/foodcourt.html.erb b/app/views/layouts/foodcourt.html.erb new file mode 100644 index 00000000..05b1542b --- /dev/null +++ b/app/views/layouts/foodcourt.html.erb @@ -0,0 +1,63 @@ + + + + + + + + SmartSales : Restaurant + <%= csrf_meta_tags %> + + + + + <%= stylesheet_link_tag 'origami', media: 'all' %> + <%= javascript_include_tag 'origami', 'data-turbolinks-track': 'reload' %> + + + + +
+
+
+
+
+
+
+
+
+
+
+
+

Please wait...

+
+
+ + +
+ + <%= render 'layouts/header' %> +
+ <%= render 'layouts/foodcourt_left_sidebar' %> + <%= render 'layouts/right_sidebar' %> +
+ + +
+ <% flash.each do |type, message| %> + <% if type == "notice" + color = "alert-success" + elsif type == "error" + color = "alert-danger" + else + color = "bg-black" + end %> + + + <% end %> + <%= yield %> +
+ + diff --git a/app/views/transactions/bookings/index.html.erb b/app/views/transactions/bookings/index.html.erb index b5f598e5..a06b3e47 100755 --- a/app/views/transactions/bookings/index.html.erb +++ b/app/views/transactions/bookings/index.html.erb @@ -3,7 +3,11 @@ - <%= link_to 'Back', dashboard_path %> + <%if current_login_employee.role == "foodcourt_cashier" %> + <%= link_to 'Back', foodcourt_food_court_path %> + <% else %> + <%= link_to 'Back', dashboard_path %> + <%end%>
diff --git a/app/views/transactions/orders/index.html.erb b/app/views/transactions/orders/index.html.erb index 47216911..357261ec 100755 --- a/app/views/transactions/orders/index.html.erb +++ b/app/views/transactions/orders/index.html.erb @@ -4,7 +4,11 @@ - <%= link_to 'Back', dashboard_path %> + <%if current_login_employee.role == "foodcourt_cashier" %> + <%= link_to 'Back', foodcourt_food_court_path %> + <% else %> + <%= link_to 'Back', dashboard_path %> + <%end%>
diff --git a/app/views/transactions/sales/index.html.erb b/app/views/transactions/sales/index.html.erb index 7ca7c08f..c0f3ee6e 100644 --- a/app/views/transactions/sales/index.html.erb +++ b/app/views/transactions/sales/index.html.erb @@ -3,7 +3,11 @@ - <%= link_to 'Back', dashboard_path %> + <%if current_login_employee.role == "foodcourt_cashier" %> + <%= link_to 'Back', transactions_bookings_path %> + <% else %> + <%= link_to 'Back', dashboard_path %> + <%end%>
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 63881a4f..5479bcca 100755 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -60,3 +60,7 @@ Rails.application.config.assets.precompile += %w( order_reservation.js ) # --- Reservation ---- Rails.application.config.assets.precompile += %w( reservation.css ) Rails.application.config.assets.precompile += %w( reservation.js ) + +# --- Foodcourt ---- +Rails.application.config.assets.precompile += %w( foodcourt.css ) +Rails.application.config.assets.precompile += %w( foodcourt.js ) diff --git a/config/routes.rb b/config/routes.rb index 23d3b3f7..4dcc5911 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -43,7 +43,7 @@ scope "(:locale)", locale: /en|mm/ do #Session Login and Logout post 'authenticate' => "authenticate#create" delete 'authenticate' => "authenticate#destroy" - + resources :shops, only: [:index, :show] resources :verifications, only: [:new] post 'verifications/update' => "verifications#update" @@ -59,7 +59,7 @@ scope "(:locale)", locale: /en|mm/ do resources :menu_item_instances, only: [:show] get "item_sets" => "item_sets#index" end - + namespace :payment do post 'mobilepayment/:cashier_id/:receipt_no/cash' =>"mobilepayment#cash" end @@ -603,5 +603,92 @@ scope "(:locale)", locale: /en|mm/ do post '/run_teamviewer' => 'home#run_teamviewer', :defaults => { :format => 'json' } # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + +#only for foodcourt + namespace :foodcourt do + root "home#index" + + post '/check_emp_access_code/:code' => 'home#check_emp_access_code', :defaults => { :format => 'json' } + + get "dashboard" => "dashboard#index" + get "get_all_menu" => "dashboard#get_all_menu" + get "/table/:table_id/sale/:sale_id/:type/edit" => "sale_edit#edit" + get "/table/sale/:sale_id/:type/edit" => "sale_edit#edit" + post 'item_void' => "sale_edit#item_void" + post 'item_foc' => "sale_edit#item_foc" + post 'item_edit' => "sale_edit#item_edit" + post 'item_void_cancel' => "sale_edit#item_void_cancel" + post 'cancel_all_void' => 'sale_edit#cancel_all_void' + post 'apply_void' => 'sale_edit#apply_void' + get 'sale/:sale_id' => 'sales#show' + get 'order/:order_id' => "orders#show" + + # Other Charges + get "/:sale_id/:type/other_charges" => "other_charges#index" + post "/:sale_id/other_charges" => "other_charges#create" + + # Discount + get "/:id/:type/discount" => "discounts#index" + post "/:id/discount" => "discounts#create" + get "/:id/:type/remove_all_discount" => "discounts#remove_all_discount" + post "/:id/remove_discount_items" => "discounts#remove_discount_items" + + # Discount for Member + post "/:id/member_discount" => "discounts#member_discount" + + get "/:id/request_bills" => "request_bills#print", :as => "request_bill" + get '/:sale_id/reprint' => 'payments#reprint', :defaults => {:format => 'json'} + + #---------Shift ---------------# + resources :shifts, only: [:index, :new, :create, :edit] + post 'close_shift' => 'shifts#update_shift' + get 'shift/:type/close' => 'shifts#show' + get 'shift/sale_summary' => 'shifts#sale_summary' + + resources :cash_mgmt, only: [:new, :create] + + post 'sale/:sale_id/:type/payment/print' => 'payments#print' #route for print receipt + get 'sale/:sale_id/:type/payment' => 'payments#show' + post 'payment/:type/foc' => 'payments#foc', :defaults => {:format => 'json'} + post 'payment/cash' => 'payments#create' + post 'payment/paymal' => 'paymal#create' + + post 'payment/:type/change_tax' => 'payments#change_tax', :defaults => {:format => 'json'} + + #---------Void --------------# + post 'sale/:sale_id/:type/void' => 'void#overall_void' + + post 'sale/:sale_id/:type/waste_and_spoilage' => "waste_spoile#waste_and_spoilage" + + #---------Add Customer --------------# + #resources :customers + get '/:sale_id/:type/customers/:dir_page', to: "customers#add_customer" + get '/:customer_id/get_customer' => 'home#get_customer', :as => "show_customer_details" + post '/:sale_id/:type/customers/update_sale', to: "customers#update_sale_by_customer" # update customer id in sale table + + post '/:sale_id/get_customer' => "customers#get_customer" + post '/:sale_id/send_account' => "customers#send_account" + + get '/:id/:type/surveys', to: "surveys#new" + match '/:id/create_survey', to: "surveys#create", as: "create_surveys", via: [:post, :patch, :put] + + get '/addorders/get_menu/:id' => "addorders#get_menu",:as => "get_menu", :defaults => { :format => 'json' } + get '/addorders/get_menu_category/:id' => "addorders#get_menu_category",:as => "get_menu_category", :defaults => { :format => 'json' } + get '/addorders/get_menu_sub_category/:id' => "addorders#get_menu_sub_category",:as => "get_menu_sub_category", :defaults => { :format => 'json' } + get '/addorders/products/list' => "addorders#get_all_product",:as => "get_all_product", :defaults => { :format => 'json' } + + get '/:addorders/:id' => "addorders#detail" + post '/:addorders/create' => "addorders#create",:as => "addorder_create", :defaults => { :format => 'json' } + + + get '/addorders/get_item_instance/:id' => "addorders#get_item_instance",:as => "get_item_instance", :defaults => { :format => 'json' } + + resources :second_display #second display routes + + post '/customer_view' => "second_display#customer_view",:as => "customer_view", :defaults => { :format => 'json' } + get "food_court" => "food_court#index" + get "app_orders" => "orders#app_orders" + get "app_order/:booking_id" => "orders#app_order_by_booking" + end end end diff --git a/server2.pid b/server2.pid index ded42b32..edf425a9 100644 --- a/server2.pid +++ b/server2.pid @@ -1 +1 @@ -3453 \ No newline at end of file +15225 \ No newline at end of file From 937f40e7c18da63e10349b5c3fd3630f3bee7379 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Mon, 2 Dec 2019 17:19:28 +0630 Subject: [PATCH 26/54] 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 From 600d3973cd61c1f14721a4141de115add5a0be71 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Mon, 2 Dec 2019 17:48:36 +0630 Subject: [PATCH 27/54] app order --- app/assets/javascripts/addorder.js | 3 ++- app/controllers/foodcourt/orders_controller.rb | 5 ++++- app/controllers/foodcourt/payments_controller.rb | 4 ++-- app/views/foodcourt/orders/app_orders.html.erb | 14 ++++++-------- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 5c4ffef3..443a30f8 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1060,7 +1060,8 @@ $(function() { window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text(); }else{ if(result.current_user_role == 'foodcourt_cashier'){ - window.location.href = "/foodcourt/sale/"+result.data["sale_id"]+"/"+type+"/payment"; } + window.location.href = "/foodcourt/sale/"+result.data["sale_id"]+"/"+type+"/payment"; + } else{ window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment"; } diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index fce37da2..1450df2d 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -91,6 +91,9 @@ class Foodcourt::OrdersController < BaseFoodcourtController .where("orders.source='app' and bookings.shop_code='#{@shop.shop_code}'").order("created_at desc") end def app_order_by_booking - + @order_items = OrderItems.joins("JOIN orders ON orders.order_id=order_items.order_id") + .joins("JOIN booking_orders ON booking_orders.order_id=orders.order_id") + .where("orders.source='app' and booking_orders.booking_id='#{params[:booking_id]}'").order("created_at desc") + end end diff --git a/app/controllers/foodcourt/payments_controller.rb b/app/controllers/foodcourt/payments_controller.rb index 37bfe276..c313b972 100755 --- a/app/controllers/foodcourt/payments_controller.rb +++ b/app/controllers/foodcourt/payments_controller.rb @@ -104,7 +104,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController end #orders print out - if type == "quick_service" + # if type == "quick_service" booking = Booking.find_by_sale_id(sale_id) if booking.dining_facility_id.to_i>0 table_id = booking.dining_facility_id @@ -127,7 +127,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from end - end + # end #for card sale data card_data = Array.new diff --git a/app/views/foodcourt/orders/app_orders.html.erb b/app/views/foodcourt/orders/app_orders.html.erb index 5356333f..9758b000 100644 --- a/app/views/foodcourt/orders/app_orders.html.erb +++ b/app/views/foodcourt/orders/app_orders.html.erb @@ -3,15 +3,13 @@
-
-
-
-
-
-
+
+
+
+
-
+
-
+
From 1607cb70d349a27cba3e33652a3a22fc95d0a37e Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Mon, 2 Dec 2019 17:19:28 +0630 Subject: [PATCH 28/54] Single database for multiple shops Use ActsAsTenant as Multi-tenancy for shops See below files: - app/controllers/concern/multi_tenancy.rb - app/models/application_record.rb - app/models/shop.rb An initializer can be created to control option in ActsAsTenant. config/initializers/acts_as_tenant.rb require 'acts_as_tenant/sidekiq' ActsAsTenant.configure do |config| config.require_tenant = false # true end more detail: https://github.com/ErwinM/acts_as_tenant --- Gemfile | 3 +++ Gemfile.lock | 8 ++++++-- app/controllers/api/api_controller.rb | 2 +- app/controllers/api/bill_controller.rb | 2 +- .../api/call_waiters_controller.rb | 2 +- .../order_reservation_controller.rb | 2 +- app/controllers/api/orders_controller.rb | 2 +- .../api/payment/mobilepayment_controller.rb | 2 +- .../api/sound_effect_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- app/controllers/base_controller.rb | 3 ++- app/controllers/base_crm_controller.rb | 2 +- app/controllers/base_inventory_controller.rb | 2 +- app/controllers/base_oqs_controller.rb | 2 +- app/controllers/base_origami_controller.rb | 2 +- app/controllers/base_report_controller.rb | 4 ++-- app/controllers/base_waiter_controller.rb | 2 +- .../concerns/login_verification.rb | 12 +++++------ app/controllers/concerns/multi_tenancy.rb | 20 +++++++++++++++++++ app/controllers/crm/customers_controller.rb | 2 +- app/controllers/home_controller.rb | 2 +- .../inventory/inventory_controller.rb | 2 +- .../inventory_definitions_controller.rb | 2 +- .../inventory/stock_check_items_controller.rb | 2 +- .../inventory/stock_checks_controller.rb | 4 ++-- .../inventory/stock_journals_controller.rb | 2 +- app/controllers/oqs/edit_controller.rb | 2 +- app/controllers/origami/alipay_controller.rb | 6 +++--- .../origami/credit_payments_controller.rb | 4 ++-- .../origami/credit_sales_controller.rb | 12 +++++------ .../origami/customers_controller.rb | 2 +- .../origami/dashboard_controller.rb | 2 +- app/controllers/origami/dinga_controller.rb | 4 ++-- .../origami/gift_voucher_controller.rb | 6 +++--- app/controllers/origami/home_controller.rb | 16 +++++++-------- app/controllers/origami/jcb_controller.rb | 6 +++--- .../origami/junction_pay_controller.rb | 4 ++-- app/controllers/origami/master_controller.rb | 6 +++--- .../origami/movetable_controller.rb | 2 +- app/controllers/origami/mpu_controller.rb | 6 +++--- .../origami/order_reservation_controller.rb | 2 +- app/controllers/origami/orders_controller.rb | 4 ++-- app/controllers/origami/paymal_controller.rb | 4 ++-- .../origami/payments_controller.rb | 8 ++++---- .../origami/paypar_payments_controller.rb | 2 +- .../origami/redeem_payments_controller.rb | 2 +- .../origami/request_bills_controller.rb | 2 +- app/controllers/origami/rooms_controller.rb | 10 +++++----- app/controllers/origami/sales_controller.rb | 4 ++-- .../origami/second_display_controller.rb | 2 +- .../origami/split_bill_controller.rb | 2 +- .../origami/table_invoices_controller.rb | 4 ++-- .../origami/unionpay_controller.rb | 6 +++--- app/controllers/origami/visa_controller.rb | 6 +++--- app/controllers/origami/void_controller.rb | 2 +- app/controllers/origami/voucher_controller.rb | 2 +- .../origami/waste_spoile_controller.rb | 2 +- .../reports/product_sale_controller.rb | 2 +- .../reports/receipt_no_controller.rb | 2 +- app/controllers/settings/shops_controller.rb | 4 ++-- .../transactions/sales_controller.rb | 2 +- app/models/application_record.rb | 11 ++++++++++ app/models/kbz_pay.rb | 14 ++++++------- app/models/menu.rb | 2 +- app/models/order_queue_station.rb | 2 +- app/models/order_reservation.rb | 10 +++++----- app/models/printer/order_queue_printer.rb | 6 +++--- app/models/room.rb | 1 - app/models/sale.rb | 14 ++++++------- app/models/shop.rb | 10 +++++++--- app/uploaders/commissioner_image_uploader.rb | 12 +++++------ app/uploaders/customer_image_uploader.rb | 12 +++++------ app/uploaders/employee_image_uploader.rb | 12 +++++------ app/uploaders/menu_item_image_uploader.rb | 12 +++++------ app/uploaders/product_image_uploader.rb | 8 ++++---- app/uploaders/shop_image_uploader.rb | 12 +++++------ .../origami/dashboard/_menu.json.jbuilder | 2 +- lib/tasks/receipt.rake | 4 ++-- 78 files changed, 215 insertions(+), 173 deletions(-) create mode 100644 app/controllers/concerns/multi_tenancy.rb diff --git a/Gemfile b/Gemfile index e0d9e933..ba568b94 100644 --- a/Gemfile +++ b/Gemfile @@ -41,6 +41,9 @@ gem 'material_icons' gem 'font-awesome-rails', '~> 4.7', '>= 4.7.0.2' gem 'rack-cors' +# Multi-tenancy for shops +gem 'acts_as_tenant' + # image upload gem 'carrierwave', '~> 1.0' gem 'mini_magick' diff --git a/Gemfile.lock b/Gemfile.lock index 633b5965..bbcc1085 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -46,6 +46,9 @@ GEM i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) + acts_as_tenant (0.4.4) + rails (>= 4.0) + request_store (>= 1.0.5) aescrypt (1.0.0) airbrussh (1.4.0) sshkit (>= 1.6.1, != 1.7.0) @@ -219,6 +222,8 @@ GEM rb-inotify (0.10.0) ffi (~> 1.0) redis (3.3.5) + request_store (1.4.1) + rack (>= 1.4) roo (1.13.2) nokogiri rubyzip @@ -315,6 +320,7 @@ PLATFORMS ruby DEPENDENCIES + acts_as_tenant aescrypt axlsx (= 2.0.1) axlsx_rails @@ -374,10 +380,8 @@ DEPENDENCIES web-console (>= 3.3.0) whenever - RUBY VERSION ruby 2.4.1p111 - BUNDLED WITH 2.0.2 diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb index 0e8ea909..8a84cfa1 100755 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -1,5 +1,5 @@ class Api::ApiController < ActionController::API - include TokenVerification + include TokenVerification, MultiTenancy include ActionController::MimeResponds # before_action :lookup_domain diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 7a00666a..77fc9204 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -106,7 +106,7 @@ class Api::BillController < Api::ApiController # unique_code = "ReceiptBillPdf" # #shop detail - # shop_details = Shop.find(1) + # shop_details = Shop.current_shop # customer= Customer.find(@sale_data.customer_id) # # get member information diff --git a/app/controllers/api/call_waiters_controller.rb b/app/controllers/api/call_waiters_controller.rb index 066fa30c..5beba9a6 100644 --- a/app/controllers/api/call_waiters_controller.rb +++ b/app/controllers/api/call_waiters_controller.rb @@ -23,7 +23,7 @@ class Api::CallWaitersController < ActionController::API end ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time,from: from, shift_ids: shift_ids # get printer info - @shop = Shop.first + @shop = Shop.current_shop unique_code = "CallWaiterPdf" print_settings = PrintSetting.find_by_unique_code(unique_code) printer = Printer::ReceiptPrinter.new(print_settings) diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb index 32c2192e..cfec740d 100644 --- a/app/controllers/api/order_reserve/order_reservation_controller.rb +++ b/app/controllers/api/order_reserve/order_reservation_controller.rb @@ -70,7 +70,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation) if !order_reservation_id.nil? && flag - shop = Shop.find_by_id(1) + shop = Shop.current_shop if !shop.nil? shop_code = shop.shop_code order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio") diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index bd2c3e18..a1e9ad9e 100755 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -46,7 +46,7 @@ class Api::OrdersController < Api::ApiController @tax_profile = TaxProfile.where("lower(group_type)='cashier'") # end - @shop = Shop.first + @shop = Shop.current_shop puts "Hello world" puts @shop.to_json return @shop.to_json diff --git a/app/controllers/api/payment/mobilepayment_controller.rb b/app/controllers/api/payment/mobilepayment_controller.rb index 220cbbeb..53daa790 100644 --- a/app/controllers/api/payment/mobilepayment_controller.rb +++ b/app/controllers/api/payment/mobilepayment_controller.rb @@ -14,7 +14,7 @@ class Api::Payment::MobilepaymentController < Api::ApiController saleObj = Sale.find(sale_id) sale_items = SaleItem.get_all_sale_items(sale_id) - shop_detail = Shop.first + shop_detail = Shop.current_shop # rounding adjustment if !path.include? ("credit_payment") diff --git a/app/controllers/api/sound_effect_controller.rb b/app/controllers/api/sound_effect_controller.rb index 97dc3db5..f3126ca2 100644 --- a/app/controllers/api/sound_effect_controller.rb +++ b/app/controllers/api/sound_effect_controller.rb @@ -2,7 +2,7 @@ class Api::SoundEffectController < Api::ApiController #sound effect / alarm api for doemal side calling def sound_effect - shop = Shop.find_by_id(1) + shop = Shop.current_shop if !shop.nil? shop_code = shop.shop_code order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio") diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 66f20c55..81b4835d 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,5 @@ class ApplicationController < ActionController::Base - include LoginVerification + include LoginVerification, MultiTenancy #before_action :check_installation protect_from_forgery with: :exception diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb index 1bf5b4d4..1bb0421e 100755 --- a/app/controllers/base_controller.rb +++ b/app/controllers/base_controller.rb @@ -1,5 +1,6 @@ class BaseController < ActionController::Base + include MultiTenancy layout "installation" protect_from_forgery with: :exception - + end diff --git a/app/controllers/base_crm_controller.rb b/app/controllers/base_crm_controller.rb index 00b5cf98..08bc8138 100755 --- a/app/controllers/base_crm_controller.rb +++ b/app/controllers/base_crm_controller.rb @@ -1,5 +1,5 @@ class BaseCrmController < ActionController::Base - include LoginVerification + include LoginVerification, layout "CRM" before_action :check_user diff --git a/app/controllers/base_inventory_controller.rb b/app/controllers/base_inventory_controller.rb index 8ee82777..bd455c33 100755 --- a/app/controllers/base_inventory_controller.rb +++ b/app/controllers/base_inventory_controller.rb @@ -1,5 +1,5 @@ class BaseInventoryController < ActionController::Base - include LoginVerification + include LoginVerification, MultiTenancy layout "inventory" before_action :check_user diff --git a/app/controllers/base_oqs_controller.rb b/app/controllers/base_oqs_controller.rb index 9b337b69..6e6a9c0f 100755 --- a/app/controllers/base_oqs_controller.rb +++ b/app/controllers/base_oqs_controller.rb @@ -1,5 +1,5 @@ class BaseOqsController < ActionController::Base - include LoginVerification + include LoginVerification, MultiTenancy layout "OQS" before_action :check_user diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index 6940a129..e9cddf05 100755 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -1,5 +1,5 @@ class BaseOrigamiController < ActionController::Base - include LoginVerification + include LoginVerification, MultiTenancy layout "origami" before_action :check_user diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index 691ece34..b3d1d23a 100755 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -1,5 +1,5 @@ class BaseReportController < ActionController::Base - include LoginVerification + include LoginVerification, MultiTenancy layout "application" before_action :check_user @@ -69,7 +69,7 @@ class BaseReportController < ActionController::Base from = from.beginning_of_day to = to.end_of_day - + return from, to end diff --git a/app/controllers/base_waiter_controller.rb b/app/controllers/base_waiter_controller.rb index 580de0f9..b1d2056c 100755 --- a/app/controllers/base_waiter_controller.rb +++ b/app/controllers/base_waiter_controller.rb @@ -1,5 +1,5 @@ class BaseWaiterController < ActionController::Base - include LoginVerification + include LoginVerification, MultiTenancy layout "waiter" before_action :check_user diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb index 8eb719cb..b1102171 100755 --- a/app/controllers/concerns/login_verification.rb +++ b/app/controllers/concerns/login_verification.rb @@ -3,7 +3,7 @@ module LoginVerification included do before_action :authenticate_session_token - helper_method :current_company,:current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail + helper_method :current_company, :current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail end #this is base api base controller to need to inherit. @@ -19,7 +19,7 @@ module LoginVerification def current_shop begin - return Shop.first + return Shop.current_shop rescue return nil end @@ -41,7 +41,7 @@ module LoginVerification #Shop Name in Navbor def shop_detail - @shop = Shop.first + @shop = current_shop end #check order reservation used @@ -78,11 +78,11 @@ module LoginVerification protected # Authenticate the user with token based authentication - def authenticate - authenticate_session_token || render_unauthorized + def authenticate + authenticate_session_token || render_unauthorized end - def authenticate_session_token + def authenticate_session_token token = session[:session_token] if (token) #@current_user = User.find_by(api_key: token) diff --git a/app/controllers/concerns/multi_tenancy.rb b/app/controllers/concerns/multi_tenancy.rb new file mode 100644 index 00000000..5009e094 --- /dev/null +++ b/app/controllers/concerns/multi_tenancy.rb @@ -0,0 +1,20 @@ +module MultiTenancy + extend ActiveSupport::Concern + + included do + set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter + before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action + helper_method :current_shop if respond_to? :helper_method + end + + private + def find_shop_by_subdomain_or_frist + if request.subdomain.present? + shop_code = request.subdomain.partition('-').last + shop = Shop.find_by(shop_code: shop_code) + else + shop = Shop.first + end + set_current_tenant(shop) + end +end diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 2f846601..023b453c 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -82,7 +82,7 @@ class Crm::CustomersController < BaseCrmController @membership_types = Lookup.collection_of("member_group_type") # @taxes = TaxProfile.where(:group_type => 'cashier') - @taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") + @taxes = TaxProfile.unscope(:order).select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") .order("group_type ASC,order_by ASC") @filter = filter diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index a82a6483..18928fc3 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -91,7 +91,7 @@ class HomeController < ApplicationController def dashboard @from, @to = get_date_range_from_params - @shop = Shop.first + @shop = Shop.current_shop @orders = Sale.receipt_date_between(@from, @to).where("payment_status = 'new' and sale_status = 'bill'") @sales = Sale.receipt_date_between(@from, @to).completed diff --git a/app/controllers/inventory/inventory_controller.rb b/app/controllers/inventory/inventory_controller.rb index a0324b15..d91e4176 100755 --- a/app/controllers/inventory/inventory_controller.rb +++ b/app/controllers/inventory/inventory_controller.rb @@ -26,6 +26,6 @@ class Inventory::InventoryController < BaseInventoryController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/inventory/inventory_definitions_controller.rb b/app/controllers/inventory/inventory_definitions_controller.rb index 01ca52b3..fca0bb07 100755 --- a/app/controllers/inventory/inventory_definitions_controller.rb +++ b/app/controllers/inventory/inventory_definitions_controller.rb @@ -106,7 +106,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end private diff --git a/app/controllers/inventory/stock_check_items_controller.rb b/app/controllers/inventory/stock_check_items_controller.rb index 7a37f789..98fb0116 100755 --- a/app/controllers/inventory/stock_check_items_controller.rb +++ b/app/controllers/inventory/stock_check_items_controller.rb @@ -64,7 +64,7 @@ class Inventory::StockCheckItemsController < BaseInventoryController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end private diff --git a/app/controllers/inventory/stock_checks_controller.rb b/app/controllers/inventory/stock_checks_controller.rb index b7f7369d..05f7c70f 100755 --- a/app/controllers/inventory/stock_checks_controller.rb +++ b/app/controllers/inventory/stock_checks_controller.rb @@ -41,7 +41,7 @@ class Inventory::StockChecksController < BaseInventoryController member_info = nil unique_code = 'StockCheckPdf' - shop_details = current_shop + shop_details = Shop.current_shop checker = Employee.find(stockcheck.check_by) print_settings = PrintSetting.find_by_unique_code(unique_code) if !print_settings.nil? @@ -66,7 +66,7 @@ class Inventory::StockChecksController < BaseInventoryController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = current_shop + @shop = Shop.current_shop end # before_action :set_stock_check, only: [:show, :edit, :update, :destroy] diff --git a/app/controllers/inventory/stock_journals_controller.rb b/app/controllers/inventory/stock_journals_controller.rb index 11db2efd..9a737da0 100755 --- a/app/controllers/inventory/stock_journals_controller.rb +++ b/app/controllers/inventory/stock_journals_controller.rb @@ -64,7 +64,7 @@ class StockJournalsController < ApplicationController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end private diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb index c6e130ec..e2499fbb 100644 --- a/app/controllers/oqs/edit_controller.rb +++ b/app/controllers/oqs/edit_controller.rb @@ -85,6 +85,6 @@ class Oqs::EditController < BaseOqsController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/alipay_controller.rb b/app/controllers/origami/alipay_controller.rb index 8c5f4884..3578724f 100644 --- a/app/controllers/origami/alipay_controller.rb +++ b/app/controllers/origami/alipay_controller.rb @@ -11,7 +11,7 @@ class Origami::AlipayController < BaseOrigamiController end total = 0 @alipaycount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_alipay = 0 @member_discount = 0 @@ -64,7 +64,7 @@ class Origami::AlipayController < BaseOrigamiController ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -88,6 +88,6 @@ class Origami::AlipayController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/credit_payments_controller.rb b/app/controllers/origami/credit_payments_controller.rb index 05faf4f7..3e9f2bd3 100755 --- a/app/controllers/origami/credit_payments_controller.rb +++ b/app/controllers/origami/credit_payments_controller.rb @@ -9,7 +9,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController @creditcount = 0 others = 0 - @shop = Shop.first + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else @@ -32,7 +32,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController sale_id = params[:sale_id] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj diff --git a/app/controllers/origami/credit_sales_controller.rb b/app/controllers/origami/credit_sales_controller.rb index 8f43edda..587b22dd 100644 --- a/app/controllers/origami/credit_sales_controller.rb +++ b/app/controllers/origami/credit_sales_controller.rb @@ -3,11 +3,11 @@ class Origami::CreditSalesController < BaseOrigamiController @cashier_type = 'cashier' @webview = false if check_mobile - @webview = true + @webview = true end - - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @@ -15,7 +15,7 @@ class Origami::CreditSalesController < BaseOrigamiController @sale = Sale.find_by_sale_id(params[:sale_id]) @sale_payment = SalePayment.select("SUM(payment_amount) as payment_amount") .where("sale_id = ? and payment_method=?", @sale.sale_id, "creditnote") - + @sale_taxes = [] sale_taxes = SaleTax.where("sale_id = ?", @sale.sale_id) if !sale_taxes.empty? @@ -24,5 +24,5 @@ class Origami::CreditSalesController < BaseOrigamiController end end end - + end diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 97f35339..b77137a9 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -87,7 +87,7 @@ class Origami::CustomersController < BaseOrigamiController @count_customer = Customer.count_customer # @taxes = TaxProfile.where(:group_type => 'cashier') - @taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") + @taxes = TaxProfile.unscope(:order).select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") .order("group_type ASC,order_by ASC") # if flash["errors"] # @crm_customer.valid? diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index 43c79179..4ff6e8b3 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -1,7 +1,7 @@ class Origami::DashboardController < BaseOrigamiController def index - @shop = Shop.first + @shop = Shop.current_shop @display_type = Lookup.find_by_lookup_type("display_type") @sale_data = Array.new diff --git a/app/controllers/origami/dinga_controller.rb b/app/controllers/origami/dinga_controller.rb index 01e35004..9754b81d 100644 --- a/app/controllers/origami/dinga_controller.rb +++ b/app/controllers/origami/dinga_controller.rb @@ -6,7 +6,7 @@ class Origami::DingaController < BaseOrigamiController @membership_rebate_balance=0 @sale_data = Sale.find_by_sale_id(@sale_id) @receipt_no = @sale_data.receipt_no - @shop = Shop.first + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(@sale_data.grand_total) else @@ -77,7 +77,7 @@ def create account_no = params[:account_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj # new_total = Sale.get_rounding_adjustment(saleObj.grand_total) diff --git a/app/controllers/origami/gift_voucher_controller.rb b/app/controllers/origami/gift_voucher_controller.rb index 572e248e..7ad78065 100644 --- a/app/controllers/origami/gift_voucher_controller.rb +++ b/app/controllers/origami/gift_voucher_controller.rb @@ -6,7 +6,7 @@ class Origami::GiftVoucherController < BaseOrigamiController sale_data = Sale.find_by_sale_id(@sale_id) total = 0 @gift_vouchercount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_gift_voucher = 0 @member_discount = 0 @@ -48,7 +48,7 @@ class Origami::GiftVoucherController < BaseOrigamiController ref_no = params[:reference_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -66,6 +66,6 @@ class Origami::GiftVoucherController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index fe074210..30a6ce92 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -4,8 +4,8 @@ class Origami::HomeController < BaseOrigamiController def index @webview = check_mobile - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @@ -21,8 +21,8 @@ class Origami::HomeController < BaseOrigamiController @print_settings = PrintSetting.get_precision_delimiter() @webview = check_mobile - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @@ -126,7 +126,7 @@ class Origami::HomeController < BaseOrigamiController lookup_edit_order = Lookup.collection_of('edit_order') if !lookup_edit_order.empty? lookup_edit_order.each do |edit_order| - if edit_order[0].downcase == "editorderorigami" + if edit_order[0].downcase == "editorderorigami" if edit_order[1] == '0' && (current_login_employee.role == 'cashier' || current_login_employee.role == 'waiter') @edit_order_origami = false end @@ -139,14 +139,14 @@ class Origami::HomeController < BaseOrigamiController lookup_changable_tax = Lookup.collection_of('changable_tax') if !lookup_changable_tax.empty? lookup_changable_tax.each do |changable_tax| - if changable_tax[0].downcase == "change" - if changable_tax[1] == '0' + if changable_tax[0].downcase == "change" + if changable_tax[1] == '0' @changable_tax = false end end end end - + end def check_emp_access_code diff --git a/app/controllers/origami/jcb_controller.rb b/app/controllers/origami/jcb_controller.rb index 1f979adc..3a64b8a0 100644 --- a/app/controllers/origami/jcb_controller.rb +++ b/app/controllers/origami/jcb_controller.rb @@ -12,7 +12,7 @@ class Origami::JcbController < BaseOrigamiController end total = 0 @jcbcount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_jcb = 0 @member_discount= 0 @@ -66,7 +66,7 @@ class Origami::JcbController < BaseOrigamiController ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -89,6 +89,6 @@ class Origami::JcbController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/junction_pay_controller.rb b/app/controllers/origami/junction_pay_controller.rb index c77c2655..1b416c6a 100644 --- a/app/controllers/origami/junction_pay_controller.rb +++ b/app/controllers/origami/junction_pay_controller.rb @@ -11,7 +11,7 @@ class Origami::JunctionPayController < BaseOrigamiController @cashier_id = current_user.emp_id @payment_method_setting_nav = PaymentMethodSetting.all - @shop = Shop.first + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else @@ -52,7 +52,7 @@ class Origami::JunctionPayController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj diff --git a/app/controllers/origami/master_controller.rb b/app/controllers/origami/master_controller.rb index 15edb703..f36b86f0 100644 --- a/app/controllers/origami/master_controller.rb +++ b/app/controllers/origami/master_controller.rb @@ -12,7 +12,7 @@ class Origami::MasterController < BaseOrigamiController end total = 0 @mastercount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_master = 0 @member_discount = 0 @@ -63,7 +63,7 @@ class Origami::MasterController < BaseOrigamiController ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -87,6 +87,6 @@ class Origami::MasterController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb index 41c58941..86680c6e 100755 --- a/app/controllers/origami/movetable_controller.rb +++ b/app/controllers/origami/movetable_controller.rb @@ -105,7 +105,7 @@ class Origami::MovetableController < BaseOrigamiController # @type = (DiningFacility.find(change_to)).type # @moved_by = @current_user.name # @date = DateTime.now - # @shop = Shop.first + # @shop = Shop.current_shop # unique_code = "MoveTablePdf" # pdf_no = PrintSetting.where(:unique_code => unique_code).count # #print_settings = PrintSetting.find_by_unique_code(unique_code) diff --git a/app/controllers/origami/mpu_controller.rb b/app/controllers/origami/mpu_controller.rb index 220219c3..1a7743c1 100644 --- a/app/controllers/origami/mpu_controller.rb +++ b/app/controllers/origami/mpu_controller.rb @@ -11,7 +11,7 @@ class Origami::MpuController < BaseOrigamiController end total = 0 @mpucount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_mpu = 0 @member_discount = 0 @@ -64,7 +64,7 @@ class Origami::MpuController < BaseOrigamiController ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -87,6 +87,6 @@ class Origami::MpuController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb index 3fdeee25..508bf483 100644 --- a/app/controllers/origami/order_reservation_controller.rb +++ b/app/controllers/origami/order_reservation_controller.rb @@ -4,7 +4,7 @@ class Origami::OrderReservationController < BaseOrigamiController @order = OrderReservation.latest_order #.active @count_on_order = OrderReservation.get_count_on_order @count_on_completed = OrderReservation.get_count_on_completed - @shop = Shop.find_by_id(1) + @shop = Shop.current_shop @receipt_bill = check_receipt_bill end diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index 5f34d9a3..2a7c9aa3 100755 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -5,8 +5,8 @@ class Origami::OrdersController < BaseOrigamiController @webview = true end - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @order = Order.find(params[:order_id]) diff --git a/app/controllers/origami/paymal_controller.rb b/app/controllers/origami/paymal_controller.rb index 36c19327..cfabd2b5 100644 --- a/app/controllers/origami/paymal_controller.rb +++ b/app/controllers/origami/paymal_controller.rb @@ -6,7 +6,7 @@ class Origami::PaymalController < BaseOrigamiController @membership_rebate_balance=0 sale_data = Sale.find_by_sale_id(@sale_id) @receipt_no = sale_data.receipt_no - @shop = Shop.first + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else @@ -75,7 +75,7 @@ def create puts params.to_json if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index c6c61602..401e231b 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -59,7 +59,7 @@ class Origami::PaymentsController < BaseOrigamiController end #shop detail - ## shop_detail = Shop.first + ## shop_detail = Shop.current_shop # customer= Customer.where('customer_id=' +.customer_id) customer = Customer.find(sale_data.customer_id) # rounding adjustment @@ -141,7 +141,7 @@ class Origami::PaymentsController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) sale_items = SaleItem.get_all_sale_items(sale_id) - #shop_detail = Shop.first + #shop_detail = Shop.current_shop # rounding adjustment if !path.include? ("credit_payment") if shop_detail.is_rounding_adj @@ -577,7 +577,7 @@ class Origami::PaymentsController < BaseOrigamiController customer= Customer.find(saleObj.customer_id) #shop detail - #shop_detail = Shop.first + #shop_detail = Shop.current_shop # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate @@ -686,7 +686,7 @@ class Origami::PaymentsController < BaseOrigamiController customer= Customer.find(saleObj.customer_id) #shop detail - #shop_detail = Shop.first + #shop_detail = Shop.current_shop printer = PrintSetting.all unique_code="ReceiptBillPdf" diff --git a/app/controllers/origami/paypar_payments_controller.rb b/app/controllers/origami/paypar_payments_controller.rb index fbcd348c..f2fb3c7b 100755 --- a/app/controllers/origami/paypar_payments_controller.rb +++ b/app/controllers/origami/paypar_payments_controller.rb @@ -7,7 +7,7 @@ class Origami::PayparPaymentsController < BaseOrigamiController payment_method = "paypar" if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment if shop_details.is_rounding_adj diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb index c0edf879..0d1836c0 100755 --- a/app/controllers/origami/redeem_payments_controller.rb +++ b/app/controllers/origami/redeem_payments_controller.rb @@ -6,7 +6,7 @@ class Origami::RedeemPaymentsController < BaseOrigamiController @membership_rebate_balance=0 sale_data = Sale.find_by_sale_id(@sale_id) - @shop = Shop.first + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 6d36f319..69a316f5 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -90,7 +90,7 @@ class Origami::RequestBillsController < ApplicationController # Not Use for these printed bill cannot give customer # unique_code = "ReceiptBillPdf" # #shop detail - # shop_details = Shop.find(1) + # shop_details = Shop.current_shop # # customer= Customer.where('customer_id=' +.customer_id) # customer= Customer.find(@sale_data.customer_id) # # get member information diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 80eb5641..c94c5c18 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -1,7 +1,7 @@ class Origami::RoomsController < BaseOrigamiController def index - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @shift = ShiftSale.current_open_shift(current_user.id) @@ -17,8 +17,8 @@ class Origami::RoomsController < BaseOrigamiController @webview = true end - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @@ -29,7 +29,7 @@ class Origami::RoomsController < BaseOrigamiController @status_sale = "" @sale_array = Array.new - @shop = Shop.first + @shop = Shop.current_shop @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb index d2af3258..98bbd288 100755 --- a/app/controllers/origami/sales_controller.rb +++ b/app/controllers/origami/sales_controller.rb @@ -5,8 +5,8 @@ class Origami::SalesController < BaseOrigamiController @webview = true end - @tables = Table.unscoped.all.active.order('status desc') - @rooms = Room.unscoped.all.active.order('status desc') + @tables = Table.unscope(:order).all.active.order('status desc') + @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") diff --git a/app/controllers/origami/second_display_controller.rb b/app/controllers/origami/second_display_controller.rb index 21c0674d..392b85e6 100644 --- a/app/controllers/origami/second_display_controller.rb +++ b/app/controllers/origami/second_display_controller.rb @@ -27,7 +27,7 @@ class Origami::SecondDisplayController < BaseOrigamiController #Shop Name in Navbor # helper_method :shop_detail # def shop_detail - # @shop = Shop.first + # @shop = Shop.current_shop # end diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index fb6db35f..12a232a6 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -413,7 +413,7 @@ class Origami::SplitBillController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb index 7082e44c..e3f9f0ab 100755 --- a/app/controllers/origami/table_invoices_controller.rb +++ b/app/controllers/origami/table_invoices_controller.rb @@ -1,7 +1,7 @@ class Origami::TableInvoicesController < BaseOrigamiController def index @table = DiningFacility.find(params[:table_id]) - shop = Shop.first + shop = Shop.current_shop puts "table bookig lenght" @sale_array = Array.new @table.bookings.each do |booking| @@ -34,7 +34,7 @@ class Origami::TableInvoicesController < BaseOrigamiController @table = DiningFacility.find(params[:table_id]) @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all - shop = Shop.first + shop = Shop.current_shop @sale_array = Array.new @table.bookings.each do |booking| if booking.sale_id.nil? diff --git a/app/controllers/origami/unionpay_controller.rb b/app/controllers/origami/unionpay_controller.rb index b351d40a..23587ca0 100644 --- a/app/controllers/origami/unionpay_controller.rb +++ b/app/controllers/origami/unionpay_controller.rb @@ -11,7 +11,7 @@ class Origami::UnionpayController < BaseOrigamiController end total = 0 @unionpaycount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_unionpay = 0 @member_discount = 0 @@ -61,7 +61,7 @@ class Origami::UnionpayController < BaseOrigamiController ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -85,6 +85,6 @@ class Origami::UnionpayController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/visa_controller.rb b/app/controllers/origami/visa_controller.rb index c50339e4..6eb11be5 100644 --- a/app/controllers/origami/visa_controller.rb +++ b/app/controllers/origami/visa_controller.rb @@ -11,7 +11,7 @@ class Origami::VisaController < BaseOrigamiController end total = 0 @visacount = 0 - @shop = Shop.first + @shop = Shop.current_shop @rounding_adj = 0 @can_visa = 0 @member_discount = 0 @@ -61,7 +61,7 @@ class Origami::VisaController < BaseOrigamiController ref_no = params[:ref_no] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj @@ -85,6 +85,6 @@ class Origami::VisaController < BaseOrigamiController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 5352b7c3..7fb54825 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -116,7 +116,7 @@ class Origami::VoidController < BaseOrigamiController customer= Customer.find(sale.customer_id) #shop detail - shop_details = current_shop + shop_details = Shop.current_shop # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate diff --git a/app/controllers/origami/voucher_controller.rb b/app/controllers/origami/voucher_controller.rb index e512a48b..1b79cb49 100755 --- a/app/controllers/origami/voucher_controller.rb +++ b/app/controllers/origami/voucher_controller.rb @@ -8,7 +8,7 @@ class Origami::VoucherController < BaseOrigamiController @vouchercount = 0 others = 0 - @shop = Shop.first + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb index 6a68a2b9..ba0846ee 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -89,7 +89,7 @@ class Origami::WasteSpoileController < BaseOrigamiController customer= Customer.find(sale.customer_id) #shop detail - shop_details = current_shop + shop_details = Shop.current_shop # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate diff --git a/app/controllers/reports/product_sale_controller.rb b/app/controllers/reports/product_sale_controller.rb index 9791545e..61f17396 100644 --- a/app/controllers/reports/product_sale_controller.rb +++ b/app/controllers/reports/product_sale_controller.rb @@ -22,6 +22,6 @@ class Reports::ProductSaleController < BaseReportController #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = Shop.current_shop end end diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index eeff4bf0..1136bc31 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -183,7 +183,7 @@ authorize_resource :class => false customer= Customer.find(saleObj.customer_id) #shop detail - #shop_detail = Shop.first + #shop_detail = Shop.current_shop # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate diff --git a/app/controllers/settings/shops_controller.rb b/app/controllers/settings/shops_controller.rb index 598e4f9b..9e902dad 100644 --- a/app/controllers/settings/shops_controller.rb +++ b/app/controllers/settings/shops_controller.rb @@ -59,11 +59,11 @@ class Settings::ShopsController < ApplicationController File.delete(delete_path) end end - save_path = Rails.root.join("public/#{current_shop.shop_code}_#{a.original_filename}") + save_path = Rails.root.join("public/#{Shop.current_shop.shop_code}_#{a.original_filename}") File.open(save_path, 'wb') do |f| f.write a.read end - audio_name = "#{current_shop.shop_code}_#{a.original_filename}" + audio_name = "#{Shop.current_shop.shop_code}_#{a.original_filename}" @settings_shop.display_images.where(:name => "order_audio").destroy_all @display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :name => "order_audio", :image => audio_name) else diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 83efc401..661b42e9 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -346,7 +346,7 @@ class Transactions::SalesController < ApplicationController customer= Customer.find(sale.customer_id) #shop detail - shop_details = Shop.find_by_id(1) + shop_details = Shop.current_shop # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 10a4cba8..590cdf8d 100755 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,14 @@ class ApplicationRecord < ActiveRecord::Base self.abstract_class = true + + def self.inherited(subclass) + super + + return unless subclass.superclass == self + return unless subclass.column_names.include? 'shop_id' + + subclass.class_eval do + acts_as_tenant(:shop) + end + end end diff --git a/app/models/kbz_pay.rb b/app/models/kbz_pay.rb index 5893e048..523a7fc5 100644 --- a/app/models/kbz_pay.rb +++ b/app/models/kbz_pay.rb @@ -3,13 +3,13 @@ class KbzPay KBZ_PAY = 'KBZPay' def self.pay(amount, receipt_no, url, key, app_id, code) - shop = Shop.first + shop = Shop.current_shop prefix = shop.shop_code receipt_no = "#{prefix}#{receipt_no}" datetime = DateTime.now.strftime("%d%m%Y%H%M") kbz_app_id = app_id - kbz_merch_code = code + kbz_merch_code = code kbz_api_key = key kbz_provider_url = "#{url}/precreate" @@ -58,17 +58,17 @@ class KbzPay # Rails.logger.debug result['Response'] return false, result['Response'] end - + end def self.query(receipt_no, current_user, url, key, app_id, code) - shop = Shop.first + shop = Shop.current_shop prefix = shop.shop_code receipt_no = "#{prefix}#{receipt_no}" amount = 0 datetime = DateTime.now.strftime("%d%m%Y%H%M") kbz_app_id = app_id - kbz_merch_code = code + kbz_merch_code = code kbz_api_key = key kbz_provider_url = "#{url}/queryorder" @@ -122,7 +122,7 @@ class KbzPay # return true, "successfully paid by KBZ PAY" elsif result['Response']['trade_status'] == "PAY_FAILED" - + # return false, "pay failed by KBZ PAY" elsif result['Response']['trade_status'] == "WAIT_PAY" # return false , "Waiting to pay by KBZ PAY" @@ -135,4 +135,4 @@ class KbzPay return amount end -end \ No newline at end of file +end diff --git a/app/models/menu.rb b/app/models/menu.rb index a825cc7b..1dd0aaed 100755 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -141,7 +141,7 @@ class Menu < ApplicationRecord end else # Menu by Menu Import - @shop = Shop.first + @shop = Shop.current_shop shop_code = "" if !@shop.nil? if @shop.shop_code diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 147ebdc4..6d8830f8 100755 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -297,7 +297,7 @@ class OrderQueueStation < ApplicationRecord @type = (DiningFacility.find(change_to)).type @moved_by = current_user @date = DateTime.now - @shop = Shop.first + @shop = Shop.current_shop unique_code = "MoveTablePdf" # pdf_no = PrintSetting.where(:unique_code => unique_code).count print_settings = PrintSetting.find_by_unique_code(unique_code) diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index 8de88ee2..60c33d2e 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -157,7 +157,7 @@ class OrderReservation < ApplicationRecord def self.update_doemal_payment(order,current_user,receipt_bill) if(Sale.exists?(order.sale_id)) saleObj = Sale.find(order.sale_id) - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment if shop_details.is_rounding_adj a = saleObj.grand_total % 25 # Modulus @@ -194,7 +194,7 @@ class OrderReservation < ApplicationRecord shift = ShiftSale.find(saleObj.shift_sale_id) cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) - shop_detail = Shop.first + shop_detail = Shop.current_shop order_reservation = OrderReservation.get_order_reservation_info(saleObj.sale_id) if !cashier_terminal.nil? # Calculate Food and Beverage Total @@ -400,7 +400,7 @@ class OrderReservation < ApplicationRecord end def self.check_new_order - shop = Shop.find_by_id(1) + shop = Shop.current_shop if !shop.shop_code.nil? shop_code = shop.shop_code else @@ -418,7 +418,7 @@ class OrderReservation < ApplicationRecord end def self.check_order_send_to_kitchen - shop = Shop.find_by_id(1) + shop = Shop.current_shop if !shop.shop_code.nil? shop_code = shop.shop_code else @@ -436,7 +436,7 @@ class OrderReservation < ApplicationRecord end def self.check_order_ready_to_delivery - shop = Shop.find_by_id(1) + shop = Shop.current_shop if !shop.shop_code.nil? shop_code = shop.shop_code else diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index ed14d884..5d72773c 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -38,7 +38,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # end - shop = Shop.first + shop = Shop.current_shop directory_name = 'public/orders_'+shop.shop_code Dir.mkdir(directory_name) unless File.exists?(directory_name) @@ -80,7 +80,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker print_setting = PrintSetting.all.order("id ASC") order=print_query('order_summary', order_id) - shop = Shop.first + shop = Shop.current_shop directory_name = 'public/orders_'+shop.shop_code Dir.mkdir(directory_name) unless File.exists?(directory_name) @@ -192,7 +192,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker order=print_query('booking_summary', booking_id) - shop = Shop.first + shop = Shop.current_shop directory_name = 'public/orders_'+shop.shop_code Dir.mkdir(directory_name) unless File.exists?(directory_name) diff --git a/app/models/room.rb b/app/models/room.rb index 87f232e9..63c548ec 100755 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -1,4 +1,3 @@ class Room < DiningFacility - has_many :bookings, :foreign_key => 'dining_facility_id' end diff --git a/app/models/sale.rb b/app/models/sale.rb index 85a81950..59d3683b 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -440,7 +440,7 @@ class Sale < ApplicationRecord #compute - invoice total def compute_by_sale_items(total_discount, discount_type=nil, order_source=nil, tax_type=nil, type=nil) - shop = Shop.first + shop = Shop.current_shop #Computation Fields subtotal_price = 0 @@ -507,7 +507,7 @@ class Sale < ApplicationRecord # Tax Re-Calculte def compute_tax(total_taxable, total_discount = 0, order_source = nil, tax_type=nil) - shop = Shop.first + shop = Shop.current_shop #if tax is not apply create new record # SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax| @@ -627,7 +627,7 @@ class Sale < ApplicationRecord # Tax Calculate def apply_tax(total_taxable, order_source = nil, tax_type = nil) - shop = Shop.first + shop = Shop.current_shop #if tax is not apply create new record # SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax| @@ -645,7 +645,7 @@ class Sale < ApplicationRecord order_source = "cashier" end - # tax_data = TaxProfile.unscoped.where("group_type=?",order_source).pluck(:id) + # tax_data = TaxProfile.unscope(:order).where("group_type=?",order_source).pluck(:id) # customer = Customer.find(self.customer_id).tax_profiles tax_profiles = unique_tax_profiles(order_source, self.customer_id) @@ -710,7 +710,7 @@ class Sale < ApplicationRecord end def adjust_rounding - shop_details = Shop.first + shop_details = Shop.current_shop # rounding adjustment if shop_details.is_rounding_adj new_total = Sale.get_rounding_adjustment(self.grand_total) @@ -726,7 +726,7 @@ class Sale < ApplicationRecord #Generate new Receipt No when it is not assigned def generate_receipt_no #shop_code and client_code - shop_details = Shop.first + shop_details = Shop.current_shop #Date-Shift- if self.receipt_no.nil? prefix = DateTime.now().utc @@ -1239,7 +1239,7 @@ end #product sale report query def self.get_menu_item_query(order_by) - query = MenuItem.unscoped.select("acc.id as account_id, + query = MenuItem.unscope(:order).select("acc.id as account_id, acc.title as account_name, mii.item_instance_code as item_code, " + "(CASE WHEN si.qty IS NOT NULL THEN SUM(si.qty) ELSE 0 END) as total_item," + diff --git a/app/models/shop.rb b/app/models/shop.rb index 75c30dd7..41110515 100755 --- a/app/models/shop.rb +++ b/app/models/shop.rb @@ -1,13 +1,17 @@ class Shop < ApplicationRecord - #ShopDetail = Shop.find_by_id(1) + #ShopDetail = Shop.current_shop # Shop Image Uploader - mount_uploader :logo, ShopImageUploader + mount_uploader :logo, ShopImageUploader - has_many :display_images + has_many :display_images accepts_nested_attributes_for :display_images def file_data=(input_data) self.data = input_data.read end + + def self.current_shop + ActsAsTenant.current_tenant + end end diff --git a/app/uploaders/commissioner_image_uploader.rb b/app/uploaders/commissioner_image_uploader.rb index 9b65e4a8..42e90a16 100644 --- a/app/uploaders/commissioner_image_uploader.rb +++ b/app/uploaders/commissioner_image_uploader.rb @@ -20,11 +20,11 @@ class CommissionerImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.first.shop_code.nil? - "#{original_filename}" if original_filename.present? + if Shop.current_shop.shop_code.nil? + "#{original_filename}" if original_filename.present? else - "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? - end + "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present? + end end # def cache_dir @@ -62,6 +62,6 @@ class CommissionerImageUploader < CarrierWave::Uploader::Base # Avoid using model.id or version_name here, see uploader/store.rb for details. # def filename # "something.jpg" if original_filename - # end + # end -end \ No newline at end of file +end diff --git a/app/uploaders/customer_image_uploader.rb b/app/uploaders/customer_image_uploader.rb index be1326d6..77a133af 100644 --- a/app/uploaders/customer_image_uploader.rb +++ b/app/uploaders/customer_image_uploader.rb @@ -20,11 +20,11 @@ class CustomerImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.first.shop_code.nil? - "#{original_filename}" if original_filename.present? + if Shop.current_shop.shop_code.nil? + "#{original_filename}" if original_filename.present? else - "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? - end + "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present? + end end # def cache_dir @@ -62,6 +62,6 @@ class CustomerImageUploader < CarrierWave::Uploader::Base # Avoid using model.id or version_name here, see uploader/store.rb for details. # def filename # "something.jpg" if original_filename - # end + # end -end \ No newline at end of file +end diff --git a/app/uploaders/employee_image_uploader.rb b/app/uploaders/employee_image_uploader.rb index 17c9d120..62aa3e15 100644 --- a/app/uploaders/employee_image_uploader.rb +++ b/app/uploaders/employee_image_uploader.rb @@ -20,11 +20,11 @@ class EmployeeImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.first.shop_code.nil? - "#{original_filename}" if original_filename.present? + if Shop.current_shop.shop_code.nil? + "#{original_filename}" if original_filename.present? else - "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? - end + "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present? + end end # def cache_dir @@ -62,6 +62,6 @@ class EmployeeImageUploader < CarrierWave::Uploader::Base # Avoid using model.id or version_name here, see uploader/store.rb for details. # def filename # "something.jpg" if original_filename - # end + # end -end \ No newline at end of file +end diff --git a/app/uploaders/menu_item_image_uploader.rb b/app/uploaders/menu_item_image_uploader.rb index 7a4b2039..5f23cafc 100755 --- a/app/uploaders/menu_item_image_uploader.rb +++ b/app/uploaders/menu_item_image_uploader.rb @@ -15,16 +15,16 @@ class MenuItemImageUploader < CarrierWave::Uploader::Base # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: def store_dir - "image/menu_images/#{Shop.first.shop_code}" + "image/menu_images/#{Shop.current_shop.shop_code}" # "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end def filename - if Shop.first.shop_code.nil? - "#{original_filename}" if original_filename.present? + if Shop.current_shop.shop_code.nil? + "#{original_filename}" if original_filename.present? else - "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? - end + "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present? + end end # def cache_dir @@ -42,7 +42,7 @@ class MenuItemImageUploader < CarrierWave::Uploader::Base # Process files as they are uploaded: # process scale: [200, 300] process :resize_to_fit => [400, 250]#[200, 150] - + # # def scale(width, height) # # do something diff --git a/app/uploaders/product_image_uploader.rb b/app/uploaders/product_image_uploader.rb index c39d867d..35fde675 100755 --- a/app/uploaders/product_image_uploader.rb +++ b/app/uploaders/product_image_uploader.rb @@ -20,11 +20,11 @@ class ProductImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.first.shop_code.nil? - "#{original_filename}" if original_filename.present? + if Shop.current_shop.shop_code.nil? + "#{original_filename}" if original_filename.present? else - "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? - end + "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present? + end end # def cache_dir diff --git a/app/uploaders/shop_image_uploader.rb b/app/uploaders/shop_image_uploader.rb index 394704c3..c27fb65c 100644 --- a/app/uploaders/shop_image_uploader.rb +++ b/app/uploaders/shop_image_uploader.rb @@ -20,11 +20,11 @@ class ShopImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.first.shop_code.nil? - "#{original_filename}" if original_filename.present? + if Shop.current_shop.shop_code.nil? + "#{original_filename}" if original_filename.present? else - "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? - end + "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present? + end end # def cache_dir @@ -62,6 +62,6 @@ class ShopImageUploader < CarrierWave::Uploader::Base # Avoid using model.id or version_name here, see uploader/store.rb for details. # def filename # "something.jpg" if original_filename - # end + # end -end \ No newline at end of file +end diff --git a/app/views/origami/dashboard/_menu.json.jbuilder b/app/views/origami/dashboard/_menu.json.jbuilder index 6d1ec624..372d521c 100644 --- a/app/views/origami/dashboard/_menu.json.jbuilder +++ b/app/views/origami/dashboard/_menu.json.jbuilder @@ -8,7 +8,7 @@ json.valid_time_to menu.valid_time_to.strftime("%H:%M") if (menu.menu_categories) order_by = Lookup.find_by_lookup_type("order_by") # if !order_by.nil? && order_by.value == "name" - # categories = MenuCategory.unscoped.where("menu_id ='#{menu.id}'").order("name asc") + # categories = MenuCategory.unscope(:order).where("menu_id ='#{menu.id}'").order("name asc") # else # categories = menu.menu_categories # end diff --git a/lib/tasks/receipt.rake b/lib/tasks/receipt.rake index 180b0de4..af50f3f3 100644 --- a/lib/tasks/receipt.rake +++ b/lib/tasks/receipt.rake @@ -3,7 +3,7 @@ namespace :consolidate do task :receipt => :environment do # Receipt.delete_all sales = Sale.all_receipts - shop = Shop.first #current_shop + shop = Shop.current_shop #Shop.current_shop sales.each do |sale| if sale.shift_sale_id.present? @@ -57,7 +57,7 @@ namespace :consolidate do ReceiptDetail.delete_all sales = Sale.all_receipt_details - shop = Shop.first #current_shop + shop = Shop.current_shop #Shop.current_shop sale_id = '' count = 0 From 6ad2f320dfca82763a2269605349611f09b94272 Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 2 Dec 2019 19:11:52 +0630 Subject: [PATCH 29/54] shop --- app/controllers/home_controller.rb | 2 +- app/controllers/settings/employees_controller.rb | 2 +- app/controllers/settings/lookups_controller.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 70ed5755..c71c8599 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -169,7 +169,7 @@ class HomeController < ApplicationController def destroy # clear in employee session - Employee.logout(@shop,session[:session_token]) + Employee.logout(current_shop,session[:session_token]) session[:session_token] = nil # redirect_to root_path render :json => {:status=> "Success", :url => root_path }.to_json diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb index 5c9dae6f..140ff2c0 100755 --- a/app/controllers/settings/employees_controller.rb +++ b/app/controllers/settings/employees_controller.rb @@ -31,7 +31,7 @@ class Settings::EmployeesController < ApplicationController # POST /employees.json def create @employee = Employee.new(employee_params) - @employee.shop_code = @shop.shop_code + @employee.shop_code =current_shop.shop_code respond_to do |format| if @employee.save format.html { redirect_to settings_employees_path, notice: 'Employee was successfully created.' } diff --git a/app/controllers/settings/lookups_controller.rb b/app/controllers/settings/lookups_controller.rb index 87c81842..4390dadd 100755 --- a/app/controllers/settings/lookups_controller.rb +++ b/app/controllers/settings/lookups_controller.rb @@ -25,7 +25,7 @@ class Settings::LookupsController < ApplicationController # POST /settings/lookups.json def create @settings_lookup = Lookup.new(settings_lookup_params) - @settings_lookup.shop_code = @shop.shop_code + @settings_lookup.shop_code = current_shop.shop_code respond_to do |format| if @settings_lookup.save format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully created.' } From 108415ed3f80df5e4a01be29a930b4216f483687 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Tue, 3 Dec 2019 10:02:49 +0630 Subject: [PATCH 30/54] update dine-in pay bill --- .../origami/payments_controller.rb | 4 +-- app/models/sale_payment.rb | 27 +++++-------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 401e231b..b6c3e5be 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -176,14 +176,14 @@ class Origami::PaymentsController < BaseOrigamiController # For Cashier by Zone # bookings = Booking.where("sale_id='#{sale_id}'") - bookings = Booking.find_by_sale_id(sale_id) + bookings = saleObj.bookings[0] shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) else if bookings.dining_facility_id.to_i > 0 - table = DiningFacility.find(bookings.dining_facility_id) + table = bookings.dining_facility cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index e0ad2383..c48b4a6b 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -87,7 +87,7 @@ class SalePayment < ApplicationRecord amount_due = amount_due - payment.payment_amount end end - if (amount_due >= 0) + if (amount_due > 0) payment_status = false membership_data = nil #route to payment type @@ -780,27 +780,14 @@ class SalePayment < ApplicationRecord def table_update_status(sale_obj) status = true sale_count = 0 - booking = Booking.find_by_sale_id(sale_obj.id) - if booking + if booking = sale_obj.bookings[0] if booking.dining_facility_id.to_i > 0 - table = DiningFacility.find(booking.dining_facility_id) - bookings = table.bookings - bookings.each do |tablebooking| - if tablebooking.booking_status != 'moved' - if tablebooking.sale_id - if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' && tablebooking.sale.sale_status != 'spoile' && tablebooking.sale.sale_status != 'waste' - status = false - sale_count += 1 - else - status = true - end - else - status = false - sale_count += 1 - end - end + table = booking.dining_facility + if Booking.left_joins(:sale).where(dining_facility_id: booking.dining_facility_id).where.not(booking_status: 'moved').where("sales.sale_status NOT IN ('completed', 'void', 'spoile', 'waste') OR sales.sale_status IS NULL").exists? + status = false end - if status && sale_count == 0 + + if status table.update_attributes(status: "available") # table.status = "available" # table.save From e0b912bfa0c970a5d5ee3f72fcb1344175b60dda Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 3 Dec 2019 13:43:26 +0630 Subject: [PATCH 31/54] current shop --- app/controllers/base_foodcourt_controller.rb | 2 +- .../concerns/login_verification.rb | 27 ++------- .../foodcourt/addorders_controller.rb | 2 +- .../foodcourt/dashboard_controller.rb | 2 +- .../foodcourt/food_court_controller.rb | 9 +-- .../foodcourt/payments_controller.rb | 42 +++++++------- .../foodcourt/shifts_controller.rb | 16 +++--- app/controllers/home_controller.rb | 9 +-- .../origami/addorders_controller.rb | 2 +- .../origami/food_court_controller.rb | 9 +-- .../origami/payments_controller.rb | 52 +++++++++--------- .../settings/cashier_terminals_controller.rb | 2 +- app/models/employee.rb | 21 +++---- app/models/inventory_definition.rb | 4 +- app/models/sale.rb | 2 - app/uploaders/employee_image_uploader.rb | 6 +- app/views/layouts/login_dashboard.html.erb | 2 +- dump.rdb | Bin 1864 -> 1864 bytes 18 files changed, 98 insertions(+), 111 deletions(-) diff --git a/app/controllers/base_foodcourt_controller.rb b/app/controllers/base_foodcourt_controller.rb index 5a37529b..3d28f342 100644 --- a/app/controllers/base_foodcourt_controller.rb +++ b/app/controllers/base_foodcourt_controller.rb @@ -1,5 +1,5 @@ class BaseFoodcourtController < ActionController::Base - include LoginVerification + include LoginVerification, MultiTenancy layout "foodcourt" before_action :check_user diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb index b14cab05..3b714cc9 100755 --- a/app/controllers/concerns/login_verification.rb +++ b/app/controllers/concerns/login_verification.rb @@ -25,16 +25,16 @@ module LoginVerification end def current_login_employee - @employee = Employee.find_by_token_session_and_shop_code(session[:session_token],@current_shop.shop_code) + @employee = Employee.find_by_token_session(session[:session_token]) end def current_user - @current_user ||= Employee.find_by_token_session_and_shop_code(session[:session_token],@current_shop.shop_code) if session[:session_token] + @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] end # Get current Cashiers def get_cashier - @cashier = Employee.where("shop_code='#{@current_shop.shop_code}' and role = 'cashier' AND token_session <> ''") + @cashier = Employee.where("role = 'cashier' AND token_session <> ''") end @@ -45,7 +45,7 @@ module LoginVerification #check order reservation used def order_reservation - order_reserve = Lookup.where("shop_code='#{@current_shop.shop_code}'").collection_of('order_reservation') + order_reserve = Lookup.collection_of('order_reservation') status = false if !order_reserve.empty? order_reserve.each do |order| @@ -61,7 +61,7 @@ module LoginVerification #check bank integration used def bank_integration - bank_integration = Lookup.where("shop_code='#{@current_shop.shop_code}'").collection_of('bank_integration') + bank_integration = Lookup.collection_of('bank_integration') status = false if !bank_integration.empty? bank_integration.each do |bank| @@ -86,7 +86,7 @@ module LoginVerification if (token) #@current_user = User.find_by(api_key: token) #Rails.logger.debug "token - " + token.to_s - @user = Employee.authenticate_by_token(token,@current_shop) + @user = Employee.authenticate_by_token(token) if @user return true #Maybe log - login? @@ -94,21 +94,6 @@ module LoginVerification end end - def authenticate_session_token - shop_code = 262 - if (shop_code) - #@current_user = User.find_by(api_key: token) - #Rails.logger.debug "token - " + token.to_s - @current_shop = Shop.find_by_shop_code(shop_code) - if @current_shop - return true - #Maybe log - login? - end - else - @current_shop = Shop.first - end - end - def render_unauthorized redirect_to root_path end diff --git a/app/controllers/foodcourt/addorders_controller.rb b/app/controllers/foodcourt/addorders_controller.rb index 7960c2f9..b0ea689d 100755 --- a/app/controllers/foodcourt/addorders_controller.rb +++ b/app/controllers/foodcourt/addorders_controller.rb @@ -136,7 +136,7 @@ class Foodcourt::AddordersController < BaseFoodcourtController @order.new_booking = true @order.waiters = current_login_employee.name @order.employee_name = current_login_employee.name - @order.shop_code =@shop.shop_code + @order.shop_code = Shop.current_shop.shop_code @order.is_extra_time = is_extra_time @order.extra_time = extra_time diff --git a/app/controllers/foodcourt/dashboard_controller.rb b/app/controllers/foodcourt/dashboard_controller.rb index 9fd19ec7..4f6c5627 100644 --- a/app/controllers/foodcourt/dashboard_controller.rb +++ b/app/controllers/foodcourt/dashboard_controller.rb @@ -102,7 +102,7 @@ class Foodcourt::DashboardController < BaseFoodcourtController end def get_all_menu - @menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all.where("shop_code='#{@shop.shop_code}'") + @menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all @item_attributes = MenuItemAttribute.all.load @item_options = MenuItemOption.all.load end diff --git a/app/controllers/foodcourt/food_court_controller.rb b/app/controllers/foodcourt/food_court_controller.rb index a02d7b89..365bbc4b 100644 --- a/app/controllers/foodcourt/food_court_controller.rb +++ b/app/controllers/foodcourt/food_court_controller.rb @@ -17,14 +17,15 @@ class Foodcourt::FoodCourtController < ApplicationController # @menus = Menu.all # @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') # end - @zone = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true") + shop = Shop.current_shop + @zone = Zone.all.where("is_active= true") @customer = Customer.all - @tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') - @rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') + @tables = Table.all.active.order('status desc') + @rooms = Room.all.active.order('status desc') @cashier_type = "food_court" #checked quick_service only @quick_service_only = true - lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier') + lookup_dine_in = Lookup.collection_of('dinein_cashier') if !lookup_dine_in.empty? lookup_dine_in.each do |dine_in| if dine_in[0].downcase == "dineincashier" diff --git a/app/controllers/foodcourt/payments_controller.rb b/app/controllers/foodcourt/payments_controller.rb index c313b972..5bfa1291 100755 --- a/app/controllers/foodcourt/payments_controller.rb +++ b/app/controllers/foodcourt/payments_controller.rb @@ -19,7 +19,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController #shop_detail = Shop.first # rounding adjustment if !path.include? ("credit_payment") - if @shop.is_rounding_adj + if Shop.current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(saleObj.grand_total) rounding_adj = new_total - saleObj.grand_total saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0 @@ -63,7 +63,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController # For Print # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server - receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf unique_code = "ReceiptBillPdf" print_settings = PrintSetting.all if !print_settings.nil? @@ -91,7 +91,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController customer= Customer.find(saleObj.customer_id) # get member information - rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + rebate = MembershipSetting.find_by_rebate(1) credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote') if customer.membership_id != nil && rebate && credit_data.nil? @@ -146,14 +146,14 @@ class Foodcourt::PaymentsController < BaseFoodcourtController card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id) # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) other_amount = SaleItem.calculate_other_charges(sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) #end end @@ -170,7 +170,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController end def show - display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code) + display_type = Lookup.find_by_lookup_type("display_type") if !display_type.nil? && display_type.value.to_i ==2 @display_type = display_type.value else @@ -190,7 +190,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController @sale_payment = SalePayment.get_credit_amount_due_left(sale_id) end - @member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code) + @member_discount = MembershipSetting.find_by_discount(1) @membership_rebate_balance=0 if Sale.exists?(sale_id) @@ -215,17 +215,17 @@ class Foodcourt::PaymentsController < BaseFoodcourtController @dining = '' @other_payment = 0.0 @pdf_view = nil - @lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",@shop.shop_code) + @lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView") if !@lookup_pdf.nil? @pdf_view = @lookup_pdf.value end - amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop) + amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,Shop.current_shop) @kbz_pay_amount += amount.to_f #for changable on/off @changable_tax = true - lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax') + 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" @@ -267,7 +267,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController #end rounding adjustment # rounding adjustment - if @shop.is_rounding_adj + if Shop.current_shop.is_rounding_adj a = saleObj.grand_total % 25 # Modulus b = saleObj.grand_total / 25 # Division #not calculate rounding if modulus is 0 and division is even @@ -293,7 +293,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController #get customer amount @customer = Customer.find(@sale_data.customer_id) # accounts = @customer.tax_profiles - accounts = TaxProfile.where("group_type = ? and shop_code='#{@shop.shop_code}'",@cashier_type).order("order_by ASC") + accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC") @account_arr =[] @tax_arr =[] accounts.each do |acc| @@ -307,7 +307,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController @account_arr.push(sale_tax) end end - rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + rebate = MembershipSetting.find_by_rebate(1) # get member information if @customer.membership_id != nil && rebate response = Customer.get_member_account(@customer) @@ -469,7 +469,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) result = { :status => true, @@ -544,7 +544,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController #shop detail #shop_detail = Shop.first - printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") + printer = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'") unique_code="ReceiptBillPdf" if !printer.empty? @@ -559,7 +559,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController end end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) @@ -568,7 +568,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil) result = { :status => true, :filepath => filename, @@ -603,7 +603,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController saleObj = Sale.find(params[:sale_id]) - if @shop.is_rounding_adj + if Shop.current_shop.is_rounding_adj a = saleObj.grand_total % 25 # Modulus b = saleObj.grand_total / 25 # Division #not calculate rounding if modulus is 0 and division is even @@ -626,9 +626,9 @@ class Foodcourt::PaymentsController < BaseFoodcourtController if cashier_type.strip.downcase == "doemal_order" unique_code = "ReceiptBillOrderPdf" else - receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf unique_code = "ReceiptBillPdf" - print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'") + print_settings = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'") if !print_settings.nil? print_settings.each do |setting| if setting.unique_code == 'ReceiptBillPdf' @@ -651,7 +651,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController end end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code) printer = Printer::ReceiptPrinter.new(print_settings) printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name) diff --git a/app/controllers/foodcourt/shifts_controller.rb b/app/controllers/foodcourt/shifts_controller.rb index d0048dbf..8ecff4d2 100755 --- a/app/controllers/foodcourt/shifts_controller.rb +++ b/app/controllers/foodcourt/shifts_controller.rb @@ -6,7 +6,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController @cashier_type = params[:type] @shift = ShiftSale.current_open_shift(current_user) #for bank integration - bank_integration = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('bank_integration') + bank_integration = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of('bank_integration') @bank_integration = 0 if !bank_integration[0].nil? @bank_integration = bank_integration[0][1] @@ -16,7 +16,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController def new @float = Lookup.where('lookup_type=?','float_value') - @terminal = CashierTerminal.available.where("shop_code='#{@shop.shop_code}'") + @terminal = CashierTerminal.available.where("shop_code='#{Shop.current_shop.shop_code}'") end def create @@ -56,7 +56,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController cashier_terminal.save #add shift_sale_id to card_settle_trans - bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',@shop.shop_code) + bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',Shop.current_shop.shop_code) if !bank_integration.nil? card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL']) @@ -74,7 +74,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController # if !close_cashier_print[0].nil? # @close_cashier_print = close_cashier_print[0][1] # end - close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") + close_cashier_pdf = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of("print_settings") unique_code = "CloseCashierPdf" if !close_cashier_pdf.empty? @@ -92,13 +92,13 @@ class Foodcourt::ShiftsController < BaseFoodcourtController #get tax shift_obj = ShiftSale.where('id =?',@shift.id) sale_items = '' - @lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code) + @lookup = Lookup.shift_sale_items_lookup_value(Shop.current_shop.shop_code) if @lookup.to_i == 1 @sale_items = Sale.get_shift_sale_items(@shift.id) other_charges = Sale.get_other_charges() @total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift) end - @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'") + @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{Shop.current_shop.shop_code}'") @total_waste = Sale.get_total_waste(shift_id).sum(:grand_total) @total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total) #other payment details for mpu or visa like card @@ -129,7 +129,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController end end end - Employee.logout(@shop,session[:session_token]) + Employee.logout(session[:session_token]) session[:session_token] = nil end @@ -143,7 +143,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController if @shift #get tax shift_obj = ShiftSale.where('id =?',@shift.id) - @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'") + @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{Shop.current_shop.shop_code}'") #other payment details for mpu or visa like card @other_payment = ShiftSale.get_by_shift_other_payment(@shift) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 6a9d0d42..772710df 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -18,8 +18,9 @@ class HomeController < ApplicationController def index # @employees = Employee.all_emp_except_waiter.order("name asc") - @employees = Employee.all.where("shop_code='#{@current_shop.shop_code}' and is_active = true").order("name asc") - @roles = Employee.where("shop_code='#{@current_shop.shop_code}'").distinct.pluck(:role) + shop = Shop.current_shop + @employees = Employee.all.where("shop_code='#{shop.shop_code}' and is_active = true").order("name asc") + @roles = Employee.where("shop_code='#{shop.shop_code}'").distinct.pluck(:role) # byebug # @roles = Lookup.collection_of("employee_roles") @@ -52,7 +53,7 @@ class HomeController < ApplicationController @login_form = LoginForm.new() @login_form.emp_id = params[:login_form][:emp_id] @login_form.password = params[:login_form][:password] - @employee = Employee.login(current_shop,@login_form.emp_id, @login_form.password) + @employee = Employee.login(@login_form.emp_id, @login_form.password) if @employee != nil if @employee.is_active @@ -169,7 +170,7 @@ class HomeController < ApplicationController def destroy # clear in employee session - Employee.logout(current_shop,session[:session_token]) + Employee.logout(session[:session_token]) session[:session_token] = nil # redirect_to root_path render :json => {:status=> "Success", :url => root_path }.to_json diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 32aec47b..9670ee23 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -131,7 +131,7 @@ class Origami::AddordersController < BaseOrigamiController @order.new_booking = true @order.waiters = current_login_employee.name @order.employee_name = current_login_employee.name - @order.shop_code =@shop.shop_code + @order.shop_code = Shop.current_shop.shop_code @order.is_extra_time = is_extra_time @order.extra_time = extra_time diff --git a/app/controllers/origami/food_court_controller.rb b/app/controllers/origami/food_court_controller.rb index 16766001..b44ac29b 100644 --- a/app/controllers/origami/food_court_controller.rb +++ b/app/controllers/origami/food_court_controller.rb @@ -17,14 +17,15 @@ class Origami::FoodCourtController < ApplicationController # @menus = Menu.all # @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') # end - @zone = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true") + shop = Shop.current_shop + @zone = Zone.all.where("shop_code='#{shop.shop_code}' and is_active= true") @customer = Customer.all - @tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') - @rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') + @tables = Table.all.active.where("shop_code='#{shop.shop_code}'").order('status desc') + @rooms = Room.all.active.where("shop_code='#{shop.shop_code}'").order('status desc') @cashier_type = "food_court" #checked quick_service only @quick_service_only = true - lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier') + lookup_dine_in = Lookup.where("shop_code='#{shop.shop_code}'").collection_of('dinein_cashier') if !lookup_dine_in.empty? lookup_dine_in.each do |dine_in| if dine_in[0].downcase == "dineincashier" diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 81803db6..271daf3b 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -32,7 +32,7 @@ class Origami::PaymentsController < BaseOrigamiController end # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server - receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf + receipt_bill_a5_pdf = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf # Print for First Bill to Customer unique_code = "ReceiptBillPdf" print_settings = PrintSetting.all @@ -63,7 +63,7 @@ class Origami::PaymentsController < BaseOrigamiController # customer= Customer.where('customer_id=' +.customer_id) customer = Customer.find(sale_data.customer_id) # rounding adjustment - if @shop.is_rounding_adj + if Shop.current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) rounding_adj = new_total - sale_data.grand_total sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0 @@ -76,14 +76,14 @@ class Origami::PaymentsController < BaseOrigamiController remark = "#{action_by} print out first bill for Receipt No #{sale_data.receipt_no}" sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type ) # get member information - rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + rebate = MembershipSetting.find_by_rebate_and_shop_code(1,Shop.current_shop.shop_code) if customer.membership_id != nil && rebate # member_info = Customer.get_member_account(customer) # current_balance = SaleAudit.paymal_search(sale_id) current_balance = 0 end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code) # find order id by sale id # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) @@ -99,7 +99,7 @@ class Origami::PaymentsController < BaseOrigamiController #TODO :: KBZPAY ( QR ) # On/Off setting ( show or not qr ) # qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD" - kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY,:shop_code => @shop.shop_code).last + kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY,:shop_code => Shop.current_shop.shop_code).last status = false qr = nil @@ -113,7 +113,7 @@ class Origami::PaymentsController < BaseOrigamiController end end - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt",current_balance,nil,other_amount,nil,nil,nil,nil) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, Shop.current_shop, "Frt",current_balance,nil,other_amount,nil,nil,nil,nil) result = { :filepath => filename, @@ -144,7 +144,7 @@ class Origami::PaymentsController < BaseOrigamiController #shop_detail = Shop.current_shop # rounding adjustment if !path.include? ("credit_payment") - if @shop.is_rounding_adj + if Shop.current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(saleObj.grand_total) rounding_adj = new_total - saleObj.grand_total saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0 @@ -198,7 +198,7 @@ class Origami::PaymentsController < BaseOrigamiController # For Print # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server - receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf + receipt_bill_a5_pdf = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf unique_code = "ReceiptBillPdf" print_settings = PrintSetting.all if !print_settings.nil? @@ -226,7 +226,7 @@ class Origami::PaymentsController < BaseOrigamiController customer= Customer.find(saleObj.customer_id) # get member information - rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + rebate = MembershipSetting.find_by_rebate_and_shop_code(1,Shop.current_shop.shop_code) credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote') if customer.membership_id != nil && rebate && credit_data.nil? @@ -281,14 +281,14 @@ class Origami::PaymentsController < BaseOrigamiController card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id) # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) other_amount = SaleItem.calculate_other_charges(sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) #end end @@ -313,7 +313,7 @@ class Origami::PaymentsController < BaseOrigamiController # end def show - display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code) + display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",Shop.current_shop.shop_code) if !display_type.nil? && display_type.value.to_i ==2 @display_type = display_type.value else @@ -333,7 +333,7 @@ class Origami::PaymentsController < BaseOrigamiController @sale_payment = SalePayment.get_credit_amount_due_left(sale_id) end - @member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code) + @member_discount = MembershipSetting.find_by_discount_and_shop_code(1,Shop.current_shop.shop_code) @membership_rebate_balance=0 if Sale.exists?(sale_id) @@ -358,17 +358,17 @@ class Origami::PaymentsController < BaseOrigamiController @dining = '' @other_payment = 0.0 @pdf_view = nil - @lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",@shop.shop_code) + @lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",Shop.current_shop.shop_code) if !@lookup_pdf.nil? @pdf_view = @lookup_pdf.value end - amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop) + amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,Shop.current_shop) @kbz_pay_amount += amount.to_f #for changable on/off @changable_tax = true - lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax') + lookup_changable_tax = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of('changable_tax') if !lookup_changable_tax.empty? lookup_changable_tax.each do |changable_tax| if changable_tax[0].downcase == "change" @@ -410,7 +410,7 @@ class Origami::PaymentsController < BaseOrigamiController #end rounding adjustment # rounding adjustment - if @shop.is_rounding_adj + if Shop.current_shop.is_rounding_adj a = saleObj.grand_total % 25 # Modulus b = saleObj.grand_total / 25 # Division #not calculate rounding if modulus is 0 and division is even @@ -436,7 +436,7 @@ class Origami::PaymentsController < BaseOrigamiController #get customer amount @customer = Customer.find(@sale_data.customer_id) # accounts = @customer.tax_profiles - accounts = TaxProfile.where("group_type = ? and shop_code='#{@shop.shop_code}'",@cashier_type).order("order_by ASC") + accounts = TaxProfile.where("group_type = ? and shop_code='#{Shop.current_shop.shop_code}'",@cashier_type).order("order_by ASC") @account_arr =[] @tax_arr =[] accounts.each do |acc| @@ -450,7 +450,7 @@ class Origami::PaymentsController < BaseOrigamiController @account_arr.push(sale_tax) end end - rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + rebate = MembershipSetting.find_by_rebate_and_shop_code(1,Shop.current_shop.shop_code) # get member information if @customer.membership_id != nil && rebate response = Customer.get_member_account(@customer) @@ -612,7 +612,7 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) result = { :status => true, @@ -703,7 +703,7 @@ class Origami::PaymentsController < BaseOrigamiController end end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) @@ -712,7 +712,7 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil) result = { :status => true, :filepath => filename, @@ -747,7 +747,7 @@ class Origami::PaymentsController < BaseOrigamiController saleObj = Sale.find(params[:sale_id]) - if @shop.is_rounding_adj + if Shop.current_shop.is_rounding_adj a = saleObj.grand_total % 25 # Modulus b = saleObj.grand_total / 25 # Division #not calculate rounding if modulus is 0 and division is even @@ -770,9 +770,9 @@ class Origami::PaymentsController < BaseOrigamiController if cashier_type.strip.downcase == "doemal_order" unique_code = "ReceiptBillOrderPdf" else - receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf + receipt_bill_a5_pdf = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf unique_code = "ReceiptBillPdf" - print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'") + print_settings = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'") if !print_settings.nil? print_settings.each do |setting| if setting.unique_code == 'ReceiptBillPdf' @@ -795,7 +795,7 @@ class Origami::PaymentsController < BaseOrigamiController end end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code) printer = Printer::ReceiptPrinter.new(print_settings) printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name) diff --git a/app/controllers/settings/cashier_terminals_controller.rb b/app/controllers/settings/cashier_terminals_controller.rb index bb57eb64..987674d5 100755 --- a/app/controllers/settings/cashier_terminals_controller.rb +++ b/app/controllers/settings/cashier_terminals_controller.rb @@ -5,7 +5,7 @@ class Settings::CashierTerminalsController < ApplicationController # GET /settings/cashier_terminals # GET /settings/cashier_terminals.json def index - @settings_cashier_terminals = CashierTerminal.where("shop_code=?",@shop.shop_code) + @settings_cashier_terminals = CashierTerminal.where("shop_code=?",Shop.current_shop.shop_code) end # GET /settings/cashier_terminals/1 diff --git a/app/models/employee.rb b/app/models/employee.rb index 67aad0f6..f27adf29 100755 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -3,6 +3,7 @@ class Employee < ApplicationRecord has_many :commissioners has_many :shit_sales belongs_to :order_queue_station + validates_presence_of :name, :role validates_presence_of :password, :on => [:create] validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true @@ -19,9 +20,9 @@ class Employee < ApplicationRecord Employee.select("id, name").map { |e| [e.name, e.id] } end - def self.login(shop,emp_id, password) - user = Employee.find_by_emp_id_and_shop_code(emp_id,shop.shop_code) - expiry_time = login_expiry_time(shop) + def self.login(emp_id, password) + user = Employee.find_by_emp_id(emp_id) + expiry_time = login_expiry_time if (user) #user.authenticate(password) if (user.authenticate(password)) @@ -36,10 +37,10 @@ class Employee < ApplicationRecord end - def self.authenticate_by_token(session_token,shop) + def self.authenticate_by_token(session_token) if (session_token) - user = Employee.find_by_token_session_and_shop_code(session_token,shop.shop_code) - expiry_time = login_expiry_time(shop) + user = Employee.find_by_token_session(session_token) + expiry_time = login_expiry_time if user && user.session_expiry.utc > DateTime.now.utc #Extend the login time each time authenticatation take place @@ -54,9 +55,9 @@ class Employee < ApplicationRecord return false end - def self.logout(shop,session_token) + def self.logout(session_token) if (session_token) - user = Employee.find_by_token_session_and_shop_code(session_token,shop.shop_code) + user = Employee.find_by_token_session(session_token) if user user.token_session = nil @@ -72,9 +73,9 @@ class Employee < ApplicationRecord retry end - def self.login_expiry_time(shop) + def self.login_expiry_time expiry_time = 30 - login_expiry = Lookup.where("shop_code='#{shop.shop_code}'").collection_of('expiry_time') + login_expiry = Lookup.collection_of('expiry_time') if !login_expiry.empty? login_expiry.each do |exp_time| if exp_time[0].downcase == "login" diff --git a/app/models/inventory_definition.rb b/app/models/inventory_definition.rb index c27dc64c..fb00113a 100755 --- a/app/models/inventory_definition.rb +++ b/app/models/inventory_definition.rb @@ -25,8 +25,8 @@ class InventoryDefinition < ApplicationRecord def self.find_product_in_inventory(item) - if product = InventoryDefinition.find_by_item_code_and_shop_code(item.item_instance_code,shop_code) - if stock_check_item = StockCheckItem.find_by_item_code_and_shop_code(item.item_instance_code,shop_code) + if product = InventoryDefinition.find_by_item_code_and_shop_code(item.item_instance_code,Shop.current_shop.shop_code) + if stock_check_item = StockCheckItem.find_by_item_code_and_shop_code(item.item_instance_code,Shop.current_shop.shop_code) return true, product end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 6c656739..66ed469a 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1585,7 +1585,6 @@ end def self.top_bottom_products(current_user,from,to,type,current_shop) - puts @current_shop query = Sale.joins("JOIN sale_items ON sale_items.sale_id = sales.sale_id") .completed .where("qty > 0 AND price > 0 AND shop_code='#{current_shop.shop_code}'") @@ -1768,7 +1767,6 @@ end query = Sale.select("SUM(sale_payments.payment_amount) - CASE WHEN sale_payments.payment_method = 'creditnote' THEN IFNULL(SUM(payments_for_credits.payment_amount), 0) ELSE ABS(SUM(CASE WHEN sale_payments.outstanding_amount < 0 THEN sale_payments.outstanding_amount ELSE 0 END)) END AS payment_amount") .joins(:sale_payments) .joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sales.sale_id") - .where("sales.shop_code='#{shop.shop_code}'") .completed if payment_method == 'card' diff --git a/app/uploaders/employee_image_uploader.rb b/app/uploaders/employee_image_uploader.rb index 62aa3e15..eed8c04f 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.current_shop.shop_code.nil? + # if Shop.current_shop.shop_code.nil? "#{original_filename}" if original_filename.present? - else + # else "#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present? - end + # end end # def cache_dir diff --git a/app/views/layouts/login_dashboard.html.erb b/app/views/layouts/login_dashboard.html.erb index 01dff3c0..9edc81bc 100755 --- a/app/views/layouts/login_dashboard.html.erb +++ b/app/views/layouts/login_dashboard.html.erb @@ -68,7 +68,7 @@
- <%= @current_shop.name %> + <%= Shop.current_shop.name rescue "" %>
diff --git a/dump.rdb b/dump.rdb index 69737e26ff408ca05d0737b209759b9137480b76..a68175fafab144fc16d0593815907ec4f4fb994e 100644 GIT binary patch delta 169 zcmX@XcY<$%f!50JPh)>^loqF^=;o&89{RABkKrG~Z&3yYzT%R^603ru{N&VPpzHzm z$sgIo1dS{YFfed~rP2~Jb5c_#u9IZ5&^0hRz&M$M(PgqcyVS%F?30%;3Qs=ACJV%1 zHjAaMf#K#GjNe!$H#15B)f*cgV3^qC!Dt55KKV6J;Vwqm$x7^!ljk$CPTVLqF`kX{ O|KE2DT+YqZZUzAJW~fRk7{%EvbPbFSFiy^7 z^AIpNz`(#=T#{H~m6n*9lbSO5Je$NMMpi*SuvkG+esXFt(3}J86BoEl%wwN?iA{L2 zKO@`3X7S0MY*H-dx<+O|EoO{nn}Zp@u}qd=l%0H Date: Tue, 3 Dec 2019 14:07:58 +0630 Subject: [PATCH 32/54] puma --- config/puma.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/config/puma.rb b/config/puma.rb index f0013d25..d24425ae 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,11 +1,11 @@ -# application_path="#{File.expand_path("../..", __FILE__)}" -# directory application_path -# #environment ENV.fetch("RAILS_ENV") { "production" } -# environment "production" -# pidfile "#{application_path}/tmp/puma/pid" -# state_path "#{application_path}/tmp/puma/state" -# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -# port ENV.fetch("PORT") { 62158 } -# workers 2 -# preload_app! -# threads 1,1 +application_path="#{File.expand_path("../..", __FILE__)}" +directory application_path +#environment ENV.fetch("RAILS_ENV") { "production" } +environment "production" +pidfile "#{application_path}/tmp/puma/pid" +state_path "#{application_path}/tmp/puma/state" +stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +port ENV.fetch("PORT") { 62158 } +workers 2 +preload_app! +threads 1,1 From 23b5d0d344a0eb0251b1235e112950509bb567f8 Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 3 Dec 2019 14:20:09 +0630 Subject: [PATCH 33/54] foodcourt/customers --- app/controllers/foodcourt/customers_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/foodcourt/customers_controller.rb b/app/controllers/foodcourt/customers_controller.rb index 853d58c0..316b9837 100644 --- a/app/controllers/foodcourt/customers_controller.rb +++ b/app/controllers/foodcourt/customers_controller.rb @@ -92,12 +92,12 @@ class Foodcourt::CustomersController < BaseFoodcourtController # if flash["errors"] # @crm_customer.valid? # end - @membership_types = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("member_group_type") + @membership_types = Lookup.collection_of("member_group_type") #get paypar accountno @paypar_accountno = Customer.where("paypar_account_no IS NOT NULL AND paypar_account_no != ''").pluck("paypar_account_no") #for create customer on/off @create_flag = true - lookup_customer = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('customer_settings') + lookup_customer = Lookup.collection_of('customer_settings') if !lookup_customer.empty? lookup_customer.each do |create_setting| if create_setting[0].downcase == "create" @@ -168,9 +168,9 @@ class Foodcourt::CustomersController < BaseFoodcourtController sale = Sale.find_by_receipt_no(receipt_no) @out = [] action_by = current_user.name - membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code) + membership_setting = MembershipSetting.find_by_membership_type("paypar_url") if membership_setting.gateway_url - member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code) + member_actions =MembershipAction.find_by_membership_type("get_account_balance") if member_actions.gateway_url @campaign_type_id = nil url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s From 78838a77185e9001c4402f26bf452ab67b09dd9e Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 3 Dec 2019 14:54:53 +0630 Subject: [PATCH 34/54] current shop --- app/controllers/api/authenticate_controller.rb | 4 ++-- app/controllers/api/bill_controller.rb | 2 +- .../api/payment/mobilepayment_controller.rb | 2 +- app/controllers/api/survey_controller.rb | 4 ++-- app/controllers/base_crm_controller.rb | 2 +- app/controllers/crm/customers_controller.rb | 6 +++--- app/controllers/crm/dining_queues_controller.rb | 13 ++++++------- app/controllers/foodcourt/addorders_controller.rb | 12 ++++++------ app/controllers/foodcourt/cash_ins_controller.rb | 4 ++-- app/controllers/foodcourt/cash_outs_controller.rb | 4 ++-- app/controllers/foodcourt/dashboard_controller.rb | 3 ++- app/controllers/foodcourt/discounts_controller.rb | 4 ++-- app/controllers/foodcourt/food_court_controller.rb | 2 +- app/controllers/foodcourt/home_controller.rb | 3 ++- .../inventory/stock_checks_controller.rb | 6 +++--- app/controllers/print_settings_controller.rb | 8 ++++---- app/views/origami/surveys/_form.html.erb | 8 ++++---- 17 files changed, 44 insertions(+), 43 deletions(-) diff --git a/app/controllers/api/authenticate_controller.rb b/app/controllers/api/authenticate_controller.rb index 8816b7af..6bd15a28 100755 --- a/app/controllers/api/authenticate_controller.rb +++ b/app/controllers/api/authenticate_controller.rb @@ -1,13 +1,13 @@ class Api::AuthenticateController < Api::ApiController skip_before_action :authenticate - before_action :find_shop + # before_action :find_shop def create emp_id = params[:emp_id] password = params[:password] if emp_id && password - @employee = Employee.login(@shop, emp_id, password) + @employee = Employee.login(emp_id, password) if @employee && @employee.role == "waiter" render json: JSON.generate({:status => true, :session_token => @employee.token_session, :name => @employee.name, :role => @employee.role}) else diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index b3742d44..22f1ede8 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -6,7 +6,7 @@ class Api::BillController < Api::ApiController @status = false @error_message = "Order ID or Booking ID is require to request for a bill." # if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id) - if !ShiftSale.current_shift(@shop.shop_code).nil? + if !ShiftSale.current_shift(Shop.current_shop.shop_code).nil? #create Bill by Booking ID table = 0 if (params[:booking_id]) diff --git a/app/controllers/api/payment/mobilepayment_controller.rb b/app/controllers/api/payment/mobilepayment_controller.rb index 7608f722..24461ae9 100644 --- a/app/controllers/api/payment/mobilepayment_controller.rb +++ b/app/controllers/api/payment/mobilepayment_controller.rb @@ -19,7 +19,7 @@ class Api::Payment::MobilepaymentController < Api::ApiController # rounding adjustment if !path.include? ("credit_payment") - if @shop.is_rounding_adj + if shop_detail.is_rounding_adj a = saleObj.grand_total % 25 # Modulus b = saleObj.grand_total / 25 # Division #not calculate rounding if modulus is 0 and division is even diff --git a/app/controllers/api/survey_controller.rb b/app/controllers/api/survey_controller.rb index 4736ba13..2f2da0e2 100644 --- a/app/controllers/api/survey_controller.rb +++ b/app/controllers/api/survey_controller.rb @@ -15,8 +15,8 @@ class Api::SurveyController < Api::ApiController def create dining_facility = DiningFacility.find(params[:id]) - open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''") - current_shift = ShiftSale.current_shift(@shop.shop_code) + open_cashier = Employee.where("role = 'cashier' AND token_session <> ''") + current_shift = ShiftSale.current_shift(Shop.current_shop.shop_code) current_shift_user =Employee.find_by_id(current_shift.employee_id) if open_cashier.count>0 shift_by_terminal = ShiftSale.current_open_shift(open_cashier[0]) diff --git a/app/controllers/base_crm_controller.rb b/app/controllers/base_crm_controller.rb index 08bc8138..2cf47467 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, MultiTenancy layout "CRM" before_action :check_user diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 9cd67dde..6d7783fa 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -38,7 +38,7 @@ class Crm::CustomersController < BaseCrmController @crm_customers.membership_type = response["customer_data"]["member_group_id"] @crm_customers.customer_type = "Dinein" @crm_customers.tax_profiles = ["1", "2"] - @crm_customers.shop_code = @shop.shop_code + @crm_customers.shop_code = Shop.current_shop.shop_code @crm_customers.save @crm_customers = Customer.search(filter) flash[:member_notice]='Customer was successfully created.' @@ -130,7 +130,7 @@ class Crm::CustomersController < BaseCrmController params[:type] = nil params[:customer_id] = params[:id] - @credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code) + @credit_sales = SalePayment.get_credit_sales(params,Shop.current_shop.shop_code) #get customer amount @customer = Customer.find(params[:id]) @@ -255,7 +255,7 @@ class Crm::CustomersController < BaseCrmController if @checked_contact.nil? respond_to do |format| @crm_customers = Customer.new(customer_params) - @crm_customers.shop_code = @shop.shop_code + @crm_customers.shop_code = Shop.current_shop.shop_code if @crm_customers.save # update tax profile customer = Customer.find(@crm_customers.customer_id) diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index cbb19b35..3eb6622e 100755 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -6,8 +6,8 @@ class Crm::DiningQueuesController < BaseCrmController # GET /crm/dining_queues.json def index today = DateTime.now.strftime('%Y-%m-%d') - @dining_queues = DiningQueue.where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status is NULL ", today).order("queue_no asc") - @complete_queue = DiningQueue.where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status = 'Assign' ", today).order("queue_no asc") + @dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status is NULL ", today).order("queue_no asc") + @complete_queue = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status = 'Assign' ", today).order("queue_no asc") if params[:term] @customer = Customer.order(:name).where('lower(name) LIKE ?', "%#{params[:term].downcase}%") @@ -40,7 +40,7 @@ class Crm::DiningQueuesController < BaseCrmController # POST /crm/dining_queues.json def create @dining_queue = DiningQueue.new(dining_queue_params) - @dining_queue.shop_code = @shop.shop_code + @dining_queue.shop_code = Shop.current_shop.shop_code respond_to do |format| if @dining_queue.save @@ -87,7 +87,7 @@ class Crm::DiningQueuesController < BaseCrmController def assign @queue = DiningQueue.find(params[:id]) - @tables = DiningFacility.where("status = 'available' and shop_code='#{@shop.shop_code}' and type!='HotelRoom'") + @tables = DiningFacility.where("status = 'available' and type!='HotelRoom'") respond_to do |format| format.html # index.html.erb end @@ -108,8 +108,7 @@ class Crm::DiningQueuesController < BaseCrmController :type => type, :checkin_at => Time.now.utc, :customer_id => queue.customer_id, - :booking_status => "assign", - :shop_code => @shop.shop_code}) + :booking_status => "assign"}) booking.save! status = queue.update_attributes(dining_facility_id: table_id,status:"Assign") @@ -138,7 +137,7 @@ class Crm::DiningQueuesController < BaseCrmController private # Use callbacks to share common setup or constraints between actions. def set_dining_queue - @dining_queue = DiningQueue.find_by_id_and_shop_code(params[:id],@shop.shop_code) + @dining_queue = DiningQueue.find_by_id(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/controllers/foodcourt/addorders_controller.rb b/app/controllers/foodcourt/addorders_controller.rb index b0ea689d..7abbdd90 100755 --- a/app/controllers/foodcourt/addorders_controller.rb +++ b/app/controllers/foodcourt/addorders_controller.rb @@ -7,10 +7,10 @@ class Foodcourt::AddordersController < BaseFoodcourtController @webview = true end - @tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") - @rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") - @all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc') - @all_room = Room.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc') + @tables = Table.all.active.order('zone_id asc').group("zone_id") + @rooms = Room.all.active.order('zone_id asc').group("zone_id") + @all_table = Table.all.active.order('status desc') + @all_room = Room.all.active.order('status desc') end def detail @@ -19,7 +19,7 @@ class Foodcourt::AddordersController < BaseFoodcourtController if check_mobile @webview = true end - display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code) + display_type = Lookup.find_by_lookup_type("display_type") if !display_type.nil? && display_type.value.to_i ==2 @display_type = display_type.value else @@ -233,7 +233,7 @@ class Foodcourt::AddordersController < BaseFoodcourtController #Send to background job for processing order = Order.find(order_id) - sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",@shop.shop_code) + sidekiq = Lookup.find_by_lookup_type("sidekiq") if ENV["SERVER_MODE"] != 'cloud' cup_status = `#{"sudo service cups status"}` print_status = check_cup_status(cup_status) diff --git a/app/controllers/foodcourt/cash_ins_controller.rb b/app/controllers/foodcourt/cash_ins_controller.rb index 9f96dffd..7245ffa7 100755 --- a/app/controllers/foodcourt/cash_ins_controller.rb +++ b/app/controllers/foodcourt/cash_ins_controller.rb @@ -15,13 +15,13 @@ class Foodcourt::CashInsController < BaseFoodcourtController p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user) shift = ShiftSale.current_open_shift(current_user) - current_shift = ShiftSale.current_shift(@shop.shop_code) + current_shift = ShiftSale.current_shift(Shop.current_shopshop_code) # set cashier if shift != nil shift = shift else - open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''") + open_cashier = Employee.where("role = 'cashier' AND token_session <> ''") if open_cashier.count>0 shift = ShiftSale.current_open_shift(open_cashier[0]) diff --git a/app/controllers/foodcourt/cash_outs_controller.rb b/app/controllers/foodcourt/cash_outs_controller.rb index f890f51c..1dbf62d2 100755 --- a/app/controllers/foodcourt/cash_outs_controller.rb +++ b/app/controllers/foodcourt/cash_outs_controller.rb @@ -10,13 +10,13 @@ class Foodcourt::CashOutsController < BaseFoodcourtController p_jour.cash_out(reference, remark, amount, current_user) shift = ShiftSale.current_open_shift(current_user) - current_shift = ShiftSale.current_shift(@shop.shop_code) + current_shift = ShiftSale.current_shift(Shop.current_shop.shop_code) # set cashier if shift != nil shift = shift else - open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''") + open_cashier = Employee.where("role = 'cashier' AND token_session <> ''") if open_cashier.count>0 shift = ShiftSale.current_open_shift(open_cashier[0]) diff --git a/app/controllers/foodcourt/dashboard_controller.rb b/app/controllers/foodcourt/dashboard_controller.rb index 4f6c5627..23c905b7 100644 --- a/app/controllers/foodcourt/dashboard_controller.rb +++ b/app/controllers/foodcourt/dashboard_controller.rb @@ -3,9 +3,10 @@ class Foodcourt::DashboardController < BaseFoodcourtController def index today = DateTime.now.strftime('%Y-%m-%d') - @display_type = Lookup.where("shop_code='#{@shop.shop_code}'").find_by_lookup_type("display_type") + @display_type = Lookup.find_by_lookup_type("display_type") @sale_data = Array.new + @shop = Shop.current_shop @total_payment_methods = Sale.total_payment_methods(@shop,today,current_user) if !@total_payment_methods.nil? @total_payment_methods.each do |payment| diff --git a/app/controllers/foodcourt/discounts_controller.rb b/app/controllers/foodcourt/discounts_controller.rb index 80d30cd9..e2ef8fcc 100755 --- a/app/controllers/foodcourt/discounts_controller.rb +++ b/app/controllers/foodcourt/discounts_controller.rb @@ -21,8 +21,8 @@ class Foodcourt::DiscountsController < BaseFoodcourtController end end - @member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code) - @accounts = Account.where("shop_code='#{@shop.shop_code}'") + @member_discount = MembershipSetting.find_by_discount(1) + @accounts = Account.where("shop_code='#{Shop.current_shop.shop_code}'") end #discount page show from origami index with selected order diff --git a/app/controllers/foodcourt/food_court_controller.rb b/app/controllers/foodcourt/food_court_controller.rb index 365bbc4b..519973ae 100644 --- a/app/controllers/foodcourt/food_court_controller.rb +++ b/app/controllers/foodcourt/food_court_controller.rb @@ -157,7 +157,7 @@ class Foodcourt::FoodCourtController < ApplicationController end def get_all_product() - @product = Product..where("shop_code='#{@shop.shop_code}'") + @product = Product.where("shop_code='#{Shop.current_shop.shop_code}'") end # render json for http status code diff --git a/app/controllers/foodcourt/home_controller.rb b/app/controllers/foodcourt/home_controller.rb index 3d424f14..f894afc9 100755 --- a/app/controllers/foodcourt/home_controller.rb +++ b/app/controllers/foodcourt/home_controller.rb @@ -4,6 +4,7 @@ class Foodcourt::HomeController < BaseFoodcourtController def index @webview = check_mobile + @shop = Shop.current_shop @tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @complete = Sale.completed_sale("cashier",@shop.shop_code) @@ -19,7 +20,7 @@ class Foodcourt::HomeController < BaseFoodcourtController # get printer info @print_settings = PrintSetting.get_precision_delimiter() @webview = check_mobile - + @shop = Shop.current_shop @tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @complete = Sale.completed_sale("cashier",@shop.shop_code) diff --git a/app/controllers/inventory/stock_checks_controller.rb b/app/controllers/inventory/stock_checks_controller.rb index e753b751..fea1ff0c 100755 --- a/app/controllers/inventory/stock_checks_controller.rb +++ b/app/controllers/inventory/stock_checks_controller.rb @@ -32,15 +32,15 @@ class Inventory::StockChecksController < BaseInventoryController def save_to_journal check = params[:data] - stockCheck = StockCheck.find_by_id_and_shop_code(check,@shop.shop_code) + stockCheck = StockCheck.find_by_id(check) stockCheck.stock_check_items.each do |item| - StockJournal.from_stock_check(item,@shop) + StockJournal.from_stock_check(item,Shop.current_shop) end end def print_stock_check stock_id = params[:stock_check_id] # sale_id - stockcheck = StockCheck.find_by_id_and_shop_code(stock_id,@shop.shop_code) + stockcheck = StockCheck.find_by_id(stock_id) stockcheck_items = stockcheck.stock_check_items member_info = nil unique_code = 'StockCheckPdf' diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb index 0d8c5280..f1f6ed68 100755 --- a/app/controllers/print_settings_controller.rb +++ b/app/controllers/print_settings_controller.rb @@ -11,7 +11,7 @@ class PrintSettingsController < ApplicationController # GET /print_settings/1 # GET /print_settings/1.json def show - @lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code) + @lookup = Lookup.shift_sale_items_lookup_value(Shop.current_shop.shop_code) end # GET /print_settings/new @@ -22,7 +22,7 @@ class PrintSettingsController < ApplicationController # GET /print_settings/1/edit def edit - @lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code) + @lookup = Lookup.shift_sale_items_lookup_value(Shop.current_shop.shop_code) @server_mode = ENV["SERVER_MODE"] end @@ -30,7 +30,7 @@ class PrintSettingsController < ApplicationController # POST /print_settings.json def create @print_setting = PrintSetting.new(print_setting_params) - @print_setting.shop_code = @shop.shop_code + @print_setting.shop_code = Shop.current_shop.shop_code respond_to do |format| if @print_setting.save format.html { redirect_to @print_setting, notice: 'Print setting was successfully created.' } @@ -48,7 +48,7 @@ class PrintSettingsController < ApplicationController respond_to do |format| if @print_setting.update(print_setting_params) if @print_setting.unique_code == 'CloseCashierPdf' - Lookup.save_shift_sale_items_settings(params[:shift_sale_items],@shop.shop_code) + Lookup.save_shift_sale_items_settings(params[:shift_sale_items],Shop.current_shop.shop_code) end format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' } diff --git a/app/views/origami/surveys/_form.html.erb b/app/views/origami/surveys/_form.html.erb index a4d8a666..b7ec4ca1 100755 --- a/app/views/origami/surveys/_form.html.erb +++ b/app/views/origami/surveys/_form.html.erb @@ -99,7 +99,7 @@ ' - +'<% Lookup.where("lookup_type = ? and shop_code='#{@shop.shop_code}'", "country" ).each do |ct| %>' + +'<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>' +'' +'<%end %>' @@ -321,7 +321,7 @@ var cashier_type = "<%= @cashier_type %>"; +'
' +' ' - +'<% Lookup.where("lookup_type = ? and shop_code='#{@shop.shop_code}'", "country" ).each do |ct| %>' + +'<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>' // if (key.toString() == '<%= ct.value.to_s %>') // var selected = "selected"; // else From c8c39b06361511312a9f39354a4094c2801525f2 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Tue, 3 Dec 2019 16:15:48 +0630 Subject: [PATCH 35/54] update origami/home/index --- app/controllers/origami/home_controller.rb | 8 ++-- app/models/dining_facility.rb | 38 +++--------------- app/models/lookup.rb | 17 ++++---- app/models/sale.rb | 2 +- app/models/sale_payment.rb | 45 +++++++++------------- app/views/origami/home/index.html.erb | 8 ++-- 6 files changed, 41 insertions(+), 77 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 30a6ce92..910fedf9 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -4,8 +4,8 @@ class Origami::HomeController < BaseOrigamiController def index @webview = check_mobile - @tables = Table.unscope(:order).all.active.order('status desc') - @rooms = Room.unscope(:order).all.active.order('status desc') + @tables = Table.unscope(:order).includes(:zone).all.active.order('status desc') + @rooms = Room.unscope(:order).includes(:zone).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @@ -21,8 +21,8 @@ class Origami::HomeController < BaseOrigamiController @print_settings = PrintSetting.get_precision_delimiter() @webview = check_mobile - @tables = Table.unscope(:order).all.active.order('status desc') - @rooms = Room.unscope(:order).all.active.order('status desc') + @tables = Table.unscope(:order).includes(:zone).all.active.order('status desc') + @rooms = Room.unscope(:order).includes(:zone).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index e5f35e03..d759ba73 100755 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -33,50 +33,22 @@ class DiningFacility < ApplicationRecord def get_current_booking checkin_time_lookup = Lookup.get_checkin_time_limit - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and (CASE WHEN checkin_at > '#{DateTime.now.utc}' THEN checkin_at >= '#{DateTime.now.utc}' ELSE checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' END) and checkout_by is null").limit(1) #and checkout_at is null - # booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_by is null").limit(1) #and checkout_at is null - if booking.count > 0 then - return booking[0] - else - return nil - end + Booking.where(dining_facility_id: self.id, booking_status: 'assign', checkout_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago).first #and checkout_at is null end def get_moved_booking checkin_time_lookup = Lookup.get_checkin_time_limit - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) - - if booking.count > 0 then - return booking[0] - else - return nil - end + Booking.where(dining_facility_id: self.id, booking_status: 'moved', checkout_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago).first end def get_new_booking # query for new - # if status - # to ask when req bill booking_status? - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and sale_id is null and checkout_at is null").limit(1) - # else - # booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and sale_id not null").limit(1) - # end - - if booking.count > 0 then - return booking[0].booking_id - else - return nil - end + Booking.where(dining_facility_id: self.id, booking_status: 'assign', sale_id: nil, checkout_at: nil).first end def get_current_checkout_booking checkin_time_lookup = Lookup.get_checkin_time_limit - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null").limit(1) - if booking.count > 0 then - return booking[0] - else - return nil - end + Booking.where(dining_facility_id: self.id, booking_status: 'assign', checkout_at: nil).where.not(reserved_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago).first end def get_checkout_booking @@ -119,7 +91,7 @@ class DiningFacility < ApplicationRecord def self.get_checkin_booking checkin_time_lookup = Lookup.get_checkin_time_limit - bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null") + bookings = Booking.where(booking_status: 'assign', checkout_at: nil).where.not(reserved_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago) arr_booking = Array.new if bookings lookup_checkout_time = Lookup.collection_of("checkout_alert_time") diff --git a/app/models/lookup.rb b/app/models/lookup.rb index 5b45822c..ac7bd6da 100755 --- a/app/models/lookup.rb +++ b/app/models/lookup.rb @@ -4,6 +4,8 @@ class Lookup < ApplicationRecord scope :number_formats, -> { where(lookup_type: 'number_format')} + TIME_LIMIT = 5 + def available_types {'Employee Roles' => 'employee_roles', 'Dining Facilities Status' => 'dining_facilities_status', @@ -23,15 +25,13 @@ class Lookup < ApplicationRecord # Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] } # end + def self.time_limit + TIME_LIMIT + end + def self.get_checkin_time_limit - time_limit = 5 - - lookup = Lookup.find_by_lookup_type('checkin_time_limit') - if !lookup.nil? - time_limit = lookup.value.to_i - end - - return time_limit + return RequestStore[:checkin_time_limit] if RequestStore[:checkin_time_limit] + RequestStore[:checkin_time_limit] = Lookup.find_by_lookup_type('checkin_time_limit').value.to_i rescue time_limit end def self.sync_url @@ -58,7 +58,6 @@ class Lookup < ApplicationRecord def self.collection_of(type) Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] } - end def self.create_shift_sale_lookup diff --git a/app/models/sale.rb b/app/models/sale.rb index 59d3683b..c7a05189 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -2025,7 +2025,7 @@ end query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id") .joins("join orders as orders on orders.order_id = sale_orders.order_id") query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' #{type}") - query = query.where("DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? ",DateTime.now.strftime('%Y-%m-%d')) + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) .group("sales.sale_id") end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index c48b4a6b..631ede89 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -960,37 +960,30 @@ class SalePayment < ApplicationRecord #credit payment query def self.get_credit_sales(params) - receipt_no = "" - customer = "" - if !params["receipt_no"].blank? - receipt_no = " and s.receipt_no LIKE '%#{params["receipt_no"]}%'" + payments = SalePayment.select("sale_payments.sale_id, sale_payments.sale_payment_id, sale_payments.payment_method, sale_payments.payment_amount") + .select("SUM(sale_payments.payment_amount) OVER (PARTITION BY sale_payments.sale_id) total_payment_amount") + + credit_sales = Sale.select("sales.sale_id, sales.receipt_no, sales.receipt_date as sale_date, sales.cashier_name") + .select("sale_payments.sale_payment_id, sale_payments.payment_amount").select("customers.name as customer_name") + .joins("JOIN (#{payments.to_sql}) AS sale_payments ON sale_payments.sale_id = sales.sale_id").joins(:customer).joins(:orders) + .completed.paid.where("sale_payments.payment_method = 'creditnote' AND sales.grand_total > sale_payments.total_payment_amount - sale_payments.payment_amount") + .group(:receipt_no) + .order(:receipt_date).order(:receipt_no) + + if params["receipt_no"].present? + credit_sales = credit_sales.where("sales.receipt_no LIKE ?", "%#{params["receipt_no"]}%") end - if !params["customer_id"].blank? - customer = " and s.customer_id = '#{params["customer_id"]}'" + if params["customer_id"].present? + credit_sales = credit_sales.where("sales.customer_id = ?", params["customer_id"]) end - order_source_query = "(select orders.source FROM orders JOIN sale_orders so ON so.order_id=orders.order_id WHERE so.sale_id=s.sale_id GROUP BY so.sale_id)" - - query = SalePayment.select("s.receipt_no, sale_payments.sale_payment_id, - sale_payments.payment_method, - SUM(sale_payments.payment_amount) as payment_amount, - s.receipt_date as sale_date, - s.sale_id, - s.cashier_name as cashier_name, c.name as customer_name") - .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") - .joins("INNER JOIN customers c ON c.customer_id = s.customer_id") - - if params[:type].nil? - query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") - elsif params[:type] == "cashier" - query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND #{order_source_query}='#{params[:type]}' OR #{order_source_query}='emenu' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") - else - query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND #{order_source_query}='#{params[:type]}' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") + if params[:type].present? + sources = [] + sources << params[:type] + sources << 'emenu' if params[:type] == 'cashier' + credit_sales = credit_sales.where("orders.source IN (?)", sources) end - query = query.group("s.receipt_no") - .order("s.receipt_date ASC, s.receipt_no ASC") - return query end def self.get_credit_amount_due_left(sale_id) diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index ba4da374..39c33749 100755 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -65,7 +65,7 @@ <% end %>
Table <%= table.name %> ( <%= table.seater %> Seat )
- <%= table.zone.name %> + <%= table.zone.name %>
<% end %> @@ -160,7 +160,7 @@ <%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %> <%= t("views.right_panel.detail.receipt_no") %> <%= t :cashier %> <%= t("views.right_panel.detail.name") %> - <%= t :customer %> <%= t("views.right_panel.detail.name") %> + <%= t :customer %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.credit_amount") %> @@ -338,8 +338,8 @@ function warnBeforeRedirect(linkURL,occupied_count) { text = "Are you sure you want to close cashier?"; } swal({ - title: "Alert!", - text: text, + title: "Alert!", + text: text, type: "warning", showCancelButton: true, html: true From be8cf2c34ee62dbaeac41c4936dab013317985ac Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 3 Dec 2019 16:46:52 +0630 Subject: [PATCH 36/54] api controller --- Gemfile.lock | 3 --- app/controllers/api/api_controller.rb | 4 +--- app/controllers/api/shops_controller.rb | 1 + config/puma.rb | 22 +++++++++++----------- dump.rdb | Bin 1864 -> 1864 bytes 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 730e1f37..50647fba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -380,8 +380,5 @@ 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 7b9b0cf2..22488792 100755 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -1,12 +1,10 @@ class Api::ApiController < ActionController::API - include TokenVerification, MultiTenancy + include TokenVerification include ActionController::MimeResponds before_action :core_allow helper_method :current_token, :current_login_employee, :get_cashier - before_action :core_allow - def core_allow headers['Access-Control-Allow-Origin'] = '*' headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS' diff --git a/app/controllers/api/shops_controller.rb b/app/controllers/api/shops_controller.rb index 23d50ebc..fb726e29 100644 --- a/app/controllers/api/shops_controller.rb +++ b/app/controllers/api/shops_controller.rb @@ -4,6 +4,7 @@ class Api::ShopsController < Api::ApiController def index @shops = Shop.select('id,logo,name,shop_code,address,phone_no').all + # render :json => {:name => "any name"} end def show diff --git a/config/puma.rb b/config/puma.rb index d24425ae..f0013d25 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,11 +1,11 @@ -application_path="#{File.expand_path("../..", __FILE__)}" -directory application_path -#environment ENV.fetch("RAILS_ENV") { "production" } -environment "production" -pidfile "#{application_path}/tmp/puma/pid" -state_path "#{application_path}/tmp/puma/state" -stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -port ENV.fetch("PORT") { 62158 } -workers 2 -preload_app! -threads 1,1 +# application_path="#{File.expand_path("../..", __FILE__)}" +# directory application_path +# #environment ENV.fetch("RAILS_ENV") { "production" } +# environment "production" +# pidfile "#{application_path}/tmp/puma/pid" +# state_path "#{application_path}/tmp/puma/state" +# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +# port ENV.fetch("PORT") { 62158 } +# workers 2 +# preload_app! +# threads 1,1 diff --git a/dump.rdb b/dump.rdb index a68175fafab144fc16d0593815907ec4f4fb994e..b94851f2964ddc5a569f60eaf2162701f9b6adb4 100644 GIT binary patch delta 177 zcmX@XcY<$%fw-0av)Er8rNyZ!y1A*jhd!+3WBAALTXeD_yTs&mZ0wUSu?e%7>lztM zY?Pk-oK1SNC!50Li)><(7$sONbd3!rr?Y8Id?Gd3pOI~{Kbr`fxvrtb0fvbS3@6Jo zim_Sf8W^loqF^=;o&89{RABkKrG~Z&3yYzT%R^603ru{N&VPpzHzm z$s5>2SS)mnEGM5})0n)0k!^A&qv7O@Y+{p*7{w<(mzw;6O%{mRCteX|v(z;(JixH| zGUGj#i49_tJsG8dI*kn{vodN;=4EFGicO3MlCl%8h)$d#Jy{c From fe56286c76dfd254c784e86aeeefb2f1e63d9252 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Tue, 3 Dec 2019 17:49:01 +0630 Subject: [PATCH 37/54] app order --- app/assets/javascripts/addorder.js | 18 - app/assets/javascripts/custom.js | 18 +- app/assets/javascripts/foodcourt.js | 591 ------------------ .../api/authenticate_controller.rb | 4 +- .../foodcourt/food_court_controller.rb | 7 +- .../foodcourt/orders_controller.rb | 63 +- app/models/order.rb | 14 + app/views/foodcourt/addorders/detail.html.erb | 42 +- .../orders/app_order_by_booking.html.erb | 39 -- .../foodcourt/orders/app_orders.html.erb | 145 ++++- config/initializers/assets.rb | 4 +- config/routes.rb | 4 +- server2.pid | 2 +- 13 files changed, 215 insertions(+), 736 deletions(-) delete mode 100644 app/assets/javascripts/foodcourt.js delete mode 100644 app/views/foodcourt/orders/app_order_by_booking.html.erb diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 443a30f8..c9796312 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1,23 +1,5 @@ //middle edit $(function() { - $("#loading_wrapper").show(); - getAllMenu(); - //get menu item cache - function getAllMenu(){ - $.ajax({ - type: "GET", - url: '/foodcourt/get_all_menu', - data: {}, - success:function(result){ - console.log(result) - localStorage.setItem("menus", JSON.stringify(result)); - var menu = localStorage.getItem("menus"); - if (menu != null ) { - $( "#loading_wrapper").hide(); - } - } - }); - } var role = $('#role').val(); var second_display_lookup = $("#display_type").val(); type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court"); diff --git a/app/assets/javascripts/custom.js b/app/assets/javascripts/custom.js index 6aeace1e..26e6c151 100644 --- a/app/assets/javascripts/custom.js +++ b/app/assets/javascripts/custom.js @@ -135,7 +135,7 @@ $(document).ready(function() { // var method = $(this).attr('data-method'); // var url = $(this).attr('data-ref'); // var html_text = $(this).siblings( "#delete_text" ).html(); - // //var page = url.substring(url.lastIndexOf('/') + 1); + // //var page = url.substring(url.lastIndexOf('/') + 1); // swal({ // title: "Confirmation", // text: html_text, @@ -147,11 +147,11 @@ $(document).ready(function() { // if (isConfirm) { // $.ajax({ // type: method, - // url: url , - // success: function(data) { + // url: url , + // success: function(data) { // location.href = data.url; // } - // }); + // }); // } else { // swal("Cancelled", "Your imaginary file is safe :)", "error"); // } @@ -167,7 +167,7 @@ $(document).ready(function() { var text = $("#notify_message").attr('data-message'); if (text != null || colorName != null){ - showNotification(colorName, text, placementFrom, placementAlign, animateEnter, animateExit); + showNotification(colorName, text, placementFrom, placementAlign, animateEnter, animateExit); } function showNotification(colorName, text, placementFrom, placementAlign, animateEnter, animateExit) { @@ -222,8 +222,8 @@ function audioPlayBackground(shop_code,audio){ function getOnlineOrderCount(){ var count = 0; //Start Ajax - $.ajax({ - async: false, + $.ajax({ + async: false, type: "GET", url: "/origami/get_order_info", dataType: "json", @@ -234,8 +234,8 @@ function getOnlineOrderCount(){ } } }); - //end Ajax + //end Ajax // alert(count); return count; } -/* online order count*/ \ No newline at end of file +/* online order count*/ diff --git a/app/assets/javascripts/foodcourt.js b/app/assets/javascripts/foodcourt.js deleted file mode 100644 index 9574824c..00000000 --- a/app/assets/javascripts/foodcourt.js +++ /dev/null @@ -1,591 +0,0 @@ -//= require jquery -//= require tether -//= require jquery_ujs -//= require bootstrap/js/popper.min -//= require bootstrap/js/bootstrap-material-design.min -//= require momentjs/moment -//= require bootstrap-material-datetimepicker/js/bootstrap-material-datetimepicker -//= require jquery-slimscroll/jquery.slimscroll.js -//= require bootstrap-notify/bootstrap-notify.js -//= require node-waves/waves.js -//= require sweetalert/sweetalert.min.js -//= require fileinput.min -//= require cable -//= require turbolinks -//= require BSBMaterial/turbolink_admin.js -//= require BSBMaterial/demo.js - -/* Constant Varaibles */ -_CREDIT_PAYMENTS_ = "/   CREDIT PAYMENTS"; -_CUSTOMERS_ = "/   CUSTOMERS"; -_DISCOUNTS_ = "/   DISCOUNTS"; -_IN_DUTIES_ = "/   IN DUTIES"; -_JCB_ = "/   JCB PAYMENT"; -_MASTER_ = "/   MASTER PAYMENT"; -_MPU_ = "/   MPU PAYMENT"; -_ALIPAY_ = "/   Alipay"; -_JUNCTIONPAY_ = "/   JunctionPay"; -_PAYMAL_ = "/   PAYMAL"; -_DINGA_ = "/   DINGA PAYMENT"; -_GIFT_VOUCHER_ = "/   GIFT VOUCHER"; -_OTHER_CHARGES_ = "/   CHARGES"; -_OTHER_PAYMENTS_ = "/   OTHER PAYMENT"; -_PAYMENTS_ = "/   PAYMENT"; -_PAYPAR_PAYMENT_ = "/   PAYPAR PAYMENT"; -_COMMISSIONS_ = "/   COMMISSIONS"; -_REDEEM_PAYMENT_ = "/   REDEEM PAYMENT"; -_SALE_EDIT_ = "/   SALE EDIT"; -_SPLIT_BILL_ = "/   SPLIT BILL"; -_UNION_ = "/   UNION PAYMENT"; -_VISA_ = "/   VISA PAYMENT"; -_VOUCHER_ = "/   VOUCHER"; -_SURVEY_ = "/   SURVEY"; -/* Constant Varaibles */ - -$(document).on('turbolinks:load', function() { - - $("#customer_image_path").fileinput({ - previewFileType: "image", - allowedFileExtensions: ["jpg", "gif", "png"], - browseClass: "btn btn-success", - browseLabel: "Pick Image", - browseIcon: " ", - removeClass: "btn btn-danger", - removeLabel: "Delete", - removeIcon: " ", - showUpload: false, - // uploadClass: "btn btn-info", - // uploadLabel: "Upload", - // uploadIcon: " ", - previewTemplates: { - image: '
\n' + - ' {caption}\n' + - '
\n', - } - }); - - $('.datetimepicker').bootstrapMaterialDatePicker({ - format: 'DD-MM-YYYY - HH:mm', - clearButton: true, - weekStart: 1 - }); - - $('.datepicker').bootstrapMaterialDatePicker({ - format: 'DD-MM-YYYY', - clearButton: true, - weekStart: 1, - time: false - }); - - $('.timepicker').bootstrapMaterialDatePicker({ - format: 'HH:mm', - clearButton: true, - date: false - }); - - // For selected order return - var order_status = ""; - order_status = $(".selected-item").children().find(".orders-order-status").text().substr(0,6).trim(); - - // Enable/Disable Button - //control_button(order_status); - - $(".orders").on('click', function(){ - $("#order-sub-total").text(''); - // $("#order-food").text(''); - // $("#order-beverage").text(''); - $("#order-discount").text(''); - $("#order-Tax").text(''); - $("#order-grand-total").text(''); - - var zone_name=$(this).find(".orders-table").text(); - var receipt_no=$(this).find(".orders-receipt-no").text(); - var unique_id = $(this).find(".orders-id").text(); - var order_status=$(this).find(".orders-order-status").text().trim(); - - // Enable/Disable Button - //control_button(order_status); - - var customer_id=$(this).find(".customer-id").text(); - show_customer_details(customer_id); - - $("#re-print").val(unique_id); - - var cashier=""; - var receipt_date=""; - var sub_total=0.0; - var discount_amount=0; - var tax_amount=0; - var grand_total_amount=0; - - $("#order-title").text("ORDER DETAILS - " + zone_name); - // clear order items - $("#order-items-table").children("tbody").empty(); - - // AJAX call for order - $.ajax({ - type: "POST", - url: "/origami/" + unique_id, - data: { 'booking_id' : unique_id }, - success:function(result){ - for (i = 0; i < result.length; i++) { - var data = JSON.stringify(result[i]); - var parse_data = JSON.parse(data); - var show_date = ""; - - // Receipt Header - receipt_no = result[i].receipt_no; - cashier = result[i].cashier_name; - if(result[i].receipt_date != null){ - receipt_date = new Date(result[i].receipt_date); - show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes() - } - - //Receipt Charges - sub_total += parseFloat(parse_data.price); - - discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount; - tax_amount = parse_data.tax_amount; - grand_total_amount = parse_data.grand_total_amount; - - // Ordered Items - var order_items_rows = "" + - "" + parse_data.item_name + "" + - "" + parse_data.qty + "" + - "" + parse_data.price + "" + - ""; - - $("#order-items-table").children("tbody").append(order_items_rows); - } - - // Cashier Info - $("#receipt_no").text(receipt_no); - $("#cashier").text(cashier == null ? "" : cashier); - $("#receipt_date").text(show_date); - - // Payment Info - $("#order-sub-total").text(sub_total); - // $("#order-food").text(''); - // $("#order-beverage").text(''); - $("#order-discount").text(discount_amount); - $("#order-Tax").text(tax_amount); - $("#order-grand-total").text(grand_total_amount); - } - }); - // End AJAX Call - - $('.orders').removeClass('selected-item'); - $(this).addClass('selected-item'); - }); - - // Payment for Bill - $('#pay-bill').click(function() { - var sale_id=$(".selected-item").find(".orders-id").text().substr(0,16); - if(sale_id!=""){ - window.location.href = '/origami/sale/'+ sale_id + "/payment" - } - else { - alert("Please select an order!"); - } - - return false; - }); - - $(document).on('click', '.access_modal', function(event){ - type = $(this).data("type"); - $(".ok").attr("data-action",type); - $('#AccessCodeModal').modal('show'); - }); - - $(document).on('click', '.access_number', function(event){ - if(event.handled !== true) { - var original_value = $('#access_code').val(); - var input_type = $(this).attr("data-type"); - - switch (input_type) { - case 'num': - var input_value = $(this).attr("data-value"); - if (original_value){ - $('#access_code').val(original_value + input_value); - }else{ - $('#access_code').val(original_value + input_value); - } - break; - case 'ok': - var type = $(this).attr("data-action"); - code = $('#access_code').val(); - check_emp_access_code(code,type) - break; - case 'clr': - $('#access_code').val(""); - break; - } - event.handled = true; - } else { - return false; - } - }); - - $(document).on("click", ".credit_detail",function(){ - var sale_id = $(this).attr("data-id"); - var cashier_type = $(this).attr("data-type"); - if(cashier_type=='cashier'){ - window.location.href = "/origami/cashier/credit_sales/"+sale_id; - }else{ - window.location.href = "/origami/quick_service/credit_sales/"+sale_id; - } - }); -}); - -/* start check first bill or not funs: */ -function checkReceiptNoInFirstBillData(receipt_no,payment) { - // localStorage.removeItem('receipt_lists'); - var status = false; - var json_data = []; - if((receipt_no!=undefined) && (receipt_no!="")){ - if(localStorage.hasOwnProperty("receipt_lists")===true){ - var arr_data = JSON.parse(localStorage.getItem("receipt_lists")); - if (payment) { - json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no }); - }else{ - json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); - } - - if((arr_data.length) > (json_data.length)){ - status = true; - } - } - } - - if (payment) { - if (json_data.length>0) { - return json_data[0]["payment"]; - }else{ - return false; - } - }else{ - return status; - } -} - -function createReceiptNoInFirstBillData(receipt_no,payment) { - var arr_data = []; - var json_data = []; - if(localStorage.hasOwnProperty("receipt_lists") === true){ - arr_data = JSON.parse(localStorage.getItem("receipt_lists")); - json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no }); - if (payment) { - jdata = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); - jdata.push({'receipt_no':receipt_no,'payment':payment}); - localStorage.setItem("receipt_lists",JSON.stringify(jdata)); - } - } - if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){ - arr_data.push({'receipt_no':receipt_no,'payment':payment}); - localStorage.setItem("receipt_lists",JSON.stringify(arr_data)); - } -} - -function deleteReceiptNoInFirstBillData(receipt_no) { - if(localStorage.hasOwnProperty("receipt_lists") ===true ){ - var arr_data = JSON.parse(localStorage.getItem("receipt_lists")); - var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); - localStorage.setItem("receipt_lists",JSON.stringify(json_data)); - } -} -/* end check first bill or not funs: */ - -//start CB ECR integration -//set CB com port data -function setCommPorts(comPortLists) { - var sale_id = $('#sale_id').val(); - $('#com_port_name').html(""); - var jsonPortLists = $.parseJSON(comPortLists); - // alert(jsonPortLists); - if((jsonPortLists!=undefined && jsonPortLists!='') && (jsonPortLists.length > 0)){ - $.each(jsonPortLists,function(key,value){ - $('#com_port_name').append(""); - }); - } - else{ - swal({ - title: 'Oops', - text: 'Payment device has been disconnected! Please plug it in.', - type: 'error', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment/others_payment"; - }); - } -} - -/** pay with CB bank **/ -function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no,cashier_type) { - $("#loading_wrapper").show(); - var com_port = $("#com_port_name").val(); - reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type); -} - -//add req data to card_sale_trans table -function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type) { - var jobj = {"cmd_type" : cmd_type, "payment_type" : "CARD", "amt" : bnk_bill_amount, "sale_id" : sale_id, "inv_no" : receipt_no, "com_port" : com_port}; - $.ajax({ - type: "POST", - url: "/origami/bank_integration/sale_trans", - data: {type:"request", data: jobj}, - dataType: "json", - success: function(data) { - if (data.status == "success"){ - card_sale_trans_id = data.card_sale_trans_id; - resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type); - } - } - }); -} - -//add res data to card_sale_trans table -function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type) { - - var resMsg = ""; - var card_payment_type=""; - if($("#loading_wrapper").is(":visible")){ - if(payment_type=="mpu" || payment_type=="visa" || payment_type=="master" || payment_type=="jcb" || payment_type=="unionpay"){ - card_payment_type = "CARD"; - } - else if(payment_type == "alipay"){ - card_payment_type = "EWALLET"; - } - - bnk_bill_amount = parseFloat(bnk_bill_amount); - - resMsg = code2lab.reqBankPayment(cmd_type,card_payment_type,bnk_bill_amount,receipt_no,com_port); - } - - if(resMsg.includes("STATUS")){ - var jobj = $.parseJSON(resMsg); - - $.ajax({ - type: "POST", - url: "/origami/bank_integration/sale_trans", - data: {type:"response", card_sale_trans_id: card_sale_trans_id, data: jobj}, - dataType: "json", - success: function(data) { - if(data.status == "success"){ - resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type); - } - } - }); - }else{ - if(payment_type!="master"){ - payment_type = payment_type.toUpperCase(); - }else{ - payment_type = "Master"; - } - - $("#loading_wrapper").hide(); - swal({ - title: 'Oops', - text: resMsg.toString(), - type: 'error', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - var url_param = "payment"; - if(location.pathname.includes("credit_payment")){ - url_param = "credit_payment"; - } - window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/"+url_param+"/others_payment/"+payment_type; - }); - } -} - - -function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type) { - $("#loading_wrapper").hide(); - var jobj = $.parseJSON(resMsg); - $("#reference_no").val(jobj.REFNUM); - if(jobj.STATUS == "Approved"){ - $.ajax({type: "POST", - url: "/origami/payment/"+payment_type, - data: "amount="+ bnk_bill_amount + "&sale_id="+ sale_id + "&ref_no=" + jobj.REFNUM, - success:function(result){ - if(result){ - swal({ - title: "Information!", - text: "Payment Successfully", - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - var url_param = "payment"; - if(location.pathname.includes("credit_payment")){ - url_param = "credit_payment"; - } - window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/"+url_param; - }); - } - } - }); - }else{ - if(payment_type!="master"){ - payment_type = payment_type.toUpperCase(); - }else{ - payment_type = "Master"; - } - swal({ - title: 'Oops', - text: "Transaction is " + (jobj.STATUS).toLowerCase(), - type: 'error', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - var url_param = "payment"; - if(location.pathname.includes("credit_payment")){ - url_param = "credit_payment"; - } - window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/"+url_param+"/others_payment/"+payment_type; - }); - } -} -//end CB ECR integration - -function setHeaderBreadCrumb(params){ - $("#others_payment").html(params); -} - -//show hide nav bar for webview -function showHideNavbar(webview,page){ - if(webview){ - $("nav.navbar").addClass("hidden"); - $("section").addClass("section-margin"); - $(".page-loader-wrapper").addClass("hidden"); - if(page!=undefined){ - $("#back").hide(); - } - }else{ - $("nav.navbar").removeClass("hidden"); - $("section").removeClass("section-margin"); - $(".page-loader-wrapper").removeClass("hidden"); - if(page!=undefined){ - $("#back").show(); - } - } -} - -function createAccessCode(code) { - localStorage.setItem("access_code",code); -} - -//get menu item cache -function getAllMenu(){ - $.ajax({ - type: "GET", - url: '/origami/get_all_menu', - data: {}, - success:function(result){ - console.log(result) - localStorage.setItem("menus", JSON.stringify(result)); - - var menu = localStorage.getItem("menus"); - if (menu != null ) { - $( "#loading_wrapper").hide(); - } - } - }); -} - -/* String format */ -if (!String.prototype.formatUnicorn) { - String.prototype.formatUnicorn=function(){ - var e=this.toString(); - if(!arguments.length){ - return e; - } - var t=typeof arguments[0],n="string"==t||"number"==t?Array.prototype.slice.call(arguments):arguments[0]; - for(var i in n){ - e=e.replace(new RegExp("\\{"+i+"\\}","gi"),n[i]==null?'':n[i]); - } - return e; - }; -} -/* String format */ - -//credit sales lists -function timeFormat(date){ - var isPM = date.getHours() >= 12; - var isMidday = date.getHours() == 12; - var time = [(date.getHours()>10? date.getHours() : '0'+date.getHours()) - (isPM && !isMidday ? 12 : 0), - (date.getMinutes()>10? date.getMinutes() : '0'+date.getMinutes()) || '00'].join(':') + - (isPM ? ' PM' : ' AM'); - return time; -} - -function getCreditData(cashier_type){ - var filter = $("#filter").val(); - var customer = $("#sel_customer").val(); - - var receipt_no = ""; - var customer_id = ""; - if((filter!=undefined) && (filter!=null) && (filter!="")){ - receipt_no = filter; - } - if((customer!=undefined) && (customer!=null) && (customer!="")){ - customer_id = customer; - } - getCreditSales(receipt_no, customer_id, cashier_type); -} - -function getCreditSales(filter, customer, cashier_type){ - // $(".credit_items").hide(); - $(".tbd_credit_lists").empty(); - var html_credit_items = $("#html_credit_items").html(); - var receipt_no = ""; - var customer_id = ""; - if((filter!=undefined) && (filter!=null) && (filter!="")){ - receipt_no = filter; - } - if((customer!=undefined) && (customer!=null) && (customer!="")){ - customer_id = customer; - } - $.ajax({ - type: "POST", - data: {receipt_no: receipt_no, customer_id: customer_id}, - dataType: 'json', - url: "/origami/"+cashier_type+"/credit_sales", - success: function(data){ - // console.log(data); - if(data.status){ - var credit_sales = data.data; - // console.log(credit_sales); - if(credit_sales.length > 0){ - $(".credit_items").show(); - for (var i = 0; i < credit_sales.length ; i++) { - var sale_date = new Date(credit_sales[i].sale_date); - var receipt_date = sale_date.getFullYear() +'-'+ (sale_date.getMonth() > 10 ? (sale_date.getMonth()+1) : '0' + (sale_date.getMonth()+1)) +'-'+ (sale_date.getDate() > 10 ? sale_date.getDate() : '0' + sale_date.getDate()); - $('.tbd_credit_lists').append(html_credit_items.formatUnicorn({ - 'key':i, - 'sale_id':credit_sales[i].sale_id, - 'receipt_date':receipt_date +" "+timeFormat(sale_date), - 'receipt_no':credit_sales[i].receipt_no, - 'cashier_name':credit_sales[i].cashier_name, - 'customer_name':credit_sales[i].customer_name, - 'credit_amount':credit_sales[i].payment_amount, - 'cashier_type':cashier_type - })); - } - } - }else{ - $(".tbd_credit_lists").html(data.message); - } - } - }); -} -//End of credit sales function diff --git a/app/controllers/api/authenticate_controller.rb b/app/controllers/api/authenticate_controller.rb index 8816b7af..287730f6 100755 --- a/app/controllers/api/authenticate_controller.rb +++ b/app/controllers/api/authenticate_controller.rb @@ -67,8 +67,8 @@ class Api::AuthenticateController < Api::ApiController params.permit(:emp_id, :password, :session_token) end - private - def find_shop + private + def find_shop @shop = Shop.find_by_shop_code(params[:shop_code]) end end diff --git a/app/controllers/foodcourt/food_court_controller.rb b/app/controllers/foodcourt/food_court_controller.rb index a02d7b89..ade02080 100644 --- a/app/controllers/foodcourt/food_court_controller.rb +++ b/app/controllers/foodcourt/food_court_controller.rb @@ -34,7 +34,12 @@ class Foodcourt::FoodCourtController < ApplicationController end end end - + @app_order_new_count =Booking.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") + .joins("JOIN orders ON orders.order_id=booking_orders.order_id") + .joins("JOIN order_items ON orders.order_id=order_items.order_id") + .joins("JOIN customers ON orders.customer_id=customers.customer_id") + .where("orders.source='app' and bookings.shop_code='#{@shop.shop_code}' and bookings.booking_status='assign'").uniq.length + puts @app_order_new_count render "foodcourt/addorders/detail" end diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index 1450df2d..42a3ece5 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -52,48 +52,31 @@ class Foodcourt::OrdersController < BaseFoodcourtController @order.order_items[order_item_index].set_menu_items = arr_instance_item_sets end end - - # bookings = Booking.all - # if !bookings.today.nil? - # @order_items_count = Hash.new - # bookings.each do |booking| - # if booking.sale_id.nil? && booking.booking_status != 'moved' - # if !booking.booking_orders.empty? - # booking.booking_orders.each do |booking_order| - # order = Order.find(booking_order.order_id) - # if !order.order_items.empty? - # if !@order_items_count.key?(booking.dining_facility_id) - # @order_items_count.store(booking.dining_facility_id, order.order_items.count) - # else - # @order_items_count[booking.dining_facility_id] += order.order_items.count - # end - # end - # end - # end - # else - # if !booking.sale_id.nil? - # sale = Sale.find(booking.sale_id) - # if sale.sale_status !='completed' - # if !@order_items_count.key?(booking.dining_facility_id) - # @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) - # else - # @order_items_count[booking.dining_facility_id] = sale.sale_items.count - # end - # end - # end - # end - # end - # end end def app_orders - @bookings = Booking.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") - .joins("JOIN orders ON orders.order_id=booking_orders.order_id") - .where("orders.source='app' and bookings.shop_code='#{@shop.shop_code}'").order("created_at desc") + if !params[:booking_id].nil? && !params[:booking_id].blank? + @booking = Booking.select("orders.*,bookings.*,customers.*") + .joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") + .joins("JOIN orders ON orders.order_id=booking_orders.order_id") + .joins("JOIN customers ON orders.customer_id=customers.customer_id") + .where("orders.source='app' and bookings.shop_code='#{@shop.shop_code}' and bookings.booking_id='#{params[:booking_id]}'").first + @customer_id =@booking.customer_id + @booking_id =@booking.booking_id + end + @bookings = Booking.select("bookings.*,customers.*") + .joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") + .joins("JOIN orders ON orders.order_id=booking_orders.order_id") + .joins("JOIN order_items ON orders.order_id=order_items.order_id") + .joins("JOIN customers ON orders.customer_id=customers.customer_id") + .where("orders.source='app' and bookings.shop_code='#{@shop.shop_code}'").order("bookings.created_at desc").uniq end - def app_order_by_booking - @order_items = OrderItems.joins("JOIN orders ON orders.order_id=order_items.order_id") - .joins("JOIN booking_orders ON booking_orders.order_id=orders.order_id") - .where("orders.source='app' and booking_orders.booking_id='#{params[:booking_id]}'").order("created_at desc") - + def completed + customer =Customer.find_by_customer_id(params[:customer_id]) + phone_number =customer.contact_no + if Order.send_message(phone_number,params[:booking_id]) + booking =Booking.find(params[:booking_id]) + booking.booking_status ='completed' + booking.save! + end end end diff --git a/app/models/order.rb b/app/models/order.rb index b42ef694..9c05ec85 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -591,5 +591,19 @@ class Order < ApplicationRecord Rails.logger.debug '...... order sync completed .....' end end + def self.send_message(phone, booking_id) + url = "http://smspoh.com/api/http/send?key=5QfyN0OtGsFXnOqwtpVAGZCyPGP28nbX_Nm_oPsUw2ybq714T_951ycz3Ypl5URA&message=Your order "+booking_id.to_s+" is ready to pick up&recipients="+ phone.to_s + begin + @result = HTTParty.get(url.to_str) + rescue HTTParty::Error + response = {status: false, message: "Can't open membership server "} + rescue Net::OpenTimeout + response = { status: false , message: "Can't open membership server "} + rescue OpenURI::HTTPError + response = { status: false, message: "Can't open membership server "} + rescue SocketError + response = { status: false, message: "Can't open membership server "} + end + end end diff --git a/app/views/foodcourt/addorders/detail.html.erb b/app/views/foodcourt/addorders/detail.html.erb index 247d4957..93ed11a7 100644 --- a/app/views/foodcourt/addorders/detail.html.erb +++ b/app/views/foodcourt/addorders/detail.html.erb @@ -1,7 +1,5 @@ <%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'addorder', 'data-turbolinks-track': 'reload' %> - - <% type = request.path_info.include?('quick_service') || request.path_info.include?('food_court')%> <% modify_order = request.path_info.include?('modify_order')%>
@@ -147,9 +145,9 @@
-
-
@@ -526,18 +524,23 @@ diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 5479bcca..3b4a86c9 100755 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -61,6 +61,4 @@ Rails.application.config.assets.precompile += %w( order_reservation.js ) Rails.application.config.assets.precompile += %w( reservation.css ) Rails.application.config.assets.precompile += %w( reservation.js ) -# --- Foodcourt ---- -Rails.application.config.assets.precompile += %w( foodcourt.css ) -Rails.application.config.assets.precompile += %w( foodcourt.js ) +Rails.application.config.assets.precompile += %w( custom.js ) diff --git a/config/routes.rb b/config/routes.rb index 4dcc5911..0377994a 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -687,8 +687,8 @@ scope "(:locale)", locale: /en|mm/ do post '/customer_view' => "second_display#customer_view",:as => "customer_view", :defaults => { :format => 'json' } get "food_court" => "food_court#index" - get "app_orders" => "orders#app_orders" - get "app_order/:booking_id" => "orders#app_order_by_booking" + get "app_orders" => "orders#app_orders",:as => "app_order_by_booking" + post ':booking_id/completed' => "orders#completed", :defaults => { :format => 'json' } end end end diff --git a/server2.pid b/server2.pid index edf425a9..f5bfccbd 100644 --- a/server2.pid +++ b/server2.pid @@ -1 +1 @@ -15225 \ No newline at end of file +22910 \ No newline at end of file From 3729c20d0553822195ff17e7ec3f7b7ff4a8045a Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 3 Dec 2019 17:50:42 +0630 Subject: [PATCH 38/54] api_controller --- app/controllers/api/api_controller.rb | 1 + app/controllers/api/bill_controller.rb | 1 + app/controllers/api/shops_controller.rb | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb index 22488792..afcc42a7 100755 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -1,5 +1,6 @@ class Api::ApiController < ActionController::API include TokenVerification + include ActionView::Rendering include ActionController::MimeResponds before_action :core_allow diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 22f1ede8..edd15a0d 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -2,6 +2,7 @@ class Api::BillController < Api::ApiController #Create invoice based on booking #Output and invoice + def create @status = false @error_message = "Order ID or Booking ID is require to request for a bill." diff --git a/app/controllers/api/shops_controller.rb b/app/controllers/api/shops_controller.rb index fb726e29..23d50ebc 100644 --- a/app/controllers/api/shops_controller.rb +++ b/app/controllers/api/shops_controller.rb @@ -4,7 +4,6 @@ class Api::ShopsController < Api::ApiController def index @shops = Shop.select('id,logo,name,shop_code,address,phone_no').all - # render :json => {:name => "any name"} end def show From 15361fe4e1813ede324afd6e0cb963d793b97b6d Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 3 Dec 2019 18:22:38 +0630 Subject: [PATCH 39/54] verfication controller --- .../api/verifications_controller.rb | 2 +- .../foodcourt/food_court_controller.rb | 2 +- .../origami/quick_service_controller.rb | 10 ++++----- config/puma.rb | 22 +++++++++---------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/controllers/api/verifications_controller.rb b/app/controllers/api/verifications_controller.rb index ba055b88..22ecf523 100644 --- a/app/controllers/api/verifications_controller.rb +++ b/app/controllers/api/verifications_controller.rb @@ -1,4 +1,4 @@ -class Api::VerificationsController < ActionController::API +class Api::VerificationsController < Api::ApiController def new phone_number = params[:phone_number] diff --git a/app/controllers/foodcourt/food_court_controller.rb b/app/controllers/foodcourt/food_court_controller.rb index df04116f..3010fafe 100644 --- a/app/controllers/foodcourt/food_court_controller.rb +++ b/app/controllers/foodcourt/food_court_controller.rb @@ -39,7 +39,7 @@ class Foodcourt::FoodCourtController < ApplicationController .joins("JOIN orders ON orders.order_id=booking_orders.order_id") .joins("JOIN order_items ON orders.order_id=order_items.order_id") .joins("JOIN customers ON orders.customer_id=customers.customer_id") - .where("orders.source='app' and bookings.shop_code='#{@shop.shop_code}' and bookings.booking_status='assign'").uniq.length + .where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}' and bookings.booking_status='assign'").uniq.length puts @app_order_new_count render "foodcourt/addorders/detail" end diff --git a/app/controllers/origami/quick_service_controller.rb b/app/controllers/origami/quick_service_controller.rb index 3d7ef13b..cb2cfb92 100644 --- a/app/controllers/origami/quick_service_controller.rb +++ b/app/controllers/origami/quick_service_controller.rb @@ -13,12 +13,12 @@ class Origami::QuickServiceController < ApplicationController # if params[:menu] == "true" @menus = [] @menu = [] - @zone = Zone.all.where("shop_code='#{@shop.shop_code}'") + @zone = Zone.all @customer = Customer.all - @tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') - @rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') + @tables = Table.all.active.order('status desc') + @rooms = Room.all.active.order('status desc') @cashier_type = "quick_service" - display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code) + display_type = Lookup.find_by_lookup_type("display_type") if !display_type.nil? && display_type.value.to_i ==2 @display_type = display_type.value else @@ -27,7 +27,7 @@ class Origami::QuickServiceController < ApplicationController #checked quick_service only @quick_service_only = false - lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('quickservice_add_order') + lookup_dine_in = Lookup.where("shop_code='#{Shop.current_shop.shop_code}'").collection_of('quickservice_add_order') if !lookup_dine_in.empty? lookup_dine_in.each do |dine_in| if dine_in[0].downcase == "quickserviceaddorder" diff --git a/config/puma.rb b/config/puma.rb index f0013d25..d24425ae 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,11 +1,11 @@ -# application_path="#{File.expand_path("../..", __FILE__)}" -# directory application_path -# #environment ENV.fetch("RAILS_ENV") { "production" } -# environment "production" -# pidfile "#{application_path}/tmp/puma/pid" -# state_path "#{application_path}/tmp/puma/state" -# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -# port ENV.fetch("PORT") { 62158 } -# workers 2 -# preload_app! -# threads 1,1 +application_path="#{File.expand_path("../..", __FILE__)}" +directory application_path +#environment ENV.fetch("RAILS_ENV") { "production" } +environment "production" +pidfile "#{application_path}/tmp/puma/pid" +state_path "#{application_path}/tmp/puma/state" +stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +port ENV.fetch("PORT") { 62158 } +workers 2 +preload_app! +threads 1,1 From 37380f6bfb24c0ad4b8421e27fdbb440a826fe92 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Tue, 3 Dec 2019 19:37:59 +0630 Subject: [PATCH 40/54] Fix json rendering error --- app/controllers/api/api_controller.rb | 10 +++++++++- app/controllers/application_controller.rb | 4 ++-- app/controllers/base_controller.rb | 5 +++-- app/controllers/base_crm_controller.rb | 4 +++- app/controllers/base_inventory_controller.rb | 4 +++- app/controllers/base_oqs_controller.rb | 4 +++- app/controllers/base_origami_controller.rb | 4 +++- app/controllers/base_report_controller.rb | 4 +++- app/controllers/base_waiter_controller.rb | 4 +++- app/controllers/concerns/multi_tenancy.rb | 1 - 10 files changed, 32 insertions(+), 12 deletions(-) diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb index 8a84cfa1..0cf85065 100755 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -1,11 +1,19 @@ class Api::ApiController < ActionController::API - include TokenVerification, MultiTenancy + include MultiTenancy + include TokenVerification include ActionController::MimeResponds + include ActionView::Rendering # before_action :lookup_domain helper_method :current_token, :current_login_employee, :get_cashier private + # ActionView::Rendering override render_to_body breaks render :json, + # resulting in an ActionView::MissingTemplate error. + def render_to_body(options) + _render_to_body_with_renderer(options) || super + end + #this is base api base controller to need to inherit. #all token authentication must be done here #response format must be set to JSON diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 81b4835d..8f537383 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,6 @@ class ApplicationController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification #before_action :check_installation protect_from_forgery with: :exception @@ -17,5 +18,4 @@ class ApplicationController < ActionController::Base flash[:warning] = exception.message redirect_to root_path end - end diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb index 1bb0421e..22cbf130 100755 --- a/app/controllers/base_controller.rb +++ b/app/controllers/base_controller.rb @@ -1,6 +1,7 @@ class BaseController < ActionController::Base include MultiTenancy - layout "installation" - protect_from_forgery with: :exception + layout "installation" + + protect_from_forgery with: :exception end diff --git a/app/controllers/base_crm_controller.rb b/app/controllers/base_crm_controller.rb index 08bc8138..577c387e 100755 --- a/app/controllers/base_crm_controller.rb +++ b/app/controllers/base_crm_controller.rb @@ -1,5 +1,7 @@ class BaseCrmController < ActionController::Base - include LoginVerification, + include MultiTenancy + include LoginVerification + layout "CRM" before_action :check_user diff --git a/app/controllers/base_inventory_controller.rb b/app/controllers/base_inventory_controller.rb index bd455c33..45fa8954 100755 --- a/app/controllers/base_inventory_controller.rb +++ b/app/controllers/base_inventory_controller.rb @@ -1,5 +1,7 @@ class BaseInventoryController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "inventory" before_action :check_user diff --git a/app/controllers/base_oqs_controller.rb b/app/controllers/base_oqs_controller.rb index 6e6a9c0f..6b01383d 100755 --- a/app/controllers/base_oqs_controller.rb +++ b/app/controllers/base_oqs_controller.rb @@ -1,5 +1,7 @@ class BaseOqsController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "OQS" before_action :check_user diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index e9cddf05..e3daff76 100755 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -1,5 +1,7 @@ class BaseOrigamiController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "origami" before_action :check_user diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index b3d1d23a..a4c7c3c3 100755 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -1,5 +1,7 @@ class BaseReportController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "application" before_action :check_user diff --git a/app/controllers/base_waiter_controller.rb b/app/controllers/base_waiter_controller.rb index b1d2056c..0962b3f0 100755 --- a/app/controllers/base_waiter_controller.rb +++ b/app/controllers/base_waiter_controller.rb @@ -1,5 +1,7 @@ class BaseWaiterController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "waiter" before_action :check_user diff --git a/app/controllers/concerns/multi_tenancy.rb b/app/controllers/concerns/multi_tenancy.rb index 5009e094..cb7c8aae 100644 --- a/app/controllers/concerns/multi_tenancy.rb +++ b/app/controllers/concerns/multi_tenancy.rb @@ -4,7 +4,6 @@ module MultiTenancy included do set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action - helper_method :current_shop if respond_to? :helper_method end private From ca92a0791976f25644e6aa286169663505db4d72 Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 3 Dec 2019 20:19:42 +0630 Subject: [PATCH 41/54] shop code missing --- app/controllers/foodcourt/void_controller.rb | 10 ++++----- .../origami/addorders_controller.rb | 5 +++-- app/controllers/origami/home_controller.rb | 4 ++-- app/models/sale.rb | 8 +++---- config/puma.rb | 22 +++++++++---------- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/app/controllers/foodcourt/void_controller.rb b/app/controllers/foodcourt/void_controller.rb index 92aba110..6d7dd34c 100755 --- a/app/controllers/foodcourt/void_controller.rb +++ b/app/controllers/foodcourt/void_controller.rb @@ -73,7 +73,7 @@ class Foodcourt::VoidController < BaseFoodcourtController # FOr Sale Audit action_by = current_user.name if access_code != "null" && current_user.role == "cashier" - action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name + action_by = Employee.find_by_emp_id_and_shop_code(access_code,Shop.current_shop.shop_code).name end # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" @@ -116,7 +116,7 @@ class Foodcourt::VoidController < BaseFoodcourtController customer= Customer.find(sale.customer_id) # get member information - rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate member_info = Customer.get_member_account(customer) rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) @@ -124,7 +124,7 @@ class Foodcourt::VoidController < BaseFoodcourtController current_balance = 0 end - printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") + printer = PrintSetting.where("shop_code='#{Shop.current_shop.shop_code}'") unique_code="ReceiptBillPdf" if !printer.empty? @@ -139,13 +139,13 @@ class Foodcourt::VoidController < BaseFoodcourtController end end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,Shop.current_shop.shop_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,Shop.current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 9670ee23..f4381fb4 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -6,7 +6,7 @@ class Origami::AddordersController < BaseOrigamiController if check_mobile @webview = true end - + @shop = Shop.current_shop @tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") @rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") @all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc') @@ -19,6 +19,7 @@ class Origami::AddordersController < BaseOrigamiController if check_mobile @webview = true end + @shop = Shop.current_shop display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code) if !display_type.nil? && display_type.value.to_i ==2 @display_type = display_type.value @@ -224,7 +225,7 @@ class Origami::AddordersController < BaseOrigamiController def process_order_queue(order_id,table_id,order_source) print_status = nil cup_status = nil - + @shop = Shop.current_shop #Send to background job for processing order = Order.find(order_id) sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",@shop.shop_code) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 349dd27f..9d57e765 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -4,7 +4,7 @@ class Origami::HomeController < BaseOrigamiController def index @webview = check_mobile - + @shop = Shop.current_shop @tables = Table.unscope(:order).all.active.order('status desc') @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") @@ -21,7 +21,7 @@ class Origami::HomeController < BaseOrigamiController # get printer info @print_settings = PrintSetting.get_precision_delimiter() @webview = check_mobile - + @shop = Shop.current_shop @tables = Table.unscope(:order).all.active.order('status desc') @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") diff --git a/app/models/sale.rb b/app/models/sale.rb index 66ed469a..a92d3b4d 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -2057,13 +2057,13 @@ end query = query.where("bookings.booking_status = 'assign' AND orders.status = 'new' AND orders.source =? ","#{type}") .group("bookings.booking_id") end - def self.completed_sale(type,shop_code) + def self.completed_sale(type) if type == "cashier" type = "and orders.source = 'emenu' or orders.source = 'cashier'" else type = "and orders.source = '#{type}'" end - query = Sale.where("sales.shop_code='#{shop_code}'") + query = Sale.where("sales.shop_code='#{Shop.current_shop.shop_code}'") query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id") .joins("join orders as orders on orders.order_id = sale_orders.order_id") query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' #{type}") @@ -2456,7 +2456,7 @@ private def update_stock_journal if self.sale_status == "void" && self.sale_status_before_last_save != "void" self.sale_items.each do |item| - found, inventory_definition = InventoryDefinition.find_product_in_inventory(item,self.shop_code) + found, inventory_definition = InventoryDefinition.find_product_in_inventory(item) if found stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first unless stock.nil? @@ -2469,7 +2469,7 @@ private end elsif self.sale_status == "waste" || self.sale_status == "spoile" || (self.payment_status == "foc" && self.payment_status_was != "foc") self.bookings.first.order_items.each do |item| - found, inventory_definition = InventoryDefinition.find_product_in_inventory(item,self.shop_code) + found, inventory_definition = InventoryDefinition.find_product_in_inventory(item) if found if stock_journal = StockJournal.find_by_trans_ref(item.order_items_id) if self.payment_status == "foc" && self.payment_status_was != "foc" diff --git a/config/puma.rb b/config/puma.rb index d24425ae..f0013d25 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,11 +1,11 @@ -application_path="#{File.expand_path("../..", __FILE__)}" -directory application_path -#environment ENV.fetch("RAILS_ENV") { "production" } -environment "production" -pidfile "#{application_path}/tmp/puma/pid" -state_path "#{application_path}/tmp/puma/state" -stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -port ENV.fetch("PORT") { 62158 } -workers 2 -preload_app! -threads 1,1 +# application_path="#{File.expand_path("../..", __FILE__)}" +# directory application_path +# #environment ENV.fetch("RAILS_ENV") { "production" } +# environment "production" +# pidfile "#{application_path}/tmp/puma/pid" +# state_path "#{application_path}/tmp/puma/state" +# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +# port ENV.fetch("PORT") { 62158 } +# workers 2 +# preload_app! +# threads 1,1 From 08f5689841c057bee526033a5a7fbd1afcfbcc1c Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Wed, 4 Dec 2019 13:33:13 +0630 Subject: [PATCH 42/54] print --- app/controllers/api/payments_controller.rb | 134 +++++++++++++++++- .../concerns/token_verification.rb | 6 +- .../reports/payment_method_controller.rb | 2 +- app/models/printer/order_queue_printer.rb | 18 +-- app/pdf/close_cashier_customise_pdf.rb | 4 +- app/pdf/close_cashier_pdf.rb | 2 +- app/pdf/close_cashier_pdf_v1.rb | 4 +- app/pdf/order_item_customise_pdf.rb | 21 +-- app/pdf/order_item_pdf.rb | 27 ++-- app/pdf/order_item_slim_customise_pdf.rb | 21 +-- app/pdf/order_item_slim_pdf.rb | 20 ++- app/pdf/order_item_star_pdf.rb | 20 ++- app/pdf/order_set_item_customise_pdf.rb | 20 ++- app/pdf/order_set_item_pdf.rb | 20 ++- app/pdf/order_summary_customise_pdf.rb | 6 + app/pdf/order_summary_pdf.rb | 8 +- app/pdf/order_summary_set_customise_pdf.rb | 8 +- app/pdf/order_summary_set_pdf.rb | 8 +- app/pdf/order_summary_slim_customise_pdf.rb | 6 + app/pdf/order_summary_slim_pdf.rb | 6 + app/pdf/receipt_bill_a5_pdf.rb | 12 +- app/pdf/receipt_bill_pdf.rb | 6 +- app/pdf/receipt_bill_star_pdf.rb | 6 +- app/views/foodcourt/addorders/detail.html.erb | 2 +- .../foodcourt/orders/app_orders.html.erb | 2 +- app/views/foodcourt/payments/show.html.erb | 1 + config/puma.rb | 22 +-- server2.pid | 2 +- 28 files changed, 314 insertions(+), 100 deletions(-) diff --git a/app/controllers/api/payments_controller.rb b/app/controllers/api/payments_controller.rb index 731b8c5c..494ff43c 100755 --- a/app/controllers/api/payments_controller.rb +++ b/app/controllers/api/payments_controller.rb @@ -1,5 +1,5 @@ class Api::PaymentsController < Api::ApiController - skip_before_action :authenticate + # skip_before_action :authenticate #Payment by Invoice ID # Payment Method - [Cash | CreditNote | VISA | MASTER | etc..] @@ -25,6 +25,9 @@ class Api::PaymentsController < Api::ApiController if params[:sale_id] && params[:card_no] sale = Sale.find_by_sale_id(params[:sale_id]) if !sale.nil? + sale_id =sale.sale_id + sale_items = SaleItem.get_all_sale_items(sale_id) + @shop =Shop.find_by_shop_code(sale.shop_code) if sale.sale_status == "new" if !params[:card_no].empty? current_shift = ShiftSale.current_shift(sale.shop_code) @@ -37,8 +40,124 @@ class Api::PaymentsController < Api::ApiController if status == true && @membership_data["status"] == true sale_payment = SalePayment.new status = sale_payment.process_payment(sale, current_login_employee, 0, "cash") - #card_balance amount for Paymal payment - card_balance_amount = SaleAudit.getCardBalanceAmount(params[:sale_id]) + + + rebate_amount = nil + # For Cashier by Zone + # bookings = Booking.where("sale_id='#{sale_id}'") + bookings = Booking.find_by_sale_id(sale_id) + + shift = ShiftSale.current_open_shift(current_login_employee) + if !shift.nil? + cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) + else + if bookings.dining_facility_id.to_i > 0 + table = DiningFacility.find(bookings.dining_facility_id) + cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) + cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) + + type = 'payment' + from = getCloudDomain #get sub domain in cloud mode + ActionCable.server.broadcast "order_channel",table: table,type:type,from:from + else + shift = ShiftSale.find(sale.shift_sale_id) + cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) + end + end + + # For Print + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf + unique_code = "ReceiptBillPdf" + print_settings = PrintSetting.all + if !print_settings.nil? + print_settings.each do |setting| + if setting.unique_code == 'ReceiptBillPdf' + unique_code = "ReceiptBillPdf" + elsif setting.unique_code == 'ReceiptBillStarPdf' + unique_code = "ReceiptBillStarPdf" + end + end + end + + if !receipt_bill_a5_pdf.empty? + receipt_bill_a5_pdf.each do |receipt_bilA5| + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[1] == '1' + unique_code = "ReceiptBillA5Pdf" + # else + + end + end + end + end + + customer= Customer.find(sale.customer_id) + + # get member information + rebate = MembershipSetting.find_by_rebate(1) + credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote') + + if customer.membership_id != nil && rebate && credit_data.nil? + member_info = Customer.get_member_account(customer) + + if member_info["status"] == true + rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) + current_balance = SaleAudit.paymal_search(sale_id) + end + end + + #orders print out + # if type == "quick_service" + booking = Booking.find_by_sale_id(sale_id) + if booking.dining_facility_id.to_i>0 + table_id = booking.dining_facility_id + else + table_id = 0 + end + + latest_order = booking.booking_orders.order("order_id DESC").limit(1).first() + if !latest_order.nil? + latest_order_no = latest_order.order_id + end + + booking.booking_orders.each do |order| + # Order.pay_process_order_queue(order.order_id, table_id) + oqs = OrderQueueStation.new + oqs.pay_process_order_queue(order.order_id, table_id) + + assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id) + from = getCloudDomain #get sub domain in cloud mode + ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from + end + + # end + + #for card sale data + card_data = Array.new + card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id) + if !card_sale_trans_ref_no.nil? + card_sale_trans_ref_no.each do |cash_sale_trans| + card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s + card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s + card_no = cash_sale_trans.pan.last(4) + card_no = card_no.rjust(19,"**** **** **** ") + card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id}) + end + end + + #card_balance amount for Paymal payment + card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id) + + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + # Calculate Food and Beverage Total + item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) + other_amount = SaleItem.calculate_other_charges(sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) render json: JSON.generate({:status => true, :balance_amount => card_balance_amount,:receipt_no => sale.receipt_no, :message => "Payment successful."}) else @@ -182,4 +301,13 @@ class Api::PaymentsController < Api::ApiController @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee) end end + #get cloud domain + def getCloudDomain + from = "" + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain.to_s + "." + request.domain.to_s + end + + return from + end end diff --git a/app/controllers/concerns/token_verification.rb b/app/controllers/concerns/token_verification.rb index c1bce9b2..ec55b8ec 100755 --- a/app/controllers/concerns/token_verification.rb +++ b/app/controllers/concerns/token_verification.rb @@ -9,18 +9,18 @@ module TokenVerification protected # Authenticate the user with token based authentication - def authenticate + def authenticate authenticate_token || render_unauthorized end def authenticate_token - authenticate_with_http_token do |token, options| + authenticate_with_http_token do |token, options| # Rails.logger.debug "token - " + token.to_s if(options.length !=0 && options["from"] == "DOEMAL") if(ENV["SERVER_MODE"] === "cloud") from = request.subdomain.downcase + "." + request.domain.downcase #"local" aes = MyAesCrypt.new - return aes.checkKeyForAuth(from, token) + return aes.checkKeyForAuth(from, token) end end diff --git a/app/controllers/reports/payment_method_controller.rb b/app/controllers/reports/payment_method_controller.rb index beec5dd9..7b51131a 100644 --- a/app/controllers/reports/payment_method_controller.rb +++ b/app/controllers/reports/payment_method_controller.rb @@ -5,7 +5,7 @@ class Reports::PaymentMethodController < BaseReportController @payments = [["All Payment",''],["Cash Payment","cash"], ["KBZ Payment", KbzPay::KBZ_PAY], ["Credit Payment","creditnote"], ["FOC Payment","foc"], ["MPU Payment","mpu"], ["Visa Payment","visa"], ["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"], - ["Alipay Payment","alipay"],["Paymal Payment", "paymal"],["Dinga Payment","dinga"], + ["Alipay Payment","alipay"],["Card Payment", "paymal"],["Dinga Payment","dinga"], ["JunctionPay","junctionpay"],["Redeem Payment","paypar"],["Gift Voucher","giftvoucher"]] from, to = get_date_range_from_params diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 32ef0081..272fc0b0 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -39,8 +39,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # end - shop = Shop.current_shop - directory_name = 'public/orders_'+shop.shop_code + # shop = Shop.current_shop + directory_name = 'public/orders_'+oqs.shop_code Dir.mkdir(directory_name) unless File.exists?(directory_name) filename = directory_name + "/order_item_#{order_id}_#{order_item_id}" + ".pdf" @@ -82,8 +82,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker order=print_query('order_summary', order_id) - shop = Shop.current_shop - directory_name = 'public/orders_'+shop.shop_code + # shop = Shop.current_shop + directory_name = 'public/orders_'+oqs.shop_code Dir.mkdir(directory_name) unless File.exists?(directory_name) # For Print Per Item @@ -195,8 +195,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker order=print_query('booking_summary', booking_id) - shop = Shop.current_shop - directory_name = 'public/orders_'+shop.shop_code + # shop = Shop.current_shop + directory_name = 'public/orders_'+oqs.shop_code Dir.mkdir(directory_name) unless File.exists?(directory_name) # For Print Per Item @@ -297,7 +297,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # Query for OQS with status def print_query(type, id) if type == "order_item" - OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name") + OrderItem.select("orders.source,cus.contact_no,rder_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name") .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id left join bookings AS b ON b.booking_id = bo.booking_id @@ -307,7 +307,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker .where("order_items.order_items_id = '#{ id }'") .group("order_items.item_code") elsif type == "order_summary" - OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name") + OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name") .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id left join bookings AS b ON b.booking_id = bo.booking_id @@ -318,7 +318,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker .group("order_items.order_items_id") else # order summary for booking - OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name") + OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name") .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id left join bookings AS b ON b.booking_id = bo.booking_id diff --git a/app/pdf/close_cashier_customise_pdf.rb b/app/pdf/close_cashier_customise_pdf.rb index 34c4288d..f23ae950 100644 --- a/app/pdf/close_cashier_customise_pdf.rb +++ b/app/pdf/close_cashier_customise_pdf.rb @@ -43,7 +43,7 @@ class CloseCashierCustomisePdf < Prawn::Document stroke_horizontal_rule - shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) + shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) end def header (shop_details) @@ -322,7 +322,7 @@ class CloseCashierCustomisePdf < Prawn::Document if other.paymal_amount && other.paymal_amount.to_f > 0 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do - text "Paymal Payment :", :size => self.item_font_size, :align => :right + text "Card Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index 976c3d93..095f1de6 100755 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -276,7 +276,7 @@ class CloseCashierPdf < Prawn::Document if other.paymal_amount && other.paymal_amount.to_f > 0 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do - text "Paymal Payment :", :size => self.item_font_size, :align => :right + text "Card Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right diff --git a/app/pdf/close_cashier_pdf_v1.rb b/app/pdf/close_cashier_pdf_v1.rb index c241c047..eb87aa5b 100644 --- a/app/pdf/close_cashier_pdf_v1.rb +++ b/app/pdf/close_cashier_pdf_v1.rb @@ -43,7 +43,7 @@ class CloseCashierPdf < Prawn::Document stroke_horizontal_rule - shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments) + shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments) end @@ -263,7 +263,7 @@ class CloseCashierPdf < Prawn::Document if other.paymal_amount && other.paymal_amount.to_f > 0 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do - text "Paymal Payment :", :size => self.item_font_size, :align => :right + text "Card Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right diff --git a/app/pdf/order_item_customise_pdf.rb b/app/pdf/order_item_customise_pdf.rb index 32be1928..da91d652 100644 --- a/app/pdf/order_item_customise_pdf.rb +++ b/app/pdf/order_item_customise_pdf.rb @@ -34,15 +34,20 @@ class OrderItemCustomisePdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if !order_item.dining.nil? - text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - else - text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - end - - stroke_horizontal_rule - move_down 3 + if order_item.source =='app' + text "Mobile Order", :size => self.header_font_size,:align => :center + move_down 1 + text "Customer Ph : #{order_item.contact_no}", :size => self.header_font_size,:align => :center + move_down 1 + end + if !order_item.dining.nil? + text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + else + text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + end + stroke_horizontal_rule + move_down 3 #order_info order_info(order_item.order_id, order_item.order_by,order_item.order_at) diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index d4a05aa2..9697ae21 100755 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -32,18 +32,23 @@ class OrderItemPdf < Prawn::Document font "#{print_settings.font}" fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end - # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" - #font "public/fonts/Chinese.ttf" - if !order_item.dining.nil? - text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - else - text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - end - - stroke_horizontal_rule - move_down 3 + # font "public/fonts/Zawgyi-One.ttf" + # font "public/fonts/padauk.ttf" + #font "public/fonts/Chinese.ttf" + if order_item.source =='app' + text "Mobile Order", :size => self.header_font_size,:align => :center + move_down 1 + text "Customer Ph : #{order_item.contact_no}", :size => self.header_font_size,:align => :center + move_down 1 + end + if !order_item.dining.nil? + text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + else + text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + end + stroke_horizontal_rule + move_down 3 #order_info order_info(order_item.order_id, order_item.order_by,order_item.order_at) diff --git a/app/pdf/order_item_slim_customise_pdf.rb b/app/pdf/order_item_slim_customise_pdf.rb index f759cbec..497f04ed 100644 --- a/app/pdf/order_item_slim_customise_pdf.rb +++ b/app/pdf/order_item_slim_customise_pdf.rb @@ -34,15 +34,20 @@ class OrderItemSlimCustomisePdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if !order_item_slim.dining.nil? - text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - else - text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - end - - stroke_horizontal_rule - move_down 1 + if order_item_slim.source =='app' + text "Mobile Order", :size => self.header_font_size,:align => :center + move_down 1 + text "Customer Ph : #{order_item_slim.contact_no}", :size => self.header_font_size,:align => :center + move_down 1 + end + if !order_item_slim.dining.nil? + text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + else + text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + end + stroke_horizontal_rule + move_down 1 #order_info order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at) diff --git a/app/pdf/order_item_slim_pdf.rb b/app/pdf/order_item_slim_pdf.rb index a32c1a26..1c667438 100755 --- a/app/pdf/order_item_slim_pdf.rb +++ b/app/pdf/order_item_slim_pdf.rb @@ -34,14 +34,20 @@ class OrderItemSlimPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if !order_item_slim.dining.nil? - text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - else - text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - end + if order_item_slim.source =='app' + text "Mobile Order", :size => self.header_font_size,:align => :center + move_down 1 + text "Customer Ph : #{order_item_slim.contact_no}", :size => self.header_font_size,:align => :center + move_down 1 + end + if !order_item_slim.dining.nil? + text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + else + text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + end - stroke_horizontal_rule - move_down 1 + stroke_horizontal_rule + move_down 1 #order_info order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at) diff --git a/app/pdf/order_item_star_pdf.rb b/app/pdf/order_item_star_pdf.rb index 0703c8a2..0a66579d 100644 --- a/app/pdf/order_item_star_pdf.rb +++ b/app/pdf/order_item_star_pdf.rb @@ -35,14 +35,20 @@ class OrderItemStarPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if !order_item.dining.nil? - text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - else - text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - end + if order_item.source =='app' + text "Mobile Order", :size => self.header_font_size,:align => :center + move_down 1 + text "Customer Ph : #{order_item.contact_no}", :size => self.header_font_size,:align => :center + move_down 1 + end + if !order_item.dining.nil? + text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + else + text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + end - stroke_horizontal_rule - move_down 3 + stroke_horizontal_rule + move_down 3 #order_info order_info(order_item.order_id, order_item.order_by,order_item.order_at) diff --git a/app/pdf/order_set_item_customise_pdf.rb b/app/pdf/order_set_item_customise_pdf.rb index f684e275..a080bfae 100644 --- a/app/pdf/order_set_item_customise_pdf.rb +++ b/app/pdf/order_set_item_customise_pdf.rb @@ -34,13 +34,19 @@ class OrderSetItemCustomisePdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if !order_set_item.dining.nil? - text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - else - text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - end - stroke_horizontal_rule - move_down 3 + if order_set_item.source =='app' + text "Mobile Order", :size => self.header_font_size,:align => :center + move_down 1 + text "Customer Ph : #{order_set_item.contact_no}", :size => self.header_font_size,:align => :center + move_down 1 + end + if !order_set_item.dining.nil? + text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + else + text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + end + stroke_horizontal_rule + move_down 3 #order_info order_info(order_set_item.order_id, order_set_item.order_by,order_set_item.order_at) diff --git a/app/pdf/order_set_item_pdf.rb b/app/pdf/order_set_item_pdf.rb index cb57c870..d014e2ce 100755 --- a/app/pdf/order_set_item_pdf.rb +++ b/app/pdf/order_set_item_pdf.rb @@ -33,13 +33,19 @@ class OrderSetItemPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if !order_set_item.dining.nil? - text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - else - text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 - end - stroke_horizontal_rule - move_down 3 + if order_set_item.source =='app' + text "Mobile Order", :size => self.header_font_size,:align => :center + move_down 1 + text "Customer Ph : #{order_set_item.contact_no}", :size => self.header_font_size,:align => :center + move_down 1 + end + if !order_set_item.dining.nil? + text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + else + text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + end + stroke_horizontal_rule + move_down 3 #order_info order_info(order_set_item.order_id, order_set_item.order_by,order_set_item.order_at) diff --git a/app/pdf/order_summary_customise_pdf.rb b/app/pdf/order_summary_customise_pdf.rb index bce29877..99b80180 100644 --- a/app/pdf/order_summary_customise_pdf.rb +++ b/app/pdf/order_summary_customise_pdf.rb @@ -34,6 +34,12 @@ class OrderSummaryCustomisePdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" + if order[0].source =='app' + text "Mobile Order", :size => self.header_font_size,:align => :center + move_down 1 + text "Customer Ph : #{order[0].contact_no}", :size => self.header_font_size,:align => :center + move_down 1 + end if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index f3d25ff1..a730f3ff 100755 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -32,7 +32,12 @@ class OrderSummaryPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - + if order[0].source =='app' + text "Mobile Order", :size => self.header_font_size,:align => :center + move_down 1 + text "Customer Ph : #{order[0].contact_no}", :size => self.header_font_size,:align => :center + move_down 1 + end if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else @@ -41,7 +46,6 @@ class OrderSummaryPdf < Prawn::Document stroke_horizontal_rule move_down 5 - #order_info order_info(order[0].order_id, order[0].order_by,order[0].order_at) diff --git a/app/pdf/order_summary_set_customise_pdf.rb b/app/pdf/order_summary_set_customise_pdf.rb index 70c116fc..f4e7cc18 100644 --- a/app/pdf/order_summary_set_customise_pdf.rb +++ b/app/pdf/order_summary_set_customise_pdf.rb @@ -33,6 +33,13 @@ class OrderSummarySetCustomisePdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" + + if order[0].source =='app' + text "Mobile Order", :size => self.header_font_size,:align => :center + move_down 1 + text "Customer Ph : #{order[0].contact_no}", :size => self.header_font_size,:align => :center + move_down 1 + end if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else @@ -41,7 +48,6 @@ class OrderSummarySetCustomisePdf < Prawn::Document stroke_horizontal_rule move_down 5 - #order_info order_info(order[0].order_id, order[0].order_by,order[0].order_at) diff --git a/app/pdf/order_summary_set_pdf.rb b/app/pdf/order_summary_set_pdf.rb index dd65f0d2..f6c56f80 100755 --- a/app/pdf/order_summary_set_pdf.rb +++ b/app/pdf/order_summary_set_pdf.rb @@ -32,6 +32,13 @@ class OrderSummarySetPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" + + if order[0].source =='app' + text "Mobile Order", :size => self.header_font_size,:align => :center + move_down 1 + text "Customer Ph : #{order[0].contact_no}", :size => self.header_font_size,:align => :center + move_down 1 + end if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else @@ -40,7 +47,6 @@ class OrderSummarySetPdf < Prawn::Document stroke_horizontal_rule move_down 5 - #order_info order_info(order[0].order_id, order[0].order_by,order[0].order_at) diff --git a/app/pdf/order_summary_slim_customise_pdf.rb b/app/pdf/order_summary_slim_customise_pdf.rb index e8bd21f2..0afcf5b2 100644 --- a/app/pdf/order_summary_slim_customise_pdf.rb +++ b/app/pdf/order_summary_slim_customise_pdf.rb @@ -33,6 +33,12 @@ class OrderSummarySlimCustomisePdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" + if order[0].source =='app' + text "Mobile Order", :size => self.header_font_size,:align => :center + move_down 1 + text "Customer Ph : #{order[0].contact_no}", :size => self.header_font_size,:align => :center + move_down 1 + end if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else diff --git a/app/pdf/order_summary_slim_pdf.rb b/app/pdf/order_summary_slim_pdf.rb index 2cbe14d8..1b7078da 100755 --- a/app/pdf/order_summary_slim_pdf.rb +++ b/app/pdf/order_summary_slim_pdf.rb @@ -32,6 +32,12 @@ class OrderSummarySlimPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" + if order[0].source =='app' + text "Mobile Order", :size => self.header_font_size,:align => :center + move_down 1 + text "Customer Ph : #{order[0].contact_no}", :size => self.header_font_size,:align => :center + move_down 1 + end if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index 7f2e47e9..5856d7ef 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -405,12 +405,16 @@ class ReceiptBillA5Pdf < Prawn::Document y_position = cursor if payment.payment_method == "paypar" bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do - text "Redeem Payment", :size => self.item_font_size,:align => :left - end + text "Redeem Payment", :size => self.item_font_size,:align => :left + end else + payment_method = payment.payment_method.capitalize + if payment.payment_method == "paymal" + payment_method ='Card' + end bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do - text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left - end + text "#{payment_method} Payment", :size => self.item_font_size,:align => :left + end end bounding_box([self.description_width,y_position], :width =>self.label_width) do diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index feb127d8..f91a4ca8 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -464,8 +464,12 @@ class ReceiptBillPdf < Prawn::Document text "Redeem Payment", :size => self.item_font_size,:align => :left end else + payment_method = payment.payment_method.capitalize + if payment.payment_method == "paymal" + payment_method ='Card' + end bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left + text "#{payment_method} Payment", :size => self.item_font_size,:align => :left end end diff --git a/app/pdf/receipt_bill_star_pdf.rb b/app/pdf/receipt_bill_star_pdf.rb index 8a9f9c9c..d2d6e68c 100644 --- a/app/pdf/receipt_bill_star_pdf.rb +++ b/app/pdf/receipt_bill_star_pdf.rb @@ -403,8 +403,12 @@ class ReceiptBillStarPdf < Prawn::Document text "Redeem Payment", :size => self.item_font_size,:align => :left end else + payment_method = payment.payment_method.capitalize + if payment.payment_method == "paymal" + payment_method ='Card' + end bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left + text "#{payment_method} Payment", :size => self.item_font_size,:align => :left end end diff --git a/app/views/foodcourt/addorders/detail.html.erb b/app/views/foodcourt/addorders/detail.html.erb index 93ed11a7..adeec6b4 100644 --- a/app/views/foodcourt/addorders/detail.html.erb +++ b/app/views/foodcourt/addorders/detail.html.erb @@ -147,7 +147,7 @@

diff --git a/app/views/foodcourt/orders/app_orders.html.erb b/app/views/foodcourt/orders/app_orders.html.erb index 62cf362b..e90d6307 100644 --- a/app/views/foodcourt/orders/app_orders.html.erb +++ b/app/views/foodcourt/orders/app_orders.html.erb @@ -11,7 +11,7 @@ <% end %> -
+
@@ -31,7 +31,6 @@
<% bk_color ='' %> - <% @bookings.each do |bk| bk_status ='completed' if bk.booking_status =='assign' @@ -63,7 +62,7 @@
ORDER DETAILS | Table-<%=@booking.dining_facility.name%>
- Booking - <%=@booking.booking_id%> + Booking - <%=@booking.booking_id%>
Order No- <%=@booking.order_id%>
@@ -74,7 +73,7 @@
-
+
@@ -84,35 +83,48 @@ - - <% count =0 %> - <% total_price =0 %> - <% total_qty =0 %> - <% @booking.booking_orders.each do |bo| %> - <% bo.order.order_items.each do |oi| %> - <% count +=1 %> - <% total_price += oi.price %> - <% total_qty += oi.qty.to_i%> - - - - - - - <% end %> - <% end %> - + + <% sub_total = 0 + count = 0 + %> + <% @sale_data.sale_items.each do |sale_item| + count += 1 + %> + <% sub_total += sale_item.price%> + + + + + + + <%end %> +
Price
<%= count%><%= oi.item_name%><%= oi.qty.to_i%><%= oi.price%>
<%= count %><%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%><%=sale_item.qty%><%=(number_with_precision(sale_item.price, precision: precision.to_i ))%>
From ccbd3c696686f396bf7ab6dffcf7bd2afe2811ae Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 5 Dec 2019 11:09:21 +0630 Subject: [PATCH 50/54] app --- app/controllers/foodcourt/orders_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index b4a24a3b..ca67efdd 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -70,7 +70,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController .joins("JOIN orders ON orders.order_id=booking_orders.order_id") .joins("JOIN order_items ON orders.order_id=order_items.order_id") .joins("JOIN customers ON orders.customer_id=customers.customer_id") - .where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}'").order("bookings.created_at desc").uniq + .where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}' and DATE(bookings.created_at) = '#{Date.today}'").order("bookings.created_at desc").uniq end def completed customer =Customer.find_by_customer_id(params[:customer_id]) From b0f6368248aad0d245f0ec3c8250ce932a0344b6 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 5 Dec 2019 14:56:47 +0630 Subject: [PATCH 51/54] shop_code --- app/controllers/foodcourt/dashboard_controller.rb | 2 +- app/controllers/foodcourt/surveys_controller.rb | 2 ++ app/controllers/foodcourt/waste_spoile_controller.rb | 2 +- app/controllers/inventory/inventory_controller.rb | 2 +- app/controllers/oqs/home_controller.rb | 1 + app/controllers/origami/cash_ins_controller.rb | 1 + app/controllers/origami/cash_outs_controller.rb | 1 + app/controllers/origami/credit_payments_controller.rb | 5 +++-- app/controllers/origami/customers_controller.rb | 4 +++- app/controllers/origami/dashboard_controller.rb | 2 +- app/controllers/origami/discounts_controller.rb | 1 + app/controllers/origami/food_court_controller.rb | 1 + app/controllers/origami/home_controller.rb | 2 ++ app/controllers/origami/order_reservation_controller.rb | 3 +++ app/controllers/origami/pending_order_controller.rb | 4 ++++ app/controllers/origami/request_bills_controller.rb | 1 + app/controllers/origami/rooms_controller.rb | 3 ++- app/controllers/origami/shifts_controller.rb | 1 + app/controllers/origami/split_bill_controller.rb | 1 + app/controllers/origami/surveys_controller.rb | 2 ++ app/controllers/origami/table_invoices_controller.rb | 4 ++-- app/controllers/origami/void_controller.rb | 2 +- app/controllers/origami/waste_spoile_controller.rb | 2 +- app/controllers/reports/commission_controller.rb | 2 ++ app/controllers/reports/credit_payment_controller.rb | 2 ++ app/controllers/reports/dailysale_controller.rb | 1 + app/controllers/reports/hourly_saleitem_controller.rb | 3 ++- app/controllers/reports/induty_controller.rb | 2 ++ app/controllers/reports/order_reservation_controller.rb | 2 ++ app/controllers/reports/payment_method_controller.rb | 3 ++- app/controllers/reports/receipt_no_controller.rb | 3 +++ app/controllers/reports/receipt_no_detail_controller.rb | 2 ++ app/controllers/reports/saleitem_controller.rb | 4 +++- app/controllers/reports/shiftsale_controller.rb | 4 +++- app/controllers/reports/staff_meal_controller.rb | 2 +- app/controllers/reports/stock_check_controller.rb | 2 ++ app/controllers/reports/void_sale_controller.rb | 6 +++--- app/controllers/reports/waste_and_spoilage_controller.rb | 1 + app/controllers/settings/accounts_controller.rb | 2 ++ app/controllers/settings/cashier_terminals_controller.rb | 1 + app/controllers/settings/commissioners_controller.rb | 1 + app/controllers/settings/commissions_controller.rb | 1 + app/controllers/settings/membership_actions_controller.rb | 1 + app/controllers/settings/membership_settings_controller.rb | 1 + app/controllers/settings/menus_controller.rb | 3 +++ app/controllers/settings/order_queue_stations_controller.rb | 1 + app/controllers/settings/products_controller.rb | 2 +- app/controllers/settings/promotions_controller.rb | 1 + app/controllers/settings/rooms_controller.rb | 1 + app/controllers/settings/tables_controller.rb | 1 + app/controllers/settings/tax_profiles_controller.rb | 1 + app/controllers/settings/zones_controller.rb | 2 ++ app/controllers/transactions/credit_notes_controller.rb | 1 + .../transactions/order_reservations_controller.rb | 1 + app/controllers/transactions/orders_controller.rb | 2 +- app/controllers/transactions/shift_sales_controller.rb | 3 ++- app/controllers/transactions/surveys_controller.rb | 1 + app/models/sale_payment.rb | 6 +++--- 58 files changed, 95 insertions(+), 26 deletions(-) diff --git a/app/controllers/foodcourt/dashboard_controller.rb b/app/controllers/foodcourt/dashboard_controller.rb index 23c905b7..de47ecf4 100644 --- a/app/controllers/foodcourt/dashboard_controller.rb +++ b/app/controllers/foodcourt/dashboard_controller.rb @@ -109,7 +109,7 @@ def get_all_menu end def get_credit_sales - credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code) + credit_sales = SalePayment.get_credit_sales(params,Shop.current_shop.shop_code) if !credit_sales.nil? result = {:status=> true, :data=> credit_sales } else diff --git a/app/controllers/foodcourt/surveys_controller.rb b/app/controllers/foodcourt/surveys_controller.rb index 363bc6ba..bfdd30f6 100644 --- a/app/controllers/foodcourt/surveys_controller.rb +++ b/app/controllers/foodcourt/surveys_controller.rb @@ -1,5 +1,6 @@ class Foodcourt::SurveysController < BaseFoodcourtController def new + @shop = Shop.current_shop @webview = false if check_mobile @webview = true @@ -38,6 +39,7 @@ class Foodcourt::SurveysController < BaseFoodcourtController end def create + @shop = Shop.current_shop @type = params[:cashier_type] @sale_id = params[:sale_id] if params[:table_id].to_i>0 diff --git a/app/controllers/foodcourt/waste_spoile_controller.rb b/app/controllers/foodcourt/waste_spoile_controller.rb index d7847b27..bcc29f6a 100755 --- a/app/controllers/foodcourt/waste_spoile_controller.rb +++ b/app/controllers/foodcourt/waste_spoile_controller.rb @@ -1,6 +1,6 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController def waste_and_spoilage - + @shop = Shop.current_shop sale_id = params[:sale_id] remark = params[:remark] order_source = params[:type] diff --git a/app/controllers/inventory/inventory_controller.rb b/app/controllers/inventory/inventory_controller.rb index e06e2341..fa5cffc6 100755 --- a/app/controllers/inventory/inventory_controller.rb +++ b/app/controllers/inventory/inventory_controller.rb @@ -21,7 +21,7 @@ class Inventory::InventoryController < BaseInventoryController #Shop Name in Navbor helper_method :shop_detail - + def shop_detail @shop = Shop.current_shop end diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index c89f6e0a..abbe2295 100755 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -1,6 +1,7 @@ class Oqs::HomeController < BaseOqsController authorize_resource :class => false def index + @shop = Shop.current_shop # Query for OQS with delivery status false # @queue_items_details = queue_items_query(false) diff --git a/app/controllers/origami/cash_ins_controller.rb b/app/controllers/origami/cash_ins_controller.rb index ac3c0648..fa0fcfc7 100755 --- a/app/controllers/origami/cash_ins_controller.rb +++ b/app/controllers/origami/cash_ins_controller.rb @@ -3,6 +3,7 @@ class Origami::CashInsController < BaseOrigamiController end def create + @shop = Shop.current_shop reference = params[:reference] remark = params[:remark] amount = params[:amount] diff --git a/app/controllers/origami/cash_outs_controller.rb b/app/controllers/origami/cash_outs_controller.rb index e576bfc5..e714ff22 100755 --- a/app/controllers/origami/cash_outs_controller.rb +++ b/app/controllers/origami/cash_outs_controller.rb @@ -3,6 +3,7 @@ class Origami::CashOutsController < BaseOrigamiController end def create + @shop = Shop.current_shop reference = params[:reference] remark = params[:remark] amount = params[:amount] diff --git a/app/controllers/origami/credit_payments_controller.rb b/app/controllers/origami/credit_payments_controller.rb index 564945f5..cd83a346 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.current_shop + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else @@ -33,7 +33,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.current_shop + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj # new_total = Sale.get_rounding_adjustment(saleObj.grand_total) @@ -49,6 +49,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController end def create_credit_payment + @shop = Shop.current_shop arr_sale = JSON.parse(params[:data]) if !ShiftSale.current_shift(@shop.shop_code).nil? if !arr_sale.nil? diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index b812605b..5c536815 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -46,6 +46,7 @@ class Origami::CustomersController < BaseOrigamiController end def add_customer + @shop = Shop.current_shop @webview = false if check_mobile @webview = true @@ -162,6 +163,7 @@ class Origami::CustomersController < BaseOrigamiController end def send_account + @shop = Shop.current_shop amount = params[:amount] account_no = params[:account_no] receipt_no = params[:receipt_no] @@ -178,7 +180,7 @@ class Origami::CustomersController < BaseOrigamiController auth_token = member_actions.auth_token.to_s membership_data = SalePayment.get_paypar_account_data(url,membership_setting.auth_token,merchant_uid,auth_token,account_no,amount,receipt_no) puts membership_data.to_json - + if membership_data["status"]==true remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Transaction ref: #{membership_data[:transaction_ref]} | Reload amount #{membership_data[:reload_amount]} | Old Balance Amount #{membership_data[:old_balance_amount]} | DateTime : #{membership_data[:date]}" sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" ) diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index bc01dc27..2a0c9a4f 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -114,7 +114,7 @@ def get_all_menu end def get_credit_sales - credit_sales = SalePayment.get_credit_sales(params,current_shop.shop_code) + credit_sales = SalePayment.get_credit_sales(params,Shop.current_shop.shop_code) if !credit_sales.nil? result = {:status=> true, :data=> credit_sales } else diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 4d9f26f8..1de3f61c 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -3,6 +3,7 @@ class Origami::DiscountsController < BaseOrigamiController #discount page show from origami index with selected order def index + @shop = Shop.current_shop # get printer info @print_settings = PrintSetting.get_precision_delimiter() @webview = false diff --git a/app/controllers/origami/food_court_controller.rb b/app/controllers/origami/food_court_controller.rb index b44ac29b..fe1ad251 100644 --- a/app/controllers/origami/food_court_controller.rb +++ b/app/controllers/origami/food_court_controller.rb @@ -154,6 +154,7 @@ class Origami::FoodCourtController < ApplicationController end def get_all_product() + @shop = Shop.current_shop @product = Product..where("shop_code='#{@shop.shop_code}'") end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index b31e1a17..a977a2c2 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -3,6 +3,7 @@ class Origami::HomeController < BaseOrigamiController before_action :set_dining, only: [:show] def index + @shop = Shop.current_shop @webview = check_mobile @@ -19,6 +20,7 @@ class Origami::HomeController < BaseOrigamiController # origami table detail def show + @shop = Shop.current_shop # get printer info @print_settings = PrintSetting.get_precision_delimiter() @webview = check_mobile diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb index 3e26e07a..79acf1c5 100644 --- a/app/controllers/origami/order_reservation_controller.rb +++ b/app/controllers/origami/order_reservation_controller.rb @@ -10,6 +10,7 @@ class Origami::OrderReservationController < BaseOrigamiController end def update + @shop = Shop.current_shop @id = params[:order_id] @status = params[:status] min_type = params[:min_type] @@ -86,6 +87,7 @@ class Origami::OrderReservationController < BaseOrigamiController end def send_status + @shop = Shop.current_shop order_reservation = OrderReservation.find_by_transaction_ref(params[:ref_no]) if !order_reservation.nil? if !ShiftSale.current_shift(@shop.shop_code).nil? || params[:status] == 'accepted' || (order_reservation.status == 'new' && params[:status] == 'rejected') @@ -105,6 +107,7 @@ class Origami::OrderReservationController < BaseOrigamiController end def check_receipt_bill + @shop = Shop.current_shop receipt_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("order_reservation") status = 0 diff --git a/app/controllers/origami/pending_order_controller.rb b/app/controllers/origami/pending_order_controller.rb index c6bdb2e7..689b2424 100644 --- a/app/controllers/origami/pending_order_controller.rb +++ b/app/controllers/origami/pending_order_controller.rb @@ -1,5 +1,6 @@ class Origami::PendingOrderController < BaseOrigamiController def index + @shop = Shop.current_shop # @dining= DiningFacility.where("status = 'occupied'") # @order = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status = 'billed' and source = 'quick_service'",DateTime.now.strftime('%Y-%m-%d')) @cashier_type = params[:type] @@ -13,6 +14,7 @@ class Origami::PendingOrderController < BaseOrigamiController end def show + @shop = Shop.current_shop id = params[:sale_id] if id.start_with?("SAL") @sale = Sale.find(id) @@ -43,6 +45,7 @@ class Origami::PendingOrderController < BaseOrigamiController end def completed_sale + @shop = Shop.current_shop @cashier_type = params[:type] @sales = Sale.pending_sale(@cashier_type) @orders = Sale.pending_order(@cashier_type) @@ -78,6 +81,7 @@ class Origami::PendingOrderController < BaseOrigamiController end def credit_sale + @shop = Shop.current_shop @cashier_type = params[:type] @sales = Sale.pending_sale(@cashier_type) @orders = Sale.pending_order(@cashier_type) diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index a3cdf679..30126177 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -8,6 +8,7 @@ class Origami::RequestBillsController < ApplicationController end # Print Request Bill and add to sale tables def print + @shop = Shop.current_shop if !ShiftSale.current_shift(@shop.shop_code).nil? order_id = params[:id] # order_id order = Order.find(order_id) diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 6f219691..a20bfb7c 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -13,12 +13,13 @@ class Origami::RoomsController < BaseOrigamiController end def show + @shop = Shop.current_shop @webview = false if check_mobile @webview = true end - + @tables = Table.unscope(:order).all.active.order('status desc') @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 15f0d2d9..1b6fd355 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -42,6 +42,7 @@ class Origami::ShiftsController < BaseOrigamiController def update_shift + @shop = Shop.current_shop closing_balance = params[:closing_balance] shift_id = params[:shift_id] @shift = ShiftSale.find_by_id(shift_id) diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index b723af80..d43b4702 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -84,6 +84,7 @@ class Origami::SplitBillController < BaseOrigamiController end def create + @shop = Shop.current_shop cashier_type = params[:cashier_type] order_ids = params[:order_ids] arr_order_ids = nil diff --git a/app/controllers/origami/surveys_controller.rb b/app/controllers/origami/surveys_controller.rb index be8d6b1c..0312c2ef 100644 --- a/app/controllers/origami/surveys_controller.rb +++ b/app/controllers/origami/surveys_controller.rb @@ -1,5 +1,6 @@ class Origami::SurveysController < BaseOrigamiController def new + @shop = Shop.current_shop @webview = false if check_mobile @webview = true @@ -38,6 +39,7 @@ class Origami::SurveysController < BaseOrigamiController end def create + @shop = Shop.current_shop @type = params[:cashier_type] @sale_id = params[:sale_id] if params[:table_id].to_i>0 diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb index 3605d8e6..5cf20f30 100755 --- a/app/controllers/origami/table_invoices_controller.rb +++ b/app/controllers/origami/table_invoices_controller.rb @@ -2,7 +2,7 @@ class Origami::TableInvoicesController < BaseOrigamiController def index @table = DiningFacility.find(params[:table_id]) - shop = Shop.current_shop + @shop = Shop.current_shop @sale_array = Array.new @table.bookings.each do |booking| @@ -33,7 +33,7 @@ class Origami::TableInvoicesController < BaseOrigamiController @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all - shop = Shop.current_shop + @shop = Shop.current_shop @sale_array = Array.new @table.bookings.each do |booking| if booking.sale_id.nil? diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index a4fd46d1..1a041638 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -1,7 +1,7 @@ class Origami::VoidController < BaseOrigamiController authorize_resource :class => false def overall_void - + @shop = Shop.current_shop sale_id = params[:sale_id] remark = params[:remark] order_source = params[:type] #tax profile source diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb index 18391443..68a29b8a 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -1,6 +1,6 @@ class Origami::WasteSpoileController < BaseOrigamiController def waste_and_spoilage - + @shop = Shop.current_shop sale_id = params[:sale_id] remark = params[:remark] order_source = params[:type] diff --git a/app/controllers/reports/commission_controller.rb b/app/controllers/reports/commission_controller.rb index b30299d2..9d855cea 100755 --- a/app/controllers/reports/commission_controller.rb +++ b/app/controllers/reports/commission_controller.rb @@ -2,6 +2,7 @@ class Reports::CommissionController < BaseReportController # authorize_resource :class => false def index + @shop = Shop.current_shop from_date, to_date = get_date_range_from_params commissioner = params[:commissioner].to_i @@ -21,6 +22,7 @@ class Reports::CommissionController < BaseReportController end def show + @shop = Shop.current_shop from, to = get_date_range_from_params @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") diff --git a/app/controllers/reports/credit_payment_controller.rb b/app/controllers/reports/credit_payment_controller.rb index c1c16623..fc3b77cf 100755 --- a/app/controllers/reports/credit_payment_controller.rb +++ b/app/controllers/reports/credit_payment_controller.rb @@ -1,6 +1,7 @@ class Reports::CreditPaymentController < BaseReportController authorize_resource :class => false def index + @shop = Shop.current_shop @filter_for_credit = [['All',''],['Paid','paid'],['Unpaid','unpaid']] @sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]] from, to = get_date_range_from_params @@ -42,6 +43,7 @@ authorize_resource :class => false end def show + @shop = Shop.current_shop from, to = get_date_range_from_params @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) diff --git a/app/controllers/reports/dailysale_controller.rb b/app/controllers/reports/dailysale_controller.rb index a4fac509..44ee4bf0 100755 --- a/app/controllers/reports/dailysale_controller.rb +++ b/app/controllers/reports/dailysale_controller.rb @@ -2,6 +2,7 @@ class Reports::DailysaleController < BaseReportController authorize_resource :class => false def index + @shop = Shop.current_shop from, to = get_date_range_from_params @sale_data = Sale.daily_sales_list(from,to,@shop.shop_code) @tax = SaleTax.get_tax(from,to,@shop.shop_code) diff --git a/app/controllers/reports/hourly_saleitem_controller.rb b/app/controllers/reports/hourly_saleitem_controller.rb index 97264236..0bc57168 100644 --- a/app/controllers/reports/hourly_saleitem_controller.rb +++ b/app/controllers/reports/hourly_saleitem_controller.rb @@ -1,7 +1,7 @@ class Reports::HourlySaleitemController < BaseReportController authorize_resource :class => false def index - + @shop = Shop.current_shop @account = Account.where("shop_code='#{@shop.shop_code}'") from, to = get_date_range_from_params @@ -65,6 +65,7 @@ class Reports::HourlySaleitemController < BaseReportController end def show + @shop = Shop.current_shop from, to, report_type = get_date_range_from_params @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) sale_data = @sale_data diff --git a/app/controllers/reports/induty_controller.rb b/app/controllers/reports/induty_controller.rb index efc821a7..d02b1378 100644 --- a/app/controllers/reports/induty_controller.rb +++ b/app/controllers/reports/induty_controller.rb @@ -1,6 +1,7 @@ class Reports::IndutyController < BaseReportController authorize_resource :class => false def index + @shop = Shop.current_shop @commissioners = Commissioner.where("shop_code='#{@shop.shop_code}'") #.where("is_active='1'") from, to = get_date_range_from_params @@ -41,6 +42,7 @@ class Reports::IndutyController < BaseReportController end def show + @shop = Shop.current_shop from, to = get_date_range_from_params @induty_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") diff --git a/app/controllers/reports/order_reservation_controller.rb b/app/controllers/reports/order_reservation_controller.rb index 4625c1f1..1fa7ac50 100644 --- a/app/controllers/reports/order_reservation_controller.rb +++ b/app/controllers/reports/order_reservation_controller.rb @@ -1,6 +1,7 @@ class Reports::OrderReservationController < BaseReportController # authorize_resource :class => false def index + @shop = Shop.current_shop @providers = [["All",''], ["Direct Delivery","direct_delivery"],["Pick-Up","pick_up"],["TURBO","turbo"],["food2u","food2u"], ["ygndoor2door","ygndoor2door"]] @payment_types = [["All",''], ["COD","cash_on_delivery"],["DINGA","dinga"]] @@ -47,6 +48,7 @@ class Reports::OrderReservationController < BaseReportController end def show + @shop = Shop.current_shop from, to = get_date_range_from_params @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") diff --git a/app/controllers/reports/payment_method_controller.rb b/app/controllers/reports/payment_method_controller.rb index 7b51131a..1c1900bc 100644 --- a/app/controllers/reports/payment_method_controller.rb +++ b/app/controllers/reports/payment_method_controller.rb @@ -1,7 +1,7 @@ class Reports::PaymentMethodController < BaseReportController # authorize_resource :class => false def index - + @shop = Shop.current_shop @payments = [["All Payment",''],["Cash Payment","cash"], ["KBZ Payment", KbzPay::KBZ_PAY], ["Credit Payment","creditnote"], ["FOC Payment","foc"], ["MPU Payment","mpu"], ["Visa Payment","visa"], ["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"], @@ -42,6 +42,7 @@ class Reports::PaymentMethodController < BaseReportController end def show + @shop = Shop.current_shop from, to = get_date_range_from_params @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 3a5848d4..0b590421 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -1,6 +1,7 @@ class Reports::ReceiptNoController < BaseReportController authorize_resource :class => false def index + @shop = Shop.current_shop @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]] @payment_method = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'") from, to = get_date_range_from_params @@ -53,6 +54,7 @@ authorize_resource :class => false end def show + @shop = Shop.current_shop from, to = get_date_range_from_params @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") @@ -76,6 +78,7 @@ authorize_resource :class => false end def sync_data + @orders, @order_items, @sales, @sale_items, @sale_taxes, @sale_payments, @sale_orders, @sale_audits, @bookings, @assigned_order_items, @shift_sales = Booking.get_sync_data(params[:sale_id]) # Here comes to call the sync api diff --git a/app/controllers/reports/receipt_no_detail_controller.rb b/app/controllers/reports/receipt_no_detail_controller.rb index 59bf70c5..ebadb2cf 100755 --- a/app/controllers/reports/receipt_no_detail_controller.rb +++ b/app/controllers/reports/receipt_no_detail_controller.rb @@ -1,6 +1,7 @@ class Reports::ReceiptNoDetailController < BaseReportController authorize_resource :class => false def index + @shop = Shop.current_shop @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]] @payment_method = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'") from, to = get_date_range_from_params @@ -48,6 +49,7 @@ authorize_resource :class => false end def show + @shop = Shop.current_shop from, to = get_date_range_from_params @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index 57680e07..bc2ba6c9 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -1,7 +1,7 @@ class Reports::SaleitemController < BaseReportController authorize_resource :class => false def index - + @shop = Shop.current_shop @account = Account.where("shop_code='#{@shop.shop_code}'") from, to = get_date_range_from_params @@ -60,6 +60,7 @@ class Reports::SaleitemController < BaseReportController end def show + @shop = Shop.current_shop from, to, report_type = get_date_range_from_params @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") @@ -85,6 +86,7 @@ class Reports::SaleitemController < BaseReportController end def print_sale_items + @shop = Shop.current_shop from, to = get_date_range_from_params shift_sale_range = '' diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb index 5f842790..504ad815 100755 --- a/app/controllers/reports/shiftsale_controller.rb +++ b/app/controllers/reports/shiftsale_controller.rb @@ -2,7 +2,7 @@ class Reports::ShiftsaleController < BaseReportController authorize_resource :class => false def index - + @shop = Shop.current_shop from, to = get_date_range_from_params @shift = '' if params[:shift_name].to_i != 0 @@ -26,6 +26,7 @@ class Reports::ShiftsaleController < BaseReportController end def show + @shop = Shop.current_shop from, to = get_date_range_from_params @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") @@ -49,6 +50,7 @@ class Reports::ShiftsaleController < BaseReportController end def print_close_receipt + @shop = Shop.current_shop shift_id = params[:id] @shift = ShiftSale.find_by_id(shift_id) shift_obj = ShiftSale.where('id =?',shift_id) diff --git a/app/controllers/reports/staff_meal_controller.rb b/app/controllers/reports/staff_meal_controller.rb index 7049ec27..b047d729 100644 --- a/app/controllers/reports/staff_meal_controller.rb +++ b/app/controllers/reports/staff_meal_controller.rb @@ -1,7 +1,7 @@ class Reports::StaffMealController < BaseReportController authorize_resource :class => false def index - + @shop = Shop.current_shop @account = Account.where("shop_code='#{@shop.shop_code}'") from, to = get_date_range_from_params diff --git a/app/controllers/reports/stock_check_controller.rb b/app/controllers/reports/stock_check_controller.rb index 6b6d88d6..a3e86f81 100755 --- a/app/controllers/reports/stock_check_controller.rb +++ b/app/controllers/reports/stock_check_controller.rb @@ -2,6 +2,7 @@ class Reports::StockCheckController < BaseReportController # authorize_resource :class => false def index + @shop = Shop.current_shop # from_date = DateTime.now.beginning_of_day.utc.getlocal # to_date = DateTime.now.end_of_day.utc.getlocal # unless params[:daterange].blank? @@ -25,6 +26,7 @@ class Reports::StockCheckController < BaseReportController end def show + @shop = Shop.current_shop from, to = get_date_range_from_params @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") diff --git a/app/controllers/reports/void_sale_controller.rb b/app/controllers/reports/void_sale_controller.rb index c31b030a..f318adb9 100755 --- a/app/controllers/reports/void_sale_controller.rb +++ b/app/controllers/reports/void_sale_controller.rb @@ -1,7 +1,7 @@ class Reports::VoidSaleController < BaseReportController authorize_resource :class => false def index - + @shop = Shop.current_shop from, to = get_date_range_from_params # @shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) @@ -9,10 +9,10 @@ authorize_resource :class => false if params[:shift_name].to_i != 0 shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#@shop.shop_code' ",shift_sale.shift_started_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at) else - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#@shop.shop_code' ",shift_sale.shift_started_at, shift_sale.shift_closed_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at, shift_sale.shift_closed_at) end end diff --git a/app/controllers/reports/waste_and_spoilage_controller.rb b/app/controllers/reports/waste_and_spoilage_controller.rb index ccf8a47f..882218e7 100755 --- a/app/controllers/reports/waste_and_spoilage_controller.rb +++ b/app/controllers/reports/waste_and_spoilage_controller.rb @@ -1,6 +1,7 @@ class Reports::WasteAndSpoilageController < BaseReportController authorize_resource :class => false def index + @shop = Shop.current_shop from, to = get_date_range_from_params @sale_type = params[:sale_type] @sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type).where("sales.shop_code='#{@shop.shop_code}'") diff --git a/app/controllers/settings/accounts_controller.rb b/app/controllers/settings/accounts_controller.rb index d46ba093..b78038b6 100755 --- a/app/controllers/settings/accounts_controller.rb +++ b/app/controllers/settings/accounts_controller.rb @@ -5,6 +5,7 @@ class Settings::AccountsController < ApplicationController # GET /settings/accounts # GET /settings/accounts.json def index + @shop = Shop.current_shop @settings_accounts = Account.all.where("shop_code='#{@shop.shop_code}'") end @@ -25,6 +26,7 @@ class Settings::AccountsController < ApplicationController # POST /settings/accounts # POST /settings/accounts.json def create + @shop = Shop.current_shop @settings_account = Account.new(account_params) @settings_account.shop_code = @shop.shop_code respond_to do |format| diff --git a/app/controllers/settings/cashier_terminals_controller.rb b/app/controllers/settings/cashier_terminals_controller.rb index 987674d5..7bd3bfc6 100755 --- a/app/controllers/settings/cashier_terminals_controller.rb +++ b/app/controllers/settings/cashier_terminals_controller.rb @@ -27,6 +27,7 @@ class Settings::CashierTerminalsController < ApplicationController # POST /settings/cashier_terminals # POST /settings/cashier_terminals.json def create + @shop = Shop.current_shop @settings_cashier_terminal = CashierTerminal.new(settings_cashier_terminal_params) @settings_cashier_terminal.shop_code = @shop.shop_code respond_to do |format| diff --git a/app/controllers/settings/commissioners_controller.rb b/app/controllers/settings/commissioners_controller.rb index 54a9e926..f3e506d1 100755 --- a/app/controllers/settings/commissioners_controller.rb +++ b/app/controllers/settings/commissioners_controller.rb @@ -28,6 +28,7 @@ class Settings::CommissionersController < ApplicationController # POST /commissioners # POST /commissioners.json def create + @shop = Shop.current_shop @commissioner = Commissioner.new(commissioner_params) @commissioner.created_by = current_user.id @commissioner.shop_code = @shop.shop_code diff --git a/app/controllers/settings/commissions_controller.rb b/app/controllers/settings/commissions_controller.rb index 519074c7..0174a526 100755 --- a/app/controllers/settings/commissions_controller.rb +++ b/app/controllers/settings/commissions_controller.rb @@ -28,6 +28,7 @@ class Settings::CommissionsController < ApplicationController # POST /commissions # POST /commissions.json def create + @shop = Shop.current_shop @commission = Commission.new(commission_params) @commission.product_type = 'menu_item' @commission.product_code = "[]" diff --git a/app/controllers/settings/membership_actions_controller.rb b/app/controllers/settings/membership_actions_controller.rb index 0f1b8c93..fc79ad2c 100755 --- a/app/controllers/settings/membership_actions_controller.rb +++ b/app/controllers/settings/membership_actions_controller.rb @@ -25,6 +25,7 @@ class Settings::MembershipActionsController < ApplicationController # POST /settings/membership_actions # POST /settings/membership_actions.json def create + @shop = Shop.current_shop @settings_membership_action = MembershipAction.new(settings_membership_action_params) @settings_membership_action.shop_code = @shop.shop_code respond_to do |format| diff --git a/app/controllers/settings/membership_settings_controller.rb b/app/controllers/settings/membership_settings_controller.rb index 698c755c..61b4a648 100755 --- a/app/controllers/settings/membership_settings_controller.rb +++ b/app/controllers/settings/membership_settings_controller.rb @@ -25,6 +25,7 @@ class Settings::MembershipSettingsController < ApplicationController # POST /settings/membership_settings # POST /settings/membership_settings.json def create + @shop = Shop.current_shop @settings_membership_setting = MembershipSetting.new(settings_membership_setting_params) @settings_membership_setting.shop_code = @shop.shop_code respond_to do |format| diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index d7cb6b8a..449ae573 100755 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -5,6 +5,7 @@ class Settings::MenusController < ApplicationController # GET /settings/menus # GET /settings/menus.json def index + @shop = Shop.current_shop @settings_menus = Menu.all.where("shop_code='#{@shop.shop_code}'").page(params[:page]).per(10) respond_to do |format| format.html @@ -30,6 +31,7 @@ class Settings::MenusController < ApplicationController # POST /settings/menus # POST /settings/menus.json def create + @shop = Shop.current_shop @settings_menu = Menu.new(settings_menu_params) @settings_menu.created_by = current_login_employee.name @settings_menu.shop_code = @shop.shop_code @@ -74,6 +76,7 @@ class Settings::MenusController < ApplicationController end def export + @shop = Shop.current_shop @settings_menus = Menu.all.where("shop_code='#{@shop.shop_code}'").page(params[:page]).per(10) menu = Menu.find(params[:id]) diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index d28bdd91..fba533ff 100755 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -29,6 +29,7 @@ class Settings::OrderQueueStationsController < ApplicationController # POST /settings/order_queue_stations # POST /settings/order_queue_stations.json def create + @shop = Shop.current_shop @settings_order_queue_station = OrderQueueStation.new(settings_order_queue_station_params) @settings_order_queue_station.created_by = current_login_employee.name @settings_order_queue_station.processing_items = "[]" diff --git a/app/controllers/settings/products_controller.rb b/app/controllers/settings/products_controller.rb index b473a54e..a7955b22 100755 --- a/app/controllers/settings/products_controller.rb +++ b/app/controllers/settings/products_controller.rb @@ -26,7 +26,7 @@ load_and_authorize_resource except: [:create] # POST /settings/products # POST /settings/products.json def create - + @shop = Shop.current_shop @settings_product = Product.new(settings_product_params) @settings_product.created_by = current_user.name @settings_product.shop_code = @shop.shop_code diff --git a/app/controllers/settings/promotions_controller.rb b/app/controllers/settings/promotions_controller.rb index 25b1b9d7..57ee2d6d 100755 --- a/app/controllers/settings/promotions_controller.rb +++ b/app/controllers/settings/promotions_controller.rb @@ -28,6 +28,7 @@ class Settings::PromotionsController < ApplicationController # POST /promotions # POST /promotions.json def create + @shop = Shop.current_shop @promotion = Promotion.new(promotion_params) @promotion.created_by = current_login_employee.id @promotion.shop_code = @shop.shop_code diff --git a/app/controllers/settings/rooms_controller.rb b/app/controllers/settings/rooms_controller.rb index 5ba5c0ef..77d91885 100755 --- a/app/controllers/settings/rooms_controller.rb +++ b/app/controllers/settings/rooms_controller.rb @@ -25,6 +25,7 @@ class Settings::RoomsController < ApplicationController # POST /settings/rooms # POST /settings/rooms.json def create + @shop = Shop.current_shop @settings_room = Room.new(settings_room_params) @settings_room.type = DiningFacility::ROOM_TYPE @settings_room.zone_id = params[:zone_id] diff --git a/app/controllers/settings/tables_controller.rb b/app/controllers/settings/tables_controller.rb index 91f35eed..60b1ca59 100755 --- a/app/controllers/settings/tables_controller.rb +++ b/app/controllers/settings/tables_controller.rb @@ -25,6 +25,7 @@ class Settings::TablesController < ApplicationController # POST /settings/tables # POST /settings/tables.json def create + @shop = Shop.current_shop @settings_table = Table.new(settings_table_params) @settings_table.type = DiningFacility::TABLE_TYPE @settings_table.zone_id = params[:zone_id] diff --git a/app/controllers/settings/tax_profiles_controller.rb b/app/controllers/settings/tax_profiles_controller.rb index 298d077d..112de9fc 100755 --- a/app/controllers/settings/tax_profiles_controller.rb +++ b/app/controllers/settings/tax_profiles_controller.rb @@ -45,6 +45,7 @@ class Settings::TaxProfilesController < ApplicationController # POST /settings/tax_profiles # POST /settings/tax_profiles.json def create + @shop = Shop.current_shop @settings_tax_profile = TaxProfile.new(settings_tax_profile_params) @settings_tax_profile.created_by = current_login_employee.name @settings_tax_profile.shop_code = @shop.shop_code diff --git a/app/controllers/settings/zones_controller.rb b/app/controllers/settings/zones_controller.rb index 22b5165d..fcad9b8d 100755 --- a/app/controllers/settings/zones_controller.rb +++ b/app/controllers/settings/zones_controller.rb @@ -5,6 +5,7 @@ class Settings::ZonesController < ApplicationController # GET /settings/zones # GET /settings/zones.json def index + @shop = Shop.current_shop @settings_zones = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true") end @@ -27,6 +28,7 @@ class Settings::ZonesController < ApplicationController # POST /settings/zones # POST /settings/zones.json def create + @shop = Shop.current_shop @settings_zone = Zone.new(settings_zone_params) @settings_zone.shop_code =@shop.shop_code @settings_zone.created_by = current_login_employee.name diff --git a/app/controllers/transactions/credit_notes_controller.rb b/app/controllers/transactions/credit_notes_controller.rb index 4042091b..6052e4b5 100755 --- a/app/controllers/transactions/credit_notes_controller.rb +++ b/app/controllers/transactions/credit_notes_controller.rb @@ -6,6 +6,7 @@ class Transactions::CreditNotesController < ApplicationController # GET /transactions/sales # GET /transactions/sales.json def index + @shop = Shop.current_shop @sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]] @customers = Customer.all diff --git a/app/controllers/transactions/order_reservations_controller.rb b/app/controllers/transactions/order_reservations_controller.rb index c59688e8..6a5c3c60 100644 --- a/app/controllers/transactions/order_reservations_controller.rb +++ b/app/controllers/transactions/order_reservations_controller.rb @@ -6,6 +6,7 @@ class Transactions::OrderReservationsController < ApplicationController # GET /transactions/order_reservations # GET /transactions/order_reservations.json def index + @shop = Shop.current_shop from, to = get_date_range_from_params filter = params[:filter] diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index 30a82ac4..dbff1b43 100755 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -3,7 +3,7 @@ class Transactions::OrdersController < ApplicationController before_action :check_user def index - + @shop = Shop.current_shop filter = params[:filter] from = params[:from] to = params[:to] diff --git a/app/controllers/transactions/shift_sales_controller.rb b/app/controllers/transactions/shift_sales_controller.rb index 7e9684bb..00442a30 100644 --- a/app/controllers/transactions/shift_sales_controller.rb +++ b/app/controllers/transactions/shift_sales_controller.rb @@ -4,6 +4,7 @@ class Transactions::ShiftSalesController < ApplicationController before_action :check_user def index + @shop = Shop.current_shop filter = params[:filter] from = params[:from] @@ -32,7 +33,7 @@ class Transactions::ShiftSalesController < ApplicationController # GET /transactions/shift_sales/1 # GET /transactions/shift_sales/1.json def show - + @shop = Shop.current_shop @shift = ShiftSale.find(params[:id]) #get tax diff --git a/app/controllers/transactions/surveys_controller.rb b/app/controllers/transactions/surveys_controller.rb index 6e75a9de..cc975810 100644 --- a/app/controllers/transactions/surveys_controller.rb +++ b/app/controllers/transactions/surveys_controller.rb @@ -1,5 +1,6 @@ class Transactions::SurveysController < ApplicationController def index + @shop = Shop.current_shop filter = params[:filter] from = params[:from] to = params[:to] diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index a111a2da..298fb1d2 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -329,7 +329,7 @@ class SalePayment < ApplicationRecord merchant_uid:merchant_uid, auth_token:auth_token}.to_json end - + # Control for Paypar Cloud begin response = HTTParty.post(url, @@ -957,14 +957,14 @@ class SalePayment < ApplicationRecord #credit payment query - def self.get_credit_sales(params) + def self.get_credit_sales(params,shop_code) payments = SalePayment.select("sale_payments.sale_id, sale_payments.sale_payment_id, sale_payments.payment_method, sale_payments.payment_amount") .select("SUM(sale_payments.payment_amount) OVER (PARTITION BY sale_payments.sale_id) total_payment_amount") credit_sales = Sale.select("sales.sale_id, sales.receipt_no, sales.receipt_date as sale_date, sales.cashier_name") .select("sale_payments.sale_payment_id, sale_payments.payment_amount").select("customers.name as customer_name") .joins("JOIN (#{payments.to_sql}) AS sale_payments ON sale_payments.sale_id = sales.sale_id").joins(:customer).joins(:orders) - .completed.paid.where("sale_payments.payment_method = 'creditnote' AND sales.grand_total > sale_payments.total_payment_amount - sale_payments.payment_amount") + .completed.paid.where("sale_payments.payment_method = 'creditnote' AND sales.grand_total > sale_payments.total_payment_amount - sale_payments.payment_amount and sales.shop_code=?",shop_code) .group(:receipt_no) .order(:receipt_date).order(:receipt_no) From 5b3a62917d86921a6dd9be4ccd004447809de254 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Mon, 9 Dec 2019 17:27:38 +0630 Subject: [PATCH 52/54] void --- app/assets/javascripts/foodcourt.js | 186 +++++++++++++ app/controllers/api/payments_controller.rb | 2 +- .../foodcourt/orders_controller.rb | 3 +- .../foodcourt/paymal_controller.rb | 2 +- .../foodcourt/paypar_payments_controller.rb | 2 +- app/controllers/foodcourt/void_controller.rb | 28 +- .../origami/request_bills_controller.rb | 4 +- .../origami/split_bill_controller.rb | 2 +- app/models/printer/printer_worker.rb | 30 +- app/models/sale.rb | 41 +++ app/models/sale_payment.rb | 7 +- .../foodcourt/orders/app_orders.html.erb | 260 +++++++++++++----- app/views/foodcourt/payments/show.html.erb | 179 +++--------- config/initializers/assets.rb | 2 + config/puma.rb | 22 +- server2.pid | 2 +- 16 files changed, 509 insertions(+), 263 deletions(-) create mode 100644 app/assets/javascripts/foodcourt.js diff --git a/app/assets/javascripts/foodcourt.js b/app/assets/javascripts/foodcourt.js new file mode 100644 index 00000000..4febbe86 --- /dev/null +++ b/app/assets/javascripts/foodcourt.js @@ -0,0 +1,186 @@ +//= require jquery +//= require tether +//= require jquery_ujs +//= require bootstrap/js/popper.min +//= require bootstrap/js/bootstrap-material-design.min +//= require momentjs/moment +//= require bootstrap-material-datetimepicker/js/bootstrap-material-datetimepicker +//= require jquery-slimscroll/jquery.slimscroll.js +//= require bootstrap-notify/bootstrap-notify.js +//= require node-waves/waves.js +//= require sweetalert/sweetalert.min.js +//= require fileinput.min +//= require cable +//= require turbolinks +//= require BSBMaterial/turbolink_admin.js +//= require BSBMaterial/demo.js + +/* Constant Varaibles */ +_CREDIT_PAYMENTS_ = "/   CREDIT PAYMENTS"; +_CUSTOMERS_ = "/   CUSTOMERS"; +_DISCOUNTS_ = "/   DISCOUNTS"; +_IN_DUTIES_ = "/   IN DUTIES"; +_JCB_ = "/   JCB PAYMENT"; +_MASTER_ = "/   MASTER PAYMENT"; +_MPU_ = "/   MPU PAYMENT"; +_ALIPAY_ = "/   Alipay"; +_JUNCTIONPAY_ = "/   JunctionPay"; +_PAYMAL_ = "/   PAYMAL"; +_DINGA_ = "/   DINGA PAYMENT"; +_GIFT_VOUCHER_ = "/   GIFT VOUCHER"; +_OTHER_CHARGES_ = "/   CHARGES"; +_OTHER_PAYMENTS_ = "/   OTHER PAYMENT"; +_PAYMENTS_ = "/   PAYMENT"; +_PAYPAR_PAYMENT_ = "/   PAYPAR PAYMENT"; +_COMMISSIONS_ = "/   COMMISSIONS"; +_REDEEM_PAYMENT_ = "/   REDEEM PAYMENT"; +_SALE_EDIT_ = "/   SALE EDIT"; +_SPLIT_BILL_ = "/   SPLIT BILL"; +_UNION_ = "/   UNION PAYMENT"; +_VISA_ = "/   VISA PAYMENT"; +_VOUCHER_ = "/   VOUCHER"; +_SURVEY_ = "/   SURVEY"; +/* Constant Varaibles */ + +$(document).on('turbolinks:load', function() { + + $("#customer_image_path").fileinput({ + previewFileType: "image", + allowedFileExtensions: ["jpg", "gif", "png"], + browseClass: "btn btn-success", + browseLabel: "Pick Image", + browseIcon: " ", + removeClass: "btn btn-danger", + removeLabel: "Delete", + removeIcon: " ", + showUpload: false, + // uploadClass: "btn btn-info", + // uploadLabel: "Upload", + // uploadIcon: " ", + previewTemplates: { + image: '
\n' + + ' {caption}\n' + + '
\n', + } + }); + + $('.datetimepicker').bootstrapMaterialDatePicker({ + format: 'DD-MM-YYYY - HH:mm', + clearButton: true, + weekStart: 1 + }); + + $('.datepicker').bootstrapMaterialDatePicker({ + format: 'DD-MM-YYYY', + clearButton: true, + weekStart: 1, + time: false + }); + + $('.timepicker').bootstrapMaterialDatePicker({ + format: 'HH:mm', + clearButton: true, + date: false + }); + + // For selected order return + var order_status = ""; + order_status = $(".selected-item").children().find(".orders-order-status").text().substr(0,6).trim(); + + + $(document).on('click', '.access_modal', function(event){ + type = $(this).data("type"); + $(".ok").attr("data-action",type); + $('#AccessCodeModal').modal('show'); + }); + + $(document).on('click', '.access_number', function(event){ + if(event.handled !== true) { + var original_value = $('#access_code').val(); + var input_type = $(this).attr("data-type"); + + switch (input_type) { + case 'num': + var input_value = $(this).attr("data-value"); + if (original_value){ + $('#access_code').val(original_value + input_value); + }else{ + $('#access_code').val(original_value + input_value); + } + break; + case 'ok': + var type = $(this).attr("data-action"); + code = $('#access_code').val(); + check_emp_access_code(code,type) + break; + case 'clr': + $('#access_code').val(""); + break; + } + event.handled = true; + } else { + return false; + } + }); +}); + +function setHeaderBreadCrumb(params){ + $("#others_payment").html(params); +} + +//show hide nav bar for webview +function showHideNavbar(webview,page){ + if(webview){ + $("nav.navbar").addClass("hidden"); + $("section").addClass("section-margin"); + $(".page-loader-wrapper").addClass("hidden"); + if(page!=undefined){ + $("#back").hide(); + } + }else{ + $("nav.navbar").removeClass("hidden"); + $("section").removeClass("section-margin"); + $(".page-loader-wrapper").removeClass("hidden"); + if(page!=undefined){ + $("#back").show(); + } + } +} + +function createAccessCode(code) { + localStorage.setItem("access_code",code); +} +function check_emp_access_code(access_code,type) { + var url = "/foodcourt/check_emp_access_code/" + access_code ; + $.ajax({ + type: 'POST', + url: url, + data: {}, + success: function (result) { + if (result.status == true) { + createAccessCode(code); + if (type == "edit") { + var dining_id = $('#dining').text(); + var sale_id = $('#sale_id').text(); + if (dining_id) { + window.location.href = '/foodcourt/table/' + dining_id + "/sale/" + sale_id + "/food_court/edit"; + }else{ + window.location.href = "/foodcourt/table/sale/" + sale_id + "/food_court/edit"; + } + }else if(type == "void"){ + $('#AccessCodeModal').modal('hide'); + $('#voidModal').modal('show'); + }else if(type == "waste") { + waste_and_spoilage("waste") + }else if(type == "spoile") { + waste_and_spoilage("spoile") + }else if(type == "foc"){ + $('#AccessCodeModal').modal('hide'); + $('#focModal').modal('show'); + } + }else{ + swal("Oops",result.message,"warning"); + } + } + }); +} diff --git a/app/controllers/api/payments_controller.rb b/app/controllers/api/payments_controller.rb index 9d060a51..d59b619f 100755 --- a/app/controllers/api/payments_controller.rb +++ b/app/controllers/api/payments_controller.rb @@ -1,5 +1,5 @@ class Api::PaymentsController < Api::ApiController - # skip_before_action :authenticate + skip_before_action :authenticate #Payment by Invoice ID # Payment Method - [Cash | CreditNote | VISA | MASTER | etc..] diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index ca67efdd..7af39af0 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -70,7 +70,8 @@ class Foodcourt::OrdersController < BaseFoodcourtController .joins("JOIN orders ON orders.order_id=booking_orders.order_id") .joins("JOIN order_items ON orders.order_id=order_items.order_id") .joins("JOIN customers ON orders.customer_id=customers.customer_id") - .where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}' and DATE(bookings.created_at) = '#{Date.today}'").order("bookings.created_at desc").uniq + .where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}'").order("bookings.created_at desc").uniq + # .where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}' and DATE(bookings.created_at) = '#{Date.today}'").order("bookings.created_at desc").uniq end def completed customer =Customer.find_by_customer_id(params[:customer_id]) diff --git a/app/controllers/foodcourt/paymal_controller.rb b/app/controllers/foodcourt/paymal_controller.rb index 5907f6ec..bf69c946 100644 --- a/app/controllers/foodcourt/paymal_controller.rb +++ b/app/controllers/foodcourt/paymal_controller.rb @@ -9,7 +9,7 @@ class Foodcourt::PaymalController < BaseFoodcourtController @receipt_no = sale_data.receipt_no @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/foodcourt/paypar_payments_controller.rb b/app/controllers/foodcourt/paypar_payments_controller.rb index 8b917115..ab67b966 100755 --- a/app/controllers/foodcourt/paypar_payments_controller.rb +++ b/app/controllers/foodcourt/paypar_payments_controller.rb @@ -7,7 +7,7 @@ class Foodcourt::PayparPaymentsController < BaseFoodcourtController payment_method = "paypar" if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - + @shop = Shop.current_shop # rounding adjustment diff --git a/app/controllers/foodcourt/void_controller.rb b/app/controllers/foodcourt/void_controller.rb index 6d7dd34c..cf148742 100755 --- a/app/controllers/foodcourt/void_controller.rb +++ b/app/controllers/foodcourt/void_controller.rb @@ -33,15 +33,6 @@ class Foodcourt::VoidController < BaseFoodcourtController sale.sale_status = 'void' sale.save - # No Need - # bookings = sale.bookings - # bookings.each do |booking| - # orders = booking.orders - # orders.each do |order| - # # order.status = 'void' - # end - # end - if sale.bookings[0].dining_facility_id.to_i > 0 table_avaliable = true table_count = 0 @@ -79,8 +70,14 @@ class Foodcourt::VoidController < BaseFoodcourtController # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,"SALEVOID" ) - # For Print + #call paymal to void + if sale.sale_payments + membership_response =sale.paymal_payment_void + end + Rails.logger.debug "---------Paymal Payment Void response in VoidController" + Rails.logger.debug membership_response.to_json + # For Print member_info = nil rebate_amount = nil current_balance = nil @@ -102,17 +99,6 @@ class Foodcourt::VoidController < BaseFoodcourtController cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) end - - # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server - # get printer info - # print_settings = PrintSetting.find_by_unique_code('ReceiptBillPdf') # SaleItemsPdf - # - # if !print_settings.nil? - # unique_code = 'ReceiptBillPdf' - # elsif - # unique_code = 'ReceiptBillStarPdf' - # end - customer= Customer.find(sale.customer_id) # get member information diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 30126177..48cb19b4 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -9,7 +9,7 @@ class Origami::RequestBillsController < ApplicationController # Print Request Bill and add to sale tables def print @shop = Shop.current_shop - if !ShiftSale.current_shift(@shop.shop_code).nil? + if !ShiftSale.current_shift.nil? order_id = params[:id] # order_id order = Order.find(order_id) booking = order.booking @@ -46,7 +46,7 @@ class Origami::RequestBillsController < ApplicationController sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type ) # Promotion Activation - Promotion.promo_activate(sale_data,@shop.shop_code) + Promotion.promo_activate(sale_data) #bill channel if ENV["SERVER_MODE"] == 'cloud' diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index d43b4702..2216d5dd 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -320,7 +320,7 @@ class Origami::SplitBillController < BaseOrigamiController end end - Promotion.promo_activate(sale_data,@shop.shop_code) + Promotion.promo_activate(sale_data) if ENV["SERVER_MODE"] == 'cloud' from = request.subdomain + "." + request.domain else diff --git a/app/models/printer/printer_worker.rb b/app/models/printer/printer_worker.rb index e0d4fc85..39cbb431 100755 --- a/app/models/printer/printer_worker.rb +++ b/app/models/printer/printer_worker.rb @@ -38,20 +38,20 @@ class Printer::PrinterWorker end def print(file_path,printer_destination = nil ) - if printer_destination.nil? - printer_destination = self.printer_destination - end - - puts printer_destination - puts '........Printer Destination..........' - - copy = self.print_copies - #Print only when printer information is not null - if !self.printer_destination.nil? - (1..copy).each do - page = Cups::PrintJob.new(file_path, printer_destination) - page.print - end - end + # if printer_destination.nil? + # printer_destination = self.printer_destination + # end + # + # puts printer_destination + # puts '........Printer Destination..........' + # + # copy = self.print_copies + # #Print only when printer information is not null + # if !self.printer_destination.nil? + # (1..copy).each do + # page = Cups::PrintJob.new(file_path, printer_destination) + # page.print + # end + # end end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 6e856245..90ed9f73 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -2430,7 +2430,48 @@ def self.get_check_sale_data(transaction_date) .where("DATE(sales.receipt_date) = ? AND sales.sale_status != ?", transaction_date, :void) .group("sales.receipt_no,sales.sale_status") end +def paymal_payment_void + puts self.sale_payments.to_json + membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",self.shop_code) + membership_actions_data = MembershipAction.find_by_membership_type_and_shop_code("void",self.shop_code) + if !membership_actions_data.nil? + sale_payments =self.sale_payments.where("payment_reference is not null") + account_no =sale_payments[0].payment_reference + url = membership_setting.gateway_url.to_s + membership_actions_data.gateway_url.to_s + merchant_uid = membership_actions_data.merchant_account_id + auth_token = membership_actions_data.auth_token + params = { receipt_no:self.receipt_no, + account_no:account_no, + merchant_uid:merchant_uid, + auth_token:auth_token}.to_json + # Control for Paypar Cloud + begin + response = HTTParty.post(url, + :body => params, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json; version=3' + }, + :timeout => 10 + ) + rescue Errno::ECONNREFUSED + response = { "status" => false, "message" => "Can't open membership server"} + rescue Net::OpenTimeout + response = { "status" => false, "message" => "No internet connection " } + rescue OpenURI::HTTPError + response = { "status" => false, "message" => "No internet connection "} + rescue SocketError + response = { "status" => false, "message" => "No internet connection "} + end + else + response = { "status" => false} + end + + Rails.logger.debug "Void Payment response" + Rails.logger.debug response.to_json + return response; +end # Loader Service SFTP End private diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 298fb1d2..96be1d56 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -533,11 +533,8 @@ class SalePayment < ApplicationRecord payment_status = false #Next time - validate if the vochure number is valid - within - # customer_data = Customer.find_by_customer_id(self.sale.customer_id) account_no = self.payment_reference - # if account_no.to_i <= 0 - # account_no = customer_data.membership_id - # end + # self.sale.customer.update_attributes(paypar_account_no: ) membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",self.sale.shop_code) membership_data = SalePayment.create_payment(membership_setting.gateway_url,"PAYMAL",account_no,self.received_amount,self.sale.sale_id) @@ -548,7 +545,7 @@ class SalePayment < ApplicationRecord if membership_data["status"]==true self.payment_method = "paymal" self.payment_amount = self.received_amount - self.payment_reference = self.voucher_no + # self.payment_reference = self.voucher_no self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f self.payment_status = "paid" payment_status = self.save! diff --git a/app/views/foodcourt/orders/app_orders.html.erb b/app/views/foodcourt/orders/app_orders.html.erb index 0f751c2d..09deb513 100644 --- a/app/views/foodcourt/orders/app_orders.html.erb +++ b/app/views/foodcourt/orders/app_orders.html.erb @@ -7,6 +7,7 @@ } <%= javascript_include_tag 'custom', 'data-turbolinks-track': 'reload' %> +<%= javascript_include_tag 'foodcourt', 'data-turbolinks-track': 'reload' %> <% if @booking.nil?%>
<% if !@booking.nil?%> -
+
<% else %>
<% end %> @@ -57,80 +58,168 @@
<% if !@booking.nil?%> -
-
-
-
- ORDER DETAILS | Table-<%=@booking.dining_facility.name%>
- Booking - <%=@booking.booking_id%>
- Order No- <%=@booking.order_id%> + +
+
+
+
+ ORDER DETAILS | Table-<%=@booking.dining_facility.name%>
+ Booking - <%=@booking.booking_id%>
+ Order No- <%=@booking.order_id%> +
-
- -
-
-
-
- - - - - - - - - - - <% sub_total = 0 - count = 0 - %> - <% @sale_data.sale_items.each do |sale_item| - count += 1 - %> - <% sub_total += sale_item.price%> +
+
+
#ItemsQtyPrice
+ - - - - - - <%end %> - -
<%= count %><%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%><%=sale_item.qty%><%=(number_with_precision(sale_item.price, precision: precision.to_i ))%>
+ # + Items + Qty + Price + + + + <% sub_total = 0 + count = 0 + %> + <% @sale_data.sale_items.each do |sale_item| + count += 1 + %> + <% sub_total += sale_item.price%> + + <%= count %> + <%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%> + <%=sale_item.qty%> + <%=(number_with_precision(sale_item.price, precision: precision.to_i ))%> + + <%end %> + + +
+
- -
+
+
+
+ + Void +
+ <% end %> +
+ + +
diff --git a/app/views/foodcourt/payments/show.html.erb b/app/views/foodcourt/payments/show.html.erb index 336c7a2d..859f35b9 100755 --- a/app/views/foodcourt/payments/show.html.erb +++ b/app/views/foodcourt/payments/show.html.erb @@ -389,53 +389,22 @@
- - <% if current_login_employee.role == "cashier" %> - <% if @other_payment <= 0 && @sale_payment.nil? %> + <% if @sale_payment.nil? %> + - - <% end %> + + <% end %> <% end %> <% end %> - -<% if (@cashier_type=="quick_service" || @cashier_type=="food_court") && @sale_payment.nil? %> -
- <% if current_login_employee.role == "cashier" %> - Edit - <% else %> -