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:
@@ -440,7 +440,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
#compute - invoice total
|
||||
def compute_by_sale_items(total_discount, discount_type=nil, order_source=nil, tax_type=nil, type=nil)
|
||||
shop = Shop.first
|
||||
shop = Shop.current_shop
|
||||
|
||||
#Computation Fields
|
||||
subtotal_price = 0
|
||||
@@ -507,7 +507,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
# Tax Re-Calculte
|
||||
def compute_tax(total_taxable, total_discount = 0, order_source = nil, tax_type=nil)
|
||||
shop = Shop.first
|
||||
shop = Shop.current_shop
|
||||
|
||||
#if tax is not apply create new record
|
||||
# SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
|
||||
@@ -627,7 +627,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
# Tax Calculate
|
||||
def apply_tax(total_taxable, order_source = nil, tax_type = nil)
|
||||
shop = Shop.first
|
||||
shop = Shop.current_shop
|
||||
|
||||
#if tax is not apply create new record
|
||||
# SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
|
||||
@@ -645,7 +645,7 @@ class Sale < ApplicationRecord
|
||||
order_source = "cashier"
|
||||
end
|
||||
|
||||
# tax_data = TaxProfile.unscoped.where("group_type=?",order_source).pluck(:id)
|
||||
# tax_data = TaxProfile.unscope(:order).where("group_type=?",order_source).pluck(:id)
|
||||
# customer = Customer.find(self.customer_id).tax_profiles
|
||||
|
||||
tax_profiles = unique_tax_profiles(order_source, self.customer_id)
|
||||
@@ -710,7 +710,7 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
def adjust_rounding
|
||||
shop_details = Shop.first
|
||||
shop_details = Shop.current_shop
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(self.grand_total)
|
||||
@@ -726,7 +726,7 @@ class Sale < ApplicationRecord
|
||||
#Generate new Receipt No when it is not assigned
|
||||
def generate_receipt_no
|
||||
#shop_code and client_code
|
||||
shop_details = Shop.first
|
||||
shop_details = Shop.current_shop
|
||||
#Date-Shift-
|
||||
if self.receipt_no.nil?
|
||||
prefix = DateTime.now().utc
|
||||
@@ -1239,7 +1239,7 @@ end
|
||||
|
||||
#product sale report query
|
||||
def self.get_menu_item_query(order_by)
|
||||
query = MenuItem.unscoped.select("acc.id as account_id,
|
||||
query = MenuItem.unscope(:order).select("acc.id as account_id,
|
||||
acc.title as account_name,
|
||||
mii.item_instance_code as item_code, " +
|
||||
"(CASE WHEN si.qty IS NOT NULL THEN SUM(si.qty) ELSE 0 END) as total_item," +
|
||||
|
||||
Reference in New Issue
Block a user