Revision a5927b9c
Von Sven Schöling vor fast 13 Jahren hinzugefügt
SL/IR.pm | ||
---|---|---|
1464 | 1464 |
} |
1465 | 1465 |
|
1466 | 1466 |
sub get_duedate { |
1467 |
$main::lxdebug->enter_sub();
|
|
1467 |
$::lxdebug->enter_sub;
|
|
1468 | 1468 |
|
1469 |
my $self = shift; |
|
1470 |
my %params = @_; |
|
1469 |
my ($self, %params) = @_; |
|
1471 | 1470 |
|
1472 | 1471 |
if (!$params{vendor_id} || !$params{invdate}) { |
1473 |
$main::lxdebug->leave_sub();
|
|
1472 |
$::lxdebug->leave_sub;
|
|
1474 | 1473 |
return $params{default}; |
1475 | 1474 |
} |
1476 | 1475 |
|
1477 |
my $myconfig = \%main::myconfig; |
|
1478 |
my $form = $main::form; |
|
1479 |
|
|
1480 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
1481 |
|
|
1476 |
my $dbh = $::form->get_standard_dbh; |
|
1482 | 1477 |
my $query = qq|SELECT ?::date + pt.terms_netto |
1483 | 1478 |
FROM vendor v |
1484 | 1479 |
LEFT JOIN payment_terms pt ON (pt.id = v.payment_id) |
1485 | 1480 |
WHERE v.id = ?|; |
1486 | 1481 |
|
1487 |
my ($sth, $duedate); |
|
1488 |
|
|
1489 |
if (($sth = $dbh->prepare($query)) && $sth->execute($params{invdate}, conv_i($params{vendor_id}))) { |
|
1490 |
($duedate) = $sth->fetchrow_array(); |
|
1491 |
$sth->finish(); |
|
1492 |
} else { |
|
1493 |
$dbh->rollback(); |
|
1494 |
} |
|
1482 |
my ($duedate) = selectfirst_array_query($::form, $dbh, $query, $params{invdate}, $params{vendor_id}); |
|
1495 | 1483 |
|
1496 | 1484 |
$duedate ||= $params{default}; |
1497 | 1485 |
|
1498 |
$main::lxdebug->leave_sub();
|
|
1486 |
$::lxdebug->leave_sub;
|
|
1499 | 1487 |
|
1500 | 1488 |
return $duedate; |
1501 | 1489 |
} |
Auch abrufbar als: Unified diff
IR::get_duedate aufgeräumt