Sha256: 272d86c4e2181cd858af82b44031e9b531cf4383caed2bc4bab90e5c2bc8ac87
Contents?: true
Size: 970 Bytes
Versions: 1
Compression:
Stored size: 970 Bytes
Contents
module LedgerGen class Transaction def initialize @postings = [] @comments = [] end def date(date) @date = date end def payee(payee) @payee = payee end def cleared! @cleared = true end def posting(*args) post = Posting.new @postings << post if args.length > 0 post.account args.shift if args.length > 0 post.amount args[0] end else yield post end end def comment(comment) @comments << comment end def to_s lines = ["#{date_string}#{cleared_string} #{@payee}"] @comments.each do |comment| lines << " ; #{comment}" end @postings.each do |post| lines << " " + post.to_s end lines.join("\n") end private def date_string @date.strftime("%Y/%m/%d") end def cleared_string @cleared ? ' *' : '' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ledger_gen-0.1.0 | lib/ledger_gen/transaction.rb |