bill print format and tax fix
This commit is contained in:
@@ -231,7 +231,7 @@ class Order < ApplicationRecord
|
||||
.joins("left join orders on orders.order_id = booking_orders.order_id")
|
||||
.joins("left join sales on sales.sale_id = bookings.sale_id")
|
||||
.where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::TABLE_TYPE,true)
|
||||
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id")
|
||||
.group("bookings.booking_id")
|
||||
# For PG
|
||||
# booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true
|
||||
# sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id
|
||||
@@ -262,7 +262,7 @@ class Order < ApplicationRecord
|
||||
.joins("left join orders on orders.order_id = booking_orders.order_id")
|
||||
.joins("left join sales on sales.sale_id = bookings.sale_id")
|
||||
.where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::ROOM_TYPE,true)
|
||||
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id")
|
||||
.group("bookings.booking_id")
|
||||
# For PG
|
||||
# booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true
|
||||
# sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id
|
||||
|
||||
@@ -23,8 +23,7 @@ class Sale < ApplicationRecord
|
||||
if (booking)
|
||||
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
|
||||
|
||||
puts booking.booking_orders.length
|
||||
|
||||
booking.booking_orders.each do |order|
|
||||
if booking.sale_id
|
||||
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by)
|
||||
@@ -90,6 +89,8 @@ class Sale < ApplicationRecord
|
||||
order.save
|
||||
|
||||
booking.sale_id = self.id
|
||||
booking.checkout_at = Time.now.utc
|
||||
booking.checkout_by = requested_by.name
|
||||
booking.save
|
||||
|
||||
return true, self.id
|
||||
@@ -190,9 +191,14 @@ class Sale < ApplicationRecord
|
||||
|
||||
# Tax Calculate
|
||||
def apply_tax(total_taxable)
|
||||
#if tax is not apply create new record
|
||||
# self.sale_taxes.each do |existing_tax|
|
||||
# #delete existing and create new
|
||||
# existing_tax.delete
|
||||
# end
|
||||
|
||||
#if tax is not apply create new record
|
||||
self.sale_taxes.each do |existing_tax|
|
||||
SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
|
||||
#delete existing and create new
|
||||
existing_tax.delete
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user