]> Dogcows Code - chaz/homebank2ledger/blobdiff - lib/App/HomeBank2Ledger/Formatter/Beancount.pm
fix formatting non-fraction amounts
[chaz/homebank2ledger] / lib / App / HomeBank2Ledger / Formatter / Beancount.pm
index 748a0bf31ecdcfd2dd71edc413eefc8dd5f512a3..dc9893499e9a8c3186e03410237dcef7e668282d 100644 (file)
@@ -278,9 +278,13 @@ sub _format_amount {
 
     my $format = "\% .$commodity->{frac}f";
     my ($whole, $fraction) = split(/\./, sprintf($format, $amount));
+    $fraction ||= 0;
 
     # beancount doesn't support different notations
-    my $num = join('.', commify($whole), $fraction);
+    my $num = commify($whole);
+    if ($commodity->{frac}) {
+        $num .= ".$fraction";
+    }
 
     $num = "$num $commodity->{iso}";
 
This page took 0.016967 seconds and 4 git commands to generate.