From a5927b9c8dd358ab3aac7cf01204774a363b3f78 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 18 Nov 2011 14:58:25 +0100 Subject: [PATCH] =?utf8?q?IR::get=5Fduedate=20aufger=C3=A4umt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/IR.pm | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) 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; } -- 2.20.1