]> Dogcows Code - chaz/homebank2ledger/blobdiff - lib/App/HomeBank2Ledger/Formatter/Beancount.pm
Version 0.006
[chaz/homebank2ledger] / lib / App / HomeBank2Ledger / Formatter / Beancount.pm
index 2ec6a2c89437bc4b40b39909cce98356ecc12906..7e3f7852bba326f7213d7c592c4fe47938f6c659 100644 (file)
@@ -7,10 +7,11 @@ use warnings;
 use strict;
 
 use App::HomeBank2Ledger::Util qw(commify rtrim);
 use strict;
 
 use App::HomeBank2Ledger::Util qw(commify rtrim);
+use Scalar::Util qw(looks_like_number);
 
 use parent 'App::HomeBank2Ledger::Formatter';
 
 
 use parent 'App::HomeBank2Ledger::Formatter';
 
-our $VERSION = '0.005'; # VERSION
+our $VERSION = '0.006'; # VERSION
 
 my %STATUS_SYMBOLS = (
     cleared => '*',
 
 my %STATUS_SYMBOLS = (
     cleared => '*',
@@ -142,6 +143,13 @@ sub _format_transaction {
         $out[-1] .= ' '.join(' ', @tags);
     }
 
         $out[-1] .= ' '.join(' ', @tags);
     }
 
+    my $metadata = $transaction->{metadata} || {};
+    for my $key (sort keys %$metadata) {
+        my $value = looks_like_number($metadata->{$key}) ? $metadata->{$key}
+                                                         : $self->_format_string($metadata->{$key});
+        push @out, "    ; ${key}: ${value}";
+    }
+
     for my $posting (@postings) {
         my @line;
 
     for my $posting (@postings) {
         my @line;
 
@@ -178,6 +186,13 @@ sub _format_transaction {
         }
 
         push @out, join('', @line);
         }
 
         push @out, join('', @line);
+
+        my $metadata = $posting->{metadata} || {};
+        for my $key (sort keys %$metadata) {
+            my $value = looks_like_number($metadata->{$key}) ? $metadata->{$key}
+                                                             : $self->_format_string($metadata->{$key});
+            push @out, "      ; ${key}: ${value}";
+        }
     }
 
     push @out, '';
     }
 
     push @out, '';
@@ -282,7 +297,7 @@ App::HomeBank2Ledger::Formatter::Beancount - Beancount formatter
 
 =head1 VERSION
 
 
 =head1 VERSION
 
-version 0.005
+version 0.006
 
 =head1 DESCRIPTION
 
 
 =head1 DESCRIPTION
 
This page took 0.01821 seconds and 4 git commands to generate.