X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2FApp%2FHomeBank2Ledger%2FFormatter%2FLedger.pm;h=dcae0ddbd27e12843ec05bcc4695a85561fdb14a;hb=e325852aa9ca67592ca857dd4f38cb3f13a97715;hp=4cf72cb895d169abaa1523139203374396c4270b;hpb=7e41aec36980b1a053b9e54cfd6119a38dd819a3;p=chaz%2Fhomebank2ledger diff --git a/lib/App/HomeBank2Ledger/Formatter/Ledger.pm b/lib/App/HomeBank2Ledger/Formatter/Ledger.pm index 4cf72cb..dcae0dd 100644 --- a/lib/App/HomeBank2Ledger/Formatter/Ledger.pm +++ b/lib/App/HomeBank2Ledger/Formatter/Ledger.pm @@ -10,7 +10,7 @@ use App::HomeBank2Ledger::Util qw(commify rtrim); use parent 'App::HomeBank2Ledger::Formatter'; -our $VERSION = '0.005'; # VERSION +our $VERSION = '0.008'; # VERSION my %STATUS_SYMBOLS = ( cleared => '*', @@ -157,6 +157,12 @@ sub _format_transaction { $memo && " ; $memo", ); + my $metadata = $transaction->{metadata} || {}; + for my $key (sort keys %$metadata) { + my $value = $self->_format_string($metadata->{$key}); + push @out, " ; ${key}: ${value}"; + } + for my $posting (@postings) { my @line; @@ -194,6 +200,12 @@ sub _format_transaction { push @out, join('', @line); + my $metadata = $posting->{metadata} || {}; + for my $key (sort keys %$metadata) { + my $value = $self->_format_string($metadata->{$key}); + push @out, " ; ${key}: ${value}"; + } + if (my $posting_payee = $posting->{payee}) { $posting_payee = $self->_format_string($posting_payee); push @out, " ; Payee: $posting_payee" if $posting_payee ne $payee; @@ -230,8 +242,12 @@ sub _format_amount { my $format = "\% .$commodity->{frac}f"; my ($whole, $fraction) = split(/\./, sprintf($format, $amount)); + $fraction ||= 0; - my $num = join($commodity->{dchar}, commify($whole, $commodity->{gchar}), $fraction); + my $num = commify($whole, $commodity->{gchar}); + if ($commodity->{frac}) { + $num .= $commodity->{dchar} . $fraction; + } my $symbol = $commodity->{symbol}; $symbol = $self->_quote_string($symbol) if $symbol =~ /[0-9\s]/; @@ -255,7 +271,7 @@ App::HomeBank2Ledger::Formatter::Ledger - Ledger formatter =head1 VERSION -version 0.005 +version 0.008 =head1 DESCRIPTION