X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fir.pl;h=bbf8340eacc5a27e65e590f72668210bcf8c1863;hb=d03b28772dce973bf100e338e0d09112f06eb328;hp=c599c832510c905ffc83e4e34be8de885a023ae0;hpb=09fe7f33a735ecc3f4a3112ad716f674983b00cc;p=kivitendo-erp.git diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index c599c8325..bbf8340ea 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -1136,6 +1136,19 @@ sub post_payment { $main::lxdebug->leave_sub(); } +sub _max_datepaid { + my $form = $main::form; + + my @dates = sort { $b->[1] cmp $a->[1] } + map { [ $_, $main::locale->reformat_date(\%main::myconfig, $_, 'yyyy-mm-dd') ] } + grep { $_ } + map { $form->{"datepaid_${_}"} } + (1..$form->{rowcount}); + + return @dates ? $dates[0]->[0] : undef; +} + + sub post { $main::lxdebug->enter_sub(); @@ -1162,16 +1175,16 @@ sub post { &validate_items; - my $closedto = $form->datetonum($form->{closedto}, \%myconfig); - my $invdate = $form->datetonum($form->{invdate}, \%myconfig); - my $i = $form->{rowcount}; + my $closedto = $form->datetonum($form->{closedto}, \%myconfig); + my $invdate = $form->datetonum($form->{invdate}, \%myconfig); + my $max_datepaid = _max_datepaid(); - $form->error($locale->text('Cannot post invoice for a closed period!')) - if ($form->date_closed($form->{"datepaid_$i"}, \%myconfig)); + $form->error($locale->text('Cannot post invoice for a closed period!')) if $max_datepaid && $form->date_closed($max_datepaid, \%myconfig); $form->isblank("exchangerate", $locale->text('Exchangerate missing!')) if ($form->{currency} ne $form->{defaultcurrency}); + my $i; for $i (1 .. $form->{paidaccounts}) { if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) { my $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);