print credit payment
This commit is contained in:
@@ -50,7 +50,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
cashier_info(sale_data, customer_name, latest_order_no)
|
||||
line_items(sale_items,precision,delimiter)
|
||||
all_total(sale_data,precision,delimiter)
|
||||
all_total(sale_data,precision,delimiter,printed_status)
|
||||
|
||||
|
||||
if member_info != nil
|
||||
@@ -94,6 +94,9 @@ class ReceiptBillPdf < Prawn::Document
|
||||
end
|
||||
|
||||
if kbz_pay_status
|
||||
if printed_status == 'credit_payment'
|
||||
printed_status = 'Paid'
|
||||
end
|
||||
kbzpay_qr_generator(printed_status, qr_code)
|
||||
end
|
||||
|
||||
@@ -305,7 +308,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
end
|
||||
|
||||
def all_total(sale_data,precision,delimiter)
|
||||
def all_total(sale_data,precision,delimiter,printed_status)
|
||||
move_down line_move
|
||||
item_name_width = self.item_width
|
||||
y_position = cursor
|
||||
@@ -432,15 +435,20 @@ class ReceiptBillPdf < Prawn::Document
|
||||
end
|
||||
move_down line_move
|
||||
|
||||
sale_payment(sale_data,precision,delimiter)
|
||||
sale_payment(sale_data,precision,delimiter,printed_status)
|
||||
end
|
||||
|
||||
def sale_payment(sale_data,precision,delimiter)
|
||||
def sale_payment(sale_data,precision,delimiter,printed_status)
|
||||
stroke_horizontal_rule
|
||||
#move_down line_move
|
||||
# sql = "SELECT SUM(payment_amount)
|
||||
# FROM sale_payments where payment_method='creditnote'
|
||||
# and sale_id='#{sale_data.sale_id}'"
|
||||
# and sale_id='#{sale_data.sale_id}'"
|
||||
|
||||
if printed_status == 'credit_payment'
|
||||
sale_payments = SalePayment.select(:payment_amount, :payment_method, :updated_at)
|
||||
.where("sale_id = '#{sale_data.sale_id}' AND payment_method != 'creditnote'")
|
||||
else
|
||||
sql = SalePayment.select("(SUM(payment_amount))").where("payment_method='creditnote' and sale_id='#{sale_data.sale_id}'").to_sql
|
||||
# sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
||||
# FROM sale_payments where payment_method='creditnote'
|
||||
@@ -458,13 +466,16 @@ class ReceiptBillPdf < Prawn::Document
|
||||
where sa.sale_id='#{sale_data.sale_id}')) = 0
|
||||
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id)
|
||||
.group("payment_method")
|
||||
|
||||
end
|
||||
|
||||
sale_payments.each do |payment|
|
||||
y_position = cursor
|
||||
if payment.payment_method == "paypar"
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "Redeem Payment", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
elsif printed_status == 'credit_payment'
|
||||
text "#{payment.payment_method.capitalize} Payment on #{payment.updated_at.strftime('%d-%m-%Y')}", :left_margin => -10, :size => self.item_font_size,:align => :left
|
||||
else
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left
|
||||
@@ -741,7 +752,9 @@ class ReceiptBillPdf < Prawn::Document
|
||||
move_down line_move
|
||||
stroke_horizontal_rule
|
||||
move_down line_move
|
||||
|
||||
if printed_status == 'credit_payment'
|
||||
printed_status = 'Paid'
|
||||
end
|
||||
move_down line_move
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width) do
|
||||
|
||||
Reference in New Issue
Block a user