From 330cfa6d7507da52bc1c2a3874b46eb23255538f Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 10 Jun 2008 14:44:19 +0000 Subject: [PATCH] =?utf8?q?Bug=20in=20Auflistung=20von=20Lieferscheinen:=20?= =?utf8?q?Gibt=20es=20mehrere=20Auftr=C3=A4ge=20mit=20der=20gleichen=20Auf?= =?utf8?q?tragsnummer,=20und=20wenn=20so=20eine=20Nummer=20bei=20einem=20L?= =?utf8?q?ieferschein=20eingetragen=20war,=20so=20wurden=20diese=20Liefers?= =?utf8?q?cheine=20gleich=20mehrfach=20aufgef=C3=BChrt.=20Die=20Links=20zu?= =?utf8?q?=20den=20Auftr=C3=A4gen=20f=C3=BChrten=20dann=20zus=C3=A4tzlich?= =?utf8?q?=20m=C3=B6glicherweise=20zu=20den=20falschen=20Auftr=C3=A4gen=20?= =?utf8?q?(von=20Verkauf=20in=20Einkauf=20und=20umgekehrt).=20Falsche=20Fo?= =?utf8?q?rm-Typen=20f=C3=BChren=20zu=20falschen=20Datenbankabfragen=20("c?= =?utf8?q?ustomer"=20vs=20"vendor"),=20sodass=20die=20Datenbankabfrage=20i?= =?utf8?q?m=20Einkauf=20tats=C3=A4chlich=20die=20Verkaufslieferscheine=20l?= =?utf8?q?ieferte.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DO.pm | 24 +++++++++++++++++++----- bin/mozilla/do.pl | 4 ++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/SL/DO.pm b/SL/DO.pm index 3be64f819..2e61270d5 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -62,14 +62,12 @@ sub transactions { dord.transaction_description, pr.projectnumber AS globalprojectnumber, e.name AS employee, - sm.name AS salesman, - oe.id AS oe_id + sm.name AS salesman FROM delivery_orders dord LEFT JOIN $vc ct ON (dord.${vc}_id = ct.id) LEFT JOIN employee e ON (dord.employee_id = e.id) LEFT JOIN employee sm ON (dord.salesman_id = sm.id) - LEFT JOIN project pr ON (dord.globalproject_id = pr.id) - LEFT JOIN oe ON ((dord.ordnumber = oe.ordnumber) AND NOT COALESCE(oe.quotation, FALSE))|; + LEFT JOIN project pr ON (dord.globalproject_id = pr.id)|; push @where, ($form->{type} eq 'sales_delivery_order' ? '' : 'NOT ') . qq|COALESCE(dord.is_sales, FALSE)|; @@ -152,7 +150,23 @@ sub transactions { $form->{DO} = selectall_hashref_query($form, $dbh, $query, @values); - $main::lxdebug->dump(0, "DO", $form->{DO}); + if (scalar @{ $form->{DO} }) { + $query = + qq|SELECT id + FROM oe + WHERE NOT COALESCE(quotation, FALSE) + AND (ordnumber = ?) + AND (COALESCE(${vc}_id, 0) != 0)|; + + my $sth = prepare_query($form, $dbh, $query); + + foreach my $dord (@{ $form->{DO} }) { + do_statement($form, $sth, $query, $dord->{ordnumber}); + ($dord->{oe_id}) = $sth->fetchrow_array(); + } + + $sth->finish(); + } $main::lxdebug->leave_sub(); } diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index 79d8172e3..8cc81f854 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -383,7 +383,7 @@ sub search { check_do_access(); - $form->{vc} = $form->{type} eq 'purchase_order' ? 'vendor' : 'customer'; + $form->{vc} = $form->{type} eq 'purchase_delivery_order' ? 'vendor' : 'customer'; $form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 }, @@ -646,7 +646,7 @@ sub invoice { $lxdebug->enter_sub(); check_do_access(); - $auth->assert($form->{type} eq 'purchase_order' || $form->{type} eq 'request_quotation' ? 'vendor_invoice_edit' : 'invoice_edit'); + $auth->assert($form->{type} eq 'purchase_delivery_order' ? 'vendor_invoice_edit' : 'invoice_edit'); $form->{deliverydate} = $form->{transdate}; $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig); -- 2.20.1