fixed conflit
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0'
|
|||||||
|
|
||||||
#gem 'mysql2', '>= 0.3.18', '< 0.5'
|
#gem 'mysql2', '>= 0.3.18', '< 0.5'
|
||||||
gem 'pg'
|
gem 'pg'
|
||||||
gem 'mysql2', '>= 0.3.18', '< 0.5'
|
gem 'mysql2'
|
||||||
|
|
||||||
#Use PosgreSQL
|
#Use PosgreSQL
|
||||||
|
|
||||||
|
|||||||
26
Gemfile.lock
26
Gemfile.lock
@@ -47,7 +47,7 @@ GEM
|
|||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
aescrypt (1.0.0)
|
aescrypt (1.0.0)
|
||||||
airbrussh (1.3.3)
|
airbrussh (1.3.4)
|
||||||
sshkit (>= 1.6.1, != 1.7.0)
|
sshkit (>= 1.6.1, != 1.7.0)
|
||||||
arel (8.0.0)
|
arel (8.0.0)
|
||||||
axlsx (2.0.1)
|
axlsx (2.0.1)
|
||||||
@@ -92,14 +92,14 @@ GEM
|
|||||||
cups (0.1.10)
|
cups (0.1.10)
|
||||||
database_cleaner (1.7.0)
|
database_cleaner (1.7.0)
|
||||||
diff-lcs (1.3)
|
diff-lcs (1.3)
|
||||||
erubi (1.8.0)
|
erubi (1.9.0)
|
||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
factory_girl (4.9.0)
|
factory_girl (4.9.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
factory_girl_rails (4.9.0)
|
factory_girl_rails (4.9.0)
|
||||||
factory_girl (~> 4.9.0)
|
factory_girl (~> 4.9.0)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
faker (2.2.2)
|
faker (2.4.0)
|
||||||
i18n (~> 1.6.0)
|
i18n (~> 1.6.0)
|
||||||
ffi (1.11.1)
|
ffi (1.11.1)
|
||||||
filterrific (5.2.1)
|
filterrific (5.2.1)
|
||||||
@@ -154,7 +154,7 @@ GEM
|
|||||||
mini_magick (4.9.5)
|
mini_magick (4.9.5)
|
||||||
mini_mime (1.0.2)
|
mini_mime (1.0.2)
|
||||||
mini_portile2 (2.4.0)
|
mini_portile2 (2.4.0)
|
||||||
minitest (5.11.3)
|
minitest (5.12.0)
|
||||||
momentjs-rails (2.20.1)
|
momentjs-rails (2.20.1)
|
||||||
railties (>= 3.1)
|
railties (>= 3.1)
|
||||||
monetize (1.9.2)
|
monetize (1.9.2)
|
||||||
@@ -167,12 +167,12 @@ GEM
|
|||||||
money (~> 6.13.2)
|
money (~> 6.13.2)
|
||||||
railties (>= 3.0)
|
railties (>= 3.0)
|
||||||
multi_xml (0.6.0)
|
multi_xml (0.6.0)
|
||||||
mysql2 (0.4.10)
|
mysql2 (0.5.2)
|
||||||
nested_form (0.3.2)
|
nested_form (0.3.2)
|
||||||
net-scp (2.0.0)
|
net-scp (2.0.0)
|
||||||
net-ssh (>= 2.6.5, < 6.0.0)
|
net-ssh (>= 2.6.5, < 6.0.0)
|
||||||
net-ssh (5.2.0)
|
net-ssh (5.2.0)
|
||||||
nio4r (2.5.1)
|
nio4r (2.5.2)
|
||||||
nokogiri (1.10.4)
|
nokogiri (1.10.4)
|
||||||
mini_portile2 (~> 2.4.0)
|
mini_portile2 (~> 2.4.0)
|
||||||
pdf-core (0.7.0)
|
pdf-core (0.7.0)
|
||||||
@@ -228,8 +228,10 @@ GEM
|
|||||||
nokogiri
|
nokogiri
|
||||||
rubyzip
|
rubyzip
|
||||||
spreadsheet (> 0.6.4)
|
spreadsheet (> 0.6.4)
|
||||||
rqrcode (0.10.1)
|
rqrcode (1.1.1)
|
||||||
chunky_png (~> 1.0)
|
chunky_png (~> 1.0)
|
||||||
|
rqrcode_core (~> 0.1.0)
|
||||||
|
rqrcode_core (0.1.0)
|
||||||
rspec-core (3.8.2)
|
rspec-core (3.8.2)
|
||||||
rspec-support (~> 3.8.0)
|
rspec-support (~> 3.8.0)
|
||||||
rspec-expectations (3.8.4)
|
rspec-expectations (3.8.4)
|
||||||
@@ -292,16 +294,16 @@ GEM
|
|||||||
rails (>= 3.1)
|
rails (>= 3.1)
|
||||||
thor (0.20.3)
|
thor (0.20.3)
|
||||||
thread_safe (0.3.6)
|
thread_safe (0.3.6)
|
||||||
tilt (2.0.9)
|
tilt (2.0.10)
|
||||||
to_xls-rails (1.3.1)
|
to_xls-rails (1.3.1)
|
||||||
spreadsheet (>= 0.8.5)
|
spreadsheet (>= 0.8.5)
|
||||||
ttfunk (1.5.1)
|
ttfunk (1.5.1)
|
||||||
turbolinks (5.2.0)
|
turbolinks (5.2.1)
|
||||||
turbolinks-source (~> 5.2)
|
turbolinks-source (~> 5.2)
|
||||||
turbolinks-source (5.2.0)
|
turbolinks-source (5.2.0)
|
||||||
tzinfo (1.2.5)
|
tzinfo (1.2.5)
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
uglifier (4.1.20)
|
uglifier (4.2.0)
|
||||||
execjs (>= 0.3.0, < 3)
|
execjs (>= 0.3.0, < 3)
|
||||||
web-console (3.7.0)
|
web-console (3.7.0)
|
||||||
actionview (>= 5.0)
|
actionview (>= 5.0)
|
||||||
@@ -347,8 +349,12 @@ DEPENDENCIES
|
|||||||
material_icons
|
material_icons
|
||||||
mini_magick
|
mini_magick
|
||||||
momentjs-rails
|
momentjs-rails
|
||||||
|
<<<<<<< HEAD
|
||||||
|
mysql2
|
||||||
|
=======
|
||||||
money-rails (~> 1.12)
|
money-rails (~> 1.12)
|
||||||
mysql2 (>= 0.3.18, < 0.5)
|
mysql2 (>= 0.3.18, < 0.5)
|
||||||
|
>>>>>>> ec9e4fb7ebe54e215a0bb8ac6c58b49fa9e20712
|
||||||
nested_form
|
nested_form
|
||||||
pdfjs_viewer-rails
|
pdfjs_viewer-rails
|
||||||
pg
|
pg
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ class Api::BillController < Api::ApiController
|
|||||||
# for Multiple Cashier by Zone
|
# for Multiple Cashier by Zone
|
||||||
table = DiningFacility.find(booking.dining_facility_id)
|
table = DiningFacility.find(booking.dining_facility_id)
|
||||||
|
|
||||||
bk_order = BookingOrder.find_by_booking_id(booking.booking_id)
|
order = booking.orders.first
|
||||||
order = Order.find(bk_order.order_id)
|
|
||||||
|
|
||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||||
|
|
||||||
@@ -40,40 +39,34 @@ class Api::BillController < Api::ApiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if booking
|
if @sale_data = booking.sale
|
||||||
if booking.sale_id.nil?
|
|
||||||
@sale = Sale.new
|
|
||||||
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, cashier, order.source,params[:current_checkin_induties_count])
|
|
||||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
|
||||||
else
|
|
||||||
@status = true
|
@status = true
|
||||||
@sale_id = booking.sale_id
|
elsif @sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, cashier, order.source, params[:current_checkin_induties_count])
|
||||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
@status = true
|
||||||
end
|
else
|
||||||
|
@status = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@status = false
|
@status = false
|
||||||
@error_message = "There is no order for '#{params[:booking_id]}'"
|
@error_message = "There is no order for '#{params[:booking_id]}'"
|
||||||
end
|
end
|
||||||
elsif (params[:order_id])
|
# elsif (params[:order_id])
|
||||||
order = Order.find(params[:order_id])
|
# order = Order.find(params[:order_id])
|
||||||
@sale = Sale.new
|
# @status, @sale_id = Sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier, order.source)
|
||||||
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier, order.source)
|
#
|
||||||
|
# # for Job
|
||||||
# for Job
|
# booking = Booking.find_by_sale_id(@sale_id)
|
||||||
booking = Booking.find_by_sale_id(@sale_id)
|
# table = DiningFacility.find(booking.dining_facility_id)
|
||||||
table = DiningFacility.find(booking.dining_facility_id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Bind shift sale id to sale
|
# Bind shift sale id to sale
|
||||||
# @sale_data.shift_sale_id = shift_by_terminal.id
|
# @sale_data.shift_sale_id = shift_by_terminal.id
|
||||||
# @sale_data.save
|
# @sale_data.save
|
||||||
if @status
|
if @sale_data
|
||||||
#check checkInOut pdf print
|
#check checkInOut pdf print
|
||||||
check_booking = Booking.find_by_sale_id(@sale_id)
|
|
||||||
checkout_time = Lookup.collection_of('checkout_time')
|
checkout_time = Lookup.collection_of('checkout_time')
|
||||||
terminal = DiningFacility.find_by_id(check_booking.dining_facility_id)
|
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||||
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
||||||
|
|
||||||
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
|
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
|
||||||
@@ -85,11 +78,11 @@ class Api::BillController < Api::ApiController
|
|||||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||||
|
|
||||||
if !printer.nil?
|
if !printer.nil?
|
||||||
order_queue_printer.print_check_in_out(printer,cashier_terminal , check_booking, table)
|
order_queue_printer.print_check_in_out(printer,cashier_terminal , booking, table)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Promotion.promo_activate(@sale)
|
Promotion.promo_activate(@sale_data)
|
||||||
|
|
||||||
#BillBroadcastJob.perform_later(table)
|
#BillBroadcastJob.perform_later(table)
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
if ENV["SERVER_MODE"] == 'cloud'
|
||||||
@@ -175,18 +168,16 @@ class Api::BillController < Api::ApiController
|
|||||||
booking_order = BookingOrder.find_by_booking_id(@booking.booking_id)
|
booking_order = BookingOrder.find_by_booking_id(@booking.booking_id)
|
||||||
order = Order.find(booking_order.order_id)
|
order = Order.find(booking_order.order_id)
|
||||||
|
|
||||||
if @booking.sale_id.nil?
|
if @sale_data = @booking.sale
|
||||||
@sale = Sale.new
|
|
||||||
@status, @sale_id = @sale.generate_invoice_from_booking(@booking.booking_id, current_login_employee, cashier, order.source,params[:current_checkin_induties_count])
|
|
||||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
|
||||||
else
|
|
||||||
@status = true
|
@status = true
|
||||||
@sale_id = @booking.sale_id
|
elsif @sale_data = Sale.generate_invoice_from_booking(@booking, current_login_employee, cashier, order.source,params[:current_checkin_induties_count])
|
||||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
@status = true
|
||||||
|
else
|
||||||
|
@status = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Promotion.promo_activate(@sale)
|
# Promotion.promo_activate(@sale)
|
||||||
@status = true
|
# @status = true
|
||||||
# render json: JSON.generate({:status => true, :sale_id => @sale_id, :sale_data => @sale_data.to_json })
|
# render json: JSON.generate({:status => true, :sale_id => @sale_id, :sale_data => @sale_data.to_json })
|
||||||
else
|
else
|
||||||
@status = false
|
@status = false
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
def first_bill
|
def first_bill
|
||||||
sale_id = params[:sale_id] # sale_id
|
sale_id = params[:sale_id] # sale_id
|
||||||
sale_data = Sale.find_by_sale_id(sale_id)
|
sale_data = Sale.find(sale_id)
|
||||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||||
member_info = nil
|
member_info = nil
|
||||||
|
|
||||||
# For Cashier by Zone
|
# For Cashier by Zone
|
||||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
booking = Booking.find_by_sale_id(sale_id)
|
||||||
# if bookings.count > 1
|
# if bookings.count > 1
|
||||||
# # for Multiple Booking
|
# # for Multiple Booking
|
||||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||||
@@ -21,12 +21,12 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
if !shift.nil?
|
if !shift.nil?
|
||||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||||
else
|
else
|
||||||
if bookings[0].dining_facility_id.to_i > 0
|
if booking.dining_facility_id.to_i > 0
|
||||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
table = DiningFacility.find(booking.dining_facility_id)
|
||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||||
else
|
else
|
||||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
shift = ShiftSale.find(sale_data.shift_sale_id)
|
||||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,43 +8,30 @@ class Origami::RequestBillsController < ApplicationController
|
|||||||
end
|
end
|
||||||
# Print Request Bill and add to sale tables
|
# Print Request Bill and add to sale tables
|
||||||
def print
|
def print
|
||||||
@sale = Sale.new
|
|
||||||
sale_order=SaleOrder.new
|
|
||||||
|
|
||||||
if !ShiftSale.current_shift.nil?
|
if !ShiftSale.current_shift.nil?
|
||||||
order_id = params[:id] # order_id
|
order_id = params[:id] # order_id
|
||||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
|
||||||
order = Order.find(order_id)
|
order = Order.find(order_id)
|
||||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
booking = order.booking
|
||||||
if check_booking.checkin_at.utc.strftime("%Y-%m-%d %H:%M") > Time.now.utc.strftime("%Y-%m-%d %H:%M") && check_booking.checkout_at.nil?
|
if booking.checkin_at.utc > Time.now.utc && booking.checkout_at.nil?
|
||||||
@status = false
|
@status = false
|
||||||
@error_message = "Operation failed, Could not request bill!"
|
@error_message = "Operation failed, Could not request bill!"
|
||||||
else
|
else
|
||||||
if check_booking.dining_facility_id.to_i > 0
|
table = DiningFacility.find(booking.dining_facility_id)
|
||||||
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, params[:current_checkin_induties_count])
|
|
||||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
|
||||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
|
||||||
|
|
||||||
|
if sale_data = booking.sale
|
||||||
|
@status = true
|
||||||
|
elsif sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, current_user, order.source, params[:current_checkin_induties_count])
|
||||||
|
@status = true
|
||||||
# in-duty update
|
# in-duty update
|
||||||
in_duties = InDuty.where("booking_id=?",bk_order.booking_id)
|
in_duties = InDuty.where("booking_id=?", booking.id)
|
||||||
if !in_duties.empty?
|
if !in_duties.empty?
|
||||||
in_duties.each do |in_duty|
|
in_duties.each do |in_duty|
|
||||||
induty = InDuty.find(in_duty.id)
|
induty = InDuty.find(in_duty.id)
|
||||||
induty.sale_id = @sale_id
|
induty.sale_id = sale_data.sale_id
|
||||||
induty.out_time =Time.now.utc
|
induty.out_time = Time.now.utc
|
||||||
induty.save
|
induty.save
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
# Bind shift sale id to sale
|
# Bind shift sale id to sale
|
||||||
@@ -54,11 +41,11 @@ class Origami::RequestBillsController < ApplicationController
|
|||||||
action_by = current_user.name
|
action_by = current_user.name
|
||||||
type = "REQUEST_BILL"
|
type = "REQUEST_BILL"
|
||||||
|
|
||||||
remark = "Request bill Receipt No #{@sale_data.receipt_no}"
|
remark = "Request bill Receipt No #{sale_data.receipt_no}"
|
||||||
sale_audit = SaleAudit.record_audit_sale(@sale_data.sale_id,remark,action_by,type )
|
sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type )
|
||||||
|
|
||||||
# Promotion Activation
|
# Promotion Activation
|
||||||
Promotion.promo_activate(@sale)
|
Promotion.promo_activate(sale_data)
|
||||||
|
|
||||||
#bill channel
|
#bill channel
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
if ENV["SERVER_MODE"] == 'cloud'
|
||||||
@@ -71,14 +58,13 @@ class Origami::RequestBillsController < ApplicationController
|
|||||||
ActionCable.server.broadcast "bill_channel",table: table, from: from
|
ActionCable.server.broadcast "bill_channel",table: table, from: from
|
||||||
end
|
end
|
||||||
if order.source == "quick_service" || order.source == "food_court"
|
if order.source == "quick_service" || order.source == "food_court"
|
||||||
result = {:status=> @status, :data => @sale.sale_id }
|
result = {:status=> @status, :data => sale_data.sale_id }
|
||||||
render :json => result.to_json
|
render :json => result.to_json
|
||||||
else
|
else
|
||||||
#check checkInOut pdf print
|
#check checkInOut pdf print
|
||||||
check_booking = Booking.find_by_sale_id(@sale_id)
|
|
||||||
checkout_time = Lookup.collection_of('checkout_time')
|
checkout_time = Lookup.collection_of('checkout_time')
|
||||||
if !check_booking.dining_facility_id.nil?
|
if !booking.dining_facility_id.nil?
|
||||||
terminal = DiningFacility.find_by_id(check_booking.dining_facility_id)
|
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||||
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
||||||
|
|
||||||
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
|
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
|
||||||
@@ -89,12 +75,13 @@ class Origami::RequestBillsController < ApplicationController
|
|||||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||||
|
|
||||||
if !printer.nil?
|
if !printer.nil?
|
||||||
order_queue_printer.print_check_in_out(printer, cashier_terminal, check_booking, table)
|
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@status = true
|
||||||
else
|
else
|
||||||
@status = false
|
@status = false
|
||||||
@error_message = "No Current Open Shift for This Employee"
|
@error_message = "No Current Open Shift for This Employee"
|
||||||
|
|||||||
@@ -117,16 +117,12 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||||
# get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
|
# get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
|
||||||
|
|
||||||
if booking
|
if sale_data = booking.sale
|
||||||
if booking.sale_id.nil?
|
|
||||||
sale = Sale.new
|
|
||||||
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user, cashier_type,params[:current_checkin_induties_count])
|
|
||||||
sale_data = Sale.find_by_sale_id(sale_id)
|
|
||||||
else
|
|
||||||
status = true
|
status = true
|
||||||
sale_id = booking.sale_id
|
elsif sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type,params[:current_checkin_induties_count])
|
||||||
sale_data = Sale.find_by_sale_id(sale_id)
|
status = true
|
||||||
end
|
else
|
||||||
|
status = false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if params[:type] == "Table"
|
if params[:type] == "Table"
|
||||||
@@ -332,8 +328,9 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sale = Sale.new
|
if sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type ,params[:current_checkin_induties_count])
|
||||||
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user, cashier_type ,params[:current_checkin_induties_count])
|
status = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Promotion.promo_activate(sale)
|
Promotion.promo_activate(sale)
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ class Order < ApplicationRecord
|
|||||||
belongs_to :customer
|
belongs_to :customer
|
||||||
has_many :order_items, autosave: true , inverse_of: :order
|
has_many :order_items, autosave: true , inverse_of: :order
|
||||||
has_many :assigned_order_items
|
has_many :assigned_order_items
|
||||||
|
has_one :booking_order
|
||||||
|
has_one :booking, through: :booking_order
|
||||||
|
|
||||||
#internal references attributes for business logic control
|
#internal references attributes for business logic control
|
||||||
attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id, :extra_time, :is_extra_time
|
attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id, :extra_time, :is_extra_time
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class Sale < ApplicationRecord
|
|||||||
has_many :sale_taxes
|
has_many :sale_taxes
|
||||||
has_many :sale_payments
|
has_many :sale_payments
|
||||||
has_many :sale_orders
|
has_many :sale_orders
|
||||||
|
has_many :orders, through: :sale_orders
|
||||||
has_many :bookings
|
has_many :bookings
|
||||||
has_many :product_commissions
|
has_many :product_commissions
|
||||||
|
|
||||||
@@ -64,34 +65,31 @@ class Sale < ApplicationRecord
|
|||||||
Rails.logger.debug '........ Sale data sync completed .......'
|
Rails.logger.debug '........ Sale data sync completed .......'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def generate_invoice_from_booking(booking_id, requested_by, cashier, order_source = nil, current_checkin_induties_count)
|
def self.generate_invoice_from_booking(booking, requested_by, cashier, order_source = nil, current_checkin_induties_count)
|
||||||
saleObj =''
|
if booking
|
||||||
booking = Booking.find(booking_id)
|
|
||||||
status = false
|
|
||||||
Rails.logger.debug "Booking -> " + booking.id.to_s
|
Rails.logger.debug "Booking -> " + booking.id.to_s
|
||||||
if (booking)
|
|
||||||
Rails.logger.debug "Booking -> Booking Order Count -> " + booking.booking_orders.count.to_s
|
Rails.logger.debug "Booking -> Booking Order Count -> " + booking.booking_orders.count.to_s
|
||||||
#get all order attached to this booking and combine into 1 invoice
|
#get all order attached to this booking and combine into 1 invoice
|
||||||
|
|
||||||
booking.booking_orders.each do |order|
|
unless sale = booking.sale
|
||||||
# puts "Hello order"
|
sale = booking.build_sale(
|
||||||
if booking.sale_id
|
{
|
||||||
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by, cashier, order_source)
|
tax_type: "execulive" # Default Tax - Values
|
||||||
else
|
}
|
||||||
status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by, cashier, order_source)
|
)
|
||||||
end
|
end
|
||||||
booking.sale_id = sale_id
|
booking.booking_orders.each do |order|
|
||||||
saleObj = Sale.find(sale_id)
|
sale.generate_invoice_from_order(order.order_id, booking, requested_by, cashier, order_source)
|
||||||
|
# saleObj = Sale.find(sale_id)
|
||||||
# order = booking.booking_orders.take.order
|
# order = booking.booking_orders.take.order
|
||||||
link_order_sale(order.order_id)
|
# link_order_sale(order.order_id)
|
||||||
end
|
end
|
||||||
# InventoryJob.perform_now(self.id)
|
# InventoryJob.perform_now(self.id)
|
||||||
# InventoryDefinition.calculate_product_count(saleObj)
|
# InventoryDefinition.calculate_product_count(saleObj)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# dining charges
|
# dining charges
|
||||||
charges = DiningCharge.where('dining_facility_id=?',booking.dining_facility_id).take
|
charges = DiningCharge.where('dining_facility_id=?', booking.dining_facility_id).take
|
||||||
if !charges.nil?
|
if !charges.nil?
|
||||||
block_count, diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at)
|
block_count, diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at)
|
||||||
if charges.charge_type =='hr'
|
if charges.charge_type =='hr'
|
||||||
@@ -102,54 +100,36 @@ class Sale < ApplicationRecord
|
|||||||
later_time = booking.checkout_at
|
later_time = booking.checkout_at
|
||||||
early_time = booking.checkin_at
|
early_time = booking.checkin_at
|
||||||
distance_in_minutes = ((later_time - early_time)/60.0).round
|
distance_in_minutes = ((later_time - early_time)/60.0).round
|
||||||
basic_pay_amount =0
|
basic_pay_amount = 0
|
||||||
name =""
|
name = ""
|
||||||
if current_checkin_induties_count != "0"
|
if current_checkin_induties_count != "0"
|
||||||
basic_pay = Commission.where('commission_type=?','Basic Pay')
|
basic_pay = Commission.where('commission_type=?','Basic Pay')
|
||||||
basic_pay.each do |pay|
|
basic_pay.each do |pay|
|
||||||
basic_pay_amount =pay.amount
|
basic_pay_amount = pay.amount
|
||||||
name =pay.name
|
name = pay.name
|
||||||
end
|
end
|
||||||
induties_pay_amount = (current_checkin_induties_count.to_i * (distance_in_minutes / 60.0).to_f * basic_pay_amount).to_i
|
induties_pay_amount = (current_checkin_induties_count.to_i * (distance_in_minutes / 60.0).to_f * basic_pay_amount).to_i
|
||||||
create_saleitem_indutycharges(charges, current_checkin_induties_count.to_i, induties_pay_amount, booking.dining_facility.name, dining_time, order_source, basic_pay_amount)
|
sale.create_saleitem_indutycharges(charges, current_checkin_induties_count.to_i, induties_pay_amount, booking.dining_facility.name, dining_time, order_source, basic_pay_amount)
|
||||||
end
|
end
|
||||||
create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time, order_source)
|
sale.create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time, order_source)
|
||||||
end
|
end
|
||||||
return status, sale_id
|
|
||||||
|
return sale
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_invoice_from_order (order_id, sale_id, booking, requested_by, cashier = nil, order_source = nil)
|
def generate_invoice_from_order(order_id, booking, requested_by, cashier = nil, order_source = nil)
|
||||||
taxable = true
|
taxable = true
|
||||||
#if sale_id is exsit and validate
|
|
||||||
#add order to that invoice
|
|
||||||
if (sale_id)
|
|
||||||
self.find(sale_id)
|
|
||||||
end
|
|
||||||
Rails.logger.debug "Does it have Existing Sale -> [#{self.id.to_s}] - Status [#{self.sale_status}]"
|
|
||||||
|
|
||||||
if self.sale_status == "void"
|
|
||||||
return false, "Invoice is void. Cannot be edited"
|
|
||||||
else
|
|
||||||
#if this is new sale generate_receipt_no
|
|
||||||
# generate_receipt_no
|
|
||||||
order = Order.find(order_id)
|
order = Order.find(order_id)
|
||||||
|
|
||||||
#Default Tax - Values
|
|
||||||
self.tax_type = "exclusive"
|
|
||||||
# current cashier login
|
# current cashier login
|
||||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||||
current_shift = ShiftSale.current_shift
|
current_shift = ShiftSale.current_shift
|
||||||
# shift with terminal zone
|
# shift with terminal zone
|
||||||
|
|
||||||
# set cashier
|
# set cashier
|
||||||
if !order_source.nil?
|
if order_source.present? && order_source.downcase == "emenu"
|
||||||
orderSoure = order_source.downcase
|
|
||||||
else
|
|
||||||
orderSoure = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
if orderSoure == "emenu"
|
|
||||||
if !booking.dining_facility_id.nil?
|
if !booking.dining_facility_id.nil?
|
||||||
table = DiningFacility.find(booking.dining_facility_id)
|
table = DiningFacility.find(booking.dining_facility_id)
|
||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||||
@@ -203,29 +183,25 @@ class Sale < ApplicationRecord
|
|||||||
Rails.logger.debug "Order -> #{order.id} | Items Count -> #{order.order_items.count}"
|
Rails.logger.debug "Order -> #{order.id} | Items Count -> #{order.order_items.count}"
|
||||||
|
|
||||||
order.order_items.each do |item|
|
order.order_items.each do |item|
|
||||||
add_item(item)
|
self.add_item(item)
|
||||||
if !item.set_menu_items.nil?
|
if !item.set_menu_items.nil?
|
||||||
add_sub_item(item.set_menu_items)
|
self.add_sub_item(item.set_menu_items)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self.orders << order
|
||||||
# link_order_sale(order.id)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
self.save!
|
|
||||||
|
|
||||||
#compute sales summary
|
#compute sales summary
|
||||||
if order_source.nil?
|
if order_source.nil?
|
||||||
order_source = order.source
|
order_source = order.source
|
||||||
end
|
end
|
||||||
compute(order_source)
|
self.compute(order_source)
|
||||||
|
|
||||||
#Update the order items that is billed
|
#Update the order items that is billed
|
||||||
order.update_items_status_to_billed(nil)
|
order.update_items_status_to_billed(nil)
|
||||||
order.status = "billed"
|
order.status = "billed"
|
||||||
order.save
|
order.save
|
||||||
|
|
||||||
booking.sale_id = self.id
|
|
||||||
if !booking.checkout_at.nil?
|
if !booking.checkout_at.nil?
|
||||||
if booking.checkout_at.utc < Time.now.utc
|
if booking.checkout_at.utc < Time.now.utc
|
||||||
booking.checkout_at = Time.now.utc.getlocal
|
booking.checkout_at = Time.now.utc.getlocal
|
||||||
@@ -238,35 +214,25 @@ class Sale < ApplicationRecord
|
|||||||
booking.save
|
booking.save
|
||||||
|
|
||||||
# InventoryJob.perform_now(self.id)
|
# InventoryJob.perform_now(self.id)
|
||||||
saleObj = Sale.find(self.id)
|
# saleObj = Sale.find(self.id)
|
||||||
# InventoryDefinition.calculate_product_count(saleObj)
|
# InventoryDefinition.calculate_product_count(saleObj)
|
||||||
|
|
||||||
return true, self.id
|
return self
|
||||||
end
|
|
||||||
|
|
||||||
return false, nil
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#fOR Quick Service pay and create
|
#fOR Quick Service pay and create
|
||||||
def self.request_bill(order,current_user,current_login_employee)
|
def self.request_bill(order,current_user,current_login_employee)
|
||||||
@sale = Sale.new
|
|
||||||
sale_order=SaleOrder.new
|
|
||||||
|
|
||||||
if !ShiftSale.current_shift.nil?
|
if !ShiftSale.current_shift.nil?
|
||||||
order_id = order.order_id # order_id
|
order_id = order.order_id # order_id
|
||||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||||
|
|
||||||
if check_booking.sale_id.nil?
|
if @sale_data = check_booking.sale
|
||||||
# Create Sale if it doesn't exist
|
# Create Sale if it doesn't exist
|
||||||
# puts "current_login_employee"
|
# puts "current_login_employee"
|
||||||
# puts current_login_employee.name
|
# puts current_login_employee.name
|
||||||
@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)
|
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||||
else
|
elsif @sale_data = Sale.generate_invoice_from_booking(check_booking,current_login_employee,current_user,order.source)
|
||||||
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
|
|
||||||
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -214,10 +214,10 @@ class SaleItem < ApplicationRecord
|
|||||||
def self.get_all_sale_items(sale_id)
|
def self.get_all_sale_items(sale_id)
|
||||||
sale_items = SaleItem.select("sale_id,product_code,item_instance_code,
|
sale_items = SaleItem.select("sale_id,product_code,item_instance_code,
|
||||||
product_name,product_alt_name,account_id,status,remark,
|
product_name,product_alt_name,account_id,status,remark,
|
||||||
(CASE WHEN (qty > 0 AND remark IS NULL) OR (qty > 0 AND status='foc') OR (qty < 0 AND status = 'foc') OR (qty < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(qty) ELSE qty END) as qty,
|
SUM(qty) as qty,
|
||||||
unit_price,
|
unit_price,
|
||||||
taxable_price,
|
taxable_price,
|
||||||
(CASE WHEN (price > 0 AND remark IS NULL) OR (qty > 0 AND status='foc') OR (qty < 0 AND status = 'foc') OR (price < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(price) ELSE price END) as price,
|
SUM(price) as price,
|
||||||
is_taxable")
|
is_taxable")
|
||||||
.where("sale_id = ?",sale_id)
|
.where("sale_id = ?",sale_id)
|
||||||
.order("product_name asc")
|
.order("product_name asc")
|
||||||
@@ -238,11 +238,7 @@ class SaleItem < ApplicationRecord
|
|||||||
is_edit = self.qty >= 0 && self.qty != self.qty_was
|
is_edit = self.qty >= 0 && self.qty != self.qty_was
|
||||||
is_foc = self.status == "foc" && self.status_was != "foc"
|
is_foc = self.status == "foc" && self.status_was != "foc"
|
||||||
cancel_foc = self.status_was == "foc"
|
cancel_foc = self.status_was == "foc"
|
||||||
# if is_foc
|
|
||||||
# StockJournal.update_stock_journal(self.item_instance_code, "foc")
|
|
||||||
# else cancel_foc
|
|
||||||
# StockJournal.update_stock_journal(self.item_instance_code, "cancel_foc")
|
|
||||||
# end
|
|
||||||
if is_void or cancel_void or is_edit or is_foc or cancel_foc
|
if is_void or cancel_void or is_edit or is_foc or cancel_foc
|
||||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
|
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
|
||||||
if found
|
if found
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
default: &default
|
|
||||||
adapter: postgresql
|
|
||||||
host: localhost
|
|
||||||
pool: 5
|
|
||||||
timeout: 5000
|
|
||||||
encoding: unicode
|
|
||||||
username: nlh
|
|
||||||
password: 7812co2Y
|
|
||||||
port: 5432
|
|
||||||
|
|
||||||
development:
|
|
||||||
<<: *default
|
|
||||||
database: sxdemo
|
|
||||||
production:
|
|
||||||
<<: *default
|
|
||||||
database: paymal
|
|
||||||
Reference in New Issue
Block a user