Created
September 28, 2012 15:49
-
-
Save thedelchop/3800629 to your computer and use it in GitHub Desktop.
Old code that was hard to read and NOT polite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DEFT | |
class RemittanceSlip | |
def initialize(*credits) | |
@credits = credits | |
end | |
def print | |
output = print_header_record | |
output << print_detail_records_for_credits | |
output << print_detail_record_for_deposit | |
output << print_trailer_record | |
end | |
private | |
def print_header_record | |
"0 01MBL RENTINGSMART PTY LTD 123456RENT PAYMENT#{Date.tomorrow.strftime("%d%m%y")} \n" | |
end | |
def print_detail_records_for_credits | |
output = "" | |
@credits.each do |credit| | |
output << print_detail_record_for(credit) | |
end | |
output | |
end | |
def print_detail_record_for(credit) | |
"1#{credit.bsb_number}#{credit.account_number.rjust(9)} 50#{format_amount(credit.amount)}#{credit.payer_full_name.ljust(32)}RENT PAYMENT 123-456303103352RENTINGSMART LTD00000000\n" | |
end | |
def print_detail_record_for_deposit | |
"1123-456303103352 13#{format_amount(@credits.sum(&:amount))}RENTINGSMART PTY LTD LANDLORD PAYMENTS 123-456303103352RENTINGSMART LTD00000000\n" | |
end | |
def print_trailer_record | |
"7999-999 0000000000#{format_amount(@credits.sum(&:amount))}#{format_amount(@credits.sum(&:amount))} #{number_of_detail_records} # | |
end | |
def format_amount(amount) | |
"%010d" % (amount*100).to_i | |
end | |
def number_of_detail_records | |
"%06d" % (@credits.size + 1) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DEFT | |
class RemittanceSlip | |
def initialize(*credits) | |
@credits = credits | |
end | |
def print | |
output = "" | |
output << "0 01MBL RENTINGSMART PTY LTD 123456RENT PAYMENT#{Date.tomorrow.strftime("%d%m%y")} \n" | |
@credits.each do |credit| | |
output << "1#{credit.bsb_number}#{credit.account_number.rjust(9)} 50#{format_amount(credit.amount)}#{credit.payer_full_name.ljust(32)}RENT PAYMENT 123-456303103352RENTINGSMART LTD00000000\n" | |
end | |
output << "1123-456303103352 13#{format_amount(@credits.sum(&:amount))}RENTINGSMART PTY LTD LANDLORD PAYMENTS 123-456303103352RENTINGSMART LTD00000000\n" | |
output << "7999-999 0000000000#{format_amount(@credits.sum(&:amount))}#{format_amount(@credits.sum(&:amount))} #{number_of_detail_records} # | |
output | |
end | |
def print_header_record | |
end | |
private | |
def format_amount(amount) | |
"%010d" % (amount*100).to_i | |
end | |
def number_of_detail_records | |
"%06d" % (@credits.size + 1) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment