check changable tax on/off settings and customer tax profiles calculation
This commit is contained in:
@@ -130,6 +130,19 @@ class Origami::HomeController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
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
|
||||
end
|
||||
|
||||
def check_emp_access_code
|
||||
|
||||
@@ -271,6 +271,20 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
if !@lookup_pdf.nil?
|
||||
@pdf_view = @lookup_pdf.value
|
||||
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
|
||||
|
||||
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")
|
||||
|
||||
@@ -12,103 +12,81 @@ class Origami::RequestBillsController < ApplicationController
|
||||
sale_order=SaleOrder.new
|
||||
|
||||
if !ShiftSale.current_shift.nil?
|
||||
tax_data = TaxProfile.unscoped.where("group_type='cashier'").pluck(:id)
|
||||
customer = Customer.find('CUS-000000000001')
|
||||
|
||||
puts "data => "
|
||||
puts tax_data
|
||||
puts customer.tax_profiles
|
||||
arr_data = []
|
||||
tax_data.each do |value1|
|
||||
puts JSON.stringify(customer.tax_profiles)
|
||||
if customer.include? value1
|
||||
arr_data << value1
|
||||
end
|
||||
order_id = params[:id] # order_id
|
||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||
order = Order.find(order_id)
|
||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
if check_booking.dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(check_booking.dining_facility_id)
|
||||
else
|
||||
table = nil
|
||||
end
|
||||
puts "unique => "
|
||||
puts arr_data
|
||||
# tax_profiles = TaxProfile.unscoped.where("id in ?",arr_data)
|
||||
# puts tax_profiles.to_json
|
||||
# order_id = params[:id] # order_id
|
||||
# bk_order = BookingOrder.find_by_order_id(order_id)
|
||||
# order = Order.find(order_id)
|
||||
# check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
# if check_booking.dining_facility_id.to_i > 0
|
||||
# table = DiningFacility.find(check_booking.dining_facility_id)
|
||||
# else
|
||||
# table = nil
|
||||
# end
|
||||
|
||||
# if check_booking.sale_id.nil?
|
||||
# # Create Sale if it doesn't exist
|
||||
# @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source)
|
||||
# @sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
# @sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
if check_booking.sale_id.nil?
|
||||
# Create Sale if it doesn't exist
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source)
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
|
||||
# # in-duty update
|
||||
# in_duties = InDuty.where("booking_id=?",bk_order.booking_id)
|
||||
# if !in_duties.empty?
|
||||
# in_duties.each do |in_duty|
|
||||
# induty = InDuty.find(in_duty.id)
|
||||
# induty.sale_id = @sale_id
|
||||
# induty.save
|
||||
# end
|
||||
# end
|
||||
# else
|
||||
# @sale_data = Sale.find_by_sale_id(check_booking.sale_id)
|
||||
# @sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
||||
# end
|
||||
# in-duty update
|
||||
in_duties = InDuty.where("booking_id=?",bk_order.booking_id)
|
||||
if !in_duties.empty?
|
||||
in_duties.each do |in_duty|
|
||||
induty = InDuty.find(in_duty.id)
|
||||
induty.sale_id = @sale_id
|
||||
induty.save
|
||||
end
|
||||
end
|
||||
else
|
||||
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
||||
end
|
||||
|
||||
# # Bind shift sale id to sale
|
||||
# # @sale_data.shift_sale_id = shift.id
|
||||
# # @sale_data.save
|
||||
# Bind shift sale id to sale
|
||||
# @sale_data.shift_sale_id = shift.id
|
||||
# @sale_data.save
|
||||
|
||||
# action_by = current_user.name
|
||||
# type = "REQUEST_BILL"
|
||||
action_by = current_user.name
|
||||
type = "REQUEST_BILL"
|
||||
|
||||
# remark = "Request bill Receipt No #{@sale_data.receipt_no}"
|
||||
# sale_audit = SaleAudit.record_audit_sale(@sale_data.sale_id,remark,action_by,type )
|
||||
remark = "Request bill Receipt No #{@sale_data.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_sale(@sale_data.sale_id,remark,action_by,type )
|
||||
|
||||
# # Promotion Activation
|
||||
# Promotion.promo_activate(@sale)
|
||||
# Promotion Activation
|
||||
Promotion.promo_activate(@sale)
|
||||
|
||||
# #bill channel
|
||||
# if ENV["SERVER_MODE"] == 'cloud'
|
||||
# from = request.subdomain + "." + request.domain
|
||||
# else
|
||||
# from = ""
|
||||
# end
|
||||
#bill channel
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
|
||||
# ActionCable.server.broadcast "bill_channel",table: table, from: from
|
||||
# if order.source == "quick_service"
|
||||
# result = {:status=> @status, :data => @sale.sale_id }
|
||||
# render :json => result.to_json
|
||||
# else
|
||||
ActionCable.server.broadcast "bill_channel",table: table, from: from
|
||||
if order.source == "quick_service"
|
||||
result = {:status=> @status, :data => @sale.sale_id }
|
||||
render :json => result.to_json
|
||||
else
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
|
||||
# printer = PrintSetting.find_by_unique_code("CheckInOutPdf")
|
||||
# unique_code = "CheckInOutPdf"
|
||||
# booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
printer = PrintSetting.find_by_unique_code("CheckInOutPdf")
|
||||
unique_code = "CheckInOutPdf"
|
||||
booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
|
||||
# # print when complete click
|
||||
# order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||
# print when complete click
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||
|
||||
# if !printer.nil?
|
||||
# order_queue_printer.print_check_in_out(printer, booking, table)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
if !printer.nil?
|
||||
order_queue_printer.print_check_in_out(printer, booking, table)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "No Current Open Shift for This Employee"
|
||||
end
|
||||
|
||||
def difference(other)
|
||||
h = other.each_with_object(Hash.new(0)) { |e,h| h[e] += 1 }
|
||||
reject { |e| h[e] > 0 && h[e] -= 1 }
|
||||
end
|
||||
|
||||
# Not Use for these printed bill cannot give customer
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
# #shop detail
|
||||
|
||||
@@ -154,6 +154,19 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
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
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -25,6 +25,7 @@ class Origami::SalesController < BaseOrigamiController
|
||||
def add_to_existing_invoice
|
||||
dining = params[:dining_id]
|
||||
sale_id = params[:sale_id]
|
||||
tax_type = params[:tax_type]
|
||||
table = DiningFacility.find(dining)
|
||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
||||
table.bookings.each do |booking|
|
||||
@@ -51,7 +52,7 @@ class Origami::SalesController < BaseOrigamiController
|
||||
end
|
||||
|
||||
# Re-compute for add
|
||||
saleobj.compute(order.source)
|
||||
saleobj.compute(order.source,tax_type)
|
||||
saleobj.save
|
||||
order.save
|
||||
booking.save
|
||||
|
||||
Reference in New Issue
Block a user