fixed conflict after merch dev for current shop

This commit is contained in:
Nweni
2019-12-02 19:30:24 +06:30
92 changed files with 1611 additions and 350 deletions

View File

@@ -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"]

19
Dockerfile.backup Normal file
View File

@@ -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"]

View File

@@ -1,6 +1,9 @@
source 'https://rubygems.org'
# ruby '2.4.1'
#ruby '2.5.0'
#ruby '2.5.7'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
@@ -40,6 +43,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'

View File

@@ -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
@@ -271,8 +276,7 @@ GEM
activemodel (>= 5.0)
spreadsheet (1.2.5)
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)
@@ -316,6 +320,7 @@ PLATFORMS
ruby
DEPENDENCIES
acts_as_tenant
aescrypt
axlsx (= 2.0.1)
axlsx_rails

View File

@@ -1,5 +1,5 @@
class Api::ApiController < ActionController::API
include TokenVerification
include TokenVerification, MultiTenancy
include ActionController::MimeResponds
before_action :core_allow

View File

@@ -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

View File

@@ -23,7 +23,8 @@ 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)

View File

@@ -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")

View File

@@ -46,6 +46,7 @@ class Api::OrdersController < Api::ApiController
@tax_profile = TaxProfile.where("lower(group_type)='cashier'")
# end
@shop = Shop.current_shop
return @shop.to_json
end

View File

@@ -14,7 +14,8 @@ 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")

View File

@@ -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")

View File

@@ -1,5 +1,5 @@
class ApplicationController < ActionController::Base
include LoginVerification
include LoginVerification, MultiTenancy
#before_action :check_installation
protect_from_forgery with: :exception

View File

@@ -1,4 +1,5 @@
class BaseController < ActionController::Base
include MultiTenancy
layout "installation"
protect_from_forgery with: :exception

View File

@@ -1,5 +1,5 @@
class BaseCrmController < ActionController::Base
include LoginVerification
include LoginVerification,
layout "CRM"
before_action :check_user

View File

@@ -1,5 +1,5 @@
class BaseInventoryController < ActionController::Base
include LoginVerification
include LoginVerification, MultiTenancy
layout "inventory"
before_action :check_user

View File

@@ -1,5 +1,5 @@
class BaseOqsController < ActionController::Base
include LoginVerification
include LoginVerification, MultiTenancy
layout "OQS"
before_action :check_user

View File

@@ -1,5 +1,5 @@
class BaseOrigamiController < ActionController::Base
include LoginVerification
include LoginVerification, MultiTenancy
layout "origami"
before_action :check_user

View File

@@ -1,5 +1,5 @@
class BaseReportController < ActionController::Base
include LoginVerification
include LoginVerification, MultiTenancy
layout "application"
before_action :check_user

View File

@@ -1,5 +1,5 @@
class BaseWaiterController < ActionController::Base
include LoginVerification
include LoginVerification, MultiTenancy
layout "waiter"
before_action :check_user

View File

@@ -2,7 +2,7 @@ module LoginVerification
extend ActiveSupport::Concern
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.
@@ -17,7 +17,11 @@ module LoginVerification
end
def current_shop
@current_shop
begin
return Shop.current_shop
rescue
return nil
end
end
def current_login_employee
@@ -36,9 +40,7 @@ module LoginVerification
#Shop Name in Navbor
def shop_detail
# shop_code ='262'
# @shop = Shop.find_by_shop_code(shop_code)
return @current_shop
@shop = current_shop
end
#check order reservation used

View File

@@ -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

View File

@@ -2,37 +2,43 @@ module NumberFormattable
extend ActiveSupport::Concern
def precision
@precision ||= Lookup.number_formats.find { |f| f.name.parameterize.underscore == 'precision'}
return @precision if defined? @precision
@number_formats = Lookup.number_formats if !defined? @number_formats
if @number_formats
@precision = @number_formats.find? { |x| x.name.parameterize.underscore == 'precision'}.value.to_i rescue nil
end
if @precision.nil?
@print_settings ||= PrintSetting.get_precision_delimiter
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
if @print_settings
@precision = OpenStruct.new(value: @print_settings.precision.to_i)
@precision = @print_settings.precision.to_i
else
@precision = OpenStruct.new(value: 2)
@precision = 2
end
end
@precison_value ||= @precision.value.to_i
end
def delimiter
@delimiter ||= Lookup.number_formats.find { |f| f.name.parameterize.underscore == 'delimiter'}
return @delimiter if defined? @delimiter
@number_formats = Lookup.number_formats if !defined? @number_formats
if @number_formats
@delimiter = @number_formats.find { |f| f.name.parameterize.underscore == 'delimiter'}.value.gsub(/\\u(\h{4})/) { |m| [$1].pack("H*").unpack("n*").pack("U*") } rescue nil
end
if @delimiter.nil?
@print_settings ||= PrintSetting.get_precision_delimiter
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
if @print_settings && @print_settings.delimiter
@delimiter = OpenStruct.new(value: ",")
@delimiter = ","
else
@delimiter = OpenStruct.new(value: "")
@delimiter = ","
end
end
@delimiter_value ||= @delimiter.value.to_s.gsub(/\\u(\h{4})/) { |m| [$1].pack("H*").unpack("n*").pack("U*") }
end
def strip_insignificant_zeros
@strip_insignificant_zeros ||= Lookup.number_formats.find { |f| f.name.parameterize.underscore == 'strip_insignificant_zeros'}
if @strip_insignificant_zeros.nil?
@strip_insignificant_zeros = OpenStruct.new(value: false)
return @strip_insignificant_zeros if defined? @strip_insignificant_zeros
@number_formats = Lookup.number_formats if !defined? @number_formats
if @number_formats
@strip_insignificant_zeros = @number_formats.find { |f| f.name.parameterize.underscore == 'strip_insignificant_zeros'}.value.in? ['1', 't', 'true', 'on', 'y', 'yes'] rescue false
end
@strip_insignificant_zeros_value ||= ['1', 't', 'true', 'on', 'y', 'yes'].include? @strip_insignificant_zeros.value.to_s
end
def number_format(number, options = {})
@@ -40,14 +46,16 @@ module NumberFormattable
# options[:delimiter] = options[:delimiter] || delimiter
options[:strip_insignificant_zeros] = options[:strip_insignificant_zeros] || strip_insignificant_zeros
number = number.to_f.round(options[:precision])
if options[:precision] > 0
if options[:strip_insignificant_zeros]
formatted = "%.12g" % number.round(options[:precision])
formatted = "%.12g" % number
else
formatted = "%.#{options[:precision]}f" % number.round(options[:precision])
formatted = "%.#{options[:precision]}f" % number
end
else
formatted = number.round(options[:precision]).to_i.to_s
formatted = number.to_i.to_s
end
if options[:delimiter] && !options[:delimiter].empty?

View File

@@ -83,7 +83,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

View File

@@ -96,7 +96,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

View File

@@ -18,4 +18,12 @@ class Inventory::InventoryController < BaseInventoryController
format.xls
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
end

View File

@@ -104,6 +104,12 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
private
# Use callbacks to share common setup or constraints between actions.
def set_inventory_definition

View File

@@ -60,6 +60,12 @@ class Inventory::StockCheckItemsController < BaseInventoryController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
private
# Use callbacks to share common setup or constraints between actions.
def set_stock_check_item

View File

@@ -45,9 +45,10 @@ class Inventory::StockChecksController < BaseInventoryController
member_info = nil
unique_code = 'StockCheckPdf'
shop_details = current_shop
checker = Employee.find_by_id_and_shop_code(stockcheck.check_by,@shop.shop_code)
print_settings = PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
shop_details = Shop.current_shop
checker = Employee.find(stockcheck.check_by)
print_settings = PrintSetting.find_by_unique_code(unique_code)
if !print_settings.nil?
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, @shop)
@@ -68,7 +69,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]

View File

@@ -61,6 +61,12 @@ class StockJournalsController < ApplicationController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
private
# Use callbacks to share common setup or constraints between actions.
def set_stock_journal

View File

@@ -81,4 +81,10 @@ class Oqs::EditController < BaseOqsController
render :json => {:status=> false, :message => "Not allowed over quantity!" }
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
end

View File

@@ -11,7 +11,8 @@ 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 +65,8 @@ 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
@@ -86,8 +88,9 @@ class Origami::AlipayController < BaseOrigamiController
end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
end

View File

@@ -9,6 +9,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController
@creditcount = 0
others = 0
@shop = Shop.current_shop
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
@@ -32,6 +33,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop.current_shop
# rounding adjustment
# if shop_details.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)

View File

@@ -6,8 +6,8 @@ class Origami::CreditSalesController < 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')
@customers = Customer.pluck("customer_id, name")

View File

@@ -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?

View File

@@ -1,19 +1,20 @@
class Origami::DashboardController < BaseOrigamiController
def index
today = DateTime.now.strftime('%Y-%m-%d')
@display_type = Lookup.where("shop_code='#{current_shop.shop_code}'").find_by_lookup_type("display_type")
@shop = Shop.current_shop
@display_type = Lookup.find_by_lookup_type("display_type")
@sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(current_user)
if !@total_payment_methods.nil?
@total_payment_methods.each do |payment|
pay = Sale.payment_sale(payment.payment_method, current_user)
@sale_data.push({payment.payment_method => pay.payment_amount})
end
if !@total_payment_methods.nil?
@total_payment_methods.each do |payment|
pay = Sale.payment_sale(payment.payment_method, current_user)
@sale_data.push({payment.payment_method => pay.payment_amount})
end
else
@sale_data = nil
end
@@ -27,15 +28,14 @@ class Origami::DashboardController < BaseOrigamiController
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
@account_data = Array.new
if !@total_accounts.nil?
@total_accounts.each do |account|
acc = Sale.account_data(account.account_id, current_user)
if !acc.nil?
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
end
@total_accounts.each do |account|
acc = Sale.account_data(account.account_id, current_user)
if !acc.nil?
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
end
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
end
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
else
@account_data = nil
end
@@ -107,7 +107,7 @@ class Origami::DashboardController < BaseOrigamiController
def get_all_menu
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).includes(:menu_categories => {:menu_items => {:item_sets => :menu_item_instances}}).active.all
@menus = Menu.includes(:menu_categories => :children).includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).includes(:menu_categories => {:menu_items => {:item_sets => :menu_item_instances}}).active.all
@item_attributes = MenuItemAttribute.all.load
@item_options = MenuItemOption.all.load

View File

@@ -6,7 +6,8 @@ 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 +78,8 @@ 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)

View File

@@ -6,7 +6,8 @@ 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,8 +49,8 @@ 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
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@@ -64,8 +65,9 @@ class Origami::GiftVoucherController < BaseOrigamiController
end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
end

View File

@@ -4,10 +4,12 @@ class Origami::HomeController < BaseOrigamiController
def index
@webview = check_mobile
@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)
@orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date 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")
@occupied_table = DiningFacility.where("shop_code='#{@shop.shop_code}' and status='occupied'").count
@@ -20,10 +22,11 @@ class Origami::HomeController < BaseOrigamiController
@print_settings = PrintSetting.get_precision_delimiter()
@webview = check_mobile
@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)
@orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date 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")
@shift = ShiftSale.current_open_shift(current_user)

View File

@@ -12,7 +12,8 @@ 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,8 +67,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
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@@ -87,8 +87,9 @@ class Origami::JcbController < BaseOrigamiController
end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
end

View File

@@ -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,8 +52,8 @@ 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
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)

View File

@@ -12,7 +12,8 @@ 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,8 +64,8 @@ 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
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@@ -85,8 +86,9 @@ class Origami::MasterController < BaseOrigamiController
end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
end

View File

@@ -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)

View File

@@ -11,7 +11,8 @@ 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,8 +65,8 @@ 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
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@@ -85,8 +86,9 @@ class Origami::MpuController < BaseOrigamiController
end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
end

View File

@@ -4,6 +4,8 @@ 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.current_shop
@receipt_bill = check_receipt_bill
end

View File

@@ -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])

View File

@@ -6,7 +6,8 @@ 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
@@ -74,7 +75,8 @@ 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

View File

@@ -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.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,8 +686,9 @@ class Origami::PaymentsController < BaseOrigamiController
customer= Customer.find(saleObj.customer_id)
#shop detail
#shop_detail = Shop.first
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
#shop_detail = Shop.current_shop
printer = PrintSetting.all
unique_code="ReceiptBillPdf"
if !printer.empty?

View File

@@ -7,8 +7,8 @@ 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.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)

View File

@@ -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

View File

@@ -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

View File

@@ -1,8 +1,9 @@
class Origami::RoomsController < BaseOrigamiController
def index
@tables = Table.unscoped.all.active.order('status desc')
@rooms = Room.unscoped.all.active.order('status desc')
@complete = Sale.completed_sale("cashier",@shop.shop_code)
@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)
@webview = false
@@ -17,9 +18,10 @@ class Origami::RoomsController < BaseOrigamiController
@webview = true
end
@tables = Table.unscoped.all.active.order('status desc')
@rooms = Room.unscoped.all.active.order('status desc')
@complete = Sale.completed_sale("cashier",@shop.shop_code)
@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")
@room = DiningFacility.find(params[:room_id])
@@ -31,6 +33,10 @@ class Origami::RoomsController < BaseOrigamiController
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
@payment_methods = PaymentMethodSetting.find_by_shop_code(@shop.shop_code)
@shop = Shop.current_shop
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all
@dining_room = @room.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ")
@order_items = Array.new
@dining_room.each do |booking|

View File

@@ -5,9 +5,10 @@ class Origami::SalesController < BaseOrigamiController
@webview = true
end
@tables = Table.unscoped.all.active.order('status desc')
@rooms = Room.unscoped.all.active.order('status desc')
@complete = Sale.completed_sale("cashier",@shop.shop_code)
@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")
@sale = Sale.find(params[:sale_id])

View File

@@ -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

View File

@@ -397,4 +397,9 @@ class Origami::SplitBillController < BaseOrigamiController
render :json => { status: true }
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
end

View File

@@ -1,6 +1,8 @@
class Origami::TableInvoicesController < BaseOrigamiController
def index
@table = DiningFacility.find(params[:table_id])
shop = Shop.current_shop
@sale_array = Array.new
@table.bookings.each do |booking|
@@ -28,10 +30,10 @@ class Origami::TableInvoicesController < BaseOrigamiController
def show
@table = DiningFacility.find(params[:table_id])
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
# shop = Shop.first
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all
shop = Shop.current_shop
@sale_array = Array.new
@table.bookings.each do |booking|
if booking.sale_id.nil?

View File

@@ -11,7 +11,8 @@ 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,8 +62,8 @@ 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
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@@ -83,8 +84,9 @@ class Origami::UnionpayController < BaseOrigamiController
end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
end

View File

@@ -11,7 +11,8 @@ 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,8 +62,8 @@ 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
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@@ -83,8 +84,9 @@ class Origami::VisaController < BaseOrigamiController
end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
end

View File

@@ -115,6 +115,8 @@ class Origami::VoidController < BaseOrigamiController
customer= Customer.find(sale.customer_id)
#shop detail
shop_details = Shop.current_shop
# get member information
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
if customer.membership_id != nil && rebate

View File

@@ -8,7 +8,8 @@ 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

View File

@@ -88,6 +88,8 @@ class Origami::WasteSpoileController < BaseOrigamiController
# unique_code = "ReceiptBillPdf"
customer= Customer.find(sale.customer_id)
#shop detail
shop_details = Shop.current_shop
# get member information
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
if customer.membership_id != nil && rebate

View File

@@ -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

View File

@@ -179,7 +179,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

View File

@@ -56,14 +56,15 @@ class Settings::ShopsController < ApplicationController
audio_data = @settings_shop.display_images.find_by_name("order_audio").image
delete_path = Rails.root.join("public/#{audio_data}")
if File.exists?(delete_path)
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

View File

@@ -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

View File

@@ -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

View File

@@ -3,7 +3,7 @@ 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}"
@@ -62,7 +62,7 @@ class KbzPay
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

View File

@@ -41,11 +41,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))

View File

@@ -141,7 +141,14 @@ class Menu < ApplicationRecord
end
else
# Menu by Menu Import
shop_code= shop.shop_code + "_"
@shop = Shop.current_shop
shop_code = ""
if !@shop.nil?
if @shop.shop_code
shop_code = @shop.shop_code + "_"
end
end
sheet = spreadsheet.sheet(0)
menu = sheet.row(1)[1]

View File

@@ -297,7 +297,8 @@ class OrderQueueStation < ApplicationRecord
@type = (DiningFacility.find(change_to)).type
@moved_by = current_user
@date = DateTime.now
@shop = Shop.find_by_shop_code(oqs.shop_code)
@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)

View File

@@ -157,7 +157,8 @@ 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.find_by_shop_code(order.shop_code)
shop_details = Shop.current_shop
# rounding adjustment
if shop_details.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
@@ -194,7 +195,8 @@ 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 +402,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 +420,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 +438,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

View File

@@ -38,8 +38,9 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end
# end
# shop = Shop.first
directory_name = 'public/orders_'+oqs.shop_code
shop = Shop.current_shop
directory_name = 'public/orders_'+shop.shop_code
Dir.mkdir(directory_name) unless File.exists?(directory_name)
filename = directory_name + "/order_item_#{order_id}_#{order_item_id}" + ".pdf"
@@ -80,8 +81,9 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_setting = PrintSetting.all.order("id ASC")
order=print_query('order_summary', order_id)
# shop = Shop.first
directory_name = 'public/orders_'+oqs.shop_code
shop = Shop.current_shop
directory_name = 'public/orders_'+shop.shop_code
Dir.mkdir(directory_name) unless File.exists?(directory_name)
# For Print Per Item
@@ -192,8 +194,9 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
order=print_query('booking_summary', booking_id)
# shop = Shop.first
directory_name = 'public/orders_'+oqs.shop_code
shop = Shop.current_shop
directory_name = 'public/orders_'+shop.shop_code
Dir.mkdir(directory_name) unless File.exists?(directory_name)
# For Print Per Item

View File

@@ -1,4 +1,3 @@
class Room < DiningFacility
has_many :bookings, :foreign_key => 'dining_facility_id'
end

View File

@@ -440,7 +440,8 @@ 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 +508,8 @@ class Sale < ApplicationRecord
# Tax Re-Calculte
def compute_tax(total_taxable, total_discount = 0, order_source = nil, tax_type=nil)
shop = Shop.find_by_shop_code(self.shop_code)
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 +629,8 @@ class Sale < ApplicationRecord
# Tax Calculate
def apply_tax(total_taxable, order_source = nil, tax_type = nil)
shop = Shop.find_by_shop_code(self.shop_code)
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 +648,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 +713,8 @@ class Sale < ApplicationRecord
end
def adjust_rounding
shop_details = Shop.find_by_shop_code(self.shop_code)
shop_details = Shop.current_shop
# rounding adjustment
if shop_details.is_rounding_adj
new_total = Sale.get_rounding_adjustment(self.grand_total)
@@ -726,7 +730,8 @@ class Sale < ApplicationRecord
#Generate new Receipt No when it is not assigned
def generate_receipt_no
#shop_code and client_code
shop_details = Shop.find_by_shop_code(self.shop_code)
shop_details = Shop.current_shop
#Date-Shift-
if self.receipt_no.nil?
prefix = DateTime.now().utc
@@ -1239,7 +1244,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," +
@@ -1588,6 +1593,8 @@ end
if !from.nil? && !to.nil?
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1613,6 +1620,8 @@ end
if !from.nil? && !to.nil?
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1649,6 +1658,8 @@ end
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1668,6 +1679,8 @@ end
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1691,6 +1704,8 @@ end
if (!from.nil? && !to.nil?)
query = query.merge(Sale.receipt_date_between(from, to))
else
query = query.merge(Sale.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day))
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1710,6 +1725,8 @@ end
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1730,6 +1747,8 @@ end
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1760,6 +1779,8 @@ end
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1812,6 +1833,8 @@ end
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1832,6 +1855,8 @@ end
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1899,6 +1924,8 @@ end
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1919,6 +1946,8 @@ end
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1939,6 +1968,8 @@ end
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1960,6 +1991,8 @@ end
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -2112,6 +2145,8 @@ def self.employee_sale(shift=nil,from=nil,to=nil,from_time=nil,to_time=nil, curr
.paid.completed.where("sales.shop_code='#{current_shop.shop_code}'")
if !from.nil? && !to.nil?
query = query.receipt_date_between(from, to)
else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)
end
if !shift.nil?

View File

@@ -399,11 +399,12 @@ class SaleItem < ApplicationRecord
stock = StockJournal.where('item_code=?', self.item_instance_code).order("id DESC").first
unless stock.nil?
check_item = StockCheckItem.where('item_code=?', self.item_instance_code).order("id DESC").first
StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS)
check_item.different = check_item.different + qty
check_item.save
end
end
StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS)
check_item.different = check_item.different + qty
check_item.save
elsif is_foc or cancel_foc
qty = StockJournal.where(trans_ref: self.sale_item_id).sum("credit-debit")
if stock_journal = StockJournal.where(trans_ref: self.sale_item_id, item_code: self.item_instance_code).order(id: :desc).first

View File

@@ -1,12 +1,18 @@
class Shop < ApplicationRecord
#ShopDetail = Shop.find_by_id(1)
#ShopDetail = Shop.current_shop
# Shop Image Uploader
mount_uploader :logo, ShopImageUploader
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

View File

@@ -345,14 +345,14 @@ class ReceiptBillPdf < Prawn::Document
sale_data.sale_taxes.each do |st|
if (st.tax_name.include? "Service")
service_tax_desc = st.tax_name
service_tax_amount = number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)
service_tax_amount = st.tax_payable_amount
if incl_tax
service_tax_rate = st.tax_rate.to_i
end
end
if (st.tax_name.include? "Commercial")
com_tax_desc = st.tax_name
com_tax_amount = number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)
com_tax_amount = st.tax_payable_amount
if incl_tax
com_tax_rate = st.tax_rate.to_i
end

View File

@@ -20,10 +20,10 @@ class CommissionerImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.first.shop_code.nil?
if Shop.current_shop.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
"#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -20,10 +20,10 @@ class CustomerImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.first.shop_code.nil?
if Shop.current_shop.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
"#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -20,10 +20,10 @@ class EmployeeImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.first.shop_code.nil?
if Shop.current_shop.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
"#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -15,15 +15,15 @@ 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?
if Shop.current_shop.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
"#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -20,10 +20,10 @@ class ProductImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.first.shop_code.nil?
if Shop.current_shop.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
"#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -20,10 +20,10 @@ class ShopImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.first.shop_code.nil?
if Shop.current_shop.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
"#{Shop.current_shop.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -8,22 +8,17 @@ 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
categories = menu.menu_categories
json.categories categories do |category|
if category.is_available
parent_category = category.parent
if !parent_category.nil?
json.sub_category "true"
else
json.sub_category "false"
end
json.sub_category category.children.present?
valid_time = category.valid_time
json.valid_time valid_time
json.id category.id
json.code category.code
json.order_by category.order_by
@@ -80,7 +75,7 @@ if (menu.menu_categories)
alt_name: its.alt_name,
min_selectable_qty: its.min_selectable_qty,
max_selectable_qty: its.max_selectable_qty,
instances: its.menu_item_instances.map { |id| {id: id}}
instances: its.menu_item_instances.map { |i| {id: i.id} }
}
}

View File

@@ -26,12 +26,13 @@
<tr>
<th colspan="<%= column_count = @payment_methods.length + 8 %>"> <%= 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 '-'%></th>
</tr>
<% @count = 1 %>
<% @payment_methods.each_slice(10) do |slice| %>
<tr>
<th></th>
<th></th>
<% alph = "A" %>
<% @count = 1 %>
<% slice.each do |payment_method| %>
<th style="text-align:center;">
<%= alph %>

BIN
config/.database.yml.swp Normal file

Binary file not shown.

View File

@@ -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

View File

@@ -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
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

File diff suppressed because it is too large Load Diff

31
docker-compose.yml.back Normal file
View File

@@ -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

View File

@@ -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