#! /usr/bin/perl
# infocon - Administration tool for InfoCon
-# Copyright (c) 1998-2003,2005-8 Martin Schulze <joey@infodrom.org>
+# Copyright (c) 1998-2003,2005-8,10 Martin Schulze <joey@infodrom.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
}
if ($opt_year) {
- if ($where) {
- $where .= " AND date ~* '$opt_year'";
- } else {
- $where .= "date ~* '$opt_year'";
- }
+ $where .= " AND " if $where;
+ $where .= sprintf("year = %d", $opt_year);
}
if ($opt_direction) {
}
}
+ if ($where !~ /visible/) {
+ $where .= " AND " if $where;
+ $where .= "visible = 1";
+ }
+
$query = "SELECT nr,date,description,price FROM $table";
$query .= " WHERE $where" if ($where);
$query .= " ORDER by date,nr";
+
$sth = $dbh->prepare($query);
if ($sth && (my $rc = $sth->execute) > 0) {
print " Nr. Datum Bezeichnung Betrag\n";
my ($date_sec,$date_min,$date_hour,$date_mday,$date_mon,$date_year,$date_wday,$date_isdst)
= localtime;
- $query = sprintf("SELECT DISTINCT description FROM %s WHERE date LIKE '%d%%' ",
+ $query = sprintf("SELECT DISTINCT description FROM %s WHERE year = %d ",
$table, $date_year+1900);
$query .= sprintf("AND category = '%s' ", $category) if defined $category;
$query .= "ORDER by description";
sub buchung_input
{
- my @fieldname = ('Datum','Category','Description','Ein/Aus','Tax percent','Tax assigned','Price','Paid');
+ my @fieldname = ('Datum','PDF','Year','Category','Description','Ein/Aus','Tax percent','Tax assigned','Price','Paid');
my @input = ();
my $weiter = 'y';
my $i;
my $attribs = $term->Attribs;
- my $sth = $dbh->prepare ("INSERT INTO $table VALUES (?,?,?,?,?,?,?,?,?)");
+ my $sth = $dbh->prepare ("INSERT INTO $table (nr,date,pdf,year,category,description,tax_percent,tax_assigned,price,paid) VALUES (?,?,?,?,?,?,?,?,?,?)");
print "Buchungseingabe\n\n";
while ($weiter =~ /[JjYy1]/) {
if ($fieldname[$i] eq "Category") {
$attribs->{completion_entry_function} = $attribs->{list_completion_function};
$attribs->{completion_word} = \@categories;
+ } elsif ($fieldname[$i] eq "Year") {
+ $attribs->{completion_entry_function} = $attribs->{list_completion_function};
+ $input[$i] = substr($input[0],-4);
+ $attribs->{completion_word} = $input[$i];
} elsif ($fieldname[$i] eq "Description") {
$attribs->{completion_entry_function} = $attribs->{list_completion_function};
@descriptions = get_descriptions $input[1];
$input[$i] = $ans;
$i++;
}
- } elsif ($fieldname[$i] eq "Paid") {
+ } elsif ($fieldname[$i] eq "Paid" || $fieldname[$i] eq "PDF") {
if ($ans =~ /[1jJyY]/) {
$input[$i] = 1;
} else {
$i++;
}
}
- if (!$input[5]) { # USt selbst berechnen
- if ($input[4] != 0) {
- $input[5] = $input[6] - ($input[6] / ((100+$input[4])/100));
+ if (!$input[6]) { # USt selbst berechnen
+ if ($input[5] != 0) {
+ $input[6] = $input[7] - ($input[7] / ((100+$input[5])/100));
}
}
- if ($input[3] =~ /[EeIi\+]/) {
- $input[5] *= -1 if ($input[5] < 0);
+ if ($input[4] =~ /[EeIi\+]/) {
$input[6] *= -1 if ($input[6] < 0);
+ $input[7] *= -1 if ($input[7] < 0);
} else {
- $input[5] *= -1 if ($input[5] > 0);
$input[6] *= -1 if ($input[6] > 0);
+ $input[7] *= -1 if ($input[7] > 0);
}
- $sth->execute (get_next_nr(), date_to_string($input[0]), $input[1], $input[2], $input[4],
- $input[5], $input[6], 1, $input[7]);
+ $sth->execute (get_next_nr(), date_to_string($input[0]), $input[1], $input[2], $input[3], $input[4],
+ $input[6], $input[7], $input[8], $input[9]);
$weiter = read_input("Weiter",'j');
- $input[5] = 0.0;
+ $input[6] = 0.0;
}
exit;
'hide=s' => \$data{hide},
'unhide=s' => \$data{unhide},
'year=i' => \$opt_year,
- 'direction=s' => \$opt_direction,
+ 'direction|d=s' => \$opt_direction,
'mailto:s' => \$data{mailto},
'all' => \$opt_all,
'verbose' => \$opt_verbose,
} elsif (defined $data{'list-categories'}) {
list_categories;
} elsif (defined $data{pay}) {
- pay_invoce($data{pay}, 1);
+ pay_invoice($data{pay}, 1);
} elsif (defined $data{unpay}) {
- pay_invoce($data{unpay}, 0);
+ pay_invoice($data{unpay}, 0);
} elsif (defined $data{hide}) {
- hide_invoce($data{hide}, 1);
+ hide_invoice($data{hide}, 1);
} elsif (defined $data{unhide}) {
- hide_invoce($data{unhide}, 0);
+ hide_invoice($data{unhide}, 0);
+} else {
+ usage;
}
-
-usage;