X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fhomebank2ledger;a=blobdiff_plain;f=lib%2FApp%2FHomeBank2Ledger%2FFormatter%2FLedger.pm;h=3a5a71379b6d6941f58c70e47793ed1e9c43c718;hp=677facb02e72a5924617ca4e726424921d9497f7;hb=5047b75a7e4c5df848f343c46d732643c27f8882;hpb=2cb8cd6b61921ef8f051f9066411deb4c829b68d diff --git a/lib/App/HomeBank2Ledger/Formatter/Ledger.pm b/lib/App/HomeBank2Ledger/Formatter/Ledger.pm index 677facb..3a5a713 100644 --- a/lib/App/HomeBank2Ledger/Formatter/Ledger.pm +++ b/lib/App/HomeBank2Ledger/Formatter/Ledger.pm @@ -49,7 +49,8 @@ sub format { Get formatted header. For example, - ; Converted from finances.xhb using homebank2ledger 0.001 + ; Name: My Finances + ; File: path/to/finances.xhb =cut @@ -61,9 +62,9 @@ sub format_header { if (my $name = $self->name) { push @out, "; Name: $name"; } - - my $file = $self->file; - push @out, "; Converted from ${file} using homebank2ledger ${VERSION}"; + if (my $file = $self->file) { + push @out, "; File: $file"; + } push @out, ''; @@ -269,6 +270,13 @@ sub _format_string { return $str; } +sub _quote_string { + my $self = shift; + my $str = shift; + $str =~ s/"/\\"/g; + return "\"$str\""; +} + sub _format_amount { my $self = shift; my $amount = shift; @@ -279,7 +287,10 @@ sub _format_amount { my $num = join($commodity->{dchar}, commify($whole, $commodity->{gchar}), $fraction); - $num = $commodity->{syprf} ? "$commodity->{symbol} $num" : "$num $commodity->{symbol}"; + my $symbol = $commodity->{symbol}; + $symbol = $self->_quote_string($symbol) if $symbol =~ /[0-9\s]/; + + $num = $commodity->{syprf} ? "$symbol $num" : "$num $symbol"; return $num; }