update customer and receipt old balance

This commit is contained in:
Aung Myo
2017-08-01 12:02:28 +06:30
parent 4f84676547
commit 8762783484
2 changed files with 17 additions and 8 deletions

View File

@@ -280,9 +280,12 @@ class ReceiptBillPdf < Prawn::Document
if rebate_amount["status"] == true
stroke_horizontal_rule
total = 0
balance = 0
rebate_balance =0
redeem = 0
rebate_amount["data"].each do |res|
total = total + res["balance"]
#total redeem amount
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem"
redeem = redeem + res["redeem"]
@@ -292,7 +295,7 @@ class ReceiptBillPdf < Prawn::Document
#total Rebate Earn
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateAccount" && res["status"]== "Rebate"
# balance = balance + res["balance"]
rebate_balance = rebate_balance + res["rebate"]
move_down 5
y_position = cursor
@@ -306,7 +309,7 @@ class ReceiptBillPdf < Prawn::Document
end
# Total Rebate Amount if birthday
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateBonusAccount" && res["status"]== "Rebate"
# balance = balance + res["balance"]
rebate_balance = rebate_balance + res["rebate"]
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
@@ -328,7 +331,12 @@ class ReceiptBillPdf < Prawn::Document
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
old = balance + redeem
if redeem == 0
old = total - rebate_balance
else
old = balance + redeem
end
move_down 5
y_position = cursor
@@ -343,11 +351,11 @@ class ReceiptBillPdf < Prawn::Document
end
if member_info["status"] == true && member_info["data"].present?
balance = 0
total_balance = 0
member_info["data"].each do |res|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
balance = balance + res["balance"]
total_balance = total_balance + res["balance"]
end
@@ -358,7 +366,7 @@ class ReceiptBillPdf < Prawn::Document
text "Total Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end