insert looktype for receipt bill

This commit is contained in:
NyanLinHtut
2019-07-01 11:11:44 +06:30
parent 66445ed318
commit aca0c390c9
2 changed files with 28 additions and 34 deletions

View File

@@ -290,8 +290,8 @@ settings/lookups => {type:close_cashier_print, name:CloseCashierPrint, value: {0
For Second Display View Setting For Second Display View Setting
settings/lookups => {type:display_type, name: Display Type, value: 2} settings/lookups => {type:display_type, name: Display Type, value: 2}
For show total and service charges in receipt bill For show total before tax in receipt bill
settings/lookups => {type:show_sub_total_and_service_charges, name:Show Sub Total and Service charges, value: {0 or 1}} settings/lookups => {type:show_total_before_tax, name:Show Total Before Tax, value: {0 or 1}}
* ToDo list * ToDo list

View File

@@ -4,13 +4,8 @@ class ReceiptBillPdf < 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, :description_width, :price_num_width, :line_move 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, :description_width, :price_num_width, :line_move
<<<<<<< HEAD
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
=======
def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
>>>>>>> 29ef6c17f910e846500d77b9f91268cb710b3a64
self.page_width = printer_settings.page_width self.page_width = printer_settings.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
@@ -109,13 +104,6 @@ class ReceiptBillPdf < Prawn::Document
shop_note(shop_details) shop_note(shop_details)
end end
<<<<<<< HEAD
=======
if kbz_pay_status
kbzpay_qr_generator(printed_status, qr_code)
end
>>>>>>> 29ef6c17f910e846500d77b9f91268cb710b3a64
footer(printed_status) footer(printed_status)
end end
@@ -340,60 +328,66 @@ class ReceiptBillPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
end end
@Service_Tax_Desc = ""
@Service_Tax_amount = 0 service_tax_desc = ""
@Service_Tax_Rate = 0 service_tax_amount = 0
@Com_Tax_Desc = "" service_tax_rate = 0
@Com_Tax_Amount = 0 com_tax_desc = ""
@Com_Tax_Rate = 0 com_tax_amount = 0
com_tax_rate = 0
if sale_data.sale_taxes.length > 0 if sale_data.sale_taxes.length > 0
incl_tax = "" incl_tax = ""
if sale_data.tax_type == "inclusive" if sale_data.tax_type == "inclusive"
incl_tax = "Incl." incl_tax = "Incl."
end end
find_lookup = Lookup.find_by_lookup_type('show_sub_total_and_service_charges') find_lookup = Lookup.find_by_lookup_type('show_total_before_tax')
if find_lookup.value == '1' if find_lookup.nil? || find_lookup == nil
lookup = Lookup.new(lookup_type: 'show_total_before_tax', name: 'Show Total Before Tax', value: '0')
lookup.save
end
check_lookup_type = Lookup.find_by_lookup_type('show_total_before_tax')
if check_lookup_type.value == '1'
sale_data.sale_taxes.each do |st| sale_data.sale_taxes.each do |st|
if (st.tax_name.include? "Service") if (st.tax_name.include? "Service")
@Service_Tax_Desc = st.tax_name service_tax_desc = st.tax_name
@Service_Tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) service_tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)
if incl_tax if incl_tax
@Service_Tax_Rate = st.tax_rate.to_i service_tax_rate = st.tax_rate.to_i
end end
end end
if (st.tax_name.include? "Commercial") if (st.tax_name.include? "Commercial")
@Com_Tax_Desc = st.tax_name com_tax_desc = st.tax_name
@Com_Tax_Amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) com_tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)
if incl_tax if incl_tax
@Com_Tax_Rate = st.tax_rate.to_i com_tax_rate = st.tax_rate.to_i
end end
end end
end end
move_down line_move move_down line_move
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{ @Service_Tax_Desc } (#{incl_tax} #{ @Service_Tax_Rate }%)", :size => self.item_font_size,:align => :left text "#{ service_tax_desc } (#{incl_tax} #{ service_tax_rate }%)", :size => self.item_font_size,:align => :left
end end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(@Service_Tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right text "#{number_with_precision(service_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end end
move_down line_move move_down line_move
y_position = cursor y_position = cursor
stroke_horizontal_rule stroke_horizontal_rule
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Sub Total + #{@Service_Tax_Desc}", :size => self.item_font_size,:align => :left text "Total Before Tax", :size => self.item_font_size,:align => :left
end end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{@Service_Tax_amount.to_i + @sub_total.to_i}" , :size => self.item_font_size,:align => :right text "#{service_tax_amount.to_i + @sub_total.to_i}" , :size => self.item_font_size,:align => :right
end end
move_down line_move move_down line_move
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{ @Com_Tax_Desc } (#{incl_tax} #{ @Com_Tax_Rate.to_i }%)", :size => self.item_font_size,:align => :left text "#{ com_tax_desc } (#{incl_tax} #{ com_tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
end end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(@Com_Tax_Amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right text "#{number_with_precision(com_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end end
else else
sale_data.sale_taxes.each do |st| sale_data.sale_taxes.each do |st|