merge with crm
This commit is contained in:
@@ -52,6 +52,7 @@ class Ability
|
||||
can :show, :payment
|
||||
can :create, :payment
|
||||
can :reprint, :payment
|
||||
can :rounding_adj, :payment
|
||||
|
||||
can :move_dining, :movetable
|
||||
can :moving, :movetable
|
||||
@@ -88,6 +89,7 @@ class Ability
|
||||
can :show, :payment
|
||||
can :create, :payment
|
||||
can :reprint, :payment
|
||||
can :rounding_adj, :payment
|
||||
|
||||
can :move_dining, :movetable
|
||||
can :moving, :movetable
|
||||
|
||||
@@ -43,10 +43,10 @@ class OrderItem < ApplicationRecord
|
||||
def self.get_order_items_details(booking_id)
|
||||
# booking_orders = BookingOrder.where("booking_id=?",booking.booking_id)
|
||||
# if booking_orders
|
||||
# booking_orders.each do |book_order|
|
||||
# booking_orders.each do |book_order|
|
||||
# order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price")
|
||||
# .joins("left join orders on orders.order_id = order_items.order_id")
|
||||
# .where("order_items.order_id=?",book_order.order)
|
||||
# .where("order_items.order_id=?",book_order.order)
|
||||
# return order_details
|
||||
# end
|
||||
# else
|
||||
@@ -57,9 +57,9 @@ class OrderItem < ApplicationRecord
|
||||
.joins("left join orders on orders.order_id = order_items.order_id")
|
||||
.joins("left join booking_orders on booking_orders.order_id = order_items.order_id")
|
||||
.joins("left join bookings on bookings.booking_id = booking_orders.booking_id")
|
||||
.where("bookings.booking_id=?",booking_id)
|
||||
.where("bookings.booking_id=?",booking_id)
|
||||
|
||||
return order_details
|
||||
return order_details
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -11,14 +11,24 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
self.print("tmp/cashier_station_#{order_id}_closing_#{time}.pdf")
|
||||
end
|
||||
|
||||
def print_close_cashier(receipt_no)
|
||||
# def print_close_cashier(receipt_no)
|
||||
# #Use CUPS service
|
||||
# #Generate PDF
|
||||
# time = DateTime.now
|
||||
# #Print
|
||||
# pdf = CashierStationClosing.new
|
||||
# pdf.render_file "tmp/cashier_station_#{order_id}_closing_#{time}.pdf"
|
||||
# self.print("tmp/receipt.pdf")
|
||||
# end
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_close_cashier(printer_settings,shift_sale,shop_details)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
time = DateTime.now
|
||||
#Print
|
||||
pdf = CashierStationClosing.new
|
||||
pdf.render_file "tmp/cashier_station_#{order_id}_closing_#{time}.pdf"
|
||||
self.print("tmp/receipt.pdf")
|
||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details)
|
||||
pdf.render_file "tmp/print_close_cashier.pdf"
|
||||
self.print("tmp/print_close_cashier.pdf")
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -94,7 +94,6 @@ class Sale < ApplicationRecord
|
||||
link_order_sale(order.id)
|
||||
|
||||
end
|
||||
|
||||
self.save!
|
||||
|
||||
#compute sales summary
|
||||
@@ -410,8 +409,8 @@ class Sale < ApplicationRecord
|
||||
else
|
||||
## up to 100
|
||||
value = 100 - get_last_no.to_f
|
||||
num += value
|
||||
puts 'up to 100'
|
||||
num += value
|
||||
puts 'up to 100'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -444,6 +443,7 @@ class Sale < ApplicationRecord
|
||||
to_date = sale_date.end_of_day.utc - diff
|
||||
|
||||
total_sale = Sale.select("IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
|
||||
IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
|
||||
IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount,
|
||||
IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
|
||||
IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj")
|
||||
@@ -451,6 +451,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
total_sale.each do |sale|
|
||||
grand_total = sale.grand_total
|
||||
old_grand_total = sale.old_grand_total
|
||||
total_discount = sale.total_discount
|
||||
void_amount = sale.void_amount
|
||||
total = {:sale_date => pay.sale_date,
|
||||
@@ -464,6 +465,7 @@ class Sale < ApplicationRecord
|
||||
:foc_amount => pay.foc_amount,
|
||||
:total_discount => total_discount,
|
||||
:grand_total => grand_total,
|
||||
:old_grand_total => old_grand_total,
|
||||
:void_amount => void_amount,
|
||||
:rounding_adj => sale.rounding_adj}
|
||||
daily_total.push(total)
|
||||
|
||||
@@ -274,6 +274,8 @@ class SalePayment < ApplicationRecord
|
||||
shift = ShiftSale.current_open_shift(self.sale.cashier_id)
|
||||
if !shift.nil?
|
||||
shift.update(self.sale)
|
||||
self.sale.shift_sale_id = shift.id
|
||||
self.sale.save
|
||||
end
|
||||
end
|
||||
|
||||
@@ -332,7 +334,7 @@ class SalePayment < ApplicationRecord
|
||||
}, :timeout => 10)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ class ShiftSale < ApplicationRecord
|
||||
#end
|
||||
end
|
||||
|
||||
def create(opening_balance,current_user)
|
||||
self.cashier_terminal_id = CashierTerminal.first.id
|
||||
def create(opening_balance,cashier_terminal, current_user)
|
||||
self.cashier_terminal_id = cashier_terminal
|
||||
self.shift_started_at = DateTime.now
|
||||
self.employee_id = current_user.id
|
||||
self.opening_balance = opening_balance
|
||||
|
||||
Reference in New Issue
Block a user