Merge branch 'r-1902001-01' into foodcourt

This commit is contained in:
Thein Lin Kyaw
2020-05-29 13:32:16 +06:30
23 changed files with 724 additions and 508 deletions

View File

@@ -64,7 +64,7 @@ class ReceiptBillPdf < Prawn::Document
cashier_info(sale_data, customer_account, 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
@@ -112,6 +112,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
@@ -323,7 +326,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
@@ -455,16 +458,21 @@ 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 2
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'
@@ -482,13 +490,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
payment_method = payment.payment_method.capitalize
if payment.payment_method == "paymal"
@@ -775,7 +786,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