From: Joey Schulze Date: Wed, 3 May 2017 23:27:07 +0000 (+0200) Subject: Add support for billing date X-Git-Url: https://git.infodrom.org/?p=infodrom.org%2Fservice.infodrom.org;a=commitdiff_plain;h=e12645b20bad69fe0a953c14e126254d6973149b Add support for billing date --- diff --git a/src/InfoCon/buch/infocon b/src/InfoCon/buch/infocon index 21e5fe7..b0d6961 100755 --- a/src/InfoCon/buch/infocon +++ b/src/InfoCon/buch/infocon @@ -465,6 +465,10 @@ sub buchung_input 'title' => 'bezahlt', 'type' => 'boolean', 'default' => 0}, + 'billing_date' => { + 'title' => 'wann', + 'type' => 'date', + 'validate' => \&validate_date}, 'weiter' => { 'title' => 'Weiter', 'type' => 'boolean', @@ -486,16 +490,19 @@ sub buchung_input if ($f eq 'tax_assigned' && $answers->{'tax_percent'} == 0) { $answers->{$f} = 0; next; - } elsif ($f eq 'paid') { + } + $ans = read_input($f, $fields->{$f}); + $answers->{$f} = $ans; + + if ($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]); + $fields->{'billing_date'}{'default'} = $answers->{'date'}; + $ans = read_input('billing_date', $fields->{'billing_date'}); + $answers->{billing_date} = $ans; } else { $answers->{billing_date} = undef; } } - $ans = read_input($f, $fields->{$f}); - $answers->{$f} = $ans; } $sth->execute(get_next_nr(), @@ -507,7 +514,7 @@ sub buchung_input $answers->{tax_percent}, $answers->{tax_assigned}, $answers->{price}, - $answers->{billing_date}, + defined $answers->{billing_date} ? date_to_string($answers->{billing_date}) : undef, $answers->{paid}); $weiter = $answers->{weiter};