bill print format and tax fix
This commit is contained in:
@@ -55,7 +55,7 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
var cashier="";
|
var cashier="";
|
||||||
var receipt_date="";
|
var receipt_date="";
|
||||||
var sub_total=0;
|
var sub_total=0.0;
|
||||||
var discount_amount=0;
|
var discount_amount=0;
|
||||||
var tax_amount=0;
|
var tax_amount=0;
|
||||||
var grand_total_amount=0;
|
var grand_total_amount=0;
|
||||||
@@ -83,34 +83,35 @@ $(document).ready(function(){
|
|||||||
show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes()
|
show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes()
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#receipt_no").text(receipt_no);
|
|
||||||
$("#cashier").text(cashier == null ? "" : cashier);
|
|
||||||
$("#receipt_date").text(show_date);
|
|
||||||
|
|
||||||
|
|
||||||
//Receipt Charges
|
//Receipt Charges
|
||||||
sub_total += (parse_data.qty*parse_data.price);
|
sub_total += parseFloat(parse_data.price);
|
||||||
|
|
||||||
discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount;
|
discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount;
|
||||||
tax_amount = parse_data.tax_amount;
|
tax_amount = parse_data.tax_amount;
|
||||||
grand_total_amount = parse_data.grand_total_amount;
|
grand_total_amount = parse_data.grand_total_amount;
|
||||||
|
|
||||||
$("#order-sub-total").text(sub_total);
|
|
||||||
// $("#order-food").text('');
|
|
||||||
// $("#order-beverage").text('');
|
|
||||||
$("#order-discount").text(discount_amount);
|
|
||||||
$("#order-Tax").text(tax_amount);
|
|
||||||
$("#order-grand-total").text(grand_total_amount);
|
|
||||||
|
|
||||||
// Ordered Items
|
// Ordered Items
|
||||||
var order_items_rows = "<tr>" +
|
var order_items_rows = "<tr>" +
|
||||||
"<td class='item-name'>" + parse_data.item_name + "</td>" +
|
"<td class='item-name'>" + parse_data.item_name + "</td>" +
|
||||||
"<td class='item-attr'>" + parse_data.qty + "</td>" +
|
"<td class='item-attr'>" + parse_data.qty + "</td>" +
|
||||||
"<td class='item-attr'>" + parse_data.qty*parse_data.price + "</td>" +
|
"<td class='item-attr'>" + parse_data.price + "</td>" +
|
||||||
"</tr>";
|
"</tr>";
|
||||||
|
|
||||||
$("#order-items-table").children("tbody").append(order_items_rows);
|
$("#order-items-table").children("tbody").append(order_items_rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cashier Info
|
||||||
|
$("#receipt_no").text(receipt_no);
|
||||||
|
$("#cashier").text(cashier == null ? "" : cashier);
|
||||||
|
$("#receipt_date").text(show_date);
|
||||||
|
|
||||||
|
// Payment Info
|
||||||
|
$("#order-sub-total").text(sub_total);
|
||||||
|
// $("#order-food").text('');
|
||||||
|
// $("#order-beverage").text('');
|
||||||
|
$("#order-discount").text(discount_amount);
|
||||||
|
$("#order-Tax").text(tax_amount);
|
||||||
|
$("#order-grand-total").text(grand_total_amount);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// End AJAX Call
|
// End AJAX Call
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ class Order < ApplicationRecord
|
|||||||
.joins("left join orders on orders.order_id = booking_orders.order_id")
|
.joins("left join orders on orders.order_id = booking_orders.order_id")
|
||||||
.joins("left join sales on sales.sale_id = bookings.sale_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)
|
.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
|
# For PG
|
||||||
# booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true
|
# 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
|
# 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 orders on orders.order_id = booking_orders.order_id")
|
||||||
.joins("left join sales on sales.sale_id = bookings.sale_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)
|
.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
|
# For PG
|
||||||
# booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true
|
# 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
|
# sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ class Sale < ApplicationRecord
|
|||||||
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
|
||||||
|
|
||||||
puts booking.booking_orders.length
|
|
||||||
booking.booking_orders.each do |order|
|
booking.booking_orders.each do |order|
|
||||||
if booking.sale_id
|
if booking.sale_id
|
||||||
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by)
|
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by)
|
||||||
@@ -90,6 +89,8 @@ class Sale < ApplicationRecord
|
|||||||
order.save
|
order.save
|
||||||
|
|
||||||
booking.sale_id = self.id
|
booking.sale_id = self.id
|
||||||
|
booking.checkout_at = Time.now.utc
|
||||||
|
booking.checkout_by = requested_by.name
|
||||||
booking.save
|
booking.save
|
||||||
|
|
||||||
return true, self.id
|
return true, self.id
|
||||||
@@ -190,9 +191,14 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
# Tax Calculate
|
# Tax Calculate
|
||||||
def apply_tax(total_taxable)
|
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
|
#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
|
#delete existing and create new
|
||||||
existing_tax.delete
|
existing_tax.delete
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
self.page_width = 210
|
self.page_width = 210
|
||||||
self.page_height = 2500
|
self.page_height = 2500
|
||||||
self.margin = 5
|
self.margin = 5
|
||||||
self.price_width = 35
|
self.price_width = 40
|
||||||
self.qty_width = 20
|
self.qty_width = 20
|
||||||
self.total_width = 35
|
self.total_width = 40
|
||||||
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
||||||
self.item_height = 15
|
self.item_height = 15
|
||||||
self.item_description_width = (self.page_width-20) / 2
|
self.item_description_width = (self.page_width-20) / 2
|
||||||
@@ -53,29 +53,36 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
# move_down 2
|
# move_down 2
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
text "Receipt No:", :size => self.item_font_size,:align => :left
|
text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
bounding_box([self.label_width, y_position], :width =>self.item_width) do
|
text "#{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
|
||||||
text "#{sale_data.receipt_no}" , :size => self.item_font_size, :align => :left
|
|
||||||
end
|
end
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
bounding_box([0, y_position], :width =>self.item_width) do
|
||||||
text "Customer:", :size => self.item_font_size,:align => :left
|
text "Waiter: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
|
||||||
end
|
|
||||||
bounding_box([self.label_width,y_position], :width =>self.item_width) do
|
|
||||||
text "#{customer_name}" , :size => self.item_font_size,:align => :left
|
|
||||||
end
|
end
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width =>self.item_width, :height => self.item_height) do
|
||||||
text "Date:", :size => self.item_font_size,:align => :left
|
text "Cashier: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
bounding_box([self.label_width,y_position], :width => self.item_width) do
|
move_down 5
|
||||||
text "#{sale_data.receipt_date.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left
|
|
||||||
|
# bounding_box([self.label_width,y_position], :width =>self.item_width) do
|
||||||
|
# text "#{customer_name}" , :size => self.item_font_size,:align => :left
|
||||||
|
# end
|
||||||
|
# move_down 5
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Time In: #{ sale_data.bookings[0].checkin_at.strftime('%I:%M %p') }", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "Time Out: #{ sale_data.bookings[0].checkout_at.strftime('%I:%M %p') }" , :size => self.item_font_size,:align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
move_down 5
|
move_down 5
|
||||||
@@ -118,7 +125,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
|
||||||
pad_top(15) {
|
pad_top(15) {
|
||||||
text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size, :overflow => :shrink_to_fix
|
text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||||
text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||||
text_box "#{total_price}", :at =>[(item_name_width),y_position], :width =>self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
text_box "#{total_price}", :at =>[(item_name_width),y_position], :width =>self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
@@ -163,7 +170,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
|
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
if sale_data.sale_taxes.length > 1
|
if sale_data.sale_taxes.length > 0
|
||||||
sale_data.sale_taxes.each do |st|
|
sale_data.sale_taxes.each do |st|
|
||||||
move_down 5
|
move_down 5
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
|||||||
@@ -306,12 +306,12 @@
|
|||||||
sub_total = 0
|
sub_total = 0
|
||||||
if @selected_item_type == "Sale"
|
if @selected_item_type == "Sale"
|
||||||
@selected_item.sale_items.each do |sale_item|
|
@selected_item.sale_items.each do |sale_item|
|
||||||
sub_total += (sale_item.qty*sale_item.unit_price)
|
sub_total = sub_total + sale_item.price
|
||||||
%>
|
%>
|
||||||
<tr>
|
<tr>
|
||||||
<td class='item-name'><%= sale_item.product_name %></td>
|
<td class='item-name'><%= sale_item.product_name %></td>
|
||||||
<td class='item-attr'><%= sale_item.qty %></td>
|
<td class='item-attr'><%= sale_item.qty %></td>
|
||||||
<td class='item-attr'><%= sale_item.qty*sale_item.price %></td>
|
<td class='item-attr'><%= sale_item.price %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<%
|
<%
|
||||||
end
|
end
|
||||||
@@ -322,7 +322,7 @@
|
|||||||
# For Order Items
|
# For Order Items
|
||||||
if @selected_item_type == "Order"
|
if @selected_item_type == "Order"
|
||||||
@selected_item.order_items.each do |order_item|
|
@selected_item.order_items.each do |order_item|
|
||||||
sub_total += (order_item.qty*order_item.unit_price)
|
sub_total = sub_total + (order_item.qty*order_item.price)
|
||||||
%>
|
%>
|
||||||
<tr>
|
<tr>
|
||||||
<td class='item-name'><%= order_item.item_name %></td>
|
<td class='item-name'><%= order_item.item_name %></td>
|
||||||
|
|||||||
Reference in New Issue
Block a user