Set billing_date when directly paying an item
[infodrom.org/service.infodrom.org] / src / InfoCon / buch / infocon
index 341489c..76e0b40 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/perl
 
 #  infocon - Administration tool for InfoCon
-#  Copyright (c) 1998-2003,2005-8,10,11,12,14,15  Martin Schulze <joey@infodrom.org>
+#  Copyright (c) 1998-2003,2005-8,10,11,12,14,15,16  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
@@ -17,8 +17,6 @@
 #  along with this program; if not, write to the Free Software
 #  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
 
-# $Id$
-
 use strict;
 use warnings;
 
@@ -448,7 +446,8 @@ sub buchung_input
 
     $term = new Term::ReadLine '' unless $term;
 
-    my $sth = $dbh->prepare ("INSERT INTO $table (nr,date,pdf,year,category,description,tax_percent,tax_assigned,price,paid) VALUES (?,?,?,?,?,?,?,?,?,?)");
+    my $sth = $dbh->prepare ("INSERT INTO $table (nr,date,pdf,year,category,description,tax_percent,tax_assigned,price,billing_date,paid) " .
+                            "VALUES (?,?,?,?,?,?,?,?,?,?,?)");
 
     print "Buchungseingabe\n\n";
     while ($weiter =~ /[JjYy1]/) {
@@ -456,6 +455,13 @@ sub buchung_input
            if ($f eq 'tax_assigned' && $answers->{'tax_percent'} == 0) {
                $answers->{$f} = 0;
                next;
+           } elsif ($f eq 'paid') {
+               if ($answers->{paid}) {
+                   my @now = localtime(time);
+                   $answers->{billing_date} = sprintf('%04d-%02d-%02d', $now[5]+1900, $now[4]+1, $now[3]);
+               } else {
+                   $answers->{billing_date} = undef;
+               }
            }
            $ans = read_input($f, $fields->{$f});
            $answers->{$f} = $ans;
@@ -470,6 +476,7 @@ sub buchung_input
                      $answers->{tax_percent},
                      $answers->{tax_assigned},
                      $answers->{price},
+                     $answers->{billing_date},
                      $answers->{paid});
 
        $weiter = $answers->{weiter};