Support category from commandline on all actions
authorJoey Schulze <joey@infodrom.org>
Wed, 3 May 2017 23:40:39 +0000 (01:40 +0200)
committerJoey Schulze <joey@infodrom.org>
Mon, 10 Jul 2017 20:48:29 +0000 (22:48 +0200)
src/InfoCon/buch/infocon

index b0d6961..843b378 100755 (executable)
@@ -168,6 +168,11 @@ sub sales_list
        $where .= sprintf("year = %d", $opt_year);
     }
 
+    if (defined $data{category}) {
+       $where .= " AND " if $where;
+       $where .= sprintf("category = %s", $dbh->quote($data{category}));
+    }
+
     if ($opt_direction) {
        if ($opt_direction eq "in") {
            $d = "price >= 0"
@@ -587,9 +592,9 @@ my %options = (
     'verbose' => \$opt_verbose,
     'help' => \&usage,
     'dm' => sub {$table = "sales_dm"},
-    'buchung-input|bi' => \$data{'buchung-input'},
-    'buchung-unpaid|bu' => \$data{'buchung-unpaid'},
-    'buchung-hidden|bh' => \$data{'buchung-hidden'},
+    'buchung-input|bi' => \&buchung_input,
+    'buchung-unpaid|bu' => \&buchung_unpaid,
+    'buchung-hidden|bh' => \&buchung_hidden,
     'list-categories|lc' => \$data{'list-categories'},
     );
 
@@ -624,12 +629,6 @@ if (defined $data{category}) {
        sales_list;
     }
     exit;
-} elsif (defined $data{'buchung-input'}) {
-    buchung_input;
-} elsif (defined $data{'buchung-unpaid'}) {
-    buchung_unpaid;
-} elsif (defined $data{'buchung-hidden'}) {
-    buchung_hidden;
 } elsif (defined $data{'list-categories'}) {
     list_categories;
 } elsif (defined $data{pay}) {