From 54ab9e0ca503f02b99f4d601682b72bc08e1b87c Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 18 Nov 2019 12:22:31 +0630 Subject: [PATCH] shops --- .../verifications_controller.rb | 27 ++++++++++++++++++ app/controllers/api/shops_controller.rb | 4 ++- app/controllers/home_controller.rb | 14 ++------- .../origami/dashboard_controller.rb | 1 - app/helpers/precision_helper.rb | 27 ++++++++++++++++++ app/models/sale.rb | 5 ++-- app/views/api/shops/index.json.jbuilder | 7 +++++ app/views/home/dashboard.html.erb | 24 ++++------------ config/initializers/action_controller.rb | 10 +++---- config/puma.rb | 22 +++++++------- config/routes.rb | 1 + dump.rdb | Bin 1534 -> 1864 bytes 12 files changed, 93 insertions(+), 49 deletions(-) create mode 100644 app/controllers/api/phone_verification/verifications_controller.rb create mode 100644 app/helpers/precision_helper.rb create mode 100644 app/views/api/shops/index.json.jbuilder diff --git a/app/controllers/api/phone_verification/verifications_controller.rb b/app/controllers/api/phone_verification/verifications_controller.rb new file mode 100644 index 00000000..077c4944 --- /dev/null +++ b/app/controllers/api/phone_verification/verifications_controller.rb @@ -0,0 +1,27 @@ +class Api::VerificationsController < ActionController::API + + def request_code + + phone_number = params[:phone_number] + + #TODO - user generate + + if @user.pin.nil? + @user.pin = rand(1000..9999) + @user.contact_no = phone_number + @user.pin_send_at = Time.now + @user.save + VerifyNumber.send_message(@user.contact_no, @user.pin) + #sent message + else + @user.contact_no = phone_number + @user.save + VerifyNumber.send_message(@user.contact_no, @user.pin) + #sent message + end + end + + def verify_code + end + +end \ No newline at end of file diff --git a/app/controllers/api/shops_controller.rb b/app/controllers/api/shops_controller.rb index e1c758fc..279af3f2 100644 --- a/app/controllers/api/shops_controller.rb +++ b/app/controllers/api/shops_controller.rb @@ -1,7 +1,9 @@ class Api::ShopsController < Api::ApiController + skip_before_action :authenticate + def index - + @shops = Shop.select('id,logo,name,shop_code,address,phone_no,cloud_url,cloud_token').all end end \ No newline at end of file diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 49b4ff5d..15072c2e 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,9 +1,9 @@ class HomeController < ApplicationController # layout "application", except: [:index, :show] # skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy] - + include PrecisionHelper before_action :check_user, only: :dashboard - + # Special check for only dashboard def check_user if current_user.nil? @@ -90,9 +90,7 @@ class HomeController < ApplicationController def dashboard @from, @to, @from_time, @to_time = get_date_range_from_params - @shop = Shop.first - today = DateTime.now.strftime('%Y-%m-%d') if !@from.nil? && !@to.nil? if !@from_time.nil? && @to_time.nil? @@ -115,12 +113,7 @@ class HomeController < ApplicationController @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) - # .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p') - # .sum(:grand_total) - logger.debug 'hourly_sales<>><><><<<<<<>><<<><><><><><><><><><<>><' - logger.debug @hourly_sales.to_json employee_sales = Sale.employee_sales(today,current_user,@from,@to,@from_time,@to_time) - # .sum("(CASE WHEN sp.payment_method='cash' THEN ((sp.payment_amount) - (sales.amount_changed)) ELSE (sp.payment_amount) END)") @employee_sales = [] if !employee_sales.nil? employee_sales.each do |emp| @@ -154,7 +147,6 @@ class HomeController < ApplicationController end @summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to,@from_time,@to_time) @total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time) - # @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) @@ -172,7 +164,7 @@ class HomeController < ApplicationController @total_foc_items = Sale.total_foc_items(today,current_user,@from,@to,@from_time,@to_time) # get printer info - @print_settings = PrintSetting.get_precision_delimiter() + # @print_settings = get_precision_delimiter end def destroy diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index 25ea8390..a4028323 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -2,7 +2,6 @@ class Origami::DashboardController < BaseOrigamiController def index @shop = Shop.first - today = DateTime.now.strftime('%Y-%m-%d') @display_type = Lookup.find_by_lookup_type("display_type") diff --git a/app/helpers/precision_helper.rb b/app/helpers/precision_helper.rb new file mode 100644 index 00000000..ada80673 --- /dev/null +++ b/app/helpers/precision_helper.rb @@ -0,0 +1,27 @@ +#PrecisionHelper +module PrecisionHelper + + def get_precision_delimiter + value_set = nil + + setting = PrintSetting.find_by_unique_code("CloseCashierPdf") + if setting.nil? + star_setting = PrintSetting.find_by_unique_code("CloseCashierStarPdf") + if star_setting.nil? + value_set = PrintSetting.find_by_unique_code("CloseCashierCustomisePdf") + else + value_set = star_setting + end + else + value_set = setting + end + + if !value_set.nil? + @precision_value = value_set.precision.to_i > 0 ? value_set.precision : 0 + @delimiter_value = value_set.delimiter ? "," : "" + end + + return @precision_value, @delimiter_value + end + +end diff --git a/app/models/sale.rb b/app/models/sale.rb index 98457d0e..d0995a26 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1589,9 +1589,10 @@ end end end end - end + end else if current_user.nil? + puts "Run employee " total = query.where('DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today) else if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor' @@ -1602,7 +1603,7 @@ end total = query.where('DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',today,today,shift.id) end end - end + end end end diff --git a/app/views/api/shops/index.json.jbuilder b/app/views/api/shops/index.json.jbuilder new file mode 100644 index 00000000..4836e68a --- /dev/null +++ b/app/views/api/shops/index.json.jbuilder @@ -0,0 +1,7 @@ +if @shops + json.status true + json.data @shops +else + json.status false + json.message "Record Not Found" +end \ No newline at end of file diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 0f9890d7..d8a5a9c8 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_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) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> + <%= number_with_precision( @summ_sale.total_discount, precision: @precision.to_i ,delimiter: @delimiter) rescue number_with_precision(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_with_precision( @summ_sale.total_tax , precision: @precision.to_i ,delimiter: @delimiter) rescue number_with_precision(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_with_precision( @summ_sale.grand_total , precision: @precision.to_i ,delimiter: @delimiter)%> @@ -240,7 +228,7 @@ @@ -253,7 +241,7 @@ <% end %> diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 205c330a..85f38ec5 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -21,11 +21,11 @@ class ActionController::Base end else # check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - else - redirect_to activate_path - end + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end end end 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/config/routes.rb b/config/routes.rb index 63d88bdf..78569cea 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,6 +44,7 @@ scope "(:locale)", locale: /en|mm/ do post 'authenticate' => "authenticate#create" delete 'authenticate' => "authenticate#destroy" + get 'get_shops' => "shops#index" namespace :restaurant do get 'zones' => "zones#index" resources :menu, only: [:index, :show] diff --git a/dump.rdb b/dump.rdb index d10886e44ca13c1d45643d5538e1d27543e2d358..9d8f3861cb642d297d6895c0836ca615b14f66b6 100644 GIT binary patch delta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Ruav-v{V-s-x)hP@}Wz=fk~L{+2A)_F|@X_=QKq5fxl5BpE(2}3sv zIlY8ni{RBp8weOYVZM_(v9o4dS6rQxVokPR4D23&SA`8l)@5N@2RMq|RdClv?w*>A}y;aoV1@){kDr3aCUszZz%D6xEkot0lo`S l<%*F(=DEd|%Wj-|s|B5$&>}k74!S7!*+%!*Tr-|*{{w+!=f3~|
<% @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_with_precision(data[""+pay_mth+""], precision: @precision.to_i ,delimiter: @delimiter) rescue number_with_precision(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_with_precision(total_card["card"], precision: @precision.to_i ,delimiter: @delimiter) rescue number_with_precision(0, precision: @precision.to_i ,delimiter: @delimiter) %>