fix conflict

This commit is contained in:
Myat Zin Wai Maw
2020-01-14 18:15:13 +06:30
131 changed files with 520 additions and 321 deletions

View File

@@ -318,9 +318,6 @@ settings/lookups => { type:customer_type, name: Staff, value:Staff }
For FoodCourt Cashier role
settings/lookups => { type:employee_roles, name: FoodCourt Cashier, value:foodcourt_cashier }
For Search Paypar security_code
settings/lookups => { type:employee_roles, name: FoodCourt Cashier, value:foodcourt_cashier }
* ToDo list

View File

@@ -1041,7 +1041,7 @@ $(function() {
}else if(result.data == 'OK'){
window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text();
}else{
if(result.current_user_role == 'foodcourt_cashier'){
if(result.current_user_role == 'cashier'){
window.location.href = "/foodcourt/sale/"+result.data["sale_id"]+"/"+type+"/payment";
}
else{

View File

@@ -26,7 +26,7 @@ class Api::CallWaitersController < ActionController::API
unique_code = "CallWaiterPdf"
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_call_waiter(print_settings,@table,@time,@shop)
printer.print_call_waiter(print_settings,@table,@time,current_shop)
end

View File

@@ -70,7 +70,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation)
if !order_reservation_id.nil? && flag
shop = @shop
shop = current_shop
if !shop.nil?
shop_code = shop.shop_code
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")

View File

@@ -51,7 +51,7 @@ class Api::OrdersController < Api::ApiController
# end
#
return @shop.to_json
return current_shop.to_json
end
@@ -66,13 +66,13 @@ class Api::OrdersController < Api::ApiController
def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s
Rails.logger.debug "Table ID - " + params[:table_id].to_s
@shop = Shop.find_by_shop_code(params[:shop_code])
current_shift = ShiftSale.current_shift
if current_shift.nil?
@status = false
@message = "No Current Open Shift for This Employee"
else
current_user =Employee.find(current_shift.employee_id)
current_user = Employee.find(current_shift.employee_id)
if checkin_checkout_time(params[:booking_id])
table = DiningFacility.find(params[:table_id]) if params[:table_id].present?
@@ -124,6 +124,9 @@ class Api::OrdersController < Api::ApiController
if @status && @booking
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
if @order.source == 'app'
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
end
end
if @order.table_id.to_i > 0
table = DiningFacility.find(@booking.dining_facility_id)

View File

@@ -10,7 +10,7 @@ class Api::Payment::CallbackController < Api::ApiController
if trade_status == "PAY_SUCCESS"
merch_order_id = params[:Request][:merch_order_id]
status, filename, sale_receipt_no, printer_name = Payment.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, shop_detail, current_user, 'kbzpay', merch_order_id)
status, filename, sale_receipt_no, printer_name = Payment.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, current_shop, current_user, 'kbzpay', merch_order_id)
render json: JSON.generate({:status => status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
end
end

View File

@@ -15,7 +15,7 @@ class Api::Payment::MobilepaymentController < Api::ApiController
saleObj = Sale.find(sale_id)
sale_items = SaleItem.get_all_sale_items(sale_id)
shop_detail = @shop
shop_detail = current_shop
# rounding adjustment
if !path.include? ("credit_payment")

View File

@@ -171,9 +171,9 @@ class Api::PaymentsController < Api::ApiController
action_by = current_login_employee.name
@status = true
@message = ""
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sale.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",sale.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

@@ -2,11 +2,11 @@ class Api::ShopsController < Api::ApiController
skip_before_action :authenticate
def index
def index
@shops = Shop.select('id,logo,name,shop_code,address,phone_no').all
end
end
def show
def show
@shop = Shop.find_by_shop_code(params[:id])
end
end
end

View File

@@ -2,7 +2,7 @@ class Api::SoundEffectController < Api::ApiController
#sound effect / alarm api for doemal side calling
def sound_effect
shop = @shop
shop = current_shop
if !shop.nil?
shop_code = shop.shop_code
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")

View File

@@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base
#before_action :check_installation
protect_from_forgery with: :exception
helper_method :shop_detail,:order_reservation, :bank_integration
helper_method :current_shop,:order_reservation, :bank_integration
# lookup domain for db from provision
# before_action :set_locale
# helper_method :current_company,:current_login_employee,:current_user

View File

@@ -2,7 +2,7 @@ module LoginVerification
extend ActiveSupport::Concern
included do
before_action :authenticate_session_token
helper_method :current_company, :current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail
helper_method :current_company, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :current_shop
end
#this is base api base controller to need to inherit.
@@ -16,32 +16,23 @@ module LoginVerification
end
end
def current_shop
begin
return Shop.current_shop
rescue
return nil
end
end
def current_login_employee
@employee = Employee.find_by_token_session(session[:session_token])
@employee ||= current_user
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
# Get current Cashiers
def get_cashier
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
@cashier ||= Employee.where("role = 'cashier' AND token_session <> ''")
end
#Shop Name in Navbor
def shop_detail
@shop ||= current_shop
end
# def shop_detail
# @shop ||= current_shop
# end
#check order reservation used
def order_reservation

View File

@@ -3,18 +3,19 @@ module MultiTenancy
included do
set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter
before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action
before_action :set_current_tenant_by_subdomain_or_frist if respond_to? :before_action
helper_method :current_shop if respond_to? :helper_method
end
private
def find_shop_by_subdomain_or_frist
if request.subdomain.present?
shop_code = request.subdomain.partition('-').last
@shop = Shop.find_by(shop_code: shop_code)
else
# @shop = Shop.first
@shop = Shop.find_by(shop_code: '262')
def set_current_tenant_by_subdomain_or_frist
if request.subdomains.last && request.subdomains.last != 'www'
set_current_tenant(Shop.find_by(subdomain: request.subdomains.last))
end
set_current_tenant(@shop)
set_current_tenant(Shop.first) if current_tenant.nil?
end
def current_shop
ActsAsTenant.current_tenant
end
end

View File

@@ -6,14 +6,13 @@ module TokenVerification
before_action :authenticate
end
protected
# Authenticate the user with token based authentication
def authenticate
authenticate_token || render_unauthorized
end
def authenticate_token
def authenticate_token
authenticate_with_http_token do |token, options|
# Rails.logger.debug "token - " + token.to_s
if(options.length !=0 && options["from"] == "DOEMAL")

View File

@@ -48,7 +48,6 @@ class Crm::CustomersController < BaseCrmController
@crm_customers.membership_type = response["customer_data"]["member_group_id"]
@crm_customers.customer_type = "Dinein"
@crm_customers.tax_profiles = ["1", "2"]
@crm_customers.shop_code = @shop.shop_code
@crm_customers.save
@crm_customers = Customer.search(filter)
flash[:member_notice]='Customer was successfully created.'
@@ -263,7 +262,6 @@ class Crm::CustomersController < BaseCrmController
if @checked_contact.nil?
respond_to do |format|
@crm_customers = Customer.new(customer_params)
@crm_customers.shop_code = @shop.shop_code
if @crm_customers.save
# update tax profile
customer = Customer.find(@crm_customers.customer_id)

View File

@@ -40,7 +40,6 @@ class Crm::DiningQueuesController < BaseCrmController
# POST /crm/dining_queues.json
def create
@dining_queue = DiningQueue.new(dining_queue_params)
@dining_queue.shop_code = @shop.shop_code
respond_to do |format|
if @dining_queue.save

View File

@@ -135,7 +135,6 @@ class Foodcourt::AddordersController < BaseFoodcourtController
@order.new_booking = true
@order.waiters = current_login_employee.name
@order.employee_name = current_login_employee.name
@order.shop_code = @shop.shop_code
@order.is_extra_time = is_extra_time
@order.extra_time = extra_time

View File

@@ -87,8 +87,9 @@ class Foodcourt::CustomersController < BaseFoodcourtController
@count_customer = Customer.count_customer
# @taxes = TaxProfile.where(:group_type => 'cashier')
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
.order("group_type ASC,order_by ASC")
@taxes = TaxProfile.unscope(:order).select("tax_profiles.id, CONCAT(tax_profiles.name, '(', lookups.name, ')') as name")
.joins(:lookup)
.order("group_type ASC, order_by ASC")
# if flash["errors"]
# @crm_customer.valid?
# end

View File

@@ -76,7 +76,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController
def completed
customer =Customer.find_by_customer_id(params[:customer_id])
phone_number =customer.contact_no
if Order.send_message(phone_number,params[:order_id],@shop.name)
if Order.send_message(phone_number,params[:order_id],current_shop.name)
booking =Booking.find(params[:booking_id])
booking.booking_status ='completed'
booking.save!

View File

@@ -20,7 +20,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
#shop_detail = Shop.first
# rounding adjustment
if !path.include? ("credit_payment")
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total - saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
@@ -154,7 +154,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
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,account_no, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,account_no, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
#end
end
@@ -223,7 +223,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
@pdf_view = @lookup_pdf.value
end
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop)
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
@kbz_pay_amount += amount.to_f
#for changable on/off
@@ -270,7 +270,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
#end rounding adjustment
# rounding adjustment
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
@@ -472,7 +472,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
result = {
:status => true,
@@ -571,7 +571,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
result = {
:status => true,
:filepath => filename,
@@ -606,7 +606,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
saleObj = Sale.find(params[:sale_id])
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even

View File

@@ -9,7 +9,7 @@ class Foodcourt::PayparPaymentsController < BaseFoodcourtController
saleObj = Sale.find(sale_id)
# rounding adjustment
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)

View File

@@ -118,7 +118,7 @@ class Foodcourt::SaleEditController < BaseFoodcourtController
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
ProductCommission.edit_product_commission(saleitemObj,sale.shop_code)
ProductCommission.edit_product_commission(saleitemObj)
end
# make cancel void item

View File

@@ -88,11 +88,11 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
end
end
end
shop_details = shop_detail
shop_details = current_shop
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
sale_items = ''
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
@lookup = Lookup.shift_sale_items_lookup_value
if @lookup.to_i == 1
@sale_items = Sale.get_shift_sale_items(@shift.id)
other_charges = Sale.get_other_charges()

View File

@@ -76,7 +76,6 @@ class Foodcourt::SurveysController < BaseFoodcourtController
@survey = Survey.new(survey_params)
@survey.shift_id = shift_by_terminal.id
@survey.foreigner = params["survey"]["foreigner"].to_json
@survey.shop_code = @shop.shop_code
# respond_to do |format|
if @survey.save
redirect_to @url

View File

@@ -132,7 +132,7 @@ class Foodcourt::VoidController < BaseFoodcourtController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.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.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,

View File

@@ -118,7 +118,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.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.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,

View File

@@ -100,7 +100,7 @@ class HomeController < ApplicationController
@sales = Sale.receipt_date_between(@from, @to).completed
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user.id)
if shift = ShiftSale.current_open_shift(current_user)
@orders = @orders.where(shift_sale_id: shift.id)
@sales = @sales.where(shift_sale_id: shift.id)
end
@@ -124,7 +124,7 @@ class HomeController < ApplicationController
end
end
@inventories = StockJournal.inventory_balances(@from,@to, current_shop).sum(:balance)
@inventories = StockJournal.inventory_balances(@from,@to).sum(:balance)
@total_trans = Sale.total_trans(current_user,@from,@to)
@total_card = Sale.total_card_sale(current_user,@from,@to)
@@ -199,13 +199,22 @@ class HomeController < ApplicationController
redirect_to dashboard_path
end
elsif employee.role == "cashier"
food_court = Lookup.find_by_lookup_type_and_value("food_court", "1")
#check if cashier has existing open cashier
shift = ShiftSale.current_open_shift(employee)
if !shift.nil?
redirect_to origami_dashboard_path
# redirect_to origami_root_path
if food_court
if !shift.nil?
redirect_to foodcourt_food_court_path
else
redirect_to new_foodcourt_shift_path
end
else
redirect_to new_origami_shift_path
if !shift.nil?
redirect_to origami_dashboard_path
# redirect_to origami_root_path
else
redirect_to new_origami_shift_path
end
end
elsif employee.role == "manager"
redirect_to dashboard_path

View File

@@ -39,7 +39,6 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
@inventory_definition.min_order_level = params[:min_order_level]
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + params[:max_stock_level].to_i
end
@inventory_definition.shop_code = @shop.shop_code
@inventory_definition.created_by = current_user.id
if @inventory_definition.save
result = {:status=> true, :message => "Inventory definition was created successfully",:data=> @inventory_definition}
@@ -91,9 +90,8 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
format.json { head :no_content }
end
# inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
StockJournal.delete_stock_journal(inventory.item_code,@shop)
StockCheckItem.delete_stock_check_item(inventory.item_code,@shop)
StockJournal.delete_stock_journal(inventory.item_code)
StockCheckItem.delete_stock_check_item(inventory.item_code)
if !inventory.nil?
inventory.destroy
flash[:message] = 'Inventory was successfully destroyed.'

View File

@@ -19,7 +19,7 @@ class Inventory::StockChecksController < BaseInventoryController
item_list = JSON.parse(params[:stock_item])
reason = params[:reason]
check = StockCheck.new
@check = check.create(current_user, reason, item_list,@shop)
@check = check.create(current_user, reason, item_list)
end
def show
@@ -33,7 +33,7 @@ class Inventory::StockChecksController < BaseInventoryController
check = params[:data]
stockCheck = StockCheck.find_by_id(check)
stockCheck.stock_check_items.each do |item|
StockJournal.from_stock_check(item,@shop)
StockJournal.from_stock_check(item)
end
end
@@ -49,7 +49,7 @@ class Inventory::StockChecksController < BaseInventoryController
print_settings = PrintSetting.find_by_unique_code(unique_code)
if !print_settings.nil?
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, @shop)
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, current_shop)
end
end

View File

@@ -25,7 +25,6 @@ class StockJournalsController < ApplicationController
# POST /stock_journals.json
def create
@stock_journal = StockJournal.new(stock_journal_params)
@stock_journal.shop_code = @shop.shop_code
respond_to do |format|
if @stock_journal.save
format.html { redirect_to @stock_journal, notice: 'Stock journal was successfully created.' }

View File

@@ -23,7 +23,7 @@ class Origami::AlipayController < BaseOrigamiController
others = 0
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total

View File

@@ -8,7 +8,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController
total = sale_data.grand_total
@creditcount = 0
others = 0
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total

View File

@@ -87,8 +87,9 @@ class Origami::CustomersController < BaseOrigamiController
@count_customer = Customer.count_customer
# @taxes = TaxProfile.where(:group_type => 'cashier')
@taxes = TaxProfile.unscope(:order).select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
.order("group_type ASC,order_by ASC")
@taxes = TaxProfile.unscope(:order).select("tax_profiles.id, CONCAT(tax_profiles.name, '(', lookups.name, ')') as name")
.joins(:lookup)
.order("group_type ASC, order_by ASC")
# if flash["errors"]
# @crm_customer.valid?
# end

View File

@@ -6,7 +6,7 @@ class Origami::DingaController < BaseOrigamiController
@membership_rebate_balance=0
@sale_data = Sale.find_by_sale_id(@sale_id)
@receipt_no = @sale_data.receipt_no
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
else
new_total = @sale_data.grand_total

View File

@@ -17,7 +17,7 @@ class Origami::GiftVoucherController < BaseOrigamiController
others = 0
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total

View File

@@ -11,7 +11,7 @@ class Origami::HomeController < BaseOrigamiController
@customers = Customer.pluck("customer_id, name")
@occupied_table = DiningFacility.where("status='occupied'").shop.count
@occupied_table = DiningFacility.where("status='occupied'").count
@shift = ShiftSale.current_open_shift(current_user)
end
@@ -33,7 +33,7 @@ class Origami::HomeController < BaseOrigamiController
@status_sale = ""
@sale_array = Array.new
@shop = shop_detail
@shop = current_shop
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all
@dining_booking = @dining.current_bookings

View File

@@ -24,7 +24,7 @@ class Origami::JcbController < BaseOrigamiController
others = 0
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total

View File

@@ -11,7 +11,7 @@ class Origami::JunctionPayController < BaseOrigamiController
@cashier_id = current_user.emp_id
@payment_method_setting_nav = PaymentMethodSetting.all
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total

View File

@@ -23,7 +23,7 @@ class Origami::MasterController < BaseOrigamiController
others = 0
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total

View File

@@ -22,7 +22,7 @@ class Origami::MpuController < BaseOrigamiController
others = 0
if @shop.is_rounding_adj && (!path.include? ("credit_payment"))
if current_shop.is_rounding_adj && (!path.include? ("credit_payment"))
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total

View File

@@ -6,7 +6,7 @@ class Origami::PaymalController < BaseOrigamiController
@membership_rebate_balance=0
sale_data = Sale.find_by_sale_id(@sale_id)
@receipt_no = sale_data.receipt_no
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total

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, "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, nil, current_shop, "Frt", current_balance, nil, other_amount, nil, nil, nil)
result = {
:filepath => filename,
@@ -192,7 +192,7 @@ class Origami::PaymentsController < BaseOrigamiController
end
#card_balance amount for Paymal payment
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
@@ -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, "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, current_shop, "Paid", current_balance, card_data, other_amount, latest_order_no, card_balance_amount, nil)
#end
end
@@ -275,7 +275,7 @@ class Origami::PaymentsController < BaseOrigamiController
@pdf_view = @lookup_pdf.value
end
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop)
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
@kbz_pay_amount += amount.to_f
#for changable on/off
@@ -322,7 +322,7 @@ class Origami::PaymentsController < BaseOrigamiController
#end rounding adjustment
# rounding adjustment
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
@@ -524,7 +524,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount, current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
result = {
:status => true,
@@ -622,7 +622,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
result = {
:status => true,
:filepath => filename,
@@ -657,7 +657,7 @@ class Origami::PaymentsController < BaseOrigamiController
saleObj = Sale.find(params[:sale_id])
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even

View File

@@ -8,7 +8,7 @@ class Origami::PayparPaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
# rounding adjustment
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)

View File

@@ -5,7 +5,7 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
@cashier_type = params[:type]
@membership_rebate_balance=0
sale_data = Sale.find_by_sale_id(@sale_id)
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total

View File

@@ -163,7 +163,7 @@ class Origami::SaleEditController < BaseOrigamiController
# end
# end
ProductCommission.edit_product_commission(saleitemObj,sale.shop_code)
ProductCommission.edit_product_commission(saleitemObj)
end
# make cancel void item

View File

@@ -91,7 +91,7 @@ class Origami::ShiftsController < BaseOrigamiController
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
sale_items = ''
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
@lookup = Lookup.shift_sale_items_lookup_value
if @lookup.to_i == 1
@sale_items = Sale.get_shift_sale_items(@shift.id)
other_charges = Sale.get_other_charges()
@@ -126,7 +126,7 @@ class Origami::ShiftsController < BaseOrigamiController
if find_close_cashier_print[0][1].to_i > 0
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, @shop,@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)
printer.print_close_cashier(print_settings,cashier_terminal, @shift, @sale_items, @total_other_charges_info, current_shop,@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)
end
end
end

View File

@@ -76,7 +76,6 @@ class Origami::SurveysController < BaseOrigamiController
@survey = Survey.new(survey_params)
@survey.shift_id = shift_by_terminal.id
@survey.foreigner = params["survey"]["foreigner"].to_json
@survey.shop_code = @shop.shop_code
# respond_to do |format|
if @survey.save
redirect_to @url

View File

@@ -9,7 +9,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
else
sale = Sale.find(booking.sale_id)
# rounding adjustment
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
a = sale.grand_total % 25 # Modulus
b = sale.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even

View File

@@ -21,7 +21,7 @@ class Origami::UnionpayController < BaseOrigamiController
total = sale_data.grand_total
others = 0
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total

View File

@@ -21,7 +21,7 @@ class Origami::VisaController < BaseOrigamiController
total = sale_data.grand_total
others = 0
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total

View File

@@ -143,7 +143,7 @@ class Origami::VoidController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.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.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,

View File

@@ -7,7 +7,7 @@ class Origami::VoucherController < BaseOrigamiController
total = sale_data.grand_total
@vouchercount = 0
others = 0
if @shop.is_rounding_adj
if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total

View File

@@ -117,7 +117,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.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.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,

View File

@@ -11,7 +11,7 @@ class PrintSettingsController < ApplicationController
# GET /print_settings/1
# GET /print_settings/1.json
def show
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
@lookup = Lookup.shift_sale_items_lookup_value
end
# GET /print_settings/new
@@ -22,7 +22,7 @@ class PrintSettingsController < ApplicationController
# GET /print_settings/1/edit
def edit
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
@lookup = Lookup.shift_sale_items_lookup_value
@server_mode = ENV["SERVER_MODE"]
end
@@ -30,7 +30,6 @@ class PrintSettingsController < ApplicationController
# POST /print_settings.json
def create
@print_setting = PrintSetting.new(print_setting_params)
@print_setting.shop_code = @shop.shop_code
respond_to do |format|
if @print_setting.save
format.html { redirect_to @print_setting, notice: 'Print setting was successfully created.' }
@@ -48,7 +47,7 @@ class PrintSettingsController < ApplicationController
respond_to do |format|
if @print_setting.update(print_setting_params)
if @print_setting.unique_code == 'CloseCashierPdf'
Lookup.save_shift_sale_items_settings(params[:shift_sale_items],@shop.shop_code)
Lookup.save_shift_sale_items_settings(params[:shift_sale_items])
end
format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' }

View File

@@ -20,7 +20,7 @@ authorize_resource :class => false
@filter = params[:filter_check]
@order_source = params[:order_source]
@sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter,@order_source,@shop.shop_code)
@sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter,@order_source)
@from = from
@to = to

View File

@@ -118,7 +118,7 @@ class Reports::HourlySaleitemController < BaseReportController
shift_name = employee.nil? ? sh_name : "#{sh_name} (#{employee.name})"
end
shop_details = shop_detail
shop_details = current_shop
account_type = params[:account_type]
@type = params[:period_type]
period_name = get_period_name(params[:period])

View File

@@ -119,7 +119,7 @@ class Reports::HourlySaleitemController < BaseReportController
shift_name = employee.nil? ? sh_name : "#{sh_name} (#{employee.name})"
end
shop_details = shop_detail
shop_details = current_shop
account_type = params[:account_type]
@type = params[:period_type]
period_name = get_period_name(params[:period])

View File

@@ -19,7 +19,7 @@ class Reports::IndutyController < BaseReportController
end
@commissioner = params[:commissioner]
@induty_data = InDuty.get_induty_by_shift(@shift_sale_range,@shift,from,to,@commissioner).where("sales.shop_code='#{@shop.shop_code}'")
@induty_data = InDuty.get_induty_by_shift(@shift_sale_range,@shift,from,to,@commissioner)
@from = from
@to = to

View File

@@ -27,7 +27,7 @@ class Reports::OrderReservationController < BaseReportController
provider = params[:provider]
payment_type = params[:payment_type]
@order_reservation_data = OrderReservation.get_order_reservation_by_shift(@shift_sale_range,@shift,from,to,provider,payment_type).where("sales.shop_code='#{@shop.shop_code}'")
@order_reservation_data = OrderReservation.get_order_reservation_by_shift(@shift_sale_range,@shift,from,to,provider,payment_type)
@from = from
@to = to
# get printer info
@@ -49,7 +49,7 @@ class Reports::OrderReservationController < BaseReportController
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|

View File

@@ -9,7 +9,7 @@ class Reports::PaymentMethodController < BaseReportController
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
@@ -21,7 +21,7 @@ class Reports::PaymentMethodController < BaseReportController
end
end
@payment_type = params[:payment_type]
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type,@shop.shop_code)
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type)
@from = from
@to = to
# get printer info
@@ -43,7 +43,7 @@ class Reports::PaymentMethodController < 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

@@ -10,7 +10,7 @@ authorize_resource :class => false
@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?
@@ -26,12 +26,12 @@ authorize_resource :class => false
@lookup = Lookup.find_by_lookup_type('reprint_receipt')
if @lookup.nil?
@lookup = Lookup.create_reprint_receipt_lookup(@shop.shop_code)
@lookup = Lookup.create_reprint_receipt_lookup
end
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}'")
@sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type)
@sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type)
@tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2)
@from = from
@@ -55,7 +55,7 @@ authorize_resource :class => false
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
@@ -215,7 +215,7 @@ authorize_resource :class => false
printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
result = {
:status => true,

View File

@@ -26,7 +26,7 @@ authorize_resource :class => false
payment_type = params[:payment_type]
@sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'")
@sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type)
@from = from
@@ -50,7 +50,7 @@ authorize_resource :class => false
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|

View File

@@ -9,7 +9,7 @@ class Reports::SaleitemController < 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?
@@ -25,9 +25,9 @@ class Reports::SaleitemController < BaseReportController
account_type = params[:account_type]
@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_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,@shop.shop_code)
@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)
@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}
@@ -60,7 +60,7 @@ class Reports::SaleitemController < BaseReportController
def show
from, to, report_type = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
@@ -114,7 +114,7 @@ class Reports::SaleitemController < BaseReportController
@type = params[:period_type]
period_name = get_period_name(params[:period])
@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)
@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)
other_charges = Sale.get_other_charges()
if shift.present?
@total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
@@ -129,11 +129,11 @@ class Reports::SaleitemController < BaseReportController
if print_settings.nil?
if !print_settings_star.nil?
printer = Printer::CashierStationPrinter.new(print_settings_star)
printer.print_sale_items_report(print_settings_star, @shop, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
printer.print_sale_items_report(print_settings_star, current_shop, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
end
else
printer = Printer::CashierStationPrinter.new(print_settings)
printer.print_sale_items_report(print_settings, @shop, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
printer.print_sale_items_report(print_settings, current_shop, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
end
respond_to do |format|

View File

@@ -8,7 +8,7 @@ class Reports::ShiftsaleController < BaseReportController
if params[:shift_name].to_i != 0
@shift = ShiftSale.find(params[:shift_name])
end
@sale_data = Sale.get_by_shiftsales(from,to,@shift,@shop.shop_code)
@sale_data = Sale.get_by_shiftsales(from,to,@shift)
@from = from
@to = to
if @shift.present?
@@ -29,7 +29,7 @@ class Reports::ShiftsaleController < BaseReportController
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
@@ -75,9 +75,9 @@ class Reports::ShiftsaleController < BaseReportController
end
shop_details = shop_detail
shop_details = current_shop
cashier_terminal = @shift.cashier_terminal
@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
@@ -97,7 +97,7 @@ class Reports::ShiftsaleController < BaseReportController
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)
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, @shop,@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)
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, current_shops,@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)
respond_to do |format|
format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'}

View File

@@ -32,9 +32,9 @@ class Reports::StaffMealController < BaseReportController
account_type = params[:account_type]
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_staff_meal_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,account_type,customer_id,@shop.shop_code)
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_staff_meal_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,account_type,customer_id)
@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

@@ -29,7 +29,7 @@ class Reports::StockCheckController < BaseReportController
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

@@ -16,7 +16,7 @@ authorize_resource :class => false
end
end
@sale_data = Sale.get_void_sale(@shift,from,to,@shop.shop_code)
@sale_data = Sale.get_void_sale(@shift,from,to)
@from = from
@to = to
@@ -39,7 +39,7 @@ authorize_resource :class => false
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

@@ -4,7 +4,7 @@ authorize_resource :class => false
from, to = get_date_range_from_params
@sale_type = params[:sale_type]
@sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type).where("sales.shop_code='#{@shop.shop_code}'")
@sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type)
@from = from
@to = to
# get printer info

View File

@@ -28,7 +28,6 @@ class Settings::AccountsController < ApplicationController
def create
@settings_account = Account.new(account_params)
@settings_account.shop_code = @shop.shop_code
respond_to do |format|
if @settings_account.save
format.html { redirect_to settings_accounts_url, notice: 'Account was successfully created.' }

View File

@@ -29,7 +29,6 @@ class Settings::CashierTerminalsController < ApplicationController
def create
@settings_cashier_terminal = CashierTerminal.new(settings_cashier_terminal_params)
@settings_cashier_terminal.shop_code = @shop.shop_code
respond_to do |format|
if @settings_cashier_terminal.save
format.html { redirect_to settings_cashier_terminals_path, notice: 'Cashier terminal was successfully created.' }

View File

@@ -31,7 +31,6 @@ class Settings::CommissionersController < ApplicationController
@commissioner = Commissioner.new(commissioner_params)
@commissioner.created_by = current_user.id
@commissioner.shop_code = @shop.shop_code
unless @commissioner.joined_date.nil?
@commissioner.joined_date = @commissioner.joined_date.utc.getlocal.strftime('%Y-%b-%d')
end

View File

@@ -32,7 +32,6 @@ class Settings::CommissionsController < ApplicationController
@commission = Commission.new(commission_params)
@commission.product_type = 'menu_item'
@commission.product_code = "[]"
@commission.shop_code = @shop.shop_code
respond_to do |format|
if @commission.save

View File

@@ -1,6 +1,6 @@
class Settings::EmployeesController < ApplicationController
load_and_authorize_resource
before_action :set_employee, only: [:show, :edit, :update, :destroy]
before_action :set_employee, only: [:show, :edit, :update, :destroy, :change_auth_token]
# GET /employees
@@ -31,7 +31,6 @@ class Settings::EmployeesController < ApplicationController
# POST /employees.json
def create
@employee = Employee.new(employee_params)
@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.' }
@@ -39,6 +38,13 @@ class Settings::EmployeesController < ApplicationController
format.html { render :new }
end
end
end
def change_app_token
@employee.app_token = @employee.generate_app_token #SecureRandom.hex(10)
@employee.save
flash[:notice] = 'Auth Token was successfully updated.'
redirect_to settings_employee_url(@employee)
end
# PATCH/PUT /employees/1
@@ -72,6 +78,6 @@ class Settings::EmployeesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def employee_params
params.require(:employee).permit(:name, :role, :is_active, :emp_id, :password,:order_queue_station_id, :image_path)
params.require(:employee).permit(:name, :role, :is_active, :emp_id, :password,:order_queue_station_id, :image_path, :app_id, :app_token)
end
end

View File

@@ -25,7 +25,6 @@ class Settings::LookupsController < ApplicationController
# POST /settings/lookups.json
def create
@settings_lookup = Lookup.new(settings_lookup_params)
@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

@@ -27,7 +27,6 @@ class Settings::MembershipActionsController < ApplicationController
def create
@settings_membership_action = MembershipAction.new(settings_membership_action_params)
@settings_membership_action.shop_code = @shop.shop_code
respond_to do |format|
if @settings_membership_action.save
format.html { redirect_to settings_membership_actions_path, notice: 'Membership action was successfully created.' }

View File

@@ -27,7 +27,6 @@ class Settings::MembershipSettingsController < ApplicationController
def create
@settings_membership_setting = MembershipSetting.new(settings_membership_setting_params)
@settings_membership_setting.shop_code = @shop.shop_code
respond_to do |format|
if @settings_membership_setting.save
format.html { redirect_to settings_membership_settings_path, notice: 'Membership setting was successfully created.' }

View File

@@ -34,7 +34,6 @@ class Settings::MenusController < ApplicationController
@settings_menu = Menu.new(settings_menu_params)
@settings_menu.created_by = current_login_employee.name
@settings_menu.shop_code = @shop.shop_code
respond_to do |format|
if @settings_menu.save
format.html { redirect_to settings_menus_path, notice: 'Menu was successfully created.' }
@@ -158,7 +157,7 @@ class Settings::MenusController < ApplicationController
def import
if params[:file]
status = Menu.import(params[:file], current_user.name,@shop)
status = Menu.import(params[:file], current_user.name)
redirect_to settings_menus_path, notice: status
end
end

View File

@@ -33,7 +33,6 @@ class Settings::OrderQueueStationsController < ApplicationController
@settings_order_queue_station = OrderQueueStation.new(settings_order_queue_station_params)
@settings_order_queue_station.created_by = current_login_employee.name
@settings_order_queue_station.processing_items = "[]"
@settings_order_queue_station.shop_code = @shop.shop_code
respond_to do |format|
if @settings_order_queue_station.save
format.html { redirect_to settings_order_queue_stations_path, notice: 'Order queue station was successfully created.' }

View File

@@ -26,7 +26,6 @@ class Settings::PaymentMethodSettingsController < ApplicationController
# POST /settings/payment_method_settings.json
def create
@settings_payment_method_setting = PaymentMethodSetting.new(settings_payment_method_setting_params)
@settings_payment_method_setting.shop_code = @shop.shop_code
respond_to do |format|
if @settings_payment_method_setting.save
format.html { redirect_to settings_payment_method_settings_path, notice: 'Payment method setting was successfully created.' }

View File

@@ -29,7 +29,6 @@ load_and_authorize_resource except: [:create]
@settings_product = Product.new(settings_product_params)
@settings_product.created_by = current_user.name
@settings_product.shop_code = @shop.shop_code
respond_to do |format|
if @settings_product.save
format.html { redirect_to settings_products_path, notice: 'Product was successfully created.' }

View File

@@ -31,7 +31,6 @@ class Settings::PromotionsController < ApplicationController
@promotion = Promotion.new(promotion_params)
@promotion.created_by = current_login_employee.id
@promotion.shop_code = @shop.shop_code
if !@promotion.promo_start_hour.nil?
@promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30)
end

View File

@@ -30,7 +30,6 @@ class Settings::RoomsController < ApplicationController
@settings_room.type = DiningFacility::ROOM_TYPE
@settings_room.zone_id = params[:zone_id]
@settings_room.created_by = current_login_employee.name
@settings_room.shop_code = @shop.shop_code
respond_to do |format|
if @settings_room.save
format.html { redirect_to settings_zone_path(@zone), notice: 'Room was successfully created.' }

View File

@@ -32,7 +32,7 @@ class Settings::ShopsController < ApplicationController
if @settings_shop.save
if params[:display_images].present?
params[:display_images]['image'].each do |a|
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => a)
@display_image = @settings_shop.display_images.create!(:shop_id => current_shop.id, :image => a)
end
end
format.html { redirect_to settings_shops_url, notice: 'Shop was successfully created.' }
@@ -60,16 +60,16 @@ class Settings::ShopsController < ApplicationController
File.delete(delete_path)
end
end
save_path = Rails.root.join("public/#{@shop.shop_code}_#{a.original_filename}")
save_path = Rails.root.join("public/#{current_shop.shop_code}_#{a.original_filename}")
File.open(save_path, 'wb') do |f|
f.write a.read
end
audio_name = "#{@shop.shop_code}_#{a.original_filename}"
audio_name = "#{current_shop.shop_code}_#{a.original_filename}"
@settings_shop.display_images.where(:name => "order_audio").destroy_all
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :name => "order_audio", :image => audio_name)
@display_image = @settings_shop.display_images.create!(:shop_id => current_shop.id, :name => "order_audio", :image => audio_name)
else
@aa = Base64.encode64(a.read)
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => "data:image/jpeg;base64,"+@aa)
@display_image = @settings_shop.display_images.create!(:shop_id => current_shop.id, :image => "data:image/jpeg;base64,"+@aa)
end
end
end

View File

@@ -29,7 +29,6 @@ class Settings::TablesController < ApplicationController
@settings_table = Table.new(settings_table_params)
@settings_table.type = DiningFacility::TABLE_TYPE
@settings_table.zone_id = params[:zone_id]
@settings_table.shop_code = @shop.shop_code
@settings_table.created_by = current_login_employee.name
respond_to do |format|
if @settings_table.save

View File

@@ -48,7 +48,6 @@ class Settings::TaxProfilesController < ApplicationController
@settings_tax_profile = TaxProfile.new(settings_tax_profile_params)
@settings_tax_profile.created_by = current_login_employee.name
@settings_tax_profile.shop_code = @shop.shop_code
respond_to do |format|
if @settings_tax_profile.save
format.html { redirect_to settings_tax_profiles_path, notice: 'Tax profile was successfully created.' }

View File

@@ -30,7 +30,6 @@ class Settings::ZonesController < ApplicationController
def create
@settings_zone = Zone.new(settings_zone_params)
@settings_zone.shop_code =@shop.shop_code
@settings_zone.created_by = current_login_employee.name
respond_to do |format|
if @settings_zone.save

View File

@@ -23,10 +23,10 @@ class Transactions::CreditNotesController < ApplicationController
.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
.where("(CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote')
THEN NULL ELSE payment_method='creditnote' END)").shop
THEN NULL ELSE payment_method='creditnote' END)")
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
else
sale = Sale.search_credit_sales(customer,filter,from,to,order_source).shop
sale = Sale.search_credit_sales(customer,filter,from,to,order_source)
if !sale.nil?
@credit_notes = sale
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)

View File

@@ -18,13 +18,13 @@ class Transactions::SalesController < ApplicationController
if receipt_no.nil? && from.nil? && to.nil?
if @shift.blank?
@sales = Sale.where("NOT sale_status='new'").shop.order("sale_id desc")
@sales = Sale.where("NOT sale_status='new'").order("sale_id desc")
else
@sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").shop.order("sale_id desc")
@sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").order("sale_id desc")
end
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
else
sale = Sale.search(receipt_no,from,to,@shift).shop
sale = Sale.search(receipt_no,from,to,@shift)
if sale.count > 0
@sales = sale
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
@@ -350,7 +350,7 @@ class Transactions::SalesController < ApplicationController
customer= Customer.find(sale.customer_id)
#shop detail
shop_details = @shop
shop_details = current_shop
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate

View File

@@ -38,7 +38,7 @@ class Transactions::ShiftSalesController < ApplicationController
#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

@@ -36,7 +36,6 @@ class AssignedOrderItem < ApplicationRecord
assigned_order_item.order_queue_station = order_queue_station
assigned_order_item.print_status = false
assigned_order_item.delivery_status = false
assigned_order_item.shop_code =order.shop_code
assigned_order_item.save!
end

View File

@@ -135,7 +135,7 @@ class Booking < ApplicationRecord
joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id")
.where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}' OR df.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")
end
.shop.order("sale_id DESC")
.order("sale_id DESC")
end
def self.get_sync_data(sale_id)

View File

@@ -20,7 +20,6 @@ class DiningFacility < ApplicationRecord
ROOM_TYPE = "Room"
default_scope { order('order_by asc') }
scope :shop, -> { where("shop_code=?",Shop.current_shop.shop_code) }
scope :active, -> {where(is_active: true)}

View File

@@ -1,5 +1,6 @@
class Employee < ApplicationRecord
has_secure_password
# has_secure_token :auth_token
has_many :commissioners
has_many :shit_sales
has_one :current_shift, -> { where.not(shift_started_at: nil).where(shift_closed_at: nil) },class_name: "ShiftSale"
@@ -11,6 +12,7 @@ class Employee < ApplicationRecord
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
validates :password, numericality: true, length: {in: 3..9}, allow_blank: true
before_create :generate_app_id, :generate_app_token , if: Proc.new { self.role == "application" }
# Employee Image Uploader
mount_uploader :image_path, EmployeeImageUploader
@@ -43,7 +45,7 @@ class Employee < ApplicationRecord
if (session_token)
user = Employee.find_by_token_session(session_token)
expiry_time = login_expiry_time
if !user.session_expiry.nil?
if user && !user.session_expiry.nil?
if user && user.session_expiry.utc > DateTime.now.utc
#Extend the login time each time authenticatation take place
user.session_expiry = user.session_expiry.utc + expiry_time.minutes
@@ -89,4 +91,18 @@ class Employee < ApplicationRecord
return expiry_time
end
def generate_app_id
# return if self.role != 'application'
self.app_id = SecureRandom.urlsafe_base64(nil, false)
rescue ActiveRecord::RecordNotUnique
retry
end
def generate_app_token
# return if self.role != 'application'
self.app_token = SecureRandom.hex(10)
rescue ActiveRecord::RecordNotUnique
retry
end
end

View File

@@ -8,7 +8,7 @@ class InventoryDefinition < ApplicationRecord
logger.debug saleObj.sale_items.to_json
if !saleObj.nil?
saleObj.sale_items.each do |item|
found, inventory_definition = find_product_in_inventory(item,saleObj.shop_code)
found, inventory_definition = find_product_in_inventory(item)
if found
check_balance(item,inventory_definition)
end

View File

@@ -1,7 +1,6 @@
class Lookup < ApplicationRecord
has_many :accounts
belongs_to :shop
scope :number_formats, -> { where(lookup_type: 'number_format')}
@@ -26,12 +25,10 @@ class Lookup < ApplicationRecord
# Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] }
# end
def self.time_limit
TIME_LIMIT
end
def self.get_checkin_time_limit
return RequestStore[:checkin_time_limit] if RequestStore[:checkin_time_limit]
RequestStore[:checkin_time_limit] = Lookup.find_by_lookup_type('checkin_time_limit').value.to_i rescue time_limit
@@ -63,41 +60,39 @@ class Lookup < ApplicationRecord
Lookup.where("lookup_type" => type ).pluck("name, value")
end
def self.create_shift_sale_lookup(shop_code)
def self.create_shift_sale_lookup
@lookup = Lookup.new
@lookup.lookup_type = 'shift_sale_items'
@lookup.name = 'Shift Sale Items'
@lookup.value = 0
@lookup.shop_code = shop_code
@lookup.save
return @lookup
end
def self.create_reprint_receipt_lookup(shop_code)
def self.create_reprint_receipt_lookup
@lookup = Lookup.new
@lookup.lookup_type = 'reprint_receipt'
@lookup.name = 'Reprint Receipt in Report'
@lookup.value = 0
@lookup.shop_code = shop_code
@lookup.save
return @lookup
end
def self.save_shift_sale_items_settings(val,shop_code)
def self.save_shift_sale_items_settings(val)
@lookup = Lookup.where("lookup_type=?", 'shift_sale_items').last
if @lookup.nil?
@lookup = Lookup.create_shift_sale_lookup(shop_code)
@lookup = Lookup.create_shift_sale_lookup
end
@lookup.value = val
@lookup.save
end
def self.shift_sale_items_lookup_value(shop_code)
def self.shift_sale_items_lookup_value
@lookup = Lookup.where("lookup_type=?", 'shift_sale_items').last
if @lookup.nil?
@lookup = Lookup.create_shift_sale_lookup(shop_code)
@lookup = Lookup.create_shift_sale_lookup
end
return @lookup.value
end

View File

@@ -8,7 +8,6 @@ class Menu < ApplicationRecord
#Default Scope to pull the active version only
default_scope { order("created_at asc") }
scope :active, -> {where("is_active = true")}
scope :shop, -> { where("menus.shop_code=?",Shop.current_shop.shop_code) }
def self.current_menu
today = DateTime.now
@@ -47,7 +46,7 @@ class Menu < ApplicationRecord
end
end
def self.import(file, created_by,shop)
def self.import(file, created_by)
status = ""
spreadsheet = open_spreadsheet(file)
if spreadsheet.sheets.count > 1
@@ -62,9 +61,9 @@ class Menu < ApplicationRecord
# Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
account = Account.find_by_id(row["id"])
if account
Account.create(title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"],shop_code: shop.shop_code)
Account.create(title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
else
Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"],shop_code: shop.shop_code)
Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
end
elsif sheet_name == "Item Set"
# ItemSet.create(id:row["id"], name: row[name], alt_name: row[alt_name], min_selectable_qty: row[min_selectable_qty], max_selectable_qty: row[max_selectable_qty])
@@ -93,9 +92,9 @@ class Menu < ApplicationRecord
elsif sheet_name == "Menu"
menu = Menu.find_by_id(row["id"])
if menu
Menu.create(name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"],shop_code: shop.shop_code)
Menu.create(name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
else
Menu.create(id:row["id"], name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"],shop_code: shop.shop_code)
Menu.create(id:row["id"], name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
end
elsif sheet_name == "Menu Category"
# MenuCategory.create(id:row["id"], menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"])
@@ -155,7 +154,7 @@ class Menu < ApplicationRecord
menu = sheet.row(1)[1]
is_ordering = sheet.row(1)[3]?sheet.row(1)[3]:0
imported_menu = Menu.create({name: menu, is_active: true, is_ordering: is_ordering, valid_days: "1,2,3,4,5,6,7",valid_time_from: "00:00:00", valid_time_to: "23:59:59", created_by: created_by,shop_code: shop.shop_code})
imported_menu = Menu.create({name: menu, is_active: true, is_ordering: is_ordering, valid_days: "1,2,3,4,5,6,7",valid_time_from: "00:00:00", valid_time_to: "23:59:59", created_by: created_by})
(4..sheet.last_row).each do |ii|
row = Hash[[sheet.row(3),sheet.row(ii)].transpose]
@@ -194,7 +193,7 @@ class Menu < ApplicationRecord
if !menu_itm
account = Account.find_by_title(row["Account"])
if account.nil?
account = Account.create({title: row["Account"], account_type: "0",shop_code: shop.shop_code})
account = Account.create({title: row["Account"], account_type: "0"})
end
image_path = ""

View File

@@ -8,7 +8,6 @@ class PaymentJournal < ApplicationRecord
self.payment_status = 'paid'
self.payment_method_references = payment_method_reference
self.created_by = current_user.id
self.shop_code = current_user.shop_code
self.save
end
@@ -18,7 +17,6 @@ class PaymentJournal < ApplicationRecord
self.debit_amount = amount
self.payment_status = 'paid'
self.created_by = current_user.id
self.shop_code = current_user.shop_code
self.save
end

View File

@@ -90,20 +90,20 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end
#Bill Receipt Print
def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation,transaction_ref)
def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, shop_details, printed_status, balance, card_data, other_amount, latest_order_no, card_balance_amount, order_reservation = nil, transaction_ref = nil)
#Use CUPS service
#Generate PDF
#Print
if printer_settings
if !printer_settings.unique_code.match?(/receiptbillorder/i)
if Lookup.collection_of("print_settings").any? { |x| x == ["ReceiptBillA5Pdf", "1"] } #print_settings with name:ReceiptBillA5Pdf
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, shop_details, printed_status, balance, card_data, other_amount, latest_order_no, card_balance_amount)
else
pdf = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code.constantize.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
pdf = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code.constantize.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, shop_details, printed_status, balance, card_data, other_amount, latest_order_no, card_balance_amount, transaction_ref)
end
else
#doemal online order pdf template
pdf = ReceiptBillOrderPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
pdf = ReceiptBillOrderPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
end
# print as print copies in printer setting

View File

@@ -33,7 +33,7 @@ class ProductCommission < ApplicationRecord
product_commission.save
end
def self.edit_product_commission(saleItemObj,shop_code)
def self.edit_product_commission(saleItemObj)
menu_item = MenuItem.find_by_item_code(saleItemObj.product_code)
commission = Commission.where("product_code = ? AND is_active = ?", menu_item.id, true).take
product_commission = ProductCommission.where('sale_item_id = ?', saleItemObj.id).take

View File

@@ -793,7 +793,7 @@ def self.daily_sales_list(from,to)
SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount,
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
.along_with_sale_payments_except_void_between(from, to)
.where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to).shop
.where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to)
.group("sale_id").to_sql
daily_total = connection.select_all("SELECT
@@ -849,7 +849,7 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
query = query.where("(receipt_date between ? and ? and sale_status=?) AND i.unit_price <> 0",from,to,status)
end
def self.get_by_shiftsales(from,to,shift,shop_code)
def self.get_by_shiftsales(from,to,shift)
if !shift.blank?
query = ShiftSale.where("shift_sales.id =?",shift.id)
else
@@ -974,7 +974,7 @@ def self.get_other_charges()
query = query.group("i.sale_item_id")
end
def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,account_type,shop_code)
def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,account_type)
# date_type_selection = get_sql_function_for_report_type(report_type)
if account_type.blank?
account_type = ''
@@ -1256,7 +1256,7 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay
return query
end
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source,shop_code)
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source)
payments_for_credits = SalePayment.select("
sales.sale_id,
DATE_FORMAT(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30'),'%d %b %y %h:%i%p') as credit_payment_receipt_date,
@@ -1312,7 +1312,7 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,
credits = credits.group("sale_payments.sale_payment_id, sales_sale_payments.sale_id")
end
def self.get_void_sale(shift,from,to,shop_code)
def self.get_void_sale(shift,from,to)
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")
@@ -1498,7 +1498,7 @@ end
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user.id)
if shift = ShiftSale.current_open_shift(current_user)
query = query.where("shift_sale_id='#{shift.id}'")
end
@@ -1525,7 +1525,7 @@ end
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user.id)
if shift = ShiftSale.current_open_shift(current_user)
query = query.where("shift_sale_id='#{shift.id}'")
end
end

Some files were not shown because too many files have changed in this diff Show More