From: Moritz Bunkus Date: Tue, 12 Jun 2007 14:09:00 +0000 (+0000) Subject: Eingangsrechnungen: Wirklich das Datum der zuletzt erstellten Rechnung benutzen,... X-Git-Tag: release-2.4.3^2~158 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=043050cb6d383b9dd9cbbc61f08de80a5d933660;p=kivitendo-erp.git Eingangsrechnungen: Wirklich das Datum der zuletzt erstellten Rechnung benutzen, nicht das maximale Datum. --- diff --git a/SL/IR.pm b/SL/IR.pm index 12add2af1..22c1a2866 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -725,11 +725,11 @@ sub retrieve_invoice { my ($query, $sth, $ref, $q_invdate); if (!$form->{id}) { - $q_invdate = qq|, COALESCE((SELECT MAX(transdate) FROM ar), current_date) AS invdate|; + $q_invdate = qq|, COALESCE((SELECT transdate FROM ar WHERE id = (SELECT MAX(id) FROM ar)), current_date) AS invdate|; if ($form->{vendor_id}) { my $vendor_id = $dbh->quote($form->{vendor_id} * 1); $q_invdate .= - qq|, COALESCE((SELECT MAX(transdate) FROM ar), current_date) + + qq|, COALESCE((SELECT transdate FROM ar WHERE id = (SELECT MAX(id) FROM ar)), current_date) + COALESCE((SELECT pt.terms_netto FROM vendor v LEFT JOIN payment_terms pt ON (v.payment_id = pt.id)