Single database for multiple shops

Use ActsAsTenant as Multi-tenancy for shops

See below files:
- app/controllers/concern/multi_tenancy.rb
- app/models/application_record.rb
- app/models/shop.rb

An initializer can be created to control option in ActsAsTenant.
config/initializers/acts_as_tenant.rb
require 'acts_as_tenant/sidekiq'
ActsAsTenant.configure do |config|
  config.require_tenant = false # true
end

more details: https://github.com/ErwinM/acts_as_tenant
This commit is contained in:
Thein Lin Kyaw
2019-12-02 17:19:28 +06:30
parent 5d10d4b6a1
commit 937f40e7c1
78 changed files with 215 additions and 173 deletions

View File

@@ -157,7 +157,7 @@ class OrderReservation < ApplicationRecord
def self.update_doemal_payment(order,current_user,receipt_bill)
if(Sale.exists?(order.sale_id))
saleObj = Sale.find(order.sale_id)
shop_details = Shop.first
shop_details = Shop.current_shop
# rounding adjustment
if shop_details.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
@@ -194,7 +194,7 @@ class OrderReservation < ApplicationRecord
shift = ShiftSale.find(saleObj.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
shop_detail = Shop.first
shop_detail = Shop.current_shop
order_reservation = OrderReservation.get_order_reservation_info(saleObj.sale_id)
if !cashier_terminal.nil?
# Calculate Food and Beverage Total
@@ -400,7 +400,7 @@ class OrderReservation < ApplicationRecord
end
def self.check_new_order
shop = Shop.find_by_id(1)
shop = Shop.current_shop
if !shop.shop_code.nil?
shop_code = shop.shop_code
else
@@ -418,7 +418,7 @@ class OrderReservation < ApplicationRecord
end
def self.check_order_send_to_kitchen
shop = Shop.find_by_id(1)
shop = Shop.current_shop
if !shop.shop_code.nil?
shop_code = shop.shop_code
else
@@ -436,7 +436,7 @@ class OrderReservation < ApplicationRecord
end
def self.check_order_ready_to_delivery
shop = Shop.find_by_id(1)
shop = Shop.current_shop
if !shop.shop_code.nil?
shop_code = shop.shop_code
else