From 4e9b1b0261e212d0d7e8c77a2e44cd92610da53a Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Thu, 9 Jan 2014 09:33:32 +0100 Subject: [PATCH] Kreditorenbuchung erzwingt jetzt Eingabe der Rechnungsnummer Behebt #2426 Damit ist das Verhalten wie bei der Einkaufsrechnung. Vorher wurde bei leer gelassener Rechnungsnummer die trans_id als Rechnungsnummer genommen. --- SL/AP.pm | 22 +++++++--------------- bin/mozilla/ap.pl | 3 ++- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/SL/AP.pm b/SL/AP.pm index 8c49bb35f..eabf47112 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -163,32 +163,24 @@ sub post_transaction { do_query($form, $dbh, $query, $form->{id}); } else { - my $uid = rand() . time; - - $uid .= $form->{login}; - - $uid = substr($uid, 2, 75); + ($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('glid')|); + $query = - qq|INSERT INTO ap (invnumber, employee_id,currency_id) | . - qq|VALUES (?, (SELECT e.id FROM employee e WHERE e.login = ?), + qq|INSERT INTO ap (id, invnumber, employee_id,currency_id) | . + qq|VALUES (?, ?, (SELECT e.id FROM employee e WHERE e.login = ?), (SELECT id FROM currencies WHERE name = ?) )|; - do_query($form, $dbh, $query, $uid, $form->{login}, $form->{currency}); + do_query($form, $dbh, $query, $form->{id}, $form->{invnumber}, $form->{login}, $form->{currency}); - $query = qq|SELECT a.id FROM ap a - WHERE a.invnumber = ?|; - ($form->{id}) = selectrow_query($form, $dbh, $query, $uid); } - $form->{invnumber} = $form->{id} unless $form->{invnumber}; - $query = qq|UPDATE ap SET - invnumber = ?, transdate = ?, ordnumber = ?, vendor_id = ?, taxincluded = ?, + transdate = ?, ordnumber = ?, vendor_id = ?, taxincluded = ?, amount = ?, duedate = ?, paid = ?, netamount = ?, currency_id = (SELECT id FROM currencies WHERE name = ?), notes = ?, department_id = ?, storno = ?, storno_id = ?, globalproject_id = ?, direct_debit = ? WHERE id = ?|; - @values = ($form->{invnumber}, conv_date($form->{transdate}), + @values = (conv_date($form->{transdate}), $form->{ordnumber}, conv_i($form->{vendor_id}), $form->{taxincluded} ? 't' : 'f', $form->{invtotal}, conv_date($form->{duedate}), $form->{invpaid}, diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index d0eeb4f9d..0bb1a8bc4 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -606,10 +606,11 @@ sub post { my ($inline) = @_; - # check if there is a vendor, invoice and due date + # check if there is a vendor, invoice, due date and invnumber $form->isblank("transdate", $locale->text("Invoice Date missing!")); $form->isblank("duedate", $locale->text("Due Date missing!")); $form->isblank("vendor", $locale->text('Vendor missing!')); + $form->isblank("invnumber", $locale->text('Invoice Number missing!')); if ($myconfig{mandatory_departments} && !$form->{department}) { $form->{saved_message} = $::locale->text('You have to specify a department.'); -- 2.20.1