From 18567de558741ddb195c8731b12c2e70f14c51fc Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 12 Jun 2007 13:17:36 +0000 Subject: [PATCH] =?utf8?q?Eingangsrechnung:=20Als=20Rechnungsdatum=20wird?= =?utf8?q?=20das=20Datum=20der=20letzten=20Eingangsrechnung=20vorausgew?= =?utf8?q?=C3=A4hlt.=20Zus=C3=A4tzlich=20wird=20das=20F=C3=A4lligkeitsdatu?= =?utf8?q?m=20in=20Abh=C3=A4ngigkeit=20von=20den=20beim=20Lieferanten=20au?= =?utf8?q?sgew=C3=A4hlten=20Zahlungsbedingungen=20gesetzt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/IR.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/SL/IR.pm b/SL/IR.pm index 177a287f0..12add2af1 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -724,7 +724,19 @@ sub retrieve_invoice { my ($query, $sth, $ref, $q_invdate); - $q_invdate = ", current_date AS invdate" unless $form->{id}; + if (!$form->{id}) { + $q_invdate = qq|, COALESCE((SELECT MAX(transdate) 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) + + COALESCE((SELECT pt.terms_netto + FROM vendor v + LEFT JOIN payment_terms pt ON (v.payment_id = pt.id) + WHERE v.id = $vendor_id), + 0) AS duedate|; + } + } # get default accounts and last invoice number -- 2.20.1