update shift close print
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -80,16 +80,6 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
end until count == 0
|
||||
end
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_close_cashier(printer_settings,shift_sale,shop_details)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
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
|
||||
|
||||
#Queue No Print
|
||||
def print_queue_no(printer_settings,queue)
|
||||
#Use CUPS service
|
||||
|
||||
@@ -41,8 +41,10 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
booking.sale_id = sale_id
|
||||
end
|
||||
|
||||
order = booking.booking_orders.take.order
|
||||
link_order_sale(order.id)
|
||||
|
||||
return status, sale_id
|
||||
end
|
||||
end
|
||||
@@ -205,6 +207,33 @@ class Sale < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
#compute - invoice total
|
||||
def compute_by_sale_items(sale_id, sale_itemss, total_discount)
|
||||
sale = Sale.find(sale_id)
|
||||
sales_items = sale_itemss
|
||||
|
||||
#Computation Fields
|
||||
subtotal_price = 0
|
||||
total_taxable = 0
|
||||
rounding_adjustment = 0
|
||||
|
||||
sales_items.each do |item|
|
||||
#compute each item and added to total
|
||||
subtotal_price = subtotal_price + item.price
|
||||
total_taxable = total_taxable + (item.taxable_price * item.qty)
|
||||
end
|
||||
|
||||
compute_tax(sale, total_taxable)
|
||||
sale.total_amount = subtotal_price
|
||||
sale.total_discount = total_discount
|
||||
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax
|
||||
#compute rounding adjustment
|
||||
# adjust_rounding
|
||||
|
||||
sale.save!
|
||||
|
||||
end
|
||||
|
||||
def compute_without_void
|
||||
sales_items = self.sale_items
|
||||
|
||||
@@ -230,6 +259,39 @@ class Sale < ApplicationRecord
|
||||
|
||||
self.save!
|
||||
end
|
||||
|
||||
# Tax Re-Calculte
|
||||
def compute_tax(sale, total_taxable)
|
||||
#if tax is not apply create new record
|
||||
SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
|
||||
#delete existing and create new
|
||||
existing_tax.delete
|
||||
end
|
||||
|
||||
total_tax_amount = 0
|
||||
#tax_profile - list by order_by
|
||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||
|
||||
# #Creat new tax records
|
||||
tax_profiles.each do |tax|
|
||||
sale_tax = SaleTax.new(:sale => sale)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
#include or execulive
|
||||
# sale_tax.tax_payable_amount = total_taxable * tax.rate
|
||||
sale_tax.tax_payable_amount = total_taxable * tax.rate / 100
|
||||
#new taxable amount
|
||||
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||
|
||||
sale_tax.inclusive = tax.inclusive
|
||||
sale_tax.save
|
||||
|
||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||
end
|
||||
|
||||
sale.total_tax = total_tax_amount
|
||||
end
|
||||
|
||||
# Tax Calculate
|
||||
def apply_tax(total_taxable)
|
||||
#if tax is not apply create new record
|
||||
@@ -344,8 +406,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
|
||||
@@ -538,11 +600,12 @@ end
|
||||
|
||||
def get_commerical_tax
|
||||
tax = 0.0
|
||||
self.sale_taxes.each do |tax|
|
||||
if tax.tax_name == "Commerical Tax"
|
||||
tax += tax.tax_payable_amount
|
||||
self.sale_taxes.each do |taxobj|
|
||||
if taxobj.tax_name == "Commerical Tax"
|
||||
tax += taxobj.tax_payable_amount
|
||||
end
|
||||
end
|
||||
return tax
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -54,6 +54,14 @@ class SalePayment < ApplicationRecord
|
||||
remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}"
|
||||
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
|
||||
|
||||
# update complete order items in oqs
|
||||
SaleOrder.where("sale_id = '#{ invoice.sale_id }'").find_each do |sodr|
|
||||
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
||||
aoi.delivery_status = 1
|
||||
aoi.save
|
||||
end
|
||||
end
|
||||
|
||||
return true, self.save
|
||||
else
|
||||
#record an payment in sale-audit
|
||||
@@ -266,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
|
||||
|
||||
@@ -324,7 +334,7 @@ class SalePayment < ApplicationRecord
|
||||
}, :timeout => 10)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
|
||||
@@ -20,16 +20,18 @@ class ShiftSale < ApplicationRecord
|
||||
#if current_user
|
||||
#find open shift where is open today and is not closed and login by current cashier
|
||||
today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||
puts today_date
|
||||
shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
|
||||
# puts today_date
|
||||
# shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
|
||||
|
||||
|
||||
shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}",today_date).take
|
||||
|
||||
return shift
|
||||
#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