print format update
This commit is contained in:
@@ -5,9 +5,10 @@
|
||||
//= require_self
|
||||
//= require_tree ./channels
|
||||
|
||||
(function() {
|
||||
this.App || (this.App = {});
|
||||
// Temp Disable
|
||||
// (function() {
|
||||
// this.App || (this.App = {});
|
||||
|
||||
App.cable = ActionCable.createConsumer();
|
||||
// App.cable = ActionCable.createConsumer();
|
||||
|
||||
}).call(this);
|
||||
// }).call(this);
|
||||
|
||||
@@ -12,6 +12,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@selected_item_type="Order"
|
||||
end
|
||||
end
|
||||
puts params[:booking_id]
|
||||
|
||||
@completed_orders = Order.get_completed_order()
|
||||
@booking_orders = Order.get_booking_order_table()
|
||||
|
||||
@@ -30,7 +30,7 @@ class Origami::RequestBillsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total)
|
||||
redirect_to origami_path(sale_order.sale_id)
|
||||
redirect_to origami_path(@sale_data.sale_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -247,8 +247,6 @@ class Order < ApplicationRecord
|
||||
.joins("left join sales on sales.sale_id = bookings.sale_id")
|
||||
.where("sales.sale_status='completed'")
|
||||
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status")
|
||||
|
||||
|
||||
end
|
||||
|
||||
#Origami: Cashier : to view booking order Table
|
||||
@@ -259,7 +257,7 @@ class Order < ApplicationRecord
|
||||
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
||||
.joins("left join orders on orders.order_id = booking_orders.order_id")
|
||||
.joins("left join sales on sales.sale_id = bookings.sale_id")
|
||||
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
|
||||
.where("sales.sale_status<>'completed' and booking_orders.order_id IS NOT NULL 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")
|
||||
|
||||
end
|
||||
@@ -273,7 +271,7 @@ class Order < ApplicationRecord
|
||||
.joins("left join orders on orders.order_id = booking_orders.order_id")
|
||||
.joins("left join sale_orders on sale_orders.order_id = orders.order_id")
|
||||
.joins("left join sales on sales.sale_id = sale_orders.sale_id")
|
||||
.where("sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true)
|
||||
.where("sales.sale_status<>'completed' and sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL 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")
|
||||
|
||||
end
|
||||
@@ -303,7 +301,7 @@ class Order < ApplicationRecord
|
||||
left join order_items on order_items.order_id = orders.order_id
|
||||
left join sale_orders on sale_orders.order_id = orders.order_id
|
||||
left join sales on sales.sale_id = sale_orders.sale_id")
|
||||
.where("sales.sale_status<>'complete' and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
|
||||
.where("sales.sale_status<>'completed' and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
|
||||
.group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id,orders.customer_id")
|
||||
|
||||
end
|
||||
|
||||
@@ -35,26 +35,27 @@ class SaleItem < ApplicationRecord
|
||||
beverage_prices=0
|
||||
|
||||
sale_items.each do |si|
|
||||
food_price = self.get_food_price(si.sale_item_id)
|
||||
beverage_price = self.get_beverage_price(si.sale_item_id)
|
||||
food_price, beverage_price = self.get_price(si.sale_item_id)
|
||||
food_prices = food_prices + food_price
|
||||
beverage_prices = beverage_prices + beverage_price
|
||||
end
|
||||
return food_prices, beverage_prices
|
||||
end
|
||||
|
||||
def self.get_food_price(sale_item_id)
|
||||
food=SaleItem.select("sale_items.price")
|
||||
.joins("left join menu_items on menu_items.item_code = sale_items.product_code")
|
||||
.where("sale_items.sale_item_id=? and menu_items.account_id=1", sale_item_id.to_s)
|
||||
food_price = food[0].price rescue 0
|
||||
end
|
||||
def self.get_price(sale_item_id)
|
||||
food_price=0
|
||||
beverage_price=0
|
||||
|
||||
def self.get_beverage_price(sale_item_id)
|
||||
beverage=SaleItem.select("sale_items.price")
|
||||
item=SaleItem.select("sale_items.price , menu_items.account_id")
|
||||
.joins("left join menu_items on menu_items.item_code = sale_items.product_code")
|
||||
.where("sale_items.sale_item_id=? and menu_items.account_id=2", sale_item_id.to_s)
|
||||
beverage_price = beverage[0].price rescue 0
|
||||
.where("sale_items.sale_item_id=?", sale_item_id.to_s)
|
||||
if item[0].account_id == 1
|
||||
food_price = item[0].price
|
||||
else
|
||||
beverage_price = item[0].price
|
||||
end
|
||||
|
||||
return food_price, beverage_price
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
class ReceiptBillPdf < Prawn::Document
|
||||
attr_accessor :receipt_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total)
|
||||
self.page_width = 300
|
||||
self.page_width = 250
|
||||
self.page_height = 1450
|
||||
self.margin = 10
|
||||
self.price_width = 50
|
||||
self.qty_width = 30
|
||||
self.total_width = 50
|
||||
self.item_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.price_width = 40
|
||||
self.qty_width = 20
|
||||
self.total_width = 40
|
||||
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)+(self.margin*4))
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.receipt_width=100
|
||||
self.label_width=80
|
||||
|
||||
# @item_width = self.page_width.to_i / 2
|
||||
# @qty_width = @item_width.to_i / 3
|
||||
@@ -22,8 +22,8 @@ class ReceiptBillPdf < Prawn::Document
|
||||
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
self.header_font_size = 12
|
||||
self.item_font_size = 10
|
||||
self.header_font_size = 11
|
||||
self.item_font_size = 9
|
||||
|
||||
header( printer_settings.printer_name, printer_settings.name)
|
||||
|
||||
@@ -31,66 +31,64 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
cashier_info(sale_data, customer_name)
|
||||
line_items(sale_items, food_total, beverage_total)
|
||||
all_total(sale_data)
|
||||
|
||||
|
||||
all_total(sale_data)
|
||||
footer
|
||||
end
|
||||
|
||||
def header (printer_name, name)
|
||||
text "#{printer_name}", :size => self.header_font_size,:align => :center
|
||||
move_down 5
|
||||
text "#{name}", :size => self.header_font_size,:align => :center
|
||||
# move_down self.item_height
|
||||
move_down 5
|
||||
text "#{printer_name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||
move_down 5
|
||||
text "#{name}", :size => self.header_font_size,:align => :center
|
||||
# move_down self.item_height
|
||||
move_down 5
|
||||
|
||||
stroke_horizontal_rule
|
||||
stroke_horizontal_rule
|
||||
end
|
||||
|
||||
def cashier_info(sale_data, customer_name)
|
||||
move_down 7
|
||||
# move_down 2
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.receipt_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
|
||||
end
|
||||
|
||||
bounding_box([self.receipt_width, y_position], :width =>self.receipt_width) do
|
||||
bounding_box([self.label_width, y_position], :width =>self.item_width) do
|
||||
text "#{sale_data.receipt_no}" , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
move_down 5
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Customer:", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.receipt_width,y_position], :width =>self.receipt_width) do
|
||||
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.receipt_width, :height => self.item_height) do
|
||||
text "Date:", :size => self.item_font_size,:align => :left
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Date:", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.receipt_width,y_position], :width =>self.receipt_width) do
|
||||
text "#{sale_data.receipt_date.strftime('%Y %m %d %h:%m')}" , :size => self.item_font_size,:align => :left
|
||||
bounding_box([self.label_width,y_position], :width => self.item_width) do
|
||||
text "#{sale_data.receipt_date.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
# stroke_horizontal_rule
|
||||
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
end
|
||||
|
||||
def line_items(sale_items, food_total, beverage_total)
|
||||
y_position = cursor
|
||||
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
pad_top(15) {
|
||||
# @item_width.to_i + @half_qty.to_i
|
||||
text_box "Items", :at =>[0,y_position], :width => self.item_width - 20, :height =>self.item_height, :size => self.item_font_size
|
||||
text_box "Price", :at =>[self.item_width-20,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
|
||||
text_box "Qty", :at =>[self.item_width+self.price_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
|
||||
text_box "Total", :at =>[self.item_width+self.price_width+self.qty_width,y_position], :width => self.total_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
|
||||
text_box "Items", :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 "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "Total", :at =>[(self.item_width+self.price_width+2),y_position], :width => self.total_width+2, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
|
||||
}
|
||||
|
||||
@@ -99,88 +97,88 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
add_line_item_row(sale_items, food_total, beverage_total)
|
||||
|
||||
|
||||
end
|
||||
|
||||
def add_line_item_row(sale_items, food_total, beverage_total)
|
||||
item_name_width = self.item_width-20
|
||||
item_name_width = (self.item_width+self.price_width)
|
||||
y_position = cursor
|
||||
move_down 5
|
||||
sub_total = 0.0
|
||||
sale_items.each do |item|
|
||||
sale_items.each do |item|
|
||||
sub_total += (item.qty*item.unit_price)
|
||||
qty = item.qty
|
||||
total_price = item.qty*item.unit_price
|
||||
price = item.unit_price
|
||||
product_name = item.product_name
|
||||
|
||||
|
||||
sub_total += item.qty*item.unit_price
|
||||
qty = item.qty
|
||||
total_price = item.qty*item.unit_price
|
||||
price = item.unit_price
|
||||
product_name = item.product_name
|
||||
|
||||
y_position = cursor
|
||||
|
||||
y_position = cursor
|
||||
pad_top(15) {
|
||||
# @item_width.to_i + @half_qty.to_i
|
||||
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 "#{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.to_i}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{total_price}", :at =>[(item_name_width+2),y_position], :width =>self.total_width+2, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
|
||||
pad_top(15) {
|
||||
# @item_width.to_i + @half_qty.to_i
|
||||
text_box "#{product_name}", :at =>[0,y_position], :width => item_name_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size
|
||||
text_box "#{price}", :at =>[item_name_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
|
||||
text_box "#{qty.to_i}", :at =>[item_name_width+self.price_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
|
||||
text_box "#{total_price}", :at =>[item_name_width+self.price_width+self.qty_width,y_position], :width =>self.total_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
|
||||
|
||||
}
|
||||
move_down 3
|
||||
end
|
||||
}
|
||||
move_down 3
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>item_name_width, :height => self.item_height) do
|
||||
text "Sub Total", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
|
||||
text "#{sub_total}" , :size => self.item_font_size,:align => :right
|
||||
bounding_box([item_name_width,y_position], :width =>self.total_width) do
|
||||
text "#{ sub_total }" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
# Food and Beverage
|
||||
food_beverage_total = food_total.to_s + '/' + beverage_total.to_s
|
||||
food_beverage_total = food_total.to_s + "/" + beverage_total.to_s
|
||||
|
||||
move_down 5
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>(item_name_width), :height => self.item_height) do
|
||||
text "Food/Beverage Total", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
|
||||
bounding_box([item_name_width,y_position], :width =>self.total_width) do
|
||||
text "#{ food_beverage_total }" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
def all_total(sale_data)
|
||||
item_name_width = self.item_width-20
|
||||
item_name_width = self.item_width
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do
|
||||
text "Discount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
|
||||
bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do
|
||||
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do
|
||||
text "Total Tax", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
|
||||
bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do
|
||||
text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
move_down 5
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do
|
||||
text "Grand Total", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
|
||||
bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do
|
||||
text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down 5
|
||||
@@ -188,4 +186,14 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
end
|
||||
|
||||
def footer
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
text "*** Thank You ***", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||
|
||||
move_down 5
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ Rails.application.routes.draw do
|
||||
mount Sidekiq::Web => '/kiq'
|
||||
|
||||
# Action Cable Creation
|
||||
mount ActionCable.server => "/cable"
|
||||
# mount ActionCable.server => "/cable"
|
||||
|
||||
#--------- SmartSales Installation ------------#
|
||||
get 'install' => 'install#index'
|
||||
|
||||
Reference in New Issue
Block a user