return sprintf("%4d%02d%02d", $year,$mon,$day);
}
+# --buchung-visible
+#
+sub toggle_visibility
+{
+ my $nr = shift;
+ my $query;
+ my @row;
+ my $sth;
+ my $value;
+
+ $query = "SELECT nr,visible FROM sales WHERE nr = $nr";
+ $sth = $dbh->prepare($query);
+ if ($sth && ($rc = $sth->execute) > 0) {
+ @row = $sth->fetchrow_array;
+ $value = $row[1]==1?0:1;
+
+ $query = "UPDATE sales SET visible=$value WHERE nr = $nr";
+ $sth = $dbh->do($query);
+ }
+}
+
sub pay_invoice
{
my $nr = shift;
my $pay = shift;
my $value = $pay==1?1:0;
my $query;
- my @row;
my $sth;
$query = "UPDATE sales SET paid=$value WHERE nr = $nr";
my $sth;
my $d;
+ if (!$opt_all || $opt_all == 0) {
+ if ($where) {
+ $where .= " AND visible = 1";
+ } else {
+ $where .= "visible = 1";
+ }
+ }
+
if ($opt_year) {
if ($where) {
$where .= " AND date ~* '$opt_year'";
print " --buchung-category|-bc [category]\n";
print " --buchung-input|-bi\n";
print " --buchung-unpaid\n";
+ print " --buchung-visible|-bv <nr>\n";
print " --pay <nr> | --unpay <nr>\n";
print " --list-categories|-lc\n";
print " Options:\n";
+ print " --all|-a\n";
print " --verbose|-v\n";
print " --year|-y year\n";
print " --direction|--dir|-d in|out\n";
$term = new Term::ReadLine '';
$i = 0;
+$opt_all = 0;
$opt_verbose = 0;
$opt_year = 0;
&usage() if ($#ARGV == -1);
$ARGV[$i] = "--buchung-category";
} elsif ($ARGV[$i] eq "-bi") {
$ARGV[$i] = "--buchung-input";
+ } elsif ($ARGV[$i] eq "-bv") {
+ $ARGV[$i] = "--buchung-visible";
} elsif ($ARGV[$i] eq "-lc") {
$ARGV[$i] = "--list-categories";
}
} else {
&sales_list();
}
+ } elsif ($ARGV[$i] eq "visible") {
+ if ($i+1 <= $#ARGV && ($ARGV[$i+1] !~ /^-/)) {
+ $i++;
+ &toggle_visibility($ARGV[$i]);
+ }
} elsif ($ARGV[$i] eq "input") {
&buchung_input();
} elsif ($ARGV[$i] eq "unpaid") {
}
} elsif ($ARGV[$i] eq "--dm") {
$table = "sales_dm";
+ } elsif ($ARGV[$i] eq "-a" || $ARGV[$i] eq "--all") {
+ $opt_all = 1;
} elsif ($ARGV[$i] eq "-v" || $ARGV[$i] eq "--verbose") {
$opt_verbose = 1;
}