X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/18567de558741ddb195c8731b12c2e70f14c51fc..ab96e204a2beec2302b1850df50f45a6e67a13c4:/SL/IR.pm?ds=sidebyside diff --git a/SL/IR.pm b/SL/IR.pm index 12add2af1..690c20d84 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -553,6 +553,7 @@ sub post_invoice { curr = ?, department_id = ?, storno = ?, + storno_id = ?, globalproject_id = ?, cp_id = ?, employee_id = ? @@ -564,7 +565,7 @@ sub post_invoice { conv_date($form->{duedate}), $taxzone_id, $form->{taxincluded} ? 't' : 'f', $form->{notes}, $form->{intnotes}, $form->{currency}, conv_i($form->{department_id}), - $form->{storno} ? 't' : 'f', + $form->{storno} ? 't' : 'f', conv_i($form->{storno_id}), conv_i($form->{globalproject_id}), conv_i($form->{cp_id}), conv_i($form->{employee_id}), conv_i($form->{id})); @@ -725,11 +726,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)