From: Sven Schöling Date: Fri, 18 Nov 2011 13:58:25 +0000 (+0100) Subject: IR::get_duedate aufgeräumt X-Git-Tag: release-2.7.0beta1~179 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a5927b9c8dd358ab3aac7cf01204774a363b3f78;p=kivitendo-erp.git IR::get_duedate aufgeräumt --- diff --git a/SL/IR.pm b/SL/IR.pm index 2bb56a720..2c46e8f61 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -1464,38 +1464,26 @@ sub post_payment { } sub get_duedate { - $main::lxdebug->enter_sub(); + $::lxdebug->enter_sub; - my $self = shift; - my %params = @_; + my ($self, %params) = @_; if (!$params{vendor_id} || !$params{invdate}) { - $main::lxdebug->leave_sub(); + $::lxdebug->leave_sub; return $params{default}; } - my $myconfig = \%main::myconfig; - my $form = $main::form; - - my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); - + my $dbh = $::form->get_standard_dbh; my $query = qq|SELECT ?::date + pt.terms_netto FROM vendor v LEFT JOIN payment_terms pt ON (pt.id = v.payment_id) WHERE v.id = ?|; - my ($sth, $duedate); - - if (($sth = $dbh->prepare($query)) && $sth->execute($params{invdate}, conv_i($params{vendor_id}))) { - ($duedate) = $sth->fetchrow_array(); - $sth->finish(); - } else { - $dbh->rollback(); - } + my ($duedate) = selectfirst_array_query($::form, $dbh, $query, $params{invdate}, $params{vendor_id}); $duedate ||= $params{default}; - $main::lxdebug->leave_sub(); + $::lxdebug->leave_sub; return $duedate; }