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 For FoodCourt Cashier role
settings/lookups => { type:employee_roles, name: FoodCourt Cashier, value:foodcourt_cashier } 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 * ToDo list

View File

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

View File

@@ -26,7 +26,7 @@ class Api::CallWaitersController < ActionController::API
unique_code = "CallWaiterPdf" unique_code = "CallWaiterPdf"
print_settings = PrintSetting.find_by_unique_code(unique_code) print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings) 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 end

View File

@@ -70,7 +70,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation) order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation)
if !order_reservation_id.nil? && flag if !order_reservation_id.nil? && flag
shop = @shop shop = current_shop
if !shop.nil? if !shop.nil?
shop_code = shop.shop_code shop_code = shop.shop_code
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio") 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 # end
# #
return @shop.to_json return current_shop.to_json
end end
@@ -66,13 +66,13 @@ class Api::OrdersController < Api::ApiController
def create def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s Rails.logger.debug "Order Source - " + params[:order_source].to_s
Rails.logger.debug "Table ID - " + params[:table_id].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 current_shift = ShiftSale.current_shift
if current_shift.nil? if current_shift.nil?
@status = false @status = false
@message = "No Current Open Shift for This Employee" @message = "No Current Open Shift for This Employee"
else else
current_user =Employee.find(current_shift.employee_id) current_user = Employee.find(current_shift.employee_id)
if checkin_checkout_time(params[:booking_id]) if checkin_checkout_time(params[:booking_id])
table = DiningFacility.find(params[:table_id]) if params[:table_id].present? table = DiningFacility.find(params[:table_id]) if params[:table_id].present?
@@ -124,6 +124,9 @@ class Api::OrdersController < Api::ApiController
if @status && @booking if @status && @booking
Order.process_order_queue(@order.order_id,@order.table_id,@order.source) 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 end
if @order.table_id.to_i > 0 if @order.table_id.to_i > 0
table = DiningFacility.find(@booking.dining_facility_id) table = DiningFacility.find(@booking.dining_facility_id)

View File

@@ -10,7 +10,7 @@ class Api::Payment::CallbackController < Api::ApiController
if trade_status == "PAY_SUCCESS" if trade_status == "PAY_SUCCESS"
merch_order_id = params[:Request][:merch_order_id] 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}) 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
end end

View File

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

View File

@@ -171,9 +171,9 @@ class Api::PaymentsController < Api::ApiController
action_by = current_login_employee.name action_by = current_login_employee.name
@status = true @status = true
@message = "" @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 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 if member_actions.gateway_url
@campaign_type_id = nil @campaign_type_id = nil
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s

View File

@@ -2,7 +2,7 @@ class Api::SoundEffectController < Api::ApiController
#sound effect / alarm api for doemal side calling #sound effect / alarm api for doemal side calling
def sound_effect def sound_effect
shop = @shop shop = current_shop
if !shop.nil? if !shop.nil?
shop_code = shop.shop_code shop_code = shop.shop_code
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio") 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 #before_action :check_installation
protect_from_forgery with: :exception 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 # lookup domain for db from provision
# before_action :set_locale # before_action :set_locale
# helper_method :current_company,:current_login_employee,:current_user # helper_method :current_company,:current_login_employee,:current_user

View File

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

View File

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

View File

@@ -6,7 +6,6 @@ module TokenVerification
before_action :authenticate before_action :authenticate
end end
protected protected
# Authenticate the user with token based authentication # Authenticate the user with token based authentication
def authenticate def authenticate

View File

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

View File

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

View File

@@ -135,7 +135,6 @@ class Foodcourt::AddordersController < BaseFoodcourtController
@order.new_booking = true @order.new_booking = true
@order.waiters = current_login_employee.name @order.waiters = current_login_employee.name
@order.employee_name = 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.is_extra_time = is_extra_time
@order.extra_time = extra_time @order.extra_time = extra_time

View File

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

View File

@@ -76,7 +76,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController
def completed def completed
customer =Customer.find_by_customer_id(params[:customer_id]) customer =Customer.find_by_customer_id(params[:customer_id])
phone_number =customer.contact_no 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.find(params[:booking_id])
booking.booking_status ='completed' booking.booking_status ='completed'
booking.save! booking.save!

View File

@@ -20,7 +20,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
#shop_detail = Shop.first #shop_detail = Shop.first
# rounding adjustment # rounding adjustment
if !path.include? ("credit_payment") 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) new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total - 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 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) other_amount = SaleItem.calculate_other_charges(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) 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
end end
@@ -223,7 +223,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
@pdf_view = @lookup_pdf.value @pdf_view = @lookup_pdf.value
end 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 @kbz_pay_amount += amount.to_f
#for changable on/off #for changable on/off
@@ -270,7 +270,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
#end rounding adjustment #end rounding adjustment
# rounding adjustment # rounding adjustment
if @shop.is_rounding_adj if current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even #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) 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 = { result = {
:status => true, :status => true,
@@ -571,7 +571,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
printer = Printer::ReceiptPrinter.new(print_settings) 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 = { result = {
:status => true, :status => true,
:filepath => filename, :filepath => filename,
@@ -606,7 +606,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController
saleObj = Sale.find(params[:sale_id]) saleObj = Sale.find(params[:sale_id])
if @shop.is_rounding_adj if current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even #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) saleObj = Sale.find(sale_id)
# rounding adjustment # rounding adjustment
if @shop.is_rounding_adj if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total) new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total-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) 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) 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 end
# make cancel void item # make cancel void item

View File

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

View File

@@ -76,7 +76,6 @@ class Foodcourt::SurveysController < BaseFoodcourtController
@survey = Survey.new(survey_params) @survey = Survey.new(survey_params)
@survey.shift_id = shift_by_terminal.id @survey.shift_id = shift_by_terminal.id
@survey.foreigner = params["survey"]["foreigner"].to_json @survey.foreigner = params["survey"]["foreigner"].to_json
@survey.shop_code = @shop.shop_code
# respond_to do |format| # respond_to do |format|
if @survey.save if @survey.save
redirect_to @url 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) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) 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 = { result = {
:filepath => filename, :filepath => filename,
:printer_model => print_settings.brand_name, :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) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) 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 = { result = {
:filepath => filename, :filepath => filename,
:printer_model => print_settings.brand_name, :printer_model => print_settings.brand_name,

View File

@@ -100,7 +100,7 @@ class HomeController < ApplicationController
@sales = Sale.receipt_date_between(@from, @to).completed @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 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) @orders = @orders.where(shift_sale_id: shift.id)
@sales = @sales.where(shift_sale_id: shift.id) @sales = @sales.where(shift_sale_id: shift.id)
end end
@@ -124,7 +124,7 @@ class HomeController < ApplicationController
end end
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_trans = Sale.total_trans(current_user,@from,@to)
@total_card = Sale.total_card_sale(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 redirect_to dashboard_path
end end
elsif employee.role == "cashier" elsif employee.role == "cashier"
food_court = Lookup.find_by_lookup_type_and_value("food_court", "1")
#check if cashier has existing open cashier #check if cashier has existing open cashier
shift = ShiftSale.current_open_shift(employee) shift = ShiftSale.current_open_shift(employee)
if !shift.nil? if food_court
redirect_to origami_dashboard_path if !shift.nil?
# redirect_to origami_root_path redirect_to foodcourt_food_court_path
else
redirect_to new_foodcourt_shift_path
end
else 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 end
elsif employee.role == "manager" elsif employee.role == "manager"
redirect_to dashboard_path 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.min_order_level = params[:min_order_level]
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + params[:max_stock_level].to_i @inventory_definition.max_stock_level = inventory.max_stock_level.to_i + params[:max_stock_level].to_i
end end
@inventory_definition.shop_code = @shop.shop_code
@inventory_definition.created_by = current_user.id @inventory_definition.created_by = current_user.id
if @inventory_definition.save if @inventory_definition.save
result = {:status=> true, :message => "Inventory definition was created successfully",:data=> @inventory_definition} 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 } format.json { head :no_content }
end end
# inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code) StockJournal.delete_stock_journal(inventory.item_code)
StockJournal.delete_stock_journal(inventory.item_code,@shop) StockCheckItem.delete_stock_check_item(inventory.item_code)
StockCheckItem.delete_stock_check_item(inventory.item_code,@shop)
if !inventory.nil? if !inventory.nil?
inventory.destroy inventory.destroy
flash[:message] = 'Inventory was successfully destroyed.' flash[:message] = 'Inventory was successfully destroyed.'

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -6,7 +6,7 @@ class Origami::DingaController < BaseOrigamiController
@membership_rebate_balance=0 @membership_rebate_balance=0
@sale_data = Sale.find_by_sale_id(@sale_id) @sale_data = Sale.find_by_sale_id(@sale_id)
@receipt_no = @sale_data.receipt_no @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) new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
else else
new_total = @sale_data.grand_total new_total = @sale_data.grand_total

View File

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

View File

@@ -11,7 +11,7 @@ class Origami::HomeController < BaseOrigamiController
@customers = Customer.pluck("customer_id, name") @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) @shift = ShiftSale.current_open_shift(current_user)
end end
@@ -33,7 +33,7 @@ class Origami::HomeController < BaseOrigamiController
@status_sale = "" @status_sale = ""
@sale_array = Array.new @sale_array = Array.new
@shop = shop_detail @shop = current_shop
@membership = MembershipSetting::MembershipSetting @membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all @payment_methods = PaymentMethodSetting.all
@dining_booking = @dining.current_bookings @dining_booking = @dining.current_bookings

View File

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

View File

@@ -11,7 +11,7 @@ class Origami::JunctionPayController < BaseOrigamiController
@cashier_id = current_user.emp_id @cashier_id = current_user.emp_id
@payment_method_setting_nav = PaymentMethodSetting.all @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) new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else else
new_total = sale_data.grand_total new_total = sale_data.grand_total

View File

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

View File

@@ -22,7 +22,7 @@ class Origami::MpuController < BaseOrigamiController
others = 0 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) new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else else
new_total = sale_data.grand_total new_total = sale_data.grand_total

View File

@@ -6,7 +6,7 @@ class Origami::PaymalController < BaseOrigamiController
@membership_rebate_balance=0 @membership_rebate_balance=0
sale_data = Sale.find_by_sale_id(@sale_id) sale_data = Sale.find_by_sale_id(@sale_id)
@receipt_no = sale_data.receipt_no @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) new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else else
new_total = sale_data.grand_total new_total = sale_data.grand_total

View File

@@ -65,7 +65,7 @@ class Origami::PaymentsController < BaseOrigamiController
end end
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 = { result = {
:filepath => filename, :filepath => filename,
@@ -192,7 +192,7 @@ class Origami::PaymentsController < BaseOrigamiController
end end
#card_balance amount for Paymal payment #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 # get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code) 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) other_amount = SaleItem.calculate_other_charges(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) 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
end end
@@ -275,7 +275,7 @@ class Origami::PaymentsController < BaseOrigamiController
@pdf_view = @lookup_pdf.value @pdf_view = @lookup_pdf.value
end 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 @kbz_pay_amount += amount.to_f
#for changable on/off #for changable on/off
@@ -322,7 +322,7 @@ class Origami::PaymentsController < BaseOrigamiController
#end rounding adjustment #end rounding adjustment
# rounding adjustment # rounding adjustment
if @shop.is_rounding_adj if current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even #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) 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 = { result = {
:status => true, :status => true,
@@ -622,7 +622,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings) 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 = { result = {
:status => true, :status => true,
:filepath => filename, :filepath => filename,
@@ -657,7 +657,7 @@ class Origami::PaymentsController < BaseOrigamiController
saleObj = Sale.find(params[:sale_id]) saleObj = Sale.find(params[:sale_id])
if @shop.is_rounding_adj if current_shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even #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)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
# rounding adjustment # rounding adjustment
if @shop.is_rounding_adj if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total) new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = new_total-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) 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] @cashier_type = params[:type]
@membership_rebate_balance=0 @membership_rebate_balance=0
sale_data = Sale.find_by_sale_id(@sale_id) 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) new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else else
new_total = sale_data.grand_total new_total = sale_data.grand_total

View File

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

View File

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

View File

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

View File

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

View File

@@ -21,7 +21,7 @@ class Origami::VisaController < BaseOrigamiController
total = sale_data.grand_total total = sale_data.grand_total
others = 0 others = 0
if @shop.is_rounding_adj if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total) new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else else
new_total = sale_data.grand_total 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) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) 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 = { result = {
:filepath => filename, :filepath => filename,
:printer_model => print_settings.brand_name, :printer_model => print_settings.brand_name,

View File

@@ -7,7 +7,7 @@ class Origami::VoucherController < BaseOrigamiController
total = sale_data.grand_total total = sale_data.grand_total
@vouchercount = 0 @vouchercount = 0
others = 0 others = 0
if @shop.is_rounding_adj if current_shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total) new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else else
new_total = sale_data.grand_total 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) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) 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 = { result = {
:filepath => filename, :filepath => filename,
:printer_model => print_settings.brand_name, :printer_model => print_settings.brand_name,

View File

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

View File

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

View File

@@ -19,7 +19,7 @@ class Reports::IndutyController < BaseReportController
end end
@commissioner = params[:commissioner] @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 @from = from
@to = to @to = to

View File

@@ -27,7 +27,7 @@ class Reports::OrderReservationController < BaseReportController
provider = params[:provider] provider = params[:provider]
payment_type = params[:payment_type] 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 @from = from
@to = to @to = to
# get printer info # get printer info
@@ -49,7 +49,7 @@ class Reports::OrderReservationController < BaseReportController
def show def show
from, to = get_date_range_from_params 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 date_arr = Array.new
@sale_data.each do |sale| @sale_data.each do |sale|

View File

@@ -9,7 +9,7 @@ class Reports::PaymentMethodController < BaseReportController
from, to = get_date_range_from_params 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 = '' @shift = ''
if params[:shift_name].to_i != 0 if params[:shift_name].to_i != 0
@@ -21,7 +21,7 @@ class Reports::PaymentMethodController < BaseReportController
end end
end end
@payment_type = params[:payment_type] @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 @from = from
@to = to @to = to
# get printer info # get printer info
@@ -43,7 +43,7 @@ class Reports::PaymentMethodController < BaseReportController
def show def show
from, to = get_date_range_from_params 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 date_arr = Array.new
@sale_data.each do |sale| @sale_data.each do |sale|

View File

@@ -10,7 +10,7 @@ authorize_resource :class => false
@shift = '' @shift = ''
if params[:shift_name].to_i != 0 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]) @shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
@@ -26,12 +26,12 @@ authorize_resource :class => false
@lookup = Lookup.find_by_lookup_type('reprint_receipt') @lookup = Lookup.find_by_lookup_type('reprint_receipt')
if @lookup.nil? if @lookup.nil?
@lookup = Lookup.create_reprint_receipt_lookup(@shop.shop_code) @lookup = Lookup.create_reprint_receipt_lookup
end end
payment_type = params[:payment_type] 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_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).where("sales.shop_code='#{@shop.shop_code}'") @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) @tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2)
@from = from @from = from
@@ -55,7 +55,7 @@ authorize_resource :class => false
def show def show
from, to = get_date_range_from_params 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 date_arr = Array.new
@sale_data.each do |sale| @sale_data.each do |sale|
@@ -215,7 +215,7 @@ authorize_resource :class => false
printer = Printer::ReceiptPrinter.new(print_settings) 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 = { result = {
:status => true, :status => true,

View File

@@ -26,7 +26,7 @@ authorize_resource :class => false
payment_type = params[:payment_type] 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 @from = from
@@ -50,7 +50,7 @@ authorize_resource :class => false
def show def show
from, to = get_date_range_from_params 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 date_arr = Array.new
@sale_data.each do |sale| @sale_data.each do |sale|

View File

@@ -9,7 +9,7 @@ class Reports::SaleitemController < BaseReportController
shift = '' shift = ''
if params[:shift_name].to_i != 0 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]) shift_sale = ShiftSale.find(params[:shift_name])
if to.blank? if to.blank?
@@ -25,9 +25,9 @@ class Reports::SaleitemController < BaseReportController
account_type = params[:account_type] account_type = params[:account_type]
@type = params[:sale_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} @account_cate_count = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1} @sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
@@ -60,7 +60,7 @@ class Reports::SaleitemController < BaseReportController
def show def show
from, to, report_type = get_date_range_from_params 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 date_arr = Array.new
@sale_data.each do |sale| @sale_data.each do |sale|
@@ -114,7 +114,7 @@ class Reports::SaleitemController < BaseReportController
@type = params[:period_type] @type = params[:period_type]
period_name = get_period_name(params[:period]) 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() other_charges = Sale.get_other_charges()
if shift.present? if shift.present?
@total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) @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.nil?
if !print_settings_star.nil? if !print_settings_star.nil?
printer = Printer::CashierStationPrinter.new(print_settings_star) 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 end
else else
printer = Printer::CashierStationPrinter.new(print_settings) 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 end
respond_to do |format| respond_to do |format|

View File

@@ -8,7 +8,7 @@ class Reports::ShiftsaleController < BaseReportController
if params[:shift_name].to_i != 0 if params[:shift_name].to_i != 0
@shift = ShiftSale.find(params[:shift_name]) @shift = ShiftSale.find(params[:shift_name])
end end
@sale_data = Sale.get_by_shiftsales(from,to,@shift,@shop.shop_code) @sale_data = Sale.get_by_shiftsales(from,to,@shift)
@from = from @from = from
@to = to @to = to
if @shift.present? if @shift.present?
@@ -29,7 +29,7 @@ class Reports::ShiftsaleController < BaseReportController
from, to = get_date_range_from_params 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 date_arr = Array.new
@sale_data.each do |sale| @sale_data.each do |sale|
@@ -75,9 +75,9 @@ class Reports::ShiftsaleController < BaseReportController
end end
shop_details = shop_detail shop_details = current_shop
cashier_terminal = @shift.cashier_terminal 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_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
@total_spoile = Sale.get_total_spoile(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 #other payment details for mpu or visa like card
@@ -97,7 +97,7 @@ class Reports::ShiftsaleController < BaseReportController
printer = Printer::CashierStationPrinter.new(print_settings) 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, 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| respond_to do |format|
format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'} 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] 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} @account_cate_count = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1} @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 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 date_arr = Array.new
@sale_data.each do |sale| @sale_data.each do |sale|

View File

@@ -16,7 +16,7 @@ authorize_resource :class => false
end end
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 @from = from
@to = to @to = to
@@ -39,7 +39,7 @@ authorize_resource :class => false
def show def show
from, to = get_date_range_from_params 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 date_arr = Array.new
@sale_data.each do |sale| @sale_data.each do |sale|

View File

@@ -4,7 +4,7 @@ authorize_resource :class => false
from, to = get_date_range_from_params from, to = get_date_range_from_params
@sale_type = params[:sale_type] @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 @from = from
@to = to @to = to
# get printer info # get printer info

View File

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

View File

@@ -29,7 +29,6 @@ class Settings::CashierTerminalsController < ApplicationController
def create def create
@settings_cashier_terminal = CashierTerminal.new(settings_cashier_terminal_params) @settings_cashier_terminal = CashierTerminal.new(settings_cashier_terminal_params)
@settings_cashier_terminal.shop_code = @shop.shop_code
respond_to do |format| respond_to do |format|
if @settings_cashier_terminal.save if @settings_cashier_terminal.save
format.html { redirect_to settings_cashier_terminals_path, notice: 'Cashier terminal was successfully created.' } 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 = Commissioner.new(commissioner_params)
@commissioner.created_by = current_user.id @commissioner.created_by = current_user.id
@commissioner.shop_code = @shop.shop_code
unless @commissioner.joined_date.nil? unless @commissioner.joined_date.nil?
@commissioner.joined_date = @commissioner.joined_date.utc.getlocal.strftime('%Y-%b-%d') @commissioner.joined_date = @commissioner.joined_date.utc.getlocal.strftime('%Y-%b-%d')
end end

View File

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

View File

@@ -1,6 +1,6 @@
class Settings::EmployeesController < ApplicationController class Settings::EmployeesController < ApplicationController
load_and_authorize_resource 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 # GET /employees
@@ -31,7 +31,6 @@ class Settings::EmployeesController < ApplicationController
# POST /employees.json # POST /employees.json
def create def create
@employee = Employee.new(employee_params) @employee = Employee.new(employee_params)
@employee.shop_code =@shop.shop_code
respond_to do |format| respond_to do |format|
if @employee.save if @employee.save
format.html { redirect_to settings_employees_path, notice: 'Employee was successfully created.' } format.html { redirect_to settings_employees_path, notice: 'Employee was successfully created.' }
@@ -41,6 +40,13 @@ class Settings::EmployeesController < ApplicationController
end 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 # PATCH/PUT /employees/1
# PATCH/PUT /employees/1.json # PATCH/PUT /employees/1.json
def update def update
@@ -72,6 +78,6 @@ class Settings::EmployeesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.
def employee_params 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
end end

View File

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

View File

@@ -27,7 +27,6 @@ class Settings::MembershipActionsController < ApplicationController
def create def create
@settings_membership_action = MembershipAction.new(settings_membership_action_params) @settings_membership_action = MembershipAction.new(settings_membership_action_params)
@settings_membership_action.shop_code = @shop.shop_code
respond_to do |format| respond_to do |format|
if @settings_membership_action.save if @settings_membership_action.save
format.html { redirect_to settings_membership_actions_path, notice: 'Membership action was successfully created.' } 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 def create
@settings_membership_setting = MembershipSetting.new(settings_membership_setting_params) @settings_membership_setting = MembershipSetting.new(settings_membership_setting_params)
@settings_membership_setting.shop_code = @shop.shop_code
respond_to do |format| respond_to do |format|
if @settings_membership_setting.save if @settings_membership_setting.save
format.html { redirect_to settings_membership_settings_path, notice: 'Membership setting was successfully created.' } 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 = Menu.new(settings_menu_params)
@settings_menu.created_by = current_login_employee.name @settings_menu.created_by = current_login_employee.name
@settings_menu.shop_code = @shop.shop_code
respond_to do |format| respond_to do |format|
if @settings_menu.save if @settings_menu.save
format.html { redirect_to settings_menus_path, notice: 'Menu was successfully created.' } format.html { redirect_to settings_menus_path, notice: 'Menu was successfully created.' }
@@ -158,7 +157,7 @@ class Settings::MenusController < ApplicationController
def import def import
if params[:file] 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 redirect_to settings_menus_path, notice: status
end end
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 = OrderQueueStation.new(settings_order_queue_station_params)
@settings_order_queue_station.created_by = current_login_employee.name @settings_order_queue_station.created_by = current_login_employee.name
@settings_order_queue_station.processing_items = "[]" @settings_order_queue_station.processing_items = "[]"
@settings_order_queue_station.shop_code = @shop.shop_code
respond_to do |format| respond_to do |format|
if @settings_order_queue_station.save if @settings_order_queue_station.save
format.html { redirect_to settings_order_queue_stations_path, notice: 'Order queue station was successfully created.' } 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 # POST /settings/payment_method_settings.json
def create def create
@settings_payment_method_setting = PaymentMethodSetting.new(settings_payment_method_setting_params) @settings_payment_method_setting = PaymentMethodSetting.new(settings_payment_method_setting_params)
@settings_payment_method_setting.shop_code = @shop.shop_code
respond_to do |format| respond_to do |format|
if @settings_payment_method_setting.save if @settings_payment_method_setting.save
format.html { redirect_to settings_payment_method_settings_path, notice: 'Payment method setting was successfully created.' } 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 = Product.new(settings_product_params)
@settings_product.created_by = current_user.name @settings_product.created_by = current_user.name
@settings_product.shop_code = @shop.shop_code
respond_to do |format| respond_to do |format|
if @settings_product.save if @settings_product.save
format.html { redirect_to settings_products_path, notice: 'Product was successfully created.' } 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 = Promotion.new(promotion_params)
@promotion.created_by = current_login_employee.id @promotion.created_by = current_login_employee.id
@promotion.shop_code = @shop.shop_code
if !@promotion.promo_start_hour.nil? if !@promotion.promo_start_hour.nil?
@promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30) @promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30)
end end

View File

@@ -30,7 +30,6 @@ class Settings::RoomsController < ApplicationController
@settings_room.type = DiningFacility::ROOM_TYPE @settings_room.type = DiningFacility::ROOM_TYPE
@settings_room.zone_id = params[:zone_id] @settings_room.zone_id = params[:zone_id]
@settings_room.created_by = current_login_employee.name @settings_room.created_by = current_login_employee.name
@settings_room.shop_code = @shop.shop_code
respond_to do |format| respond_to do |format|
if @settings_room.save if @settings_room.save
format.html { redirect_to settings_zone_path(@zone), notice: 'Room was successfully created.' } 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 @settings_shop.save
if params[:display_images].present? if params[:display_images].present?
params[:display_images]['image'].each do |a| 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
end end
format.html { redirect_to settings_shops_url, notice: 'Shop was successfully created.' } format.html { redirect_to settings_shops_url, notice: 'Shop was successfully created.' }
@@ -60,16 +60,16 @@ class Settings::ShopsController < ApplicationController
File.delete(delete_path) File.delete(delete_path)
end end
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| File.open(save_path, 'wb') do |f|
f.write a.read f.write a.read
end 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 @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 else
@aa = Base64.encode64(a.read) @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 end
end end

View File

@@ -29,7 +29,6 @@ class Settings::TablesController < ApplicationController
@settings_table = Table.new(settings_table_params) @settings_table = Table.new(settings_table_params)
@settings_table.type = DiningFacility::TABLE_TYPE @settings_table.type = DiningFacility::TABLE_TYPE
@settings_table.zone_id = params[:zone_id] @settings_table.zone_id = params[:zone_id]
@settings_table.shop_code = @shop.shop_code
@settings_table.created_by = current_login_employee.name @settings_table.created_by = current_login_employee.name
respond_to do |format| respond_to do |format|
if @settings_table.save 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 = TaxProfile.new(settings_tax_profile_params)
@settings_tax_profile.created_by = current_login_employee.name @settings_tax_profile.created_by = current_login_employee.name
@settings_tax_profile.shop_code = @shop.shop_code
respond_to do |format| respond_to do |format|
if @settings_tax_profile.save if @settings_tax_profile.save
format.html { redirect_to settings_tax_profiles_path, notice: 'Tax profile was successfully created.' } 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 def create
@settings_zone = Zone.new(settings_zone_params) @settings_zone = Zone.new(settings_zone_params)
@settings_zone.shop_code =@shop.shop_code
@settings_zone.created_by = current_login_employee.name @settings_zone.created_by = current_login_employee.name
respond_to do |format| respond_to do |format|
if @settings_zone.save 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") .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) .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') 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) @credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
else 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? if !sale.nil?
@credit_notes = sale @credit_notes = sale
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20) @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 receipt_no.nil? && from.nil? && to.nil?
if @shift.blank? 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 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 end
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20) @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
else else
sale = Sale.search(receipt_no,from,to,@shift).shop sale = Sale.search(receipt_no,from,to,@shift)
if sale.count > 0 if sale.count > 0
@sales = sale @sales = sale
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20) @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
@@ -350,7 +350,7 @@ class Transactions::SalesController < ApplicationController
customer= Customer.find(sale.customer_id) customer= Customer.find(sale.customer_id)
#shop detail #shop detail
shop_details = @shop shop_details = current_shop
# get member information # get member information
rebate = MembershipSetting.find_by_rebate(1) rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate if customer.membership_id != nil && rebate

View File

@@ -38,7 +38,7 @@ class Transactions::ShiftSalesController < ApplicationController
#get tax #get tax
shift_obj = ShiftSale.where('id =?',@shift.id) 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 details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift) @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.order_queue_station = order_queue_station
assigned_order_item.print_status = false assigned_order_item.print_status = false
assigned_order_item.delivery_status = false assigned_order_item.delivery_status = false
assigned_order_item.shop_code =order.shop_code
assigned_order_item.save! assigned_order_item.save!
end end

View File

@@ -135,7 +135,7 @@ class Booking < ApplicationRecord
joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id") 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}%") .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 end
.shop.order("sale_id DESC") .order("sale_id DESC")
end end
def self.get_sync_data(sale_id) def self.get_sync_data(sale_id)

View File

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

View File

@@ -1,5 +1,6 @@
class Employee < ApplicationRecord class Employee < ApplicationRecord
has_secure_password has_secure_password
# has_secure_token :auth_token
has_many :commissioners has_many :commissioners
has_many :shit_sales has_many :shit_sales
has_one :current_shift, -> { where.not(shift_started_at: nil).where(shift_closed_at: nil) },class_name: "ShiftSale" 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 :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
validates :password, numericality: true, length: {in: 3..9}, 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 # Employee Image Uploader
mount_uploader :image_path, EmployeeImageUploader mount_uploader :image_path, EmployeeImageUploader
@@ -43,7 +45,7 @@ class Employee < ApplicationRecord
if (session_token) if (session_token)
user = Employee.find_by_token_session(session_token) user = Employee.find_by_token_session(session_token)
expiry_time = login_expiry_time 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 if user && user.session_expiry.utc > DateTime.now.utc
#Extend the login time each time authenticatation take place #Extend the login time each time authenticatation take place
user.session_expiry = user.session_expiry.utc + expiry_time.minutes user.session_expiry = user.session_expiry.utc + expiry_time.minutes
@@ -89,4 +91,18 @@ class Employee < ApplicationRecord
return expiry_time return expiry_time
end 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 end

View File

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

View File

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

View File

@@ -8,7 +8,6 @@ class Menu < ApplicationRecord
#Default Scope to pull the active version only #Default Scope to pull the active version only
default_scope { order("created_at asc") } default_scope { order("created_at asc") }
scope :active, -> {where("is_active = true")} scope :active, -> {where("is_active = true")}
scope :shop, -> { where("menus.shop_code=?",Shop.current_shop.shop_code) }
def self.current_menu def self.current_menu
today = DateTime.now today = DateTime.now
@@ -47,7 +46,7 @@ class Menu < ApplicationRecord
end end
end end
def self.import(file, created_by,shop) def self.import(file, created_by)
status = "" status = ""
spreadsheet = open_spreadsheet(file) spreadsheet = open_spreadsheet(file)
if spreadsheet.sheets.count > 1 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.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"]) account = Account.find_by_id(row["id"])
if account 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 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 end
elsif sheet_name == "Item Set" 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]) # 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" elsif sheet_name == "Menu"
menu = Menu.find_by_id(row["id"]) menu = Menu.find_by_id(row["id"])
if menu 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 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 end
elsif sheet_name == "Menu Category" 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"]) # 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] menu = sheet.row(1)[1]
is_ordering = sheet.row(1)[3]?sheet.row(1)[3]:0 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| (4..sheet.last_row).each do |ii|
row = Hash[[sheet.row(3),sheet.row(ii)].transpose] row = Hash[[sheet.row(3),sheet.row(ii)].transpose]
@@ -194,7 +193,7 @@ class Menu < ApplicationRecord
if !menu_itm if !menu_itm
account = Account.find_by_title(row["Account"]) account = Account.find_by_title(row["Account"])
if account.nil? 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 end
image_path = "" image_path = ""

View File

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

View File

@@ -90,20 +90,20 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end end
#Bill Receipt Print #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 #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
if printer_settings if printer_settings
if !printer_settings.unique_code.match?(/receiptbillorder/i) if !printer_settings.unique_code.match?(/receiptbillorder/i)
if Lookup.collection_of("print_settings").any? { |x| x == ["ReceiptBillA5Pdf", "1"] } #print_settings with name:ReceiptBillA5Pdf 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 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 end
else else
#doemal online order pdf template #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 end
# print as print copies in printer setting # print as print copies in printer setting

View File

@@ -33,7 +33,7 @@ class ProductCommission < ApplicationRecord
product_commission.save product_commission.save
end 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) menu_item = MenuItem.find_by_item_code(saleItemObj.product_code)
commission = Commission.where("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 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='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") 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) .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 .group("sale_id").to_sql
daily_total = connection.select_all("SELECT 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) query = query.where("(receipt_date between ? and ? and sale_status=?) AND i.unit_price <> 0",from,to,status)
end end
def self.get_by_shiftsales(from,to,shift,shop_code) def self.get_by_shiftsales(from,to,shift)
if !shift.blank? if !shift.blank?
query = ShiftSale.where("shift_sales.id =?",shift.id) query = ShiftSale.where("shift_sales.id =?",shift.id)
else else
@@ -974,7 +974,7 @@ def self.get_other_charges()
query = query.group("i.sale_item_id") query = query.group("i.sale_item_id")
end 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) # date_type_selection = get_sql_function_for_report_type(report_type)
if account_type.blank? if account_type.blank?
account_type = '' account_type = ''
@@ -1256,7 +1256,7 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay
return query return query
end 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(" payments_for_credits = SalePayment.select("
sales.sale_id, 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, 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") credits = credits.group("sale_payments.sale_payment_id, sales_sale_payments.sale_id")
end end
def self.get_void_sale(shift,from,to,shop_code) def self.get_void_sale(shift,from,to)
sale_arr = Array.new 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") 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 end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') 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}'") query = query.where("shift_sale_id='#{shift.id}'")
end end
@@ -1525,7 +1525,7 @@ end
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') 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}'") query = query.where("shift_sale_id='#{shift.id}'")
end end
end end

View File

@@ -34,7 +34,7 @@ class SalePayment < ApplicationRecord
end end
end end
def self.get_kbz_pay_amount(sale_id, current_user,shop) def self.get_kbz_pay_amount(sale_id, current_user)
amount = 0 amount = 0
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).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 sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last
@@ -705,7 +705,7 @@ class SalePayment < ApplicationRecord
self.sale.cashier_name = Employee.find(shift.employee_id).name self.sale.cashier_name = Employee.find(shift.employee_id).name
self.sale.save self.sale.save
else else
shift = ShiftSale.current_shift(self.sale.shop_code) shift = ShiftSale.current_shift
shift.update(self.sale) shift.update(self.sale)
self.sale.shift_sale_id = shift.id self.sale.shift_sale_id = shift.id
self.sale.cashier_id = shift.employee_id self.sale.cashier_id = shift.employee_id

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