diff --git a/192.168.1.242.crt b/192.168.1.242.crt deleted file mode 100644 index caa6b07a..00000000 --- a/192.168.1.242.crt +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDaDCCAlACCQCMa8dYfX0ohTANBgkqhkiG9w0BAQsFADB2MQswCQYDVQQGEwJZ -RzELMAkGA1UECAwCWUcxCzAJBgNVBAcMAllHMQwwCgYDVQQKDANDMkwxCjAIBgNV -BAsMATMxCzAJBgNVBAMMAlNYMSYwJAYJKoZIhvcNAQkBFhdud2VuaS5hdW5nQGNv -ZGUybGFiLmNvbTAeFw0xOTExMjYwNTM0NTNaFw0yMDExMjUwNTM0NTNaMHYxCzAJ -BgNVBAYTAllHMQswCQYDVQQIDAJZRzELMAkGA1UEBwwCWUcxDDAKBgNVBAoMA0My -TDEKMAgGA1UECwwBMzELMAkGA1UEAwwCU1gxJjAkBgkqhkiG9w0BCQEWF253ZW5p -LmF1bmdAY29kZTJsYWIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC -AQEAzjshIBw0Dnv4nFxBBtDd6TbcIR9GGndM7aKOr8yZBv7qKiRoFr9vtT/M1JZh -MO2G0DxvH9BjR1oVWNuAOBx7JUf9wweZ0ntaYT+kPen66LqTn5gFfCAJ+EAzIvaq -s2zlWB8Opl1kahW3LDLngmJGQPBTXO5UVfZHcxgyEGa4b+KdG9s8xqIC4HpvEOST -JmtZiuk/f/9tD7TqWhLsm/Aaw851/6kNjwZJYLbb/Trw8p04iLyyFl1yxVGQLfKB -uoT9tZizPJwZpxCPcvfk2aea0tO+tzBGvtC0VxIUGmBtsZyexVKj/dRuxYhYhFiT -m+0LXyBVyBU5tnuSlvTTM6Qy+wIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBUS4G7 -xFFlR7Jy1pru4sBMJk11r1pXjUU4lW8bgR1GYC/truda9JyIYlsnrpb+AkhKC1wT -cDufZs+mciN9u8K0eBSdwcAE+m1mSxa1AZbRLyXb9JxWEYmY53K/ktocQloBM3id -sNZQpsSsqZ4DEuaIzgc3A8C+bQbKi1/P2vo12quzGqebIryvy5QPXpi47ECmSGqW -mIBLhPoy3gzm6PamdY+0z+nKGTdAPS15tTpYsfRA3u54fiavluJYNRV2cFYlGPsS -6YmcQNV1R+ONfjaPCqH24/NNVgeeaKzb6uGIpgOfB2cb8aXjTDVUT0qVgJ3S9M4p -HflFmRqebVXhDDiE ------END CERTIFICATE----- diff --git a/192.168.1.242.key b/192.168.1.242.key deleted file mode 100644 index f47102c2..00000000 --- a/192.168.1.242.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDOOyEgHDQOe/ic -XEEG0N3pNtwhH0Yad0ztoo6vzJkG/uoqJGgWv2+1P8zUlmEw7YbQPG8f0GNHWhVY -24A4HHslR/3DB5nSe1phP6Q96froupOfmAV8IAn4QDMi9qqzbOVYHw6mXWRqFbcs -MueCYkZA8FNc7lRV9kdzGDIQZrhv4p0b2zzGogLgem8Q5JMma1mK6T9//20PtOpa -Euyb8BrDznX/qQ2PBklgttv9OvDynTiIvLIWXXLFUZAt8oG6hP21mLM8nBmnEI9y -9+TZp5rS0763MEa+0LRXEhQaYG2xnJ7FUqP91G7FiFiEWJOb7QtfIFXIFTm2e5KW -9NMzpDL7AgMBAAECggEABCQj0iU+1lue7mTb2WswSZKUcQXTvoxOuybcfqM5H27W -/OmmPW6yq40Qa+RpJzZd0qikApuIotIoQ5SEypunzWPYsKXibNuVQQaqIaQlKa81 -b6r50ThDevyvCjCx1NCG+nIFNUoCzi6JcxXCmFeo2Xz574/JmcBMRv9hYfruETEO -g5KvR+bhymaDGgKPoIgro2ar3DjKYMuWwaHJQClx3laYPIgnyGFvmTG/if5UykF4 -oTDnjVYkWqw8XOvsL5WhDBGbTq/f1jB7IjfIt1+pV51synVsa/zGNe3jQstCNBX0 -LK+7k8ub6v3jg2ZU0xx7z+hPuOIwz9HLjVEMfZWZwQKBgQDrSmJfbb7FMrPMKeaU -TEX6+fJRQkfgUdtfx8MK5PytV4WzkHOyJ2ankkpyh5TQG77MUzubfGPmg5nBT2+I -TEZO8rH83nOvMKLmXoPp0TvyBxGt0OqBb6RE+mc5rQmPk4lEtUq+i0L+/fB4RYMe -CZgn8pjuvBi+4oQOiQPSl+SwuQKBgQDgYffroNTn1i3VYNU3DYp9xjSLor7TPdsv -S2Xi5FXaZr9PcXdviBE9siY9KEBuiWVA5Q9Wv8XdBbA26VmEzyf+k7KzMr4Z6k5H -SlqClr4AFes6KYmvP2DrVaUsxlUeDO0saxahEK8PkMYTWbWDTAv0d2YD/mLcesEr -haeCCpyfUwKBgQCVCUDWgYVdE4ifwcq0FLwfBUNgBUPR6wex267Hr9P9WHrwCoe+ -SQbVDezqLscsKuboNbCEBH6i/KjfsZlMFERUrZXgPme4iG4mzadw63+1BpVELBje -dADxUEsiVWDA+Qrx4oO9vihprCAtjppG5HzkkN4eGjbycjiDnHY3Zs8MwQKBgAqS -kyv3GBEUdnRna6R8btoeTLuHn5Y0g+9mjhZyy9jOnpUPs6D9uFI/4q1fCCotLygv -otljj98qNXNg62bmm+vS6ciny21NLQMO7dTZZXp7jenfqy0mv1pXXsENV1VjJonB -Qf+02YrSN4MR5wuYubd7KMNnaSEaZ5+1XH80IM0hAoGBAJfHi94ZzPW2PDQr1GIm -CS0O0cHjQNI2+5Yde2U+WuXh/U2rMyB9iTyImqw/weTVFXS2AiRmss7CBTpIxhCP -1gVoNcRRfU7kmuiBXthgB/BuhSdeh/OQo7e9pKiNqoieMO+j8ocyvbMi8NSUl7pK -P9O47XLOplsft4lXqG6gkn8C ------END PRIVATE KEY----- diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index ab557a69..b754e506 100755 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -109,7 +109,7 @@ class Api::OrdersController < Api::ApiController @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/api/payments_controller.rb b/app/controllers/api/payments_controller.rb index 494ff43c..eb86ce55 100755 --- a/app/controllers/api/payments_controller.rb +++ b/app/controllers/api/payments_controller.rb @@ -30,7 +30,7 @@ class Api::PaymentsController < Api::ApiController @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) + current_shift = ShiftSale.current_shift current_login_employee =Employee.find(current_shift.employee_id) @status, @message = send_account_paymal(sale.grand_total, params[:card_no], sale.receipt_no,current_login_employee) if @status diff --git a/app/controllers/api/verifications_controller.rb b/app/controllers/api/verifications_controller.rb index 22ecf523..b53b2bad 100644 --- a/app/controllers/api/verifications_controller.rb +++ b/app/controllers/api/verifications_controller.rb @@ -1,5 +1,5 @@ class Api::VerificationsController < Api::ApiController - + skip_before_action :authenticate def new phone_number = params[:phone_number] diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index 0349356a..ad6549a7 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -68,7 +68,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'").order("bookings.created_at desc").uniq + .where("orders.source='app' 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 fca05a41..5907f6ec 100644 --- a/app/controllers/foodcourt/paymal_controller.rb +++ b/app/controllers/foodcourt/paymal_controller.rb @@ -1,4 +1,5 @@ class Foodcourt::PaymalController < BaseFoodcourtController + def index @sale_id = params[:sale_id] payment_method = params[:payment_method] @@ -6,7 +7,9 @@ class Foodcourt::PaymalController < BaseFoodcourtController @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 diff --git a/app/controllers/foodcourt/paypar_payments_controller.rb b/app/controllers/foodcourt/paypar_payments_controller.rb index fd1b4c1b..8b917115 100755 --- a/app/controllers/foodcourt/paypar_payments_controller.rb +++ b/app/controllers/foodcourt/paypar_payments_controller.rb @@ -7,7 +7,8 @@ class Foodcourt::PayparPaymentsController < BaseFoodcourtController payment_method = "paypar" if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - # shop_details = Shop.first + + @shop = Shop.current_shop # rounding adjustment if @shop.is_rounding_adj diff --git a/app/controllers/foodcourt/request_bills_controller.rb b/app/controllers/foodcourt/request_bills_controller.rb index 4e3057fe..d97dcd1f 100755 --- a/app/controllers/foodcourt/request_bills_controller.rb +++ b/app/controllers/foodcourt/request_bills_controller.rb @@ -8,7 +8,7 @@ class Foodcourt::RequestBillsController < ApplicationController end # Print Request Bill and add to sale tables def print - 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 @@ -45,7 +45,7 @@ class Foodcourt::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' @@ -62,14 +62,14 @@ class Foodcourt::RequestBillsController < ApplicationController render :json => result.to_json else #check checkInOut pdf print - checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time') + checkout_time = Lookup.collection_of('checkout_time') if !booking.dining_facility_id.nil? terminal = DiningFacility.find_by_id(booking.dining_facility_id) cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id) if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server unique_code = "CheckInOutPdf" - printer = PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + printer = PrintSetting.find_by_unique_code(unique_code) # print when complete click order_queue_printer = Printer::OrderQueuePrinter.new(printer) diff --git a/app/controllers/foodcourt/sales_controller.rb b/app/controllers/foodcourt/sales_controller.rb index f51786f9..cbc34cbe 100755 --- a/app/controllers/foodcourt/sales_controller.rb +++ b/app/controllers/foodcourt/sales_controller.rb @@ -7,7 +7,7 @@ class Foodcourt::SalesController < BaseFoodcourtController @tables = Table.unscoped.all.active.order('status desc') @rooms = Room.unscoped.all.active.order('status desc') - @complete = Sale.completed_sale("cashier",@shop.shop_code) + @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") @sale = Sale.find(params[:sale_id]) diff --git a/app/controllers/settings/payment_method_settings_controller.rb b/app/controllers/settings/payment_method_settings_controller.rb index e85e7a99..e6361610 100755 --- a/app/controllers/settings/payment_method_settings_controller.rb +++ b/app/controllers/settings/payment_method_settings_controller.rb @@ -26,7 +26,7 @@ class Settings::PaymentMethodSettingsController < ApplicationController # POST /settings/payment_method_settings.json def create @settings_payment_method_setting = PaymentMethodSetting.new(settings_payment_method_setting_params) - @settings_payment_method_setting.shop_code = @shop.shop_code + @settings_payment_method_setting.shop_code = Shop.current_shop.shop_code respond_to do |format| if @settings_payment_method_setting.save format.html { redirect_to settings_payment_method_settings_path, notice: 'Payment method setting was successfully created.' } diff --git a/app/controllers/transactions/bookings_controller.rb b/app/controllers/transactions/bookings_controller.rb index 8bb56249..0a6f7cbb 100644 --- a/app/controllers/transactions/bookings_controller.rb +++ b/app/controllers/transactions/bookings_controller.rb @@ -9,10 +9,10 @@ class Transactions::BookingsController < ApplicationController to = params[:to] if filter.nil? && from.nil? && to.nil? - @bookings = Booking.where("shop_code='#{@shop.shop_code}'").order("sale_id desc") + @bookings = Booking.order("sale_id desc") @bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(20) else - booking = Booking.search(filter,from,to).where("bookings.shop_code='#{@shop.shop_code}'") + booking = Booking.search(filter,from,to) if booking.count > 0 @bookings = booking @bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(20) diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 6556159c..d8c2e120 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -18,13 +18,13 @@ class Transactions::SalesController < ApplicationController if receipt_no.nil? && from.nil? && to.nil? if @shift.blank? - @sales = Sale.where("NOT sale_status='new' and shop_code='#{@shop.shop_code}'").order("sale_id desc") + @sales = Sale.where("NOT sale_status='new'").order("sale_id desc") else - @sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}' and shop_code='#{@shop.shop_code}'").order("sale_id desc") + @sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").order("sale_id desc") end @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20) else - sale = Sale.search(receipt_no,from,to,@shift).where("sales.shop_code='#{@shop.shop_code}'") + sale = Sale.search(receipt_no,from,to,@shift) if sale.count > 0 @sales = sale @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20) @@ -89,8 +89,8 @@ class Transactions::SalesController < ApplicationController # GET /transactions/sales/1 # GET /transactions/sales/1.json def show - @membership = MembershipSetting.find_by_shop_code(@shop.shop_code) - @payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}' and is_active='1'") + @membership = MembershipSetting.find_by_shop_code(Shop.current_shop.shop_code) + @payment_methods = PaymentMethodSetting.where("is_active='1'") @sale = Sale.find(params[:id]) @order_items = [] diff --git a/app/models/promotion.rb b/app/models/promotion.rb index 3e657e63..9359510a 100755 --- a/app/models/promotion.rb +++ b/app/models/promotion.rb @@ -15,11 +15,11 @@ class Promotion < ApplicationRecord promo_day.include? Date.today.wday.to_s end - def self.promo_activate(saleObj,shop_code) + def self.promo_activate(saleObj) current_day = Time.now.strftime("%Y-%m-%d") current_time = Time.now.strftime('%H:%M:%S') day = Date.today.wday - promoList = is_between_promo_datetime(current_day,current_time,shop_code) + promoList = is_between_promo_datetime(current_day,current_time) promoList.each do |promo| if promo.is_promo_day @@ -30,8 +30,8 @@ class Promotion < ApplicationRecord end end - def self.is_between_promo_datetime(current_day,current_time,shop_code) #database is not local time - promoList = Promotion.where("shop_code='#{shop_code}' and (Date_Format(promo_start_date, '%Y-%m-%d') <=? AND Date_Format(promo_end_date, '%Y-%m-%d') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time) + def self.is_between_promo_datetime(current_day,current_time) #database is not local time + promoList = Promotion.where("(Date_Format(promo_start_date, '%Y-%m-%d') <=? AND Date_Format(promo_end_date, '%Y-%m-%d') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time) return promoList end diff --git a/app/models/sale.rb b/app/models/sale.rb index ebcd512b..6e856245 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -149,12 +149,12 @@ class Sale < ApplicationRecord if !booking.dining_facility_id.nil? table = DiningFacility.find(booking.dining_facility_id) cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) - shift = ShiftSale.where("shop_code='#{order.shop_code}' and shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{cashier_zone.cashier_terminal_id}").first + shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{cashier_zone.cashier_terminal_id}").first #for multiple zone with terminal if shift.nil? multiple_zone = CashierTerminalByZone.where("zone_id = #{table.zone_id}") multiple_zone.each do |zone| - shift = ShiftSale.where("shop_code='#{order.shop_code}' and shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{zone.cashier_terminal_id}").first + shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{zone.cashier_terminal_id}").first if !shift.nil? then break end @@ -192,7 +192,7 @@ class Sale < ApplicationRecord self.requested_by = requested_by.name self.requested_at = DateTime.now.utc.getlocal - self.shop_code = order.shop_code + self.shop_code = Shop.current_shop.shop_code Rails.logger.debug "Order -> #{order.id} | order_status -> #{order.status}" if order self.customer_id = order.customer_id @@ -255,7 +255,7 @@ class Sale < ApplicationRecord # @sale_data.save # Promotion Activation - Promotion.promo_activate(@sale_data,order.shop_code) + Promotion.promo_activate(@sale_data) @status = true return @status, @sale_data else @@ -1053,19 +1053,19 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou product = self.get_product_sale() if shift.present? - query = query.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a) + query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a) if type.nil? || type == 'all' || type == "other" - other_charges = other_charges.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) + other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) end - product = product.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) - discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount) - change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed) + product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) + discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount) + change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") - .where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a) + .where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a) sale_cash.each do |s_c| total_cash_amount += s_c.cash_amount.to_f total_card_amount += s_c.card_amount.to_f @@ -1076,19 +1076,19 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou ### => get all sales range in shift_sales elsif shift_sale_range.present? - query = query.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift_sale_range.to_a) + query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift_sale_range.to_a) if type.nil? || type == 'all' || type == "other" - other_charges = other_charges.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) + other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) end - product = product.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) - discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) - change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) + product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) + discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) + change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") - .where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a) + .where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a) sale_cash.each do |s_c| total_cash_amount += s_c.cash_amount.to_f total_card_amount += s_c.card_amount.to_f @@ -1099,20 +1099,20 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f else - query = query.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to) + query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to) if type.nil? || type == 'all' || type == "other" - other_charges = other_charges.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status='completed'",from,to) + other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) end product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) - discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) - change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) + discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) + change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") - .where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to) + .where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to) sale_cash.each do |s_c| total_cash_amount += s_c.cash_amount.to_f total_card_amount += s_c.card_amount.to_f @@ -1158,19 +1158,19 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status,account_ product = self.get_product_sale() if shift.present? - query = query.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",shift.to_a) + query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",shift.to_a) # if type.nil? || type == 'all' || type == "other" # other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) # end - product = product.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) - discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount) - change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed) + product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) + discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount) + change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") - .where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a) + .where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a) sale_cash.each do |s_c| total_cash_amount += s_c.cash_amount.to_f total_card_amount += s_c.card_amount.to_f @@ -1181,12 +1181,12 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status,account_ ### => get all sales range in shift_sales elsif shift_sale_range.present? - query = query.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",shift_sale_range.to_a) + query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",shift_sale_range.to_a) # if type.nil? || type == 'all' || type == "other" # other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) # end - product = product.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) - discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) + product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) + discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, @@ -2063,7 +2063,7 @@ end else type = "and orders.source = '#{type}'" end - query = Sale.where("sales.shop_code='#{Shop.current_shop.shop_code}'") + query = Sale.all 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}") @@ -2126,7 +2126,7 @@ def self.get_sale_data_for_other_payment_credit(sale_id) end def unique_tax_profiles(order_source, customer_id) - tax_data = TaxProfile.where(group_type: order_source,shop_code: self.shop_code) + tax_data = TaxProfile.where(group_type: order_source) customer_tax_profiles = Customer.select(:tax_profiles).where(customer_id: customer_id).first if customer_tax_profiles.present? tax_data = tax_data.where(id: customer_tax_profiles.tax_profiles) @@ -2140,7 +2140,7 @@ def self.employee_sale(shift=nil,from=nil,to=nil,from_time=nil,to_time=nil, curr query = Sale.joins(:cashier) .joins(:sale_payments) - .paid.completed.where("sales.shop_code='#{current_shop.shop_code}'") + .paid.completed if !from.nil? && !to.nil? query = query.receipt_date_between(from, to) else @@ -2179,19 +2179,19 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco product = self.get_product_sale() if shift.present? - query = query.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a) + query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a) if type.nil? || type == 'all' || type == "other" - other_charges = other_charges.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) + other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) end - product = product.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) - discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount) - change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed) + product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) + discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount) + change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") - .where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a) + .where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a) sale_cash.each do |s_c| total_cash_amount += s_c.cash_amount.to_f total_card_amount += s_c.card_amount.to_f @@ -2202,19 +2202,19 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco ### => get all sales range in shift_sales elsif shift_sale_range.present? - query = query.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift_sale_range.to_a) + query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift_sale_range.to_a) if type.nil? || type == 'all' || type == "other" - other_charges = other_charges.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) + other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) end - product = product.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) - discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) - change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) + product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) + discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) + change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") - .where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a) + .where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a) sale_cash.each do |s_c| total_cash_amount += s_c.cash_amount.to_f total_card_amount += s_c.card_amount.to_f @@ -2225,20 +2225,20 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f else - query = query.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to) + query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to) if type.nil? || type == 'all' || type == "other" - other_charges = other_charges.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status='completed'",from,to) + other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) end - product = product.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status='completed'",from,to) + product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) - discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) - change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) + discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) + change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") - .where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to) + .where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to) sale_cash.each do |s_c| total_cash_amount += s_c.cash_amount.to_f total_card_amount += s_c.card_amount.to_f diff --git a/app/models/verify_number.rb b/app/models/verify_number.rb index 6cb885b1..f8a67226 100644 --- a/app/models/verify_number.rb +++ b/app/models/verify_number.rb @@ -1,4 +1,4 @@ -class VerifyNumber < ApplicationRecord +class VerifyNumber def self.send_message(phone, pin) diff --git a/app/views/api/verifications/new.json.jbuilder b/app/views/api/verifications/new.json.jbuilder index c187f79b..d642e169 100644 --- a/app/views/api/verifications/new.json.jbuilder +++ b/app/views/api/verifications/new.json.jbuilder @@ -1,7 +1,11 @@ -if @result && @cus +if @result json.status true json.sent_pin true + elsif @cus + json.status true + json.sent_pin false + json.customer_id @cus.id else json.status false - json.message "Customer Not Found" + json.message "Phone number invalid" end diff --git a/app/views/foodcourt/orders/app_orders.html.erb b/app/views/foodcourt/orders/app_orders.html.erb index 0ff8af0f..42492fe5 100644 --- a/app/views/foodcourt/orders/app_orders.html.erb +++ b/app/views/foodcourt/orders/app_orders.html.erb @@ -149,8 +149,8 @@ text: 'Send sms to customer ', type: "success", }, function () { - window.location.href ="<%=foodcourt_app_order_by_booking_path %>"; - } + window.location.href ="<%=foodcourt_app_order_by_booking_path %>"; + }); } }); } 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