}
if ($opt_year) {
- if ($where) {
- $where .= " AND date LIKE '$opt_year%'";
- } else {
- $where .= "date LIKE '$opt_year%'";
- }
+ $where .= " AND " if $where;
+ $where .= sprintf("year = %d", $opt_year);
}
if ($opt_direction) {
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','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 (nr,date,category,description,tax_percent,tax_assigned,price,paid) VALUES (?,?,?,?,?,?,?,?)");
+ my $sth = $dbh->prepare ("INSERT INTO $table (nr,date,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];
$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], $input[7]);
+ $sth->execute (get_next_nr(), date_to_string($input[0]), $input[1], $input[2], $input[3],
+ $input[5], $input[6], $input[7], $input[8]);
$weiter = read_input("Weiter",'j');
- $input[5] = 0.0;
+ $input[6] = 0.0;
}
exit;