Merge branch 'r-1902001-01' of gitlab.com:code2lab/SXRestaurant into r-1902001-01
This commit is contained in:
@@ -19,12 +19,13 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
|
||||
table = DiningFacility.find(params[:dining_id])
|
||||
#Send to background job for processing
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "check_in_booking_channel",table: table,from:from
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "check_in_booking_channel",table: table,from:from
|
||||
|
||||
check_out_time = nil
|
||||
extra_minutes = nil
|
||||
alert_time_min = 0
|
||||
@@ -65,93 +66,59 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
if params[:dining_id]
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
if dining_facility.is_active && dining_facility.status == "available"
|
||||
if params[:checkin_time]
|
||||
checkin_at = nil
|
||||
if !params[:checkin_time].empty?
|
||||
checkin_at = Time.parse(params[:checkin_time]).utc
|
||||
if dining_facility.current_checkin_booking.nil?
|
||||
if params[:checkin_time].present?
|
||||
checkin_at = Time.parse(params[:checkin_time])
|
||||
else
|
||||
checkin_at = Time.now.utc
|
||||
checkin_at = Time.now
|
||||
end
|
||||
|
||||
if !checkin_at.nil?
|
||||
if dining_facility.check_time(checkin_at, "checkin")
|
||||
booking = dining_facility.get_current_booking
|
||||
if booking.nil?
|
||||
checkout_at = nil
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
||||
today = Time.now
|
||||
if !lookup_checkout_time.empty?
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking",
|
||||
:checkin_by=>current_login_employee.name,:checkin_at => checkin_at,:checkout_at =>nil, :booking_status => "assign", :reserved_at => nil, :reserved_by => nil })
|
||||
if booking.save!
|
||||
dining_facility.status = "occupied"
|
||||
dining_facility.save!
|
||||
render :json => { :status => true, :booking_id => booking.booking_id, :checkin_at => booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M:%S"), :message => "Check-in success" }
|
||||
else
|
||||
render :json => { :status => false, :error_message => "Booking does not create successfully!" }
|
||||
end
|
||||
else
|
||||
render :json => { :status => false, :error_message => "Booking already exist!" }
|
||||
lookup_checkout_time.each do |checkout_time|
|
||||
start_time, end_time = checkout_time[0].split("-").map{ |t| Time.parse(t.strip).strftime("%H:%M%p") }
|
||||
if start_time <= today.strftime("%H:%M%p") && today.strftime("%H:%M%p") <= end_time
|
||||
checkout_at = checkin_at + (checkout_time[1]).to_i.minutes
|
||||
end
|
||||
else
|
||||
render :json => { :status => false, :error_message => "Checkin time not available!" }
|
||||
end
|
||||
else
|
||||
render :json => { :status => false, :error_message => "Operation failed!" }
|
||||
end
|
||||
|
||||
booking = nil
|
||||
ActiveRecord::Base.transaction do
|
||||
booking = Booking.create({
|
||||
:dining_facility_id => params[:dining_id],
|
||||
:type => "TableBooking",
|
||||
:checkin_by => current_login_employee.name,
|
||||
:checkin_at => checkin_at,
|
||||
:checkout_at => checkout_at,
|
||||
:booking_status => "assign",
|
||||
:reserved_at => checkout_at,
|
||||
:reserved_by => current_login_employee.name })
|
||||
|
||||
dining_facility.status = "occupied"
|
||||
dining_facility.save!
|
||||
end
|
||||
|
||||
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "CheckInOutPdf"
|
||||
printer = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# print when complete click
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||
|
||||
if !printer.nil?
|
||||
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, dining_facility)
|
||||
end
|
||||
end
|
||||
render :json => { :status => true, :booking_id => booking.booking_id, :checkin_at => booking.checkin_at.strftime("%Y-%m-%d %H:%M"), :checkout_at => booking.checkout_at.strftime("%Y-%m-%d %H:%M") }
|
||||
else
|
||||
booking = dining_facility.current_checkout_booking
|
||||
if booking.nil?
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
||||
|
||||
if !lookup_checkout_time.empty?
|
||||
today = Time.now.utc.getlocal
|
||||
checkout_at = Time.now.utc.getlocal
|
||||
|
||||
lookup_checkout_time.each do |checkout_time|
|
||||
arr_time = checkout_time[0].split("-")
|
||||
start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p")
|
||||
end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p")
|
||||
if start_time <= today.strftime("%H:%M%p") && today.strftime("%H:%M%p") <= end_time
|
||||
checkout_at = checkout_at + (checkout_time[1]).to_i.minutes
|
||||
end
|
||||
end
|
||||
|
||||
if checkout_at.strftime("%Y-%m-%d %H:%M%p") >= today.strftime("%Y-%m-%d %H:%M%p")
|
||||
# if dining_facility.type == "Table"
|
||||
# type = "TableBooking"
|
||||
# else
|
||||
# type = "RoomBooking"
|
||||
# end
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking",
|
||||
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
|
||||
if booking.save!
|
||||
dining_facility.status = "occupied"
|
||||
dining_facility.save!
|
||||
end
|
||||
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
|
||||
unique_code = "CheckInOutPdf"
|
||||
printer = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# print when complete click
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||
|
||||
if !printer.nil?
|
||||
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, dining_facility)
|
||||
end
|
||||
end
|
||||
render :json => { :status => true, :booking_id => booking.booking_id, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
|
||||
else
|
||||
render :json => { :status => true }
|
||||
end
|
||||
else
|
||||
render :json => { :status => true }
|
||||
end
|
||||
else
|
||||
render :json => { :status => false, :error_message => "Booking already exist!" }
|
||||
end
|
||||
render :json => { :status => false, :error_message => "Booking already exist!" }
|
||||
end
|
||||
else
|
||||
error_message = "#{dining_facility.type} is not available!"
|
||||
@@ -161,6 +128,8 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
error_message = "dining_id is required!"
|
||||
render :json => { :status => false, :error_message => error_message }
|
||||
end
|
||||
rescue ActiveRecord::RecordInvalid => exception
|
||||
render :json => { :status => false, :error_message => exception.message }
|
||||
end
|
||||
|
||||
def request_time
|
||||
|
||||
@@ -37,18 +37,16 @@ class Api::OrdersController < Api::ApiController
|
||||
@booking = table.get_booking
|
||||
end
|
||||
|
||||
@tax_profile = nil
|
||||
@tax_profile = TaxProfile.where("lower(group_type)='cashier'")
|
||||
# arr_tax = []
|
||||
|
||||
# if !arr_tax.empty?
|
||||
# @tax_profile = TaxProfile.where(:id => arr_tax)
|
||||
# else
|
||||
@tax_profile = TaxProfile.where("lower(group_type)='cashier'")
|
||||
# @tax_profile = TaxProfile.where("lower(group_type)='cashier'")
|
||||
# end
|
||||
|
||||
@shop = Shop.current_shop
|
||||
puts "Hello world"
|
||||
puts @shop.to_json
|
||||
return @shop.to_json
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
class InstallController < BaseController
|
||||
skip_before_action :lookup_domain
|
||||
# skip_before_action :set_current_tenant_by_subdomain_or_name
|
||||
skip_before_action :verify_authenticity_token
|
||||
# before_action :check_license
|
||||
|
||||
def index
|
||||
end
|
||||
@@ -9,7 +8,7 @@ class InstallController < BaseController
|
||||
def activate
|
||||
flag = "<%= ENV['AES_IV'] %>"
|
||||
key_base = "<%= ENV['secret_key_base'] %>"
|
||||
|
||||
|
||||
restaurant = params[:restaurant_name]
|
||||
license_key = params[:license_key]
|
||||
# admin_user = params[:admin_user]
|
||||
@@ -18,20 +17,20 @@ class InstallController < BaseController
|
||||
db_schema = params[:db_schema]
|
||||
db_user = params[:db_user]
|
||||
db_password = params[:db_password]
|
||||
phrase = license_key
|
||||
|
||||
phrase = license_key
|
||||
|
||||
# Check Exists IV
|
||||
# if flag == "<%= ENV['AES_IV'] %>"
|
||||
# # Export for Key
|
||||
# aes = MyAesCrypt.new
|
||||
# # Export for Key
|
||||
# aes = MyAesCrypt.new
|
||||
# aes_key, aes_iv = aes.export_key(phrase)
|
||||
# else
|
||||
# else
|
||||
# aes_key = ENV["AES_KEY"]
|
||||
# aes_iv = ENV["AES_IV"]
|
||||
# end
|
||||
|
||||
@license = License.new(ENV["SX_PROVISION_URL"])
|
||||
response = @license.license_activate(restaurant, license_key, db_host, db_schema, db_user, db_password)
|
||||
@license = License.new(ENV["SX_PROVISION_URL"], request.host)
|
||||
response = @license.license_activate(restaurant, license_key, db_host, db_schema, db_user, db_password)
|
||||
if response[:status]
|
||||
redirect_to root_url, notice: response["message"]
|
||||
else
|
||||
@@ -39,28 +38,24 @@ class InstallController < BaseController
|
||||
end
|
||||
end
|
||||
|
||||
def check_license
|
||||
if License.check_license_file
|
||||
redirect_to root_url
|
||||
def lookup_domain
|
||||
if ENV["SERVER_MODE"] == "cloud"
|
||||
not_found
|
||||
elsif ENV["SERVER_MODE"] == "application"
|
||||
if check_license #(request.host)
|
||||
redirect_to root_url
|
||||
end
|
||||
elsif request.subdomains.last && request.subdomains.last != "www"
|
||||
if check_license #(request.host)
|
||||
redirect_to root_url
|
||||
elsif !check_subdomain(request.host)
|
||||
not_found
|
||||
end
|
||||
else
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
||||
# def lookup_domain
|
||||
# if request.subdomain.present? && request.subdomain != "www"
|
||||
# @license = current_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase)
|
||||
# if (!@license.nil?)
|
||||
# # logger.info "Location - " + @license.name
|
||||
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||
# else
|
||||
# # reconnect_default_db
|
||||
# logger.info 'License is nil'
|
||||
# # redirect_to root_url(:host => request.domain) + "store_error"
|
||||
# render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# def current_license(url, key)
|
||||
# @license = License.new(url, key)
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} "
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_name, action_by,remark,"ITEMDISCOUNT" )
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class Origami::OthersPaymentsController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
path = request.fullpath
|
||||
if path.include? ("credit_payment")
|
||||
@payment_method_setting = PaymentMethodSetting.where("LOWER(payment_method) in ('mpu','visa','master','jcb','unionpay','alipay') and is_active='1'")
|
||||
@payment_method_setting = PaymentMethodSetting.where("is_active='1'")
|
||||
else
|
||||
@payment_method_setting = PaymentMethodSetting.all
|
||||
end
|
||||
@@ -39,7 +39,92 @@ class Origami::OthersPaymentsController < BaseOrigamiController
|
||||
# end
|
||||
end
|
||||
|
||||
def new
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
payment_methods = PaymentMethodSetting.pluck(:payment_method)
|
||||
if @payment_method = payment_methods.find { |m| m.parameterize == params[:method] }
|
||||
path = request.fullpath
|
||||
# limit master_amount
|
||||
if path.include? ("credit_payment")
|
||||
sale_data = Sale.get_sale_data_for_other_payment_credit(@sale_id)
|
||||
else
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
end
|
||||
total = 0
|
||||
@shop = Shop.current_shop
|
||||
@paid_amount = 0
|
||||
@can_paid = 0
|
||||
@rounding_adj = 0
|
||||
@member_discount = 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
if path.include? ("credit_payment")
|
||||
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||
else
|
||||
sale_payment_data = sale_data.sale_payments
|
||||
end
|
||||
|
||||
sale_payment_data.each do |sale_payment|
|
||||
if sale_payment.payment_method == @payment_method.parameterize
|
||||
@paid_amount = @paid_amount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_paid = total - @paid_amount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
end
|
||||
else
|
||||
if path.include? ("credit_payment")
|
||||
redirect_to "sale/#{@sale_id}/#{@cashier_type}/payment/others_payment"
|
||||
else
|
||||
redirect_to "sale/#{@sale_id}/#{@cashier_type}/credit_payment/others_payment"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
payment_method = params[:method]
|
||||
if PaymentMethodSetting.pluck(:payment_method).map(&:parameterize).include? payment_method
|
||||
if saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.current_shop
|
||||
|
||||
path = request.fullpath
|
||||
payment_for = false
|
||||
if path.include? ("credit_payment")
|
||||
payment_for = true
|
||||
end
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, current_user, cash, payment_method, ref_no, payment_for)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -51,7 +51,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#TODO :: KBZPAY ( QR )
|
||||
# On/Off setting ( show or not qr )
|
||||
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
||||
kbz_pay_method = PaymentMethodSetting.where(payment_method: KbzPay::KBZ_PAY, gateway_communication_type: ['api', 'Api'], is_active: true)
|
||||
.where.not(gateway_url: [nil, ''], auth_token: [nil, ''], merchant_account_id: [nil, '']).last
|
||||
|
||||
status = false
|
||||
qr = nil
|
||||
@@ -90,6 +91,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
latest_order_no = nil
|
||||
is_kbz = params[:is_kbz]
|
||||
|
||||
|
||||
if saleObj = Sale.find(sale_id)
|
||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||
|
||||
@@ -106,7 +108,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user)
|
||||
end
|
||||
|
||||
if !path.include? ("credit_payment")
|
||||
|
||||
rebate_amount = nil
|
||||
|
||||
# For Cashier by Zone
|
||||
@@ -200,12 +202,18 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||
credit_pdf = Lookup.find_by_lookup_type("credit_pdf")
|
||||
if (path.include? ("credit_payment")) && !credit_pdf.nil? && credit_pdf.value.to_i == 1
|
||||
printed_status = 'credit_payment'
|
||||
else
|
||||
printed_status = 'Paid'
|
||||
end
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, printed_status,current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||
|
||||
#end
|
||||
end
|
||||
|
||||
if !saleObj.nil?
|
||||
# InventoryJob.perform_now(self.id)
|
||||
# InventoryDefinition.calculate_product_count(saleObj)
|
||||
@@ -225,15 +233,29 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# end
|
||||
|
||||
def show
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
@shop = Shop.current_shop
|
||||
@customer = @sale.customer
|
||||
@customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
|
||||
if dining_facility = @sale.booking.dining_facility
|
||||
@table_no = dining_facility.type + ' ' + dining_facility.name
|
||||
@checkin_time = @sale.booking.checkin_at
|
||||
@dining = dining_facility
|
||||
end
|
||||
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@display_type = nil
|
||||
end
|
||||
end
|
||||
|
||||
path = request.fullpath
|
||||
sale_id = params[:sale_id]
|
||||
|
||||
@trans_flag = true
|
||||
|
||||
if params[:type] == "transaction"
|
||||
@trans_flag = false
|
||||
@cashier_type = "cashier"
|
||||
@@ -241,201 +263,111 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
end
|
||||
|
||||
if path.include? ("credit_payment")
|
||||
@sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount")
|
||||
if path.include? 'credit_payment'
|
||||
@sale_payment = false
|
||||
@amount_due = @sale.sale_payments.where(payment_method: 'creditnote').pluck('SUM(payment_amount)').first
|
||||
payments = @sale.sale_payments.joins(:sale_audit).group_by(&:payment_method).map { |method, payments| [method, payments.sum { |payment| payment.payment_amount }] }
|
||||
else
|
||||
@sale_payment = true
|
||||
@amount_due = @sale.grand_total
|
||||
payments = @sale.sale_payments.left_joins(:sale_audit).where(sale_audits: {sale_audit_id: nil}).group_by(&:payment_method).map { |method, payments| [method, payments.sum { |payment| payment.payment_amount }] }
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@membership_rebate_balance=0
|
||||
@payment_methods = PaymentMethodSetting.where(is_active: true).pluck(:payment_method)
|
||||
@cash = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'cash' }
|
||||
@credit = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'creditnote' }
|
||||
@other_payments = payments.select { |payment| !['cash', 'creditnote'].include? payment[0] }.map { |method, amount| [ @payment_methods.find { |payment_method| payment_method.parameterize == method }, amount ] }
|
||||
@other_payment = @other_payments.sum { |payment| payment[1] }
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
@cash = 0.0
|
||||
@kbz_pay_amount = 0.0
|
||||
@other = 0.0
|
||||
@ppamount = 0.0
|
||||
@visacount= 0.0
|
||||
@jcbcount= 0.0
|
||||
@mastercount = 0.0
|
||||
@unionpaycount = 0.0
|
||||
@alipaycount = 0.0
|
||||
@junctionpaycount = 0.0
|
||||
@credit = 0.0
|
||||
@paymalcount = 0.0
|
||||
@dingacount = 0.0
|
||||
@giftvouchercount = 0.0
|
||||
@sale_data = Sale.find_by_sale_id(sale_id)
|
||||
@balance = 0
|
||||
@accountable_type = ''
|
||||
@table_no = ''
|
||||
@dining = ''
|
||||
@other_payment = 0.0
|
||||
@pdf_view = nil
|
||||
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
|
||||
if !@lookup_pdf.nil?
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
#total customer with individual total amount
|
||||
@individual_total = Array.new
|
||||
if !@sale.equal_persons.nil?
|
||||
per_person_amount = @sale.grand_total / @sale.equal_persons.to_i
|
||||
@individual_total.push({'total_customer' => @sale.equal_persons.to_i, 'per_person_amount' => per_person_amount })
|
||||
end
|
||||
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
|
||||
@kbz_pay_amount += amount.to_f
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
if changable_tax[1] == '0'
|
||||
@changable_tax = false
|
||||
end
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
if changable_tax[1] == '0'
|
||||
@changable_tax = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@shop = shop_detail #show shop info
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
@customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
|
||||
@pdf_view = nil
|
||||
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
|
||||
if !@lookup_pdf.nil?
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
# amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
|
||||
# @kbz_pay_amount += amount.to_f
|
||||
|
||||
#total customer with individual total amount
|
||||
@individual_total = Array.new
|
||||
if !saleObj.equal_persons.nil?
|
||||
per_person_amount = saleObj.grand_total.to_f / saleObj.equal_persons.to_i
|
||||
@individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f })
|
||||
# rounding adjustment
|
||||
# if @shop.is_rounding_adj
|
||||
# a = saleObj.grand_total % 25 # Modulus
|
||||
# b = saleObj.grand_total / 25 # Division
|
||||
# #not calculate rounding if modulus is 0 and division is even
|
||||
# #calculate rounding if modulus is zero or not zero and division are not even
|
||||
# if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# @rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:@rounding_adj)
|
||||
# @sale_data.grand_total = new_total
|
||||
# @sale_data.old_grand_total = saleObj.grand_total
|
||||
# @sale_data.rounding_adjustment = @rounding_adj
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
#end rounding adjustment
|
||||
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
@tax_arr =[]
|
||||
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc.id)
|
||||
# @account_arr.push(account)
|
||||
@tax_arr.push(account.name)
|
||||
end
|
||||
|
||||
sale_taxes = @sale.sale_taxes
|
||||
if !sale_taxes.empty?
|
||||
sale_taxes.each do |sale_tax|
|
||||
@account_arr.push(sale_tax)
|
||||
end
|
||||
end
|
||||
|
||||
# rounding adjustment
|
||||
# if @shop.is_rounding_adj
|
||||
# a = saleObj.grand_total % 25 # Modulus
|
||||
# b = saleObj.grand_total / 25 # Division
|
||||
# #not calculate rounding if modulus is 0 and division is even
|
||||
# #calculate rounding if modulus is zero or not zero and division are not even
|
||||
# if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# @rounding_adj = new_total-saleObj.grand_total
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
#end rounding adjustment
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
#calculate rounding if modulus is zero or not zero and division are not even
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
@rounding_adj = new_total-saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:@rounding_adj)
|
||||
@sale_data.grand_total = new_total
|
||||
@sale_data.old_grand_total = saleObj.grand_total
|
||||
@sale_data.rounding_adjustment = @rounding_adj
|
||||
else
|
||||
@rounding_adj = @sale_data.rounding_adjustment
|
||||
end
|
||||
else
|
||||
@rounding_adj = @sale_data.rounding_adjustment
|
||||
end
|
||||
#end rounding adjustment
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale_data.customer_id)
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
@tax_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc.id)
|
||||
# @account_arr.push(account)
|
||||
@tax_arr.push(account.name)
|
||||
end
|
||||
sale_taxes = SaleTax.where("sale_id = ?", saleObj.sale_id)
|
||||
if !sale_taxes.empty?
|
||||
sale_taxes.each do |sale_tax|
|
||||
@account_arr.push(sale_tax)
|
||||
end
|
||||
end
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
# get member information
|
||||
if @customer.membership_id != nil && rebate
|
||||
response = Customer.get_member_account(@customer)
|
||||
if response["status"]==true
|
||||
response["account_data"].each do |res|
|
||||
# get member information
|
||||
@balance = 0
|
||||
@accountable_type = ''
|
||||
if @customer.membership_id != nil && rebate
|
||||
response = Customer.get_member_account(@customer)
|
||||
if response["status"]==true
|
||||
response["account_data"].each do |res|
|
||||
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||
@balance = @balance.to_f + res["balance"].to_f
|
||||
# @accountable_type = res["accountable_type"]
|
||||
@accountable_type = "Rebate Balance"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#end customer amount
|
||||
|
||||
#paymal payment
|
||||
|
||||
@sale_data.bookings.each do |sbk|
|
||||
if sbk.dining_facility_id.to_i >0
|
||||
df = DiningFacility.find(sbk.dining_facility_id)
|
||||
@table_no = df.type + ' ' + df.name
|
||||
@checkin_time = sbk.checkin_at
|
||||
@dining = df
|
||||
break
|
||||
else
|
||||
@table_no = nil
|
||||
@checkin_time = nil
|
||||
@dining = nil
|
||||
end
|
||||
end
|
||||
|
||||
if path.include? ("credit_payment")
|
||||
@sale_payment_data = SalePayment.get_sale_payment_for_credit(@sale_data)
|
||||
else
|
||||
@sale_payment_data = SalePayment.get_sale_payments(@sale_data)
|
||||
end
|
||||
@sale_payment_data.each do |spay|
|
||||
if spay.payment_method == "cash"
|
||||
@cash += spay.payment_amount
|
||||
end
|
||||
if spay.payment_method !="creditnote"
|
||||
@other_payment += spay.payment_amount
|
||||
end
|
||||
|
||||
if spay.payment_method == "mpu"
|
||||
@other += spay.payment_amount
|
||||
elsif spay.payment_method == "paypar"
|
||||
@ppamount += spay.payment_amount
|
||||
elsif spay.payment_method == "visa"
|
||||
@visacount += spay.payment_amount
|
||||
elsif spay.payment_method == "jcb"
|
||||
@jcbcount += spay.payment_amount
|
||||
elsif spay.payment_method == "master"
|
||||
@mastercount += spay.payment_amount
|
||||
elsif spay.payment_method == "unionpay"
|
||||
@unionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "JunctionPay"
|
||||
@junctionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "creditnote"
|
||||
@credit += spay.payment_amount
|
||||
elsif spay.payment_method == "paymal"
|
||||
@paymalcount += spay.payment_amount
|
||||
elsif spay.payment_method == "alipay"
|
||||
@alipaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "dinga"
|
||||
@dingacount += spay.payment_amount
|
||||
elsif spay.payment_method == "giftvoucher"
|
||||
@giftvouchercount += spay.payment_amount
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
#end customer amount
|
||||
end
|
||||
|
||||
def reprint
|
||||
|
||||
@@ -112,7 +112,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
|
||||
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
|
||||
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
|
||||
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
@@ -125,7 +125,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
end
|
||||
find_close_cashier_print = Lookup.collection_of('close_cashier_print')
|
||||
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_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_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,@payment_methods)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
17
app/controllers/renew_license_controller.rb
Normal file
17
app/controllers/renew_license_controller.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class RenewLicenseController < ApplicationController
|
||||
|
||||
def expire
|
||||
@license = current_license
|
||||
@plan = @license.read_license("plan_name")
|
||||
@bis_name = @license.read_license_no_decrypt("shop_name")
|
||||
@expired_at = @license.read_license("renewable_date")
|
||||
@license_status = @license.detail_with_local_file
|
||||
end
|
||||
|
||||
def renew
|
||||
status, message = current_license.verify_license
|
||||
|
||||
redirect_to expire_url(message: message, status: status)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,28 +1,30 @@
|
||||
class Reports::PaymentMethodController < BaseReportController
|
||||
class Reports::PaymentMethodController < BaseReportController
|
||||
# authorize_resource :class => false
|
||||
def index
|
||||
|
||||
@payments = [["All Payment",''],["Cash Payment","cash"], ["KBZ Payment", KbzPay::KBZ_PAY], ["Credit Payment","creditnote"],
|
||||
["FOC Payment","foc"], ["MPU Payment","mpu"], ["Visa Payment","visa"],
|
||||
["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"],
|
||||
["Alipay Payment","alipay"],["Paymal Payment", "paymal"],["Dinga Payment","dinga"],
|
||||
["JunctionPay","junctionpay"],["Redeem Payment","paypar"],["Gift Voucher","giftvoucher"]]
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
|
||||
|
||||
@payments = [["All Payment",''],["Cash Payment","cash"], ["Credit Payment","creditnote"],
|
||||
["FOC Payment","foc"]]
|
||||
|
||||
@payment_methods.each do |m|
|
||||
@payments.push(["#{m} Payment", m.parameterize])
|
||||
end
|
||||
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
else
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
@payment_type = params[:payment_type]
|
||||
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type)
|
||||
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift,from,to,@payment_type)
|
||||
@from = from
|
||||
@to = to
|
||||
# get printer info
|
||||
@@ -58,10 +60,10 @@ class Reports::PaymentMethodController < BaseReportController
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -80,6 +80,7 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
|
||||
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@@ -95,8 +96,8 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
|
||||
# printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_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_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,@payment_methods)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'}
|
||||
format
|
||||
|
||||
Reference in New Issue
Block a user