Other Charges added to CloseCashierPdf and SaleItemsPdf
This commit is contained in:
@@ -95,6 +95,8 @@ class Origami::ShiftsController < BaseOrigamiController
|
|||||||
@lookup = Lookup.shift_sale_items_lookup_value
|
@lookup = Lookup.shift_sale_items_lookup_value
|
||||||
if @lookup.to_i == 1
|
if @lookup.to_i == 1
|
||||||
@sale_items = Sale.get_shift_sale_items(@shift.id)
|
@sale_items = Sale.get_shift_sale_items(@shift.id)
|
||||||
|
other_charges = Sale.get_other_charges()
|
||||||
|
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
|
||||||
end
|
end
|
||||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||||
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
||||||
@@ -123,7 +125,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
find_close_cashier_print = Lookup.collection_of('close_cashier_print')
|
find_close_cashier_print = Lookup.collection_of('close_cashier_print')
|
||||||
if find_close_cashier_print[0][1].to_i > 0
|
if find_close_cashier_print[0][1].to_i > 0
|
||||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
|||||||
# self.print(filename, cashier_terminal.printer_name)
|
# self.print(filename, cashier_terminal.printer_name)
|
||||||
# end
|
# end
|
||||||
|
|
||||||
def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items, total_other_charges_info,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
|
|
||||||
if !sale_items.blank? or !sale_items.nil?
|
if !sale_items.blank? or !sale_items.nil?
|
||||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||||
@@ -59,7 +59,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
|||||||
cashier = shift_sale.employee.name
|
cashier = shift_sale.employee.name
|
||||||
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
|
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
|
||||||
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
||||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
|
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
|
||||||
|
|
||||||
if !close_cashier_pdf.empty?
|
if !close_cashier_pdf.empty?
|
||||||
@@ -68,7 +68,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
|||||||
if close_cashier[1] == '1'
|
if close_cashier[1] == '1'
|
||||||
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
else
|
else
|
||||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1016,8 +1016,8 @@ def self.get_item_query(type)
|
|||||||
query = query.joins(" JOIN accounts acc ON acc.id = i.account_id")
|
query = query.joins(" JOIN accounts acc ON acc.id = i.account_id")
|
||||||
query = query.where("#{sale_type}")
|
query = query.where("#{sale_type}")
|
||||||
query = query.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price")
|
query = query.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, SUM(i.qty) desc, i.menu_category_code desc, i.unit_price asc")
|
.order("acc.title desc, i.account_id desc, i.menu_category_code desc, i.item_instance_code asc, SUM(i.qty) desc, i.unit_price asc")
|
||||||
# query = query.order("SUM(i.qty) desc")
|
# query = query.order("i.menu_category_name asc, SUM(i.qty) desc")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_other_charges()
|
def self.get_other_charges()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
include ActionView::Helpers::NumberHelper
|
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
|
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, shift_sale, sale_items, acc_cate_count, menu_cate_count, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
def initialize(printer_settings, shift_sale, sale_items, total_other_charges_info, acc_cate_count, menu_cate_count, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||||
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
|
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
|
||||||
self.page_height = printer_settings.page_height
|
self.page_height = printer_settings.page_height
|
||||||
self.header_font_size = printer_settings.header_font_size.to_i
|
self.header_font_size = printer_settings.header_font_size.to_i
|
||||||
@@ -57,7 +57,7 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
|
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
|
||||||
|
|
||||||
if !sale_items.nil? or !sale_items.blank?
|
if !sale_items.nil? or !sale_items.blank?
|
||||||
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges)
|
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges_info)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -505,13 +505,6 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges)
|
def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges)
|
||||||
self.item_width = 73
|
|
||||||
self.price_width = 60
|
|
||||||
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
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||||
text "Sale Items Summary", :size => self.header_font_size, :align => :center
|
text "Sale Items Summary", :size => self.header_font_size, :align => :center
|
||||||
@@ -547,33 +540,23 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
text "#{item['menu_category_name']}", :size => self.header_font_size, :align => :left
|
text "#{item['menu_category_name']}", :size => self.header_font_size, :align => :left
|
||||||
end
|
end
|
||||||
|
|
||||||
# write_stroke_dash
|
add_item_line('Items', 'Price', 'Qty', 'Total')
|
||||||
# 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 => :right, :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
|
move_down 2
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
move_down 3
|
move_down 3
|
||||||
|
|
||||||
y_position = cursor
|
# y_position = cursor
|
||||||
pad_top(15) {
|
# pad_top(15) {
|
||||||
bounding_box([0,y_position], :width =>self.item_width) do
|
# 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
|
# text "#{item['product_name']}", :size => self.item_font_size, :align => :left#, :overflow => :shrink_to_fix
|
||||||
end
|
# 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['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['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
|
# 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
|
||||||
}
|
# }
|
||||||
|
add_item_line(item['product_name'], item['unit_price'].to_i, item['total_item'].to_i, item['grand_total'].to_i)
|
||||||
|
|
||||||
if item['total_item'].to_i > 0 or item['status_type'] == 'foc' or item['status_type'] == 'void'
|
if item['total_item'].to_i > 0 or item['status_type'] == 'foc' or item['status_type'] == 'void'
|
||||||
total_qty += item['total_item'].to_i
|
total_qty += item['total_item'].to_i
|
||||||
@@ -589,16 +572,66 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
total_details('Sub Total', total_qty, sub_total)
|
total_details('Sub Total', total_qty, sub_total)
|
||||||
move_down 5
|
move_down 5
|
||||||
|
total_other_amount, total_other_item = other_charges_detail(total_other_charges)
|
||||||
|
|
||||||
|
total_items += total_other_item
|
||||||
|
total_amount += total_other_amount
|
||||||
move_down 5
|
move_down 5
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
total_details('Total Amount', total_items, total_amount)
|
total_details('Total Amount', total_items, total_amount)
|
||||||
|
|
||||||
# other_charges = get_other_charges(total_other_charges)
|
|
||||||
total_details('Total Other Amount', nil, total_other_charges)
|
|
||||||
move_down 20
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def other_charges_detail(total_other_charges)
|
||||||
|
total_charges = 0
|
||||||
|
total_charges_items = 0
|
||||||
|
|
||||||
|
unless total_other_charges.nil?
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||||
|
text "Other Charges", :size => self.header_font_size, :align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
add_item_line('Items', 'Price', 'Qty', 'Total')
|
||||||
|
move_down 2
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
total_other_charges.each do |charges|
|
||||||
|
move_down 3
|
||||||
|
add_item_line(charges['product_name'], charges['unit_price'].to_i, charges['total_item'].to_i, charges['grand_total'].to_i)
|
||||||
|
|
||||||
|
total_charges_items += charges['total_item'].to_i
|
||||||
|
total_charges += charges['grand_total'].to_i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
total_details('Total Charges Amount', total_charges_items, total_charges)
|
||||||
|
|
||||||
|
return total_charges, total_charges_items
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_item_line(product_name, unit_price, total_item, grand_total)
|
||||||
|
self.item_width = 73
|
||||||
|
self.price_width = 60
|
||||||
|
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
|
||||||
|
pad_top(15) {
|
||||||
|
bounding_box([0,y_position], :width =>self.item_width) do
|
||||||
|
text "#{product_name}", :size => self.item_font_size, :align => :left#, :overflow => :shrink_to_fix
|
||||||
|
end
|
||||||
|
text_box "#{unit_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 "#{total_item}", :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 "#{grand_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
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def total_details(col_name, total_qty, sub_total)
|
def total_details(col_name, total_qty, sub_total)
|
||||||
self.item_width = 73
|
self.item_width = 73
|
||||||
self.price_width = 60
|
self.price_width = 60
|
||||||
@@ -607,7 +640,6 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
item_label_total_front_width = (self.item_width+self.price_width) + 2
|
item_label_total_front_width = (self.item_width+self.price_width) + 2
|
||||||
item_label_total_end_width = 64
|
item_label_total_end_width = 64
|
||||||
|
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
pad_top(15) {
|
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 "#{col_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class SaleItemsPdf < Prawn::Document
|
|||||||
sale_details(period, type, account, from_date, to_date, shift)
|
sale_details(period, type, account, from_date, to_date, shift)
|
||||||
|
|
||||||
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges)
|
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges)
|
||||||
|
move_down 10
|
||||||
end
|
end
|
||||||
|
|
||||||
def header (shop_details)
|
def header (shop_details)
|
||||||
@@ -128,13 +129,6 @@ class SaleItemsPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges)
|
def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges)
|
||||||
self.item_width = 73
|
|
||||||
self.price_width = 60
|
|
||||||
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
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||||
text "Sale Items Summary", :size => self.header_font_size, :align => :center
|
text "Sale Items Summary", :size => self.header_font_size, :align => :center
|
||||||
@@ -171,33 +165,14 @@ class SaleItemsPdf < Prawn::Document
|
|||||||
text "#{item['menu_category_name']}", :size => self.header_font_size, :align => :left
|
text "#{item['menu_category_name']}", :size => self.header_font_size, :align => :left
|
||||||
end
|
end
|
||||||
|
|
||||||
# write_stroke_dash
|
add_item_line('Items', 'Price', 'Qty', 'Total')
|
||||||
# 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 => :right, :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
|
move_down 2
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
move_down 3
|
move_down 3
|
||||||
|
add_item_line(item['product_name'], item['unit_price'].to_i, item['total_item'].to_i, item['grand_total'].to_i)
|
||||||
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 or item['status_type'] == 'foc' or item['status_type'] == 'void'
|
if item['total_item'].to_i > 0 or item['status_type'] == 'foc' or item['status_type'] == 'void'
|
||||||
total_qty += item['total_item'].to_i
|
total_qty += item['total_item'].to_i
|
||||||
@@ -213,13 +188,13 @@ class SaleItemsPdf < Prawn::Document
|
|||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
total_details('Sub Total', total_qty, sub_total)
|
total_details('Sub Total', total_qty, sub_total)
|
||||||
move_down 5
|
move_down 5
|
||||||
|
total_other_amount, total_other_item = other_charges_detail(total_other_charges)
|
||||||
|
|
||||||
|
total_items += total_other_item
|
||||||
|
total_amount += total_other_amount
|
||||||
move_down 5
|
move_down 5
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
total_details('Total Amount', total_items, total_amount)
|
total_details('Total Amount', total_items, total_amount)
|
||||||
|
|
||||||
other_charges = get_other_charges(total_other_charges)
|
|
||||||
total_details('Total Other Amount', nil, other_charges)
|
|
||||||
move_down 20
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -239,15 +214,53 @@ class SaleItemsPdf < Prawn::Document
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_other_charges(total_other_charges)
|
def other_charges_detail(total_other_charges)
|
||||||
other_sub_total = 0
|
total_charges = 0
|
||||||
|
total_charges_items = 0
|
||||||
|
|
||||||
unless total_other_charges.nil?
|
unless total_other_charges.nil?
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||||
|
text "Other Charges", :size => self.header_font_size, :align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
add_item_line('Items', 'Price', 'Qty', 'Total')
|
||||||
|
move_down 2
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
total_other_charges.each do |charges|
|
total_other_charges.each do |charges|
|
||||||
other_sub_total += charges.grand_total
|
move_down 3
|
||||||
|
add_item_line(charges['product_name'], charges['unit_price'].to_i, charges['total_item'].to_i, charges['grand_total'].to_i)
|
||||||
|
|
||||||
|
total_charges_items += charges['total_item'].to_i
|
||||||
|
total_charges += charges['grand_total'].to_i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return other_sub_total
|
move_down 5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
total_details('Total Charges Amount', total_charges_items, total_charges)
|
||||||
|
|
||||||
|
return total_charges, total_charges_items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_item_line(product_name, unit_price, total_item, grand_total)
|
||||||
|
self.item_width = 73
|
||||||
|
self.price_width = 60
|
||||||
|
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
|
||||||
|
pad_top(15) {
|
||||||
|
bounding_box([0,y_position], :width =>self.item_width) do
|
||||||
|
text "#{product_name}", :size => self.item_font_size, :align => :left#, :overflow => :shrink_to_fix
|
||||||
|
end
|
||||||
|
text_box "#{unit_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 "#{total_item}", :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 "#{grand_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
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user