This commit is contained in:
yarzar_code
2020-01-12 20:07:28 +06:30
parent 314cc507a3
commit dff2c69627
89 changed files with 492 additions and 469 deletions

View File

@@ -1,6 +1,5 @@
class Api::AuthenticateController < Api::ApiController
skip_before_action :authenticate
# before_action :find_shop
def create
emp_id = params[:emp_id]
@@ -67,8 +66,5 @@ class Api::AuthenticateController < Api::ApiController
params.permit(:emp_id, :password, :session_token)
end
private
def find_shop
@shop = Shop.find_by_shop_code(params[:shop_code])
end
end

View File

@@ -18,7 +18,7 @@ module LoginVerification
def current_shop
begin
return @shop
return Shop.current_shop
rescue
return nil
end
@@ -40,7 +40,7 @@ module LoginVerification
#Shop Name in Navbor
def shop_detail
@shop = current_shop
@shop ||= current_shop
end
#check order reservation used

View File

@@ -12,8 +12,7 @@ module MultiTenancy
shop_code = request.subdomain.partition('-').last
@shop = Shop.find_by(shop_code: shop_code)
else
# @shop = Shop.first
@shop = Shop.find_by(shop_code: '262')
@shop = Shop.first
end
set_current_tenant(@shop)
end

View File

@@ -9,15 +9,25 @@ class Crm::CustomersController < BaseCrmController
filter = params[:filter]
filter_card_no = params[:filter_card_no]
type = params[:type]
puts "type :"
puts type
puts "filter :"
puts filter
puts "filter card no"
puts filter_card_no
@customer_update_phone_email_membertype =false
if filter_card_no==""
@crm_customers = Customer.all
puts "Filter card no"
elsif !filter_card_no.nil?
@crm_customers=Customer.where("card_no=?",filter_card_no)
puts "Null filter card no"
elsif filter.nil? || filter_card_no==""
@crm_customers = Customer.all
puts "filter null filter card no nulll"
else
@crm_customers = Customer.search(filter)
puts "else"
# paymal_customer = Customer.search_paypar_account_no(filter)
# search account no from paypar
if type == "card"

View File

@@ -22,7 +22,7 @@ class Foodcourt::DiscountsController < BaseFoodcourtController
end
@member_discount = MembershipSetting.find_by_discount(1)
@accounts = Account.where("shop_code='#{@shop.shop_code}'")
@accounts = Account.all
end
#discount page show from origami index with selected order

View File

@@ -74,7 +74,7 @@ class Foodcourt::FoodCourtController < ApplicationController
end
def get_all_product()
@product = Product.where("shop_code='#{@shop.shop_code}'")
@product = Product.all
end
# render json for http status code

View File

@@ -4,13 +4,13 @@ class Foodcourt::HomeController < BaseFoodcourtController
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')
@tables = Table.unscoped.all.active.order('status desc')
@rooms = Room.unscoped.all.active.order('status desc')
@complete = Sale.completed_sale("cashier")
@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')
@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
@occupied_table = DiningFacility.where("status='occupied'").count
@shift = ShiftSale.current_open_shift(current_user)
end
@@ -19,10 +19,10 @@ class Foodcourt::HomeController < BaseFoodcourtController
# get printer info
@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')
@tables = Table.unscoped.all.active.order('status desc')
@rooms = Room.unscoped.all.active.order('status desc')
@complete = Sale.completed_sale("cashier")
@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')
@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)
@@ -30,8 +30,8 @@ class Foodcourt::HomeController < BaseFoodcourtController
@status_sale = ""
@sale_array = Array.new
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
@membership = MembershipSetting.all
@payment_methods = PaymentMethodSetting.all
@dining_booking = @dining.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}' ")
#@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'")
@order_items = Array.new
@@ -103,16 +103,16 @@ class Foodcourt::HomeController < BaseFoodcourtController
end
#for bank integration
@checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time')
@checkout_alert_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_alert_time')
@checkout_time = Lookup.collection_of('checkout_time')
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
accounts = TaxProfile.where("shop_code='#{@shop.shop_code}' and group_type = ?","cashier").order("order_by ASC")
accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC")
@tax_arr =[]
accounts.each do |acc|
@tax_arr.push(acc.name)
end
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill')
lookup_spit_bill = Lookup.collection_of('split_bill')
@split_bill = 0
if !lookup_spit_bill[0].nil?
@split_bill = lookup_spit_bill[0][1]
@@ -120,7 +120,7 @@ class Foodcourt::HomeController < BaseFoodcourtController
#for edit order on/off
@edit_order_origami = true
lookup_edit_order = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('edit_order')
lookup_edit_order = Lookup.collection_of('edit_order')
if !lookup_edit_order.empty?
lookup_edit_order.each do |edit_order|
if edit_order[0].downcase == "editorderorigami"
@@ -133,7 +133,7 @@ class Foodcourt::HomeController < BaseFoodcourtController
#for changable on/off
@changable_tax = true
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
lookup_changable_tax = Lookup.collection_of('changable_tax')
if !lookup_changable_tax.empty?
lookup_changable_tax.each do |changable_tax|
if changable_tax[0].downcase == "change"

View File

@@ -71,7 +71,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("sales.sale_status !=? and orders.source='app' and DATE(bookings.created_at)=?",'void',@shop.shop_code,Date.today).order("bookings.created_at desc").uniq
.where("sales.sale_status !=? and orders.source='app' and DATE(bookings.created_at)=?",'void',Date.today).order("bookings.created_at desc").uniq
end
def completed
customer =Customer.find_by_customer_id(params[:customer_id])

View File

@@ -547,7 +547,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
#shop detail
#shop_detail = Shop.first
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
printer = PrintSetting.all
unique_code="ReceiptBillPdf"
if !printer.empty?
@@ -562,7 +562,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
@@ -631,7 +631,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
else
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
@@ -654,7 +654,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
print_settings=PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)

View File

@@ -6,7 +6,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
@cashier_type = params[:type]
@shift = ShiftSale.current_open_shift(current_user)
#for bank integration
bank_integration = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('bank_integration')
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1]
@@ -15,8 +15,8 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
end
def new
@float = Lookup.where('lookup_type=? and shop_code=?','float_value',@shop.shop_code)
@terminal = CashierTerminal.available.where("shop_code='#{@shop.shop_code}'")
@float = Lookup.where('lookup_type=?','float_value')
@terminal = CashierTerminal.available
end
def create
@@ -56,7 +56,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
cashier_terminal.save
#add shift_sale_id to card_settle_trans
bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',@shop.shop_code)
bank_integration = Lookup.find_by_lookup_type('bank_integration')
if !bank_integration.nil?
card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL'])
@@ -74,7 +74,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
# if !close_cashier_print[0].nil?
# @close_cashier_print = close_cashier_print[0][1]
# end
close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings")
close_cashier_pdf = Lookup.collection_of("print_settings")
unique_code = "CloseCashierPdf"
if !close_cashier_pdf.empty?
@@ -98,7 +98,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
other_charges = Sale.get_other_charges()
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
end
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
#other payment details for mpu or visa like card
@@ -143,7 +143,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
if @shift
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
#other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)

View File

@@ -18,8 +18,8 @@ class Foodcourt::SurveysController < BaseFoodcourtController
if @booking.dining_facility_id.to_i>0
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
@table_type = @dining_facility.type
@survey_data = Survey.find_by_dining_name_and_shop_code(@dining_facility.name,@shop.shop_code)
survey_process = Survey.find_by_receipt_no_and_shop_code(@receipt_no,@shop.shop_code)
@survey_data = Survey.find_by_dining_name(@dining_facility.name)
survey_process = Survey.find_by_receipt_no(@receipt_no)
if !survey_process.nil?
@survey_data = survey_process
end
@@ -33,7 +33,7 @@ class Foodcourt::SurveysController < BaseFoodcourtController
@table_type = @dining_facility.type
@receipt_no = nil
@grand_total = nil
@survey_data = Survey.find_by_dining_name_and_receipt_no_and_shop_code(@dining_facility.name,nil,@shop.shop_code)
@survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,nil)
end
end
@@ -46,7 +46,7 @@ class Foodcourt::SurveysController < BaseFoodcourtController
# cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
# set cashier
open_cashier = Employee.where("role = 'cashier' AND token_session <> '' and shop_code='#{@shop.shop_code}'")
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
current_shift = ShiftSale.current_shift
current_shift_user =Employee.find_by_id(current_user.employee_id)
if open_cashier.count>0

View File

@@ -64,7 +64,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
# FOr Sale Audit
action_by = current_user.name
if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
action_by = Employee.find_by_emp_id(access_code).name
end
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
@@ -111,7 +111,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
current_balance = 0
end
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
printer = PrintSetting.all
unique_code="ReceiptBillPdf"
if !printer.empty?
@@ -126,7 +126,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)

View File

@@ -54,7 +54,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController
# FOr Sale Audit
action_by = current_user.name
if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
action_by = Employee.find_by_emp_id(access_code).name
end
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark )
@@ -88,7 +88,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController
customer= Customer.find(sale.customer_id)
# get member information
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
@@ -96,7 +96,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController
current_balance = 0
end
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
printer = PrintSetting.all
unique_code="ReceiptBillPdf"
if !printer.empty?
@@ -112,7 +112,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController
end
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)

View File

@@ -18,8 +18,8 @@ class HomeController < ApplicationController
def index
# @employees = Employee.all_emp_except_waiter.order("name asc")
@employees = Employee.all.where("shop_code='#{@shop.shop_code}' and is_active = true").order("name asc")
@roles = Employee.where("shop_code='#{@shop.shop_code}'").distinct.pluck(:role)
@employees = Employee.all.where("is_active = true").order("name asc")
@roles = Employee.distinct.pluck(:role)
# byebug
# @roles = Lookup.collection_of("employee_roles")

View File

@@ -3,14 +3,14 @@ class Inventory::InventoryController < BaseInventoryController
def index
filter = params[:filter]
@inventory_definitions = InventoryDefinition.get_by_category(@shop,filter)
@inventory_definitions = InventoryDefinition.get_by_category(filter)
end
def show
inventory_definition_id = params[:inventory_definition_id]
inventory = InventoryDefinition.find_by_id_and_shop_code(inventory_definition_id,@shop.shop_code)
@stock_journals = StockJournal.where("item_code=? and shop_code='#{@shop.shop_code}'",inventory.item_code).order("id DESC")
inventory = InventoryDefinition.find_by_id(inventory_definition_id)
@stock_journals = StockJournal.where("item_code=?",inventory.item_code).order("id DESC")
@stock_journals = Kaminari.paginate_array(@stock_journals).page(params[:page]).per(20)
respond_to do |format|

View File

@@ -4,7 +4,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# GET /inventory_definitions
# GET /inventory_definitions.json
def index
@inventory_definitions = InventoryDefinition.where("shop_code='#{@shop.shop_code}'")
@inventory_definitions = InventoryDefinition.all
end
# GET /inventory_definitions/1
@@ -14,7 +14,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# GET /inventory_definitions/new
def new
@menus = Menu.where("shop_code='#{@shop.shop_code}'").order('created_at asc')
@menus = Menu.order('created_at asc')
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
@inventory_definition = InventoryDefinition.new
end
@@ -26,7 +26,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# POST /inventory_definitions
# POST /inventory_definitions.json
def create
inventory = InventoryDefinition.find_by_item_code_and_shop_code(params[:item_code],@shop.shop_code)
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
if inventory.nil?
@inventory_definition = InventoryDefinition.new
@@ -84,7 +84,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# DELETE /inventory_definitions/1
# DELETE /inventory_definitions/1.json
def destroy
inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
inventory = InventoryDefinition.find_by_id(params[:id])
@inventory_definition.destroy
respond_to do |format|
format.html { redirect_to inventory_inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
@@ -107,7 +107,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
private
# Use callbacks to share common setup or constraints between actions.
def set_inventory_definition
@inventory_definition = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
@inventory_definition = InventoryDefinition.find_by_id(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.

View File

@@ -8,7 +8,6 @@ class Inventory::StockChecksController < BaseInventoryController
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
.where("inventory_definitions.shop_code='#{@shop.shop_code}'")
.group("mi.menu_category_id")
.order("mi.menu_category_id desc")
unless !@category.nil?
@@ -24,7 +23,7 @@ class Inventory::StockChecksController < BaseInventoryController
end
def show
@check = StockCheck.find_by_id_and_shop_code(params[:id],@shop.shop_code)
@check = StockCheck.find_by_id(params[:id])
@stock_check_items = StockCheckItem.get_items_with_category(params[:id])

View File

@@ -6,8 +6,8 @@ class Oqs::HomeController < BaseOqsController
# Query for OQS with delivery status true
# @tables = DiningFacility.all.active.order('status desc')
@tables = DiningFacility.all.active.where("type = 'Table' and shop_code='#{@shop.shop_code}' ").order('status desc')
@rooms = DiningFacility.all.active.where("type = 'Room' and shop_code='#{@shop.shop_code}' ").order('status desc')
@tables = DiningFacility.all.active.where("type = 'Table'").order('status desc')
@rooms = DiningFacility.all.active.where("type = 'Room'").order('status desc')
@filter = params[:filter]
@@ -232,7 +232,7 @@ class Oqs::HomeController < BaseOqsController
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
query = query.where("df.shop_code='#{@shop.shop_code}' and df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("odt.order_items_id")
.order("assigned_order_items.created_at desc")

View File

@@ -19,7 +19,7 @@ class Origami::AddordersController < BaseOrigamiController
if check_mobile
@webview = true
end
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
display_type = Lookup.find_by_lookup_type("display_type")
if !display_type.nil? && display_type.value.to_i ==2
@display_type = display_type.value
else

View File

@@ -21,7 +21,7 @@ class Origami::CashInsController < BaseOrigamiController
shift = shift
else
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
if open_cashier.count>0
shift = ShiftSale.current_open_shift(open_cashier[0])

View File

@@ -16,7 +16,7 @@ class Origami::CashOutsController < BaseOrigamiController
if shift != nil
shift = shift
else
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
if open_cashier.count>0
shift = ShiftSale.current_open_shift(open_cashier[0])

View File

@@ -92,12 +92,12 @@ class Origami::CustomersController < BaseOrigamiController
# if flash["errors"]
# @crm_customer.valid?
# end
@membership_types = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("member_group_type")
@membership_types = Lookup.collection_of("member_group_type")
#get paypar accountno
@paypar_accountno = Customer.where("paypar_account_no IS NOT NULL AND paypar_account_no != ''").pluck("paypar_account_no")
#for create customer on/off
@create_flag = true
lookup_customer = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('customer_settings')
lookup_customer = Lookup.collection_of('customer_settings')
if !lookup_customer.empty?
lookup_customer.each do |create_setting|
if create_setting[0].downcase == "create"
@@ -168,9 +168,9 @@ class Origami::CustomersController < BaseOrigamiController
sale = Sale.find_by_receipt_no(receipt_no)
@out = []
action_by = current_user.name
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code)
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code)
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
if member_actions.gateway_url
@campaign_type_id = nil
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s

View File

@@ -47,21 +47,21 @@ class Origami::DashboardController < BaseOrigamiController
@print_settings = PrintSetting.get_precision_delimiter()
@current_user = current_user
#dine-in cashier
dinein_cashier = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('dinein_cashier')
dinein_cashier = Lookup.collection_of('dinein_cashier')
@dinein_cashier = 0
if !dinein_cashier[0].nil?
@dinein_cashier = dinein_cashier[0][1]
end
#quick service
quick_service = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('quick_service')
quick_service = Lookup.collection_of('quick_service')
@quick_service = 0
if !quick_service[0].nil?
@quick_service = quick_service[0][1]
end
#fourt court
food_court = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('food_court')
food_court = Lookup.collection_of('food_court')
@food_court = 0
@food_court_name = nil
if !food_court[0].nil?
@@ -70,7 +70,7 @@ class Origami::DashboardController < BaseOrigamiController
end
#order reservation
order_reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('order_reservation')
order_reservation = Lookup.collection_of('order_reservation')
@order_reservation = 0
if !order_reservation.empty?
order_reservation.each do |order_reserve|
@@ -81,7 +81,7 @@ class Origami::DashboardController < BaseOrigamiController
end
#dashboard settings on/off for supervisor and cashier
dashboard_settings = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('dashboard_settings')
dashboard_settings = Lookup.collection_of('dashboard_settings')
@setting_flag = true
if !dashboard_settings.empty?
dashboard_settings.each do |setting|
@@ -92,7 +92,7 @@ class Origami::DashboardController < BaseOrigamiController
end
#reservation
reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('reservation')
reservation = Lookup.collection_of('reservation')
@reservation = 0
if !reservation.empty?
reservation.each do |reserve|

View File

@@ -21,8 +21,8 @@ class Origami::DiscountsController < BaseOrigamiController
end
end
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
@accounts = Account.where("shop_code='#{@shop.shop_code}'")
@member_discount = MembershipSetting.find_by_discount(1)
@accounts = Account.all
end
#discount page show from origami index with selected order

View File

@@ -17,10 +17,10 @@ class Origami::FoodCourtController < ApplicationController
# @menus = Menu.all
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
# end
@zone = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true")
@zone = Zone.all.where("is_active= true")
@customer = Customer.all
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@cashier_type = "food_court"
display_type = Lookup.find_by_lookup_type("display_type")
if !display_type.nil? && display_type.value.to_i ==2
@@ -31,7 +31,7 @@ class Origami::FoodCourtController < ApplicationController
#checked quick_service only
@quick_service_only = true
lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier')
lookup_dine_in = Lookup.collection_of('dinein_cashier')
if !lookup_dine_in.empty?
lookup_dine_in.each do |dine_in|
if dine_in[0].downcase == "dineincashier"
@@ -160,7 +160,7 @@ class Origami::FoodCourtController < ApplicationController
end
def get_all_product()
@product = Product..where("shop_code='#{@shop.shop_code}'")
@product = Product.all
end
# render json for http status code

View File

@@ -73,16 +73,16 @@ class Origami::HomeController < BaseOrigamiController
end
#for bank integration
@checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time')
@checkout_alert_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_alert_time')
@checkout_time = Lookup.collection_of('checkout_time')
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
accounts = TaxProfile.where("shop_code='#{@shop.shop_code}' and group_type = ?","cashier").order("order_by ASC")
accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC")
@tax_arr =[]
accounts.each do |acc|
@tax_arr.push(acc.name)
end
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill')
lookup_spit_bill = Lookup.collection_of('split_bill')
@split_bill = 0
if !lookup_spit_bill[0].nil?
@split_bill = lookup_spit_bill[0][1]
@@ -90,7 +90,7 @@ class Origami::HomeController < BaseOrigamiController
#for edit order on/off
@edit_order_origami = true
lookup_edit_order = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('edit_order')
lookup_edit_order = Lookup.collection_of('edit_order')
if !lookup_edit_order.empty?
lookup_edit_order.each do |edit_order|
if edit_order[0].downcase == "editorderorigami"
@@ -103,7 +103,7 @@ class Origami::HomeController < BaseOrigamiController
#for changable on/off
@changable_tax = true
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
lookup_changable_tax = Lookup.collection_of('changable_tax')
if !lookup_changable_tax.empty?
lookup_changable_tax.each do |changable_tax|
if changable_tax[0].downcase == "change"

View File

@@ -98,12 +98,12 @@ class Origami::OrderReservationController < BaseOrigamiController
end
def get_order_info
order_reservation = OrderReservation.where("status = 'new' and shop_code='#{current_shop.shop_code}'").count()
order_reservation = OrderReservation.where("status = 'new'").count()
render :json => order_reservation
end
def check_receipt_bill
receipt_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("order_reservation")
receipt_bill = Lookup.collection_of("order_reservation")
status = 0
if !receipt_bill.nil?

View File

@@ -32,9 +32,9 @@ class Origami::PaymalController < BaseOrigamiController
if customer_data
@membership_id = customer_data.membership_id
if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code)
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code)
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
if member_actions.gateway_url
@campaign_type_id = nil
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s

View File

@@ -65,7 +65,7 @@ class Origami::PaymentsController < BaseOrigamiController
end
end
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil,nil,nil)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal, sale_items, sale_data, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt", current_balance, nil, other_amount, nil, nil, nil)
result = {
:filepath => filename,
@@ -202,7 +202,7 @@ class Origami::PaymentsController < BaseOrigamiController
other_amount = SaleItem.calculate_other_charges(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
#end
end
@@ -225,7 +225,7 @@ class Origami::PaymentsController < BaseOrigamiController
# end
def show
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code)
display_type = Lookup.find_by_lookup_type("display_type")
if !display_type.nil? && display_type.value.to_i ==2
@display_type = display_type.value
else
@@ -245,7 +245,7 @@ class Origami::PaymentsController < BaseOrigamiController
@sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount")
end
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
@member_discount = MembershipSetting.find_by_discount(1)
@membership_rebate_balance=0
if Sale.exists?(sale_id)
@@ -270,7 +270,7 @@ class Origami::PaymentsController < BaseOrigamiController
@dining = ''
@other_payment = 0.0
@pdf_view = nil
@lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",@shop.shop_code)
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
if !@lookup_pdf.nil?
@pdf_view = @lookup_pdf.value
end
@@ -280,7 +280,7 @@ class Origami::PaymentsController < BaseOrigamiController
#for changable on/off
@changable_tax = true
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
lookup_changable_tax = Lookup.collection_of('changable_tax')
if !lookup_changable_tax.empty?
lookup_changable_tax.each do |changable_tax|
if changable_tax[0].downcase == "change"
@@ -348,7 +348,7 @@ class Origami::PaymentsController < BaseOrigamiController
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
# accounts = @customer.tax_profiles
accounts = TaxProfile.where("group_type = ? and shop_code='#{@shop.shop_code}'",@cashier_type).order("order_by ASC")
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
@account_arr =[]
@tax_arr =[]
accounts.each do |acc|
@@ -362,7 +362,7 @@ class Origami::PaymentsController < BaseOrigamiController
@account_arr.push(sale_tax)
end
end
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
rebate = MembershipSetting.find_by_rebate(1)
# get member information
if @customer.membership_id != nil && rebate
response = Customer.get_member_account(@customer)
@@ -613,7 +613,7 @@ class Origami::PaymentsController < BaseOrigamiController
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
@@ -680,9 +680,9 @@ class Origami::PaymentsController < BaseOrigamiController
if cashier_type.strip.downcase == "doemal_order"
unique_code = "ReceiptBillOrderPdf"
else
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'

View File

@@ -30,8 +30,8 @@ class Origami::RoomsController < BaseOrigamiController
@status_order = ""
@status_sale = ""
@sale_array = Array.new
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
@payment_methods = PaymentMethodSetting.find_by_shop_code(@shop.shop_code)
@membership = MembershipSetting.all
@payment_methods = PaymentMethodSetting.all
@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}' ")

View File

@@ -15,7 +15,7 @@ class Origami::ShiftsController < BaseOrigamiController
end
def new
@float = Lookup.where('lookup_type=? and shop_code=?','float_value',@shop.shop_code)
@float = Lookup.where('lookup_type=?','float_value')
@terminal = CashierTerminal.available
end
@@ -56,7 +56,7 @@ class Origami::ShiftsController < BaseOrigamiController
cashier_terminal.save
#add shift_sale_id to card_settle_trans
bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',@shop.shop_code)
bank_integration = Lookup.find_by_lookup_type('bank_integration')
if !bank_integration.nil?
card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL'])
@@ -74,7 +74,7 @@ class Origami::ShiftsController < BaseOrigamiController
# if !close_cashier_print[0].nil?
# @close_cashier_print = close_cashier_print[0][1]
# end
close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings")
close_cashier_pdf = Lookup.collection_of("print_settings")
unique_code = "CloseCashierPdf"
if !close_cashier_pdf.empty?
@@ -97,7 +97,7 @@ class Origami::ShiftsController < BaseOrigamiController
other_charges = Sale.get_other_charges()
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
end
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
#other payment details for mpu or visa like card
@@ -144,7 +144,7 @@ class Origami::ShiftsController < BaseOrigamiController
if @shift
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
#other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)

View File

@@ -18,8 +18,8 @@ class Origami::SurveysController < BaseOrigamiController
if @booking.dining_facility_id.to_i>0
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
@table_type = @dining_facility.type
@survey_data = Survey.find_by_dining_name_and_shop_code(@dining_facility.name,@shop.shop_code)
survey_process = Survey.find_by_receipt_no_and_shop_code(@receipt_no,@shop.shop_code)
@survey_data = Survey.find_by_dining_name(@dining_facility.name)
survey_process = Survey.find_by_receipt_no(@receipt_no)
if !survey_process.nil?
@survey_data = survey_process
end
@@ -46,7 +46,7 @@ class Origami::SurveysController < BaseOrigamiController
# cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
# set cashier
open_cashier = Employee.where("role = 'cashier' AND token_session <> '' and shop_code='#{@shop.shop_code}'")
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
current_shift = ShiftSale.current_shift
current_shift_user =Employee.find_by_id(current_user.employee_id)
if open_cashier.count>0

View File

@@ -39,7 +39,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
@status_sale = 'sale'
@customer = @sale.customer
#for split bill
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill')
lookup_spit_bill = Lookup.collection_of('split_bill')
@split_bill = 0
if !lookup_spit_bill[0].nil?
@split_bill = lookup_spit_bill[0][1]

View File

@@ -72,7 +72,7 @@ class Origami::VoidController < BaseOrigamiController
# FOr Sale Audit
action_by = current_user.name
if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
action_by = Employee.find_by_emp_id(access_code).name
end
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
@@ -114,7 +114,7 @@ class Origami::VoidController < BaseOrigamiController
customer= Customer.find(sale.customer_id)
# get member information
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
@@ -122,7 +122,7 @@ class Origami::VoidController < BaseOrigamiController
current_balance = 0
end
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
printer = PrintSetting.all
unique_code="ReceiptBillPdf"
if !printer.empty?
@@ -137,7 +137,7 @@ class Origami::VoidController < BaseOrigamiController
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)

View File

@@ -54,7 +54,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
# FOr Sale Audit
action_by = current_user.name
if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
action_by = Employee.find_by_emp_id(access_code).name
end
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark )
@@ -87,7 +87,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
# unique_code = "ReceiptBillPdf"
customer= Customer.find(sale.customer_id)
# get member information
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
@@ -95,7 +95,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
current_balance = 0
end
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
printer = PrintSetting.all
unique_code="ReceiptBillPdf"
if !printer.empty?
@@ -111,7 +111,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
end
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)

View File

@@ -6,7 +6,7 @@ class Reports::CommissionController < BaseReportController
commissioner = params[:commissioner].to_i
@com_id = commissioner
@commissioner = Commissioner.active.where("shop_code='#{@shop.shop_code}'")
@commissioner = Commissioner.active
@transaction = ProductCommission.get_transaction(from_date, to_date, commissioner)
@@ -23,7 +23,7 @@ class Reports::CommissionController < BaseReportController
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|

View File

@@ -5,16 +5,16 @@ authorize_resource :class => false
@sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]]
from, to = get_date_range_from_params
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@shift = ''
if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end

View File

@@ -7,7 +7,7 @@ class Reports::DailysaleController < BaseReportController
@tax = SaleTax.get_tax(from,to)
@from = from
@to = to
@payment_methods = PaymentMethodSetting.where("is_active='1' and shop_code=?",@shop.shop_code).pluck("payment_method")
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
respond_to do |format|

View File

@@ -1,7 +1,7 @@
class Reports::HourlySaleitemController < BaseReportController
authorize_resource :class => false
def index
@account = Account.where("shop_code='#{@shop.shop_code}'")
@account = Account.all
from, to = get_date_range_from_params
@start_time = params[:start_time]
@@ -12,16 +12,16 @@ class Reports::HourlySaleitemController < BaseReportController
shift = ''
if params[:shift_name].to_i != 0
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else
if shift_sale.shift_closed_at.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
end
@@ -31,7 +31,7 @@ class Reports::HourlySaleitemController < BaseReportController
@type = params[:sale_type]
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_hourly_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,filter,@start_time,@end_time)
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil).where("sales.shop_code='#{@shop.shop_code}'")
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}

View File

@@ -1,20 +1,20 @@
class Reports::IndutyController < BaseReportController
authorize_resource :class => false
def index
@commissioners = Commissioner.where("shop_code='#{@shop.shop_code}'") #.where("is_active='1'")
@commissioners = Commissioner.all
from, to = get_date_range_from_params
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@shift = ''
if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at, shift_sale.shift_closed_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
@@ -43,7 +43,7 @@ class Reports::IndutyController < BaseReportController
def show
from, to = get_date_range_from_params
@induty_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
@induty_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@commissioner = params[:commissioner]
date_arr = Array.new

View File

@@ -11,16 +11,16 @@ class Reports::OrderReservationController < BaseReportController
@shift = ''
if params[:shift_name].to_i != 0
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else
if shift_sale.shift_closed_at.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
end

View File

@@ -15,9 +15,9 @@ class Reports::PaymentMethodController < BaseReportController
if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
@payment_type = params[:payment_type]

View File

@@ -2,7 +2,7 @@ class Reports::ReceiptNoController < BaseReportController
authorize_resource :class => false
def index
@payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]]
@payment_method = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
@payment_method = PaymentMethodSetting.all
from, to = get_date_range_from_params
@shift_sale_range = ''
@@ -14,17 +14,17 @@ authorize_resource :class => false
@shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",@shift_sale.shift_started_at)
else
if @shift_sale.shift_closed_at.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",@shift_sale.shift_started_at)
else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}' ",@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
end
end
end
@lookup = Lookup.find_by_lookup_type_and_shop_code('reprint_receipt',@shop.shop_code)
@lookup = Lookup.find_by_lookup_type('reprint_receipt')
if @lookup.nil?
@lookup = Lookup.create_reprint_receipt_lookup(@shop.shop_code)
end
@@ -32,7 +32,7 @@ authorize_resource :class => false
payment_type = params[:payment_type]
@sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'")
@sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'")
@tax_profiles = TaxProfile.where("shop_code='#{@shop.shop_code}'").group('name').order('order_by asc') #.limit(2)
@tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2)
@from = from
@to = to

View File

@@ -2,7 +2,7 @@ class Reports::ReceiptNoDetailController < BaseReportController
authorize_resource :class => false
def index
@payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]]
@payment_method = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
@payment_method = PaymentMethodSetting.all
from, to = get_date_range_from_params
@shift_sale_range = ''
@@ -17,9 +17,9 @@ authorize_resource :class => false
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at)
else
if @shift_sale.shift_closed_at.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",@shift_sale.shift_started_at)
else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
end
end
end

View File

@@ -1,7 +1,7 @@
class Reports::SaleitemController < BaseReportController
authorize_resource :class => false
def index
@account = Account.where("shop_code='#{@shop.shop_code}'")
@account = Account.all
from, to = get_date_range_from_params
shift_sale_range = ''
@@ -13,12 +13,12 @@ class Reports::SaleitemController < BaseReportController
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at)
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else
if shift_sale.shift_closed_at.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
end
@@ -92,16 +92,16 @@ class Reports::SaleitemController < BaseReportController
shift_name = 'All Shift'
if params[:shift_name].to_i != 0
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else
if shift_sale.shift_closed_at.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'" ,shift_sale.shift_started_at)
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL" ,shift_sale.shift_started_at)
else
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
@@ -117,14 +117,14 @@ class Reports::SaleitemController < BaseReportController
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,@shop.shop_code)
other_charges = Sale.get_other_charges()
if shift.present?
@total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed' and sales.shop_code='#{@shop.shop_code}'",shift.to_a)
@total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
else
@total_other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed' and sales.shop_code='#{@shop.shop_code}'",from,to)
@total_other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
end
# get printer info
print_settings = PrintSetting.find_by_unique_code_and_shop_code('SaleItemsPdf',@shop.shop_code) # SaleItemsPdf
print_settings_star = PrintSetting.find_by_unique_code_and_shop_code('SaleItemsStarPdf',@shop.shop_code)
print_settings = PrintSetting.find_by_unique_code('SaleItemsPdf') # SaleItemsPdf
print_settings_star = PrintSetting.find_by_unique_code('SaleItemsStarPdf')
if print_settings.nil?
if !print_settings_star.nil?

View File

@@ -58,7 +58,7 @@ class Reports::ShiftsaleController < BaseReportController
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings")
close_cashier_pdf = Lookup.collection_of("print_settings")
unique_code = "CloseCashierPdf"
@@ -93,7 +93,7 @@ class Reports::ShiftsaleController < BaseReportController
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
# get printer info
print_settings = PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::CashierStationPrinter.new(print_settings)
# printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)

View File

@@ -2,7 +2,7 @@ class Reports::StaffMealController < BaseReportController
authorize_resource :class => false
def index
@account = Account.where("shop_code='#{@shop.shop_code}'")
@account = Account.all
from, to = get_date_range_from_params
shift_sale_range = ''
@@ -10,16 +10,16 @@ class Reports::StaffMealController < BaseReportController
shift = ''
if params[:shift_name].to_i != 0
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else
if shift_sale.shift_closed_at.blank?
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
end

View File

@@ -12,9 +12,9 @@ class Reports::StockCheckController < BaseReportController
# end
from_date, to_date = get_date_range_from_params
@item_code = params[:item_code]
@inventory_definitions = InventoryDefinition.active.where("shop_code='#{@shop.shop_code}'")
@inventory_definitions = InventoryDefinition.active
@transaction = StockCheckItem.where("shop_code='#{@shop.shop_code}'").get_transaction(from_date, to_date, @item_code)
@transaction = StockCheckItem.get_transaction(from_date, to_date, @item_code)
@from = from_date
@to = to_date
# get printer info

View File

@@ -9,10 +9,10 @@ authorize_resource :class => false
if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at)
else
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at, shift_sale.shift_closed_at)
@shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end

View File

@@ -6,7 +6,7 @@ class Settings::AccountsController < ApplicationController
# GET /settings/accounts.json
def index
@settings_accounts = Account.all.where("shop_code='#{@shop.shop_code}'")
@settings_accounts = Account.all
end
# GET /settings/accounts/1

View File

@@ -5,7 +5,7 @@ class Settings::CashierTerminalsController < ApplicationController
# GET /settings/cashier_terminals
# GET /settings/cashier_terminals.json
def index
@settings_cashier_terminals = CashierTerminal.where("shop_code=?",@shop.shop_code)
@settings_cashier_terminals = CashierTerminal.all
end
# GET /settings/cashier_terminals/1

View File

@@ -31,7 +31,7 @@ class Settings::EmployeesController < ApplicationController
# POST /employees.json
def create
@employee = Employee.new(employee_params)
@employee.shop_code =current_shop.shop_code
@employee.shop_code =@shop.shop_code
respond_to do |format|
if @employee.save
format.html { redirect_to settings_employees_path, notice: 'Employee was successfully created.' }

View File

@@ -25,7 +25,7 @@ class Settings::LookupsController < ApplicationController
# POST /settings/lookups.json
def create
@settings_lookup = Lookup.new(settings_lookup_params)
@settings_lookup.shop_code = current_shop.shop_code
@settings_lookup.shop_code = @shop.shop_code
respond_to do |format|
if @settings_lookup.save
format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully created.' }

View File

@@ -6,7 +6,7 @@ class Settings::MenusController < ApplicationController
# GET /settings/menus.json
def index
@settings_menus = Menu.all.where("shop_code='#{@shop.shop_code}'").page(params[:page]).per(10)
@settings_menus = Menu.all.page(params[:page]).per(10)
respond_to do |format|
format.html
format.xlsx
@@ -77,7 +77,7 @@ class Settings::MenusController < ApplicationController
def export
@settings_menus = Menu.all.where("shop_code='#{@shop.shop_code}'").page(params[:page]).per(10)
@settings_menus = Menu.all.page(params[:page]).per(10)
menu = Menu.find(params[:id])
p = Axlsx::Package.new

View File

@@ -6,7 +6,7 @@ class Settings::OrderQueueStationsController < ApplicationController
# GET /settings/order_queue_stations
# GET /settings/order_queue_stations.json
def index
@settings_order_queue_stations = OrderQueueStation.where("shop_code=?",@shop.shop_code)
@settings_order_queue_stations = OrderQueueStation.all
@settings_order_queue_stations = Kaminari.paginate_array(@settings_order_queue_stations).page(params[:page]).per(50)
end

View File

@@ -7,7 +7,7 @@ class Settings::OutOfStockController < ApplicationController
end
def new
@menus = Menu.where("shop_code='#{@shop.shop_code}'").order('created_at asc')
@menus = Menu.order('created_at asc')
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
end

View File

@@ -6,7 +6,7 @@ class Settings::ZonesController < ApplicationController
# GET /settings/zones.json
def index
@settings_zones = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true")
@settings_zones = Zone.all.where("is_active= true")
end
# GET /settings/zones/1

View File

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

View File

@@ -13,11 +13,11 @@ class Transactions::OrderReservationsController < ApplicationController
if from.nil? && to.nil?
@order_reservations = OrderReservation.select("order_reservations.*, deliveries.provider, deliveries.delivery_fee")
.joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id")
.where("NOT order_reservation_status='new' and order_reservations.shop_code='#{@shop.shop_code}'")
.where("NOT order_reservation_status='new'")
.order("order_reservation_id desc")
@order_reservations = Kaminari.paginate_array(@order_reservations).page(params[:page]).per(20)
else
order_reservation = OrderReservation.search(filter,from,to).where("order_reservations.shop_code='#{@shop.shop_code}'")
order_reservation = OrderReservation.search(filter,from,to)
if order_reservation.length > 0
@order_reservations = order_reservation
@order_reservations = Kaminari.paginate_array(@order_reservations).page(params[:page]).per(20)

View File

@@ -9,9 +9,9 @@ class Transactions::OrdersController < ApplicationController
to = params[:to]
if filter.nil? && from.nil? && to.nil?
orders = Order.where("shop_code='#{@shop.shop_code}'").order("order_id desc")
orders = Order.order("order_id desc")
else
orders = Order.search(filter,from,to).where("orders.shop_code='#{@shop.shop_code}'")
orders = Order.search(filter,from,to)
end
if !orders.nil?

View File

@@ -89,7 +89,7 @@ class Transactions::SalesController < ApplicationController
# GET /transactions/sales/1
# GET /transactions/sales/1.json
def show
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
@membership = MembershipSetting.all
@payment_methods = PaymentMethodSetting.where("is_active='1'")
@sale = Sale.find(params[:id])

View File

@@ -11,10 +11,10 @@ class Transactions::ShiftSalesController < ApplicationController
to = params[:to]
if filter.nil? && from.nil? && to.nil?
@shift_sales = ShiftSale.where("shop_code='#{@shop.shop_code}'").order("id desc")
@shift_sales = ShiftSale.order("id desc")
@shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20)
else
shift_sale = ShiftSale.search(filter,from,to).where("shift_sales.shop_code='#{@shop.shop_code}'")
shift_sale = ShiftSale.search(filter,from,to)
if shift_sale.count > 0
@shift_sales = shift_sale
@shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20)

View File

@@ -6,9 +6,9 @@ class Transactions::SurveysController < ApplicationController
to = params[:to]
if filter.nil? && from.nil? && to.nil?
@surveys = Survey.where("shop_code='#{@shop.shop_code}'")
@surveys = Survey.all
else
@surveys = Survey.search(filter,from,to).where("shop_code='#{@shop.shop_code}'")
@surveys = Survey.search(filter,from,to)
end
@filter = filter

View File

@@ -54,7 +54,7 @@ class DiningFacility < ApplicationRecord
def get_checkout_booking
booking = self.current_reserved_booking
if booking
lookup_checkout_time = Lookup.where("shop_code='#{self.shop_code}'").collection_of("checkout_alert_time")
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
free_time_min = 0
if !lookup_checkout_time.empty?
now = Time.now.utc
@@ -95,7 +95,7 @@ class DiningFacility < ApplicationRecord
bookings = self.current_checkin_booking
arr_booking = Array.new
if bookings
lookup_checkout_time = Lookup.where("shop_code='#{self.shop_code}'").collection_of("checkout_alert_time")
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
free_time_min = 0
if !lookup_checkout_time.empty?
now = Time.now.utc

View File

@@ -25,8 +25,8 @@ class InventoryDefinition < ApplicationRecord
def self.find_product_in_inventory(item)
if product = InventoryDefinition.find_by_item_code_and_shop_code(item.item_instance_code,Shop.current_shop.shop_code)
if stock_check_item = StockCheckItem.find_by_item_code_and_shop_code(item.item_instance_code,Shop.current_shop.shop_code)
if product = InventoryDefinition.find_by_item_code(item.item_instance_code)
if stock_check_item = StockCheckItem.find_by_item_code(item.item_instance_code)
return true, product
end
end
@@ -34,7 +34,7 @@ class InventoryDefinition < ApplicationRecord
def self.check_balance(item, inventory_definition) # item => saleItemOBj
stock = StockJournal.where("shop_code='#{inventory_definition.shop_code}' and item_code=?", item.item_instance_code).order("id DESC").first
stock = StockJournal.where("item_code=?", item.item_instance_code).order("id DESC").first
unless stock.nil?
modify_balance(item, stock, inventory_definition)
else
@@ -99,7 +99,7 @@ class InventoryDefinition < ApplicationRecord
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
.joins(" JOIN accounts acc ON acc.id = mi.account_id")
.where("inventory_definitions.shop_code='#{shop.shop_code}' and (inventory_definitions.item_code LIKE ? OR inventory_definitions.min_order_level LIKE ?
.where("(inventory_definitions.item_code LIKE ? OR inventory_definitions.min_order_level LIKE ?
OR inventory_definitions.max_stock_level LIKE ? OR sj.balance LIKE ? OR mi.name LIKE ?
OR mii.item_instance_name LIKE ? OR mc.name LIKE ?)","%#{filter}%","%#{filter}%","%#{filter}%",
"%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")

View File

@@ -86,7 +86,7 @@ class Lookup < ApplicationRecord
end
def self.save_shift_sale_items_settings(val,shop_code)
@lookup = Lookup.where("shop_code='#{shop_code}' and lookup_type=?", 'shift_sale_items').last
@lookup = Lookup.where("lookup_type=?", 'shift_sale_items').last
if @lookup.nil?
@lookup = Lookup.create_shift_sale_lookup(shop_code)
end
@@ -95,7 +95,7 @@ class Lookup < ApplicationRecord
end
def self.shift_sale_items_lookup_value(shop_code)
@lookup = Lookup.where("shop_code='#{shop_code}' and lookup_type=?", 'shift_sale_items').last
@lookup = Lookup.where("lookup_type=?", 'shift_sale_items').last
if @lookup.nil?
@lookup = Lookup.create_shift_sale_lookup(shop_code)
end

View File

@@ -212,7 +212,7 @@ class Order < ApplicationRecord
def self.pay_process_order_queue(id,table_id)
# if ENV["SERVER_MODE"] != 'cloud'
order = Order.find(id)
sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",order.shop_code)
sidekiq = Lookup.find_by_lookup_type("sidekiq")
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(id, table_id)
else

View File

@@ -153,23 +153,36 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# Query for OQS with status
def print_query(type, id)
query = OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name")
.joins("left join orders ON orders.order_id = order_items.order_id")
.joins("left join booking_orders AS bo ON bo.order_id=order_items.order_id")
.joins("left join bookings AS b ON b.booking_id = bo.booking_id")
.joins("left join dining_facilities AS df ON df.id = b.dining_facility_id")
.joins("left join customers as cus ON cus.customer_id = orders.customer_id")
.joins("left join menu_items as item ON item.item_code = order_items.item_code")
if type == "order_item"
query.where("order_items.order_items_id = ?", id)
OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name")
.joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.booking_id = bo.booking_id
left join dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id
left join menu_items as item ON item.item_code = order_items.item_code")
.where("order_items.order_items_id = '#{ id }'")
.group("order_items.item_code")
elsif type == "order_summary"
query.where("orders.order_id = ?", id)
OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name")
.joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.booking_id = bo.booking_id
left join dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id
left join menu_items as item ON item.item_code = order_items.item_code")
.where("orders.order_id = '#{ id }'")
.group("order_items.order_items_id")
else
# order summary for booking
query.where("b.booking_id = ?", id)
OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name")
.joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.booking_id = bo.booking_id
left join dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id
left join menu_items as item ON item.item_code = order_items.item_code")
.where("b.booking_id = '#{ id }'")
end
end

View File

@@ -42,17 +42,17 @@ class Printer::PrinterWorker
end
def print(file_path, printer_destination = nil )
if printer_destination.nil?
printer_destination = self.printer_destination
end
# if printer_destination.nil?
# printer_destination = self.printer_destination
# end
copy = self.print_copies
#Print only when printer information is not null
if !self.printer_destination.nil?
(1..copy).each do
page = Cups::PrintJob.new(file_path, printer_destination)
page.print
end
end
# copy = self.print_copies
# #Print only when printer information is not null
# if !self.printer_destination.nil?
# (1..copy).each do
# page = Cups::PrintJob.new(file_path, printer_destination)
# page.print
# end
# end
end
end

View File

@@ -35,7 +35,7 @@ class ProductCommission < ApplicationRecord
def self.edit_product_commission(saleItemObj,shop_code)
menu_item = MenuItem.find_by_item_code(saleItemObj.product_code)
commission = Commission.where("shop_code='#{shop_code}' and product_code = ? AND is_active = ?", menu_item.id, true).take
commission = Commission.where("product_code = ? AND is_active = ?", menu_item.id, true).take
product_commission = ProductCommission.where('sale_item_id = ?', saleItemObj.id).take
if !product_commission.nil?

View File

@@ -849,9 +849,9 @@ end
def self.get_by_shiftsales(from,to,shift,shop_code)
if !shift.blank?
query = ShiftSale.where("shift_sales.id =? and shop_code='#{shop_code}'",shift.id)
query = ShiftSale.where("shift_sales.id =?",shift.id)
else
query = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? ) and shop_code='#{shop_code}'", from, to, from, to)
query = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to)
end
shift_sale_data = Hash.new
@@ -1127,13 +1127,13 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
# end
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)
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
@@ -1144,20 +1144,20 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account
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' and sales.customer_id IN(#{customer_id})",from,to)
query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",from,to)
# if type.nil? || type == 'all' || type == "other"
# 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
@@ -1263,8 +1263,7 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,
CONCAT(DATE_FORMAT(CONVERT_TZ(shift_sales.shift_started_at,'+00:00','+06:30'),'%d %b %y %h:%i%p'),' - ',DATE_FORMAT(CONVERT_TZ(shift_sales.shift_closed_at,'+00:00','+06:30'),'%d %b %y %h:%i%p')) as credit_payment_shift_name")
.joins(:sale_audit)
.joins(:sale => :shift_sale)
.joins(:sale => :cashier)
.where("sales.shop_code='#{shop_code}'").to_sql
.joins(:sale => :cashier).to_sql
credits = SalePayment.select("
sale_payments.sale_payment_id,
@@ -1315,7 +1314,6 @@ end
sale_arr = Array.new
query = Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment")
.where("sales.shop_code='#{shop_code}'")
# .joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id")
# .where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ?
# OR sh.shift_closed_at between ? and ? )", from ,to, from, to)
@@ -1488,7 +1486,7 @@ end
def self.top_bottom_products(current_user,from,to,type,current_shop)
query = Sale.joins("JOIN sale_items ON sale_items.sale_id = sales.sale_id")
.completed
.where("qty > 0 AND price > 0 AND shop_code='#{current_shop.shop_code}'")
.where("qty > 0 AND price > 0")
.group("SUBSTRING_INDEX(product_name, ' - ', 1)")
if !from.nil? && !to.nil?
@@ -1600,7 +1598,7 @@ end
query = SalePayment.credits
.joins(:sale)
.joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sale_payments.sale_id")
.where("sale_payments.payment_method= ? AND sales.sale_status = ? AND sales.shop_code=?", 'creditnote', 'completed',current_shop.shop_code)
.where("sale_payments.payment_method= ? AND sales.sale_status = ?", 'creditnote', 'completed')
if (!from.nil? && !to.nil?)
query = query.merge(Sale.receipt_date_between(from, to))
@@ -1818,7 +1816,6 @@ end
query = Sale.select("count(distinct sale_orders.order_id) as total_order")
.joins(:sale_orders)
.where("shop_code='#{current_shop.shop_code}'")
.completed
if (!from.nil? && !to.nil?)
@@ -2357,8 +2354,8 @@ def self.get_check_sale_data(transaction_date)
.group("sales.receipt_no,sales.sale_status")
end
def paymal_payment_void
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",self.shop_code)
membership_actions_data = MembershipAction.find_by_membership_type_and_shop_code("void",self.shop_code)
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_actions_data = MembershipAction.find_by_membership_type("void")
if !membership_actions_data.nil?
sale_payments =self.sale_payments.where("payment_reference is not null")
if !sale_payments.empty?

View File

@@ -36,7 +36,7 @@ class SalePayment < ApplicationRecord
def self.get_kbz_pay_amount(sale_id, current_user,shop)
amount = 0
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY,:shop_code => shop.shop_code).last
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last
if !sale_payment.nil? and !kbz_pay_method.nil?
if sale_payment.payment_status == 'pending'
@@ -295,7 +295,7 @@ class SalePayment < ApplicationRecord
def self.create_payment(paypar_url,payment_type,membership_id,received_amount,sale_id)
# membership_actions_data = MembershipAction.find_by_membership_type("create_payment");
sale_data = Sale.find_by_sale_id(sale_id)
membership_actions_data = PaymentMethodSetting.find_by_payment_method_and_shop_code(payment_type,sale_data.shop_code)
membership_actions_data = PaymentMethodSetting.find_by_payment_method(payment_type)
customer_data = Customer.find_by_customer_id(sale_data.customer_id)
if !membership_actions_data.nil?
@@ -530,7 +530,7 @@ class SalePayment < ApplicationRecord
#Next time - validate if the vochure number is valid - within
account_no = self.payment_reference
# self.sale.customer.update_attributes(paypar_account_no: )
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",self.sale.shop_code)
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.create_payment(membership_setting.gateway_url,"PAYMAL",account_no,self.received_amount,self.sale.sale_id)
#record an payment in sale-audit
@@ -783,8 +783,8 @@ class SalePayment < ApplicationRecord
overall_dis = sObj.total_discount
if credit != 1
membership = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sObj.shop_code)
memberaction = MembershipAction.find_by_membership_type_and_shop_code("get_member_campaign",sObj.shop_code)
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_member_campaign")
merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s
@@ -868,8 +868,8 @@ class SalePayment < ApplicationRecord
if total_amount >= 0
receipt_no = sObj.receipt_no
membership = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sObj.shop_code)
memberaction = MembershipAction.find_by_membership_type_and_shop_code("rebate",sObj.shop_code)
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("rebate")
merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s

View File

@@ -31,7 +31,7 @@ class SaleTax < ApplicationRecord
def self.get_tax(from,to)
query = SaleTax.select("sale_taxes.tax_name,SUM(sale_taxes.tax_payable_amount) as tax_amount")
.joins("join sales on sales.sale_id = sale_taxes.sale_id")
.where("sales.shop_code=? and sale_status = ? AND sales.receipt_date between ? and ? AND total_amount != 0 AND inclusive = 0",Shop.current_shop.shop_code, 'completed', from, to)
.where("sale_status = ? AND sales.receipt_date between ? and ? AND total_amount != 0 AND inclusive = 0", 'completed', from, to)
.group("sale_taxes.tax_name")
end

View File

@@ -28,7 +28,7 @@ class ShiftSale < ApplicationRecord
#find open shift where is open today and is not closed and login by current cashier
#DATE(shift_started_at)=? and
today_date = DateTime.now.strftime("%Y-%m-%d")
shift = ShiftSale.where("shop_code='#{current_user.shop_code}' and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user.id}").take
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user.id}").take
return shift
#end
end

View File

@@ -68,6 +68,6 @@ class StockCheckItem < ApplicationRecord
end
def self.delete_stock_check_item(item_code,shop)
self.where("item_code=? and shop_code='#{shop.shop_code}'", item_code).delete_all
self.where("item_code=?", item_code).delete_all
end
end

View File

@@ -36,7 +36,7 @@ class StockJournal < ApplicationRecord
end
def self.from_stock_check(item,shop)
stock_journal = StockJournal.where("shop_code='#{shop.shop_code}' and item_code=?", item.item_code).order("id DESC").first
stock_journal = StockJournal.where("item_code=?", item.item_code).order("id DESC").first
if stock_journal.nil?
old_blance = 0
inventory_definition_id = InventoryDefinition.find_by_item_code_and_shop_code(item.item_code,shop.shop_code).id
@@ -79,7 +79,7 @@ class StockJournal < ApplicationRecord
end
def self.delete_stock_journal(item_code,shop)
self.where("item_code=? and shop_code='#{shop.shop_code}'", item_code).delete_all
self.where("item_code=?", item_code).delete_all
end
end

View File

@@ -31,7 +31,7 @@ class OrderSummaryPdf < Prawn::Document
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
# font "public/fonts/padauk.ttf"z
if order[0].source =='app'
text "Mobile Order", :size => self.header_font_size,:align => :left
move_down 1

View File

@@ -72,6 +72,8 @@ class ReceiptBillPdf < Prawn::Document
else
customer(customer_account,nil)
end
puts "Card data = >" +card_data
puts "Printed =>" + printed_status
#start card sale trans data
if card_data != nil
card_sale_data(card_data)

View File

@@ -308,6 +308,8 @@
$("#type").val("card");
}
}
$("#sxModal").hide();
//$("#filter_form").submit();
}
}

View File

@@ -175,8 +175,6 @@
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
$("#filter_form").submit();
},100);
});

View File

@@ -375,7 +375,6 @@
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
},100);
}
});
@@ -395,7 +394,6 @@
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#search").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
@@ -497,6 +495,7 @@
$("#type").val("card");
}
}
$("#sxModal").hide();
}
}

View File

@@ -248,18 +248,28 @@
// Read Card Reader
$(".btn_member").on('click', function(){
var cardNo = "";
$("#is_paymemberModal").hide();
$("#sxModal").show();
setTimeout(function(){
getCardNo();
},100);
});
// Read NFC card no from java
function getCardNo(){
code2lab.readNFC();
}
// get CardNo from Java
function setCardNo(cardNo){
var sale_id = $("#sale_id").text() || 0;
var receipt_no = $("#receipt_no").val() || "";
var customer_mamber_card_no = 0;
var payment_amount = parseFloat($("#used_amount").text());
$("#is_paymemberModal").hide();
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
customer_mamber_card_no = $("#paypar_account_no").val();
if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0;
@@ -316,18 +326,7 @@
}else{
swal("Opp","Please Check Member","warning")
}
},100);
});
// Read NFC card no from java
function getCardNo(){
code2lab.readNFC();
}
// get CardNo from Java
function setCardNo(cardNo){
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
$("#sxModal").hide();
}
}

View File

@@ -1150,26 +1150,156 @@ $(document).ready(function(){
// Read Card Reader
$(".btn_member").on('click', function(){
var cardNo = "";
$("#is_memberModal").hide();
$("#sxModal").attr('data-for', 'member');
$("#sxModal").show();
setTimeout(function(){
getCardNo();
},100);
});
function pay_with_card(cardNo) {
var sale_id = $("#sale_id").text() || 0;
var receipt_no = "";
if(($("#receipt_no").html() != undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
var customer_mamber_card_no = 0;
var payment_amount = parseFloat($("#grand_total").text());
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0;
}
if(sale_id != 0 && customer_mamber_card_no !=0){
$("#loading_wrapper").show();
$.ajax({
type: "POST",
url: "/foodcourt/"+sale_id+"/send_account" ,
data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no},
dataType: "json",
success: function(data) {
$("#loading_wrapper").hide();
if (data.status == true) {
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
// $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({
type: "POST",
url: "<%=foodcourt_payment_paymal_path%>",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no},
success: function(result){
if(result.status == true){
swal({
title: "Information!",
text: result.message,
type: 'success',
html: true,
closeOnConfirm: true,
closeOnCancel: false,
allowOutsideClick: false
}, function (isConfirm) {
$('.confirm').attr("disabled","disabled");
sub_total = $('#sub-total').text();
member = $('#membership_id').text();
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').text();
// var item_row = $('.is_card');
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var kbz_amt = "<%= @kbz_pay_amount %>";
var is_kbz = false;
if (kbz_amt > 0) {
is_kbz = true
}
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
calculate_member_discount(sale_id,tax_type);
/* check credit payment or not*/
var url = "<%= foodcourt_payment_cash_path %>";
$.ajax({type: "POST",
url: url,
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz+"&account_no="+customer_mamber_card_no,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
/* end delete receipt no in first bill*/
localStorage.removeItem("cash");
window.location.href = "<%= foodcourt_food_court_path %>";
}
});
var second_display_lookup = $("#display_type").val();
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
customer_display_view(null,"reload");
}
});
}else{
swal({
title: 'Oops',
text: result.message,
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}else{
swal({
title: 'Oops',
text: data.message,
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}else{
swal({
title: 'Oops',
text: 'Please Check Member',
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
function member_card(cardNo) {
var customer_id = '';
var customer_name = '';
var membership_id = '';
var membership_type = '';
var sale_id = $("#sale_id").text() || 0;
var customer_mamber_card_no = 0;
$("#is_memberModal").hide();
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
if(sale_id != 0 && cardNo != 0){
$.ajax({
type: "POST",
url: "/foodcourt/"+sale_id+"/get_customer" ,
data: { filter : customer_mamber_card_no ,type :"card"},
data: { filter : cardNo ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
@@ -1185,8 +1315,7 @@ $(document).ready(function(){
}
});
}
},100);
});
}
// Read NFC card no from java
function getCardNo(){
@@ -1197,8 +1326,15 @@ $(document).ready(function(){
// get CardNo from Java
function setCardNo(cardNo){
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
if ($("#sxModal").attr("data-for") == 'member') {
member_card(cardNo);
} else if ($("#sxModal").attr('data-for') == 'payment') {
pay_with_card(cardNo);
}
$("#sxModal").hide();
}
}
@@ -1460,138 +1596,13 @@ $(document).ready(function(){
// Read Card Reader - Paymal payment for FoodCourt
$(".btn_paymal_member").on('click', function (){
var cardNo = "";
var sale_id = $("#sale_id").text() || 0;
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
var customer_mamber_card_no = 0;
var payment_amount = parseFloat($("#grand_total").text());
$("#is_paymemberModal").hide();
$("#sxModal").attr('data-for', 'payment');
$("#sxModal").show();
setTimeout(function(){
var cardNo = setTimeout(function(){
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0;
}
if(sale_id != 0 && customer_mamber_card_no !=0){
$("#loading_wrapper").show();
$.ajax({
type: "POST",
url: "/foodcourt/"+sale_id+"/send_account" ,
data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no},
dataType: "json",
success: function(data) {
$("#loading_wrapper").hide();
if (data.status == true) {
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
// $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({
type: "POST",
url: "<%=foodcourt_payment_paymal_path%>",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no},
success: function(result){
if(result.status == true){
swal({
title: "Information!",
text: result.message,
type: 'success',
html: true,
closeOnConfirm: true,
closeOnCancel: false,
allowOutsideClick: false
}, function (isConfirm) {
$('.confirm').attr("disabled","disabled");
sub_total = $('#sub-total').text();
member = $('#membership_id').text();
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').text();
// var item_row = $('.is_card');
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var kbz_amt = "<%= @kbz_pay_amount %>";
var is_kbz = false;
if (kbz_amt > 0) {
is_kbz = true
}
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
calculate_member_discount(sale_id,tax_type);
/* check credit payment or not*/
var url = "<%= foodcourt_payment_cash_path %>";
$.ajax({type: "POST",
url: url,
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz+"&account_no="+customer_mamber_card_no,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
/* end delete receipt no in first bill*/
localStorage.removeItem("cash");
window.location.href = "<%= foodcourt_food_court_path %>";
}
});
var second_display_lookup = $("#display_type").val();
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
customer_display_view(null,"reload");
}
});
}else{
swal({
title: 'Oops',
text: result.message,
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}else{
swal({
title: 'Oops',
text: data.message,
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}else{
swal({
title: 'Oops',
text: 'Please Check Member',
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
},100);
setCardNo(cardNo);
});
// QR Code Reader

View File

@@ -396,7 +396,6 @@
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
},100);
}
});
@@ -416,7 +415,6 @@
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#search").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
@@ -518,6 +516,7 @@
$("#type").val("card");
}
}
$("#sxModal").hide();
}
}

View File

@@ -265,7 +265,6 @@
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
@@ -332,6 +331,7 @@
function setCardNo(cardNo){
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
$("#sxModal").hide();
}
}

View File

@@ -259,7 +259,6 @@
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0;
@@ -328,6 +327,7 @@
function setCardNo(cardNo){
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
$("#sxModal").hide();
}
}

View File

@@ -1305,7 +1305,6 @@ $(document).ready(function(){
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
@@ -1342,6 +1341,7 @@ $(document).ready(function(){
function setCardNo(cardNo){
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
$("#sxModal").hide();
}
}
@@ -1707,7 +1707,6 @@ $(document).ready(function(){
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0;

View File

@@ -1,5 +1,5 @@
class AddIsOutOfStockToMenuItemInstaces < ActiveRecord::Migration[5.1]
def change
add_column :menu_item_instances, :is_out_of_stock, :boolean, :default => 0
end
end
# class AddIsOutOfStockToMenuItemInstaces < ActiveRecord::Migration[5.1]
# def change
# add_column :menu_item_instances, :is_out_of_stock, :boolean, :default => 0
# end
# end

View File

@@ -1,10 +1,10 @@
class CreateOutOfStocks < ActiveRecord::Migration[5.1]
def change
create_table :out_of_stocks do |t|
t.datetime :date
t.string :item_instance_code
# def change
# create_table :out_of_stocks do |t|
# t.datetime :date
# t.string :item_instance_code
t.timestamps
end
end
# t.timestamps
# end
# end
end