fixed conflix after pull split bill

This commit is contained in:
Aung Myo
2018-02-19 14:21:26 +06:30
24 changed files with 977 additions and 275 deletions

View File

@@ -1,7 +1,7 @@
class ReceiptBillA5Pdf < 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, :description_width, :price_num_width
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)
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,survey)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 15
@@ -65,6 +65,12 @@ class ReceiptBillA5Pdf < Prawn::Document
customer(customer_name)
#start card sale trans data
if card_data != nil
card_sale_data(card_data)
end
#end card sale trans data
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
end
@@ -73,6 +79,12 @@ class ReceiptBillA5Pdf < Prawn::Document
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
end
#start for individual payment
if !survey.nil?
individual_payment(sale_data, survey, printer_settings.precision, delimiter)
end
#end for individual payment
sign(sale_data)
footer(printed_status)
@@ -459,6 +471,28 @@ class ReceiptBillA5Pdf < Prawn::Document
end
end
#individual payment per person
def individual_payment(sale_data, survey, precision, delimiter)
per_person = sale_data.grand_total.to_f / survey.total_customer.to_i
move_down 5
stroke_horizontal_rule
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width+50) do
text "Individual amount for #{survey.total_customer} persons", :size => self.item_font_size+1,:align => :left
end
bounding_box([0,y_position], :width =>self.label_width) do
move_down 15
text "Total", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 15
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)} per person", :size => self.item_font_size,:align => :right
end
end
def sign(sale_data)
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
if payment.payment_method == "creditnote"
@@ -513,6 +547,29 @@ class ReceiptBillA5Pdf < Prawn::Document
move_down 10
end
#start card sale trans data
def card_sale_data(card_data)
if card_data != nil && !card_data.empty?
move_down 5
stroke_horizontal_rule
move_down 5
y_position = cursor
card_data.each do |data|
if data['app'] == 'CUP'
data['app'] = 'UNIONPAY'
elsif data['app'] == 'MASTERCARD'
data['app'] = 'MASTER'
end
text "DATE/TIME: #{data['res_date']} #{data['res_time']} ", :size => @item_font_size, :align => :left
text "BATCH NUM: #{data['batch_no']} TRACE#: #{data['trace']}",:size => @item_font_size, :align => :left
text "RREF NUM: #{data['ref_no']} APPR CODE: #{data['app_code']} ",:size => @item_font_size, :align => :left
text "TID: #{data['tid']} ",:size => @item_font_size, :align => :left
text "#{data['app']} #{data['pan']} ",:size => @item_font_size, :align => :left
end
end
end
#check ReceiptBillAltName included
def show_alt_name
bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf

View File

@@ -1,7 +1,7 @@
class ReceiptBillPdf < 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, :description_width, :price_num_width
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)
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,survey)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 0
@@ -79,6 +79,12 @@ class ReceiptBillPdf < Prawn::Document
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
end
#start for individual payment
if !survey.nil?
individual_payment(sale_data, survey, printer_settings.precision, delimiter)
end
#end for individual payment
sign(sale_data)
footer(printed_status)
@@ -474,6 +480,28 @@ class ReceiptBillPdf < Prawn::Document
end
end
#individual payment per person
def individual_payment(sale_data, survey, precision, delimiter)
per_person = sale_data.grand_total.to_f / survey.total_customer.to_i
move_down 5
stroke_horizontal_rule
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width+50) do
text "Individual amount for #{survey.total_customer} persons", :size => self.item_font_size+1,:align => :left
end
bounding_box([0,y_position], :width =>self.label_width) do
move_down 15
text "Total", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 15
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)} per person", :size => self.item_font_size,:align => :right
end
end
def sign(sale_data)
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
if payment.payment_method == "creditnote"