From 7faa3a9515d353967da7e81af5ad6039cdcc94c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22flowdy=22=20He=C3=9F?= Date: Sat, 18 Feb 2017 12:51:28 +0100 Subject: [PATCH] Fixed multi-line purpose input for `./trsr charge` --- trsr | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/trsr b/trsr index a992634..fe69a3e 100755 --- a/trsr +++ b/trsr @@ -155,16 +155,18 @@ sub charge_account { while ( defined( my $line = ) ) { _strip_comment_from($line) // next; my ($date, $account, $debit, $credit, $purpose) = $ACCOUNT - ? do { my @columns = split /[,\s]\s*/, $line, 4; + ? do { my @columns = split /[, \t][ ]*/, $line, 4; splice @columns, 1, 0, $ACCOUNT; @columns } - : split /[,\s]\s*/, $line, 5 + : split /[, \t][ ]*/, $line, 5 ; $account = $db->resultset("Account")->find($account) // die "User not found: $account\n"; + chomp $credit if !defined $purpose; + _append_adj_lines_to($purpose); if ( $debit =~ /^\d/ ) { @@ -218,7 +220,7 @@ sub charge_account { }); if ( $debit =~ /^[a-z]/i ) { $targets{ $debit } = $c->credId; } - elsif ( $debit ne q{+} ) { + elsif ( length $debit && $debit ne q{+} ) { croak "Invalid field input: $debit neither number nor name"; } @@ -259,9 +261,8 @@ sub integer_money_value { sub _append_adj_lines_to { my ($has_more, $line); - $DB::single=1; for ( $_[0] //= do { $has_more = 1; } ) { - if ( s/^"// .. s/(?; last if $line eq $/;