add star printer setting
This commit is contained in:
@@ -82,6 +82,14 @@ For ReceiptBillA5Pdf
|
||||
For ReceiptBillAltName options
|
||||
1) settings/lookups => { type:print_settings, name:ReceiptBillAltName, value:1 }
|
||||
|
||||
For CloseCashierPrint with Star Printer
|
||||
1) settings/print_settings
|
||||
a) Unique Code => CloseCashierStarPdf
|
||||
|
||||
For Sale Items Summary Include at CloseCashierPrint
|
||||
1) settings/print_settings
|
||||
a) Check => Shift Sale Items
|
||||
|
||||
For Bank Integration setting
|
||||
1) rake db:migrate for card_sale_trans, card_settle_trans
|
||||
2) settings/lookups => { type:bank_integration, name: Bank Integration, value:1 }
|
||||
|
||||
@@ -122,9 +122,19 @@ class Reports::SaleitemController < BaseReportController
|
||||
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code('CloseCashierPdf') # SaleItemsPdf
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
print_settings_star = PrintSetting.find_by_unique_code('CloseCashierStarPdf')
|
||||
|
||||
if print_settings.nil?
|
||||
if !print_settings_star.nil?
|
||||
printer = Printer::CashierStationPrinter.new(print_settings_star)
|
||||
printer.print_sale_items_report(print_settings_star, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data)
|
||||
end
|
||||
else
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
printer.print_sale_items_report(print_settings, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data)
|
||||
end
|
||||
|
||||
|
||||
printer.print_sale_items_report(print_settings, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to '/en/reports/saleitem/', notice: 'Printing Completed.'}
|
||||
|
||||
@@ -5,7 +5,12 @@ class PrintSetting < ApplicationRecord
|
||||
def self.get_precision_delimiter
|
||||
setting = PrintSetting.find_by_unique_code("CloseCashierPdf")
|
||||
if setting.nil?
|
||||
setting = PrintSetting.find_by_unique_code("CloseCashierCustomisePdf")
|
||||
star_setting = PrintSetting.find_by_unique_code("CloseCashierStarPdf")
|
||||
if star_setting.nil?
|
||||
setting = PrintSetting.find_by_unique_code("CloseCashierCustomisePdf")
|
||||
else
|
||||
return star_setting
|
||||
end
|
||||
end
|
||||
return setting
|
||||
end
|
||||
|
||||
@@ -84,7 +84,14 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
def print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items)
|
||||
filename = "tmp/reports_sale_items.pdf"
|
||||
|
||||
pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, nil, nil, nil)
|
||||
if print_settings.unique_code == "CloseCashierPdf"
|
||||
pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, nil, nil, nil)
|
||||
puts 'Printing!!!!'
|
||||
end
|
||||
if print_settings.unique_code == "CloseCashierStarPdf"
|
||||
pdf = SaleItemsStarPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, nil, nil, nil)
|
||||
puts 'PrintingStar!!!!'
|
||||
end
|
||||
|
||||
pdf.render_file filename
|
||||
|
||||
|
||||
@@ -2534,6 +2534,15 @@ end
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_shift_sale_items(sh_id)
|
||||
query = Sale.select("sales.shift_sale_id as shift_sale_id, i.account_id as account_id, acc.title as account_name, i.item_instance_code as item_code, i.menu_category_name, i.menu_category_code as menu_category_id, i.product_name as product_name, i.unit_price, i.price as price, i.qty as qty, SUM(i.qty) as total_item, SUM(i.qty * i.unit_price) as grand_total, i.status as status_type, i.remark as remark")
|
||||
.joins("JOIN sale_items i on i.sale_id = sales.sale_id")
|
||||
.joins("JOIN accounts acc on acc.id = i.account_id")
|
||||
.where("sales.shift_sale_id=?", sh_id)
|
||||
.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price")
|
||||
.order("acc.title desc, i.account_id desc, i.menu_category_code desc, i.unit_price asc")
|
||||
end
|
||||
|
||||
def self.pending_sale(type)
|
||||
query = Sale.all
|
||||
query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id")
|
||||
|
||||
233
app/pdf/sale_items_star_pdf.rb
Normal file
233
app/pdf/sale_items_star_pdf.rb
Normal file
@@ -0,0 +1,233 @@
|
||||
class SaleItemsStarPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
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,:text_width
|
||||
|
||||
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, acc_cate_count, menu_cate_count, total_by_acc)
|
||||
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
|
||||
self.page_height = printer_settings.page_height
|
||||
self.header_font_size = printer_settings.header_font_size.to_i
|
||||
self.item_font_size = printer_settings.item_font_size.to_i
|
||||
self.margin = 5
|
||||
self.price_width = 60
|
||||
self.qty_width = 20
|
||||
self.total_width = 40
|
||||
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
||||
self.item_height = 15
|
||||
self.item_description_width = (self.page_width-20) / 2
|
||||
@label_name_width = 50
|
||||
@label_item_width = self.page_width-@label_name_width
|
||||
self.label_width = 100
|
||||
|
||||
self.text_width = (self.page_width - 80) - self.price_width / 3
|
||||
# @item_width = self.page_width.to_i / 2
|
||||
# @qty_width = @item_width.to_i / 3
|
||||
# @double = @qty_width * 1.3
|
||||
# @half_qty = @qty_width / 2
|
||||
#setting page margin and width
|
||||
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
# db font setup
|
||||
if printer_settings.font != ""
|
||||
font_families.update("#{printer_settings.font}" => {
|
||||
:normal => "public/fonts/#{printer_settings.font}.ttf",
|
||||
:italic => "public/fonts/#{printer_settings.font}.ttf",
|
||||
:bold => "public/fonts/#{printer_settings.font}.ttf",
|
||||
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
|
||||
})
|
||||
|
||||
font "#{printer_settings.font}"
|
||||
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||
end
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
#precision checked
|
||||
if printer_settings.precision.to_i > 2
|
||||
printer_settings.precision = 2
|
||||
end
|
||||
#check delimiter
|
||||
if printer_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
|
||||
header( shop_details)
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
sale_details(period, type, account, from_date, to_date, shift)
|
||||
|
||||
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc)
|
||||
end
|
||||
|
||||
def header (shop_details)
|
||||
move_down 7
|
||||
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||
move_down 5
|
||||
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
|
||||
# move_down self.item_height
|
||||
move_down 5
|
||||
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
|
||||
move_down 5
|
||||
|
||||
stroke_horizontal_rule
|
||||
end
|
||||
|
||||
def sale_details(period, type, account, from_date, to_date, shift)
|
||||
move_down 7
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
|
||||
text "Period : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
|
||||
text "#{period}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
|
||||
text "Type : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
|
||||
text "#{type}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
|
||||
text "Account : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
|
||||
text "#{account}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
|
||||
text "From Date : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
|
||||
text "#{ from_date.utc.getlocal.strftime("%d-%m-%Y")}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
|
||||
text "To Date : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
|
||||
text "#{ to_date.utc.getlocal.strftime("%d-%m-%Y")}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
|
||||
text "Shift : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([@label_name_width,y_position], :width => @label_item_width) do
|
||||
text "#{shift}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 10
|
||||
end
|
||||
|
||||
def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc)
|
||||
self.item_width = 73
|
||||
self.price_width = 35
|
||||
item_label_qty_front_width = (self.item_width+self.price_width) + 2
|
||||
item_label_qty_end_width = 32
|
||||
item_label_total_front_width = (self.item_width+self.price_width) + 2
|
||||
item_label_total_end_width = 64
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||
text "Sale Items Summary", :size => self.header_font_size, :align => :center
|
||||
end
|
||||
|
||||
total_items = 0
|
||||
total_amount = 0
|
||||
total_qty = 0
|
||||
sub_total = 0
|
||||
|
||||
arr = Array.new
|
||||
|
||||
unless sale_items.nil?
|
||||
sale_items.each do |item|
|
||||
|
||||
if !arr.include?(item['menu_category_id'])
|
||||
|
||||
unless total_qty == 0 and sub_total == 0
|
||||
total_details('Sub Total', total_qty, sub_total)
|
||||
end
|
||||
|
||||
total_qty = 0
|
||||
sub_total = 0
|
||||
|
||||
move_down 10
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||
text "#{item['menu_category_name']}", :size => self.header_font_size, :align => :left
|
||||
end
|
||||
|
||||
# write_stroke_dash
|
||||
# dash(1, :space => 1, :phase => 1)
|
||||
# stroke_horizontal_rule
|
||||
# move_down 2
|
||||
y_position = cursor
|
||||
pad_top(15) {
|
||||
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 => :left, :overflow => :shrink_to_fix
|
||||
text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
}
|
||||
move_down 2
|
||||
stroke_horizontal_rule
|
||||
end
|
||||
|
||||
|
||||
move_down 3
|
||||
|
||||
y_position = cursor
|
||||
pad_top(15) {
|
||||
bounding_box([0,y_position], :width =>self.item_width) do
|
||||
text "#{item['product_name']}", :size => self.item_font_size, :align => :left#, :overflow => :shrink_to_fix
|
||||
end
|
||||
text_box "#{item['unit_price'].to_i}", :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 "#{item['total_item'].to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{item['grand_total'].to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
}
|
||||
|
||||
if item['total_item'].to_i > 0
|
||||
total_qty += item['total_item'].to_i
|
||||
total_items += item['total_item'].to_i
|
||||
end
|
||||
|
||||
sub_total += item['grand_total'].to_i
|
||||
total_amount += item['grand_total'].to_i
|
||||
arr.push(item['menu_category_id'])
|
||||
end
|
||||
|
||||
# stroke_horizontal_rule
|
||||
total_details('Sub Total', total_qty, sub_total)
|
||||
move_down 5
|
||||
total_details('Total Amount', total_items, total_amount)
|
||||
move_down 10
|
||||
end
|
||||
end
|
||||
|
||||
def total_details(col_name, total_qty, sub_total)
|
||||
self.item_width = 73
|
||||
self.price_width = 35
|
||||
item_label_qty_front_width = (self.item_width+self.price_width) + 2
|
||||
item_label_qty_end_width = 32
|
||||
item_label_total_front_width = (self.item_width+self.price_width) + 2
|
||||
item_label_total_end_width = 64
|
||||
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
y_position = cursor
|
||||
pad_top(15) {
|
||||
text_box "#{col_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||
text_box "#{total_qty.to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{sub_total.to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
@@ -46,6 +46,8 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% puts 'testing!!!!!!' %>
|
||||
<% puts @print_settings.precision.to_i %>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user