From 17409513173051b5401dccf5a7ef56678ea8a041 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 2 Oct 2009 11:23:58 +0200 Subject: [PATCH] Anzeige einer Spalte "Dokument" im Lagerbewegungsbericht mit Verlinkung auf den Beleg, von dem aus Waren ein-/ausgelagert wurden. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Ist nur mit Lieferscheinen getestet, weil bisher nur von Lieferscheinen aus direkt ein-/ausgelagert werden kann, aber der Mechanismus ist bereits für alle Verkaufs- und Einkaufsbelege implementiert. Fix für Bug 1058. --- SL/WH.pm | 68 ++++++++++++++++--- bin/mozilla/wh.pl | 23 ++++++- locale/de/all | 4 ++ locale/de/wh | 4 ++ templates/webpages/wh/journal_filter_de.html | 2 + .../webpages/wh/journal_filter_master.html | 2 + 6 files changed, 91 insertions(+), 12 deletions(-) diff --git a/SL/WH.pm b/SL/WH.pm index 91ac12707..7ef012d91 100644 --- a/SL/WH.pm +++ b/SL/WH.pm @@ -158,13 +158,13 @@ sub transfer_assembly { # Hier wird das prepared Statement für die Schleife über alle Lagerplätze vorbereitet my $transferPartSQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, comment, employee_id, qty, trans_id, trans_type_id) - VALUES (?, ?, ?, ?, ?,(SELECT id FROM employee WHERE login = ?), ?, nextval('id'), + VALUES (?, ?, ?, ?, ?,(SELECT id FROM employee WHERE login = ?), ?, nextval('id'), (SELECT id FROM transfer_type WHERE direction = 'out' AND description = 'used'))|; my $sthTransferPartSQL = prepare_query($form, $dbh, $transferPartSQL); my $kannNichtFertigen =""; # der return-string für die fehlermeldung inkl. welche waren zum fertigen noch fehlen - while (my $hash_ref = $sth_part_qty_assembly->fetchrow_hashref()) { # Schleife für $query=select parts_id,qty from assembly + while (my $hash_ref = $sth_part_qty_assembly->fetchrow_hashref()) { # Schleife für $query=select parts_id,qty from assembly my $partsQTY = $hash_ref->{qty} * $params{qty}; # benötigte teile * anzahl erzeugnisse my $currentPart_ID = $hash_ref->{parts_id}; @@ -215,9 +215,9 @@ sub transfer_assembly { return $kannNichtFertigen; } - # soweit alles gut. Jetzt noch die wirkliche Lagerbewegung für das Erzeugnis ausführen ... + # soweit alles gut. Jetzt noch die wirkliche Lagerbewegung für das Erzeugnis ausführen ... my $transferAssemblySQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, comment, employee_id, qty, trans_id, trans_type_id) - VALUES (?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'), + VALUES (?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'), (SELECT id FROM transfer_type WHERE direction = 'in' AND description = 'stock'))|; my $sthTransferAssemblySQL = prepare_query($form, $dbh, $transferAssemblySQL); do_statement($form, $sthTransferAssemblySQL, $transferAssemblySQL, $params{assembly_id}, $params{dst_warehouse_id}, $params{dst_bin_id}, $params{chargenumber}, $params{comment}, $params{login}, $params{qty}); @@ -328,6 +328,7 @@ sub get_warehouse_journal { "comment" => "i1.comment", "trans_type" => "tt.description", "trans_id" => "i1.trans_id", + "oe_id" => "COALESCE(i1.oe_id, i2.oe_id)", "date" => "i1.itime::DATE", "itime" => "i1.itime", "employee" => "e.name", @@ -407,6 +408,45 @@ sub get_warehouse_journal { my $sth = prepare_execute_query($form, $dbh, $query, @filter_vars, @filter_vars, @filter_vars); + my ($h_oe_id, $q_oe_id); + if ($form->{l_oe_id}) { + $q_oe_id = <fetchrow_hashref(NAME_lc)) { map { /^r_/; $ref->{"$'"} = $ref->{$_} } keys %$ref; @@ -423,10 +463,16 @@ sub get_warehouse_journal { next if (('<=' eq $f_qty_op) && ($qty > $f_qty)); } + if ($h_oe_id && $ref->{oe_id}) { + do_statement($form, $h_oe_id, $q_oe_id, ($ref->{oe_id}) x 4); + $ref->{oe_id_info} = $h_oe_id->fetchrow_hashref() || {}; + } + push @contents, $ref; } $sth->finish(); + $h_oe_id->finish() if $h_oe_id; $main::lxdebug->leave_sub(); @@ -732,7 +778,7 @@ $main::lxdebug->enter_sub(); my $self = shift; my %params = @_; - Common::check_params(\%params, qw(parts_id warehouse_id)); #die brauchen wir + Common::check_params(\%params, qw(parts_id warehouse_id)); #die brauchen wir my $myconfig = \%main::myconfig; my $form = $main::form; @@ -742,10 +788,10 @@ $main::lxdebug->enter_sub(); my $query = qq| SELECT SUM(qty), bin_id, chargenumber FROM inventory where parts_id = ? AND warehouse_id = ? GROUP BY bin_id, chargenumber|; my $sth_QTY = prepare_execute_query($form, $dbh, $query, ,$params{parts_id}, $params{warehouse_id}); #info: aufruf an DBUtils.pm - + my $max_qty_parts = 0; #Initialisierung mit 0 while (my $ref = $sth_QTY->fetchrow_hashref()) { # wir laufen über alle chargen und Lagerorte (s.a. SQL-Query oben) - $max_qty_parts += $ref->{sum}; + $max_qty_parts += $ref->{sum}; } $main::lxdebug->leave_sub(); @@ -763,7 +809,7 @@ $main::lxdebug->enter_sub(); my $self = shift; my %params = @_; - Common::check_params(\%params, qw(parts_id )); #die brauchen wir + Common::check_params(\%params, qw(parts_id )); #die brauchen wir my $myconfig = \%main::myconfig; my $form = $main::form; @@ -773,9 +819,9 @@ $main::lxdebug->enter_sub(); my $query = qq| SELECT partnumber, description FROM parts where id = ? |; my $sth = prepare_execute_query($form, $dbh, $query, ,$params{parts_id}); #info: aufruf zu DBUtils.pm - - my $ref = $sth->fetchrow_hashref(); - my $part_description = $ref->{partnumber} . " " . $ref->{description}; + + my $ref = $sth->fetchrow_hashref(); + my $part_description = $ref->{partnumber} . " " . $ref->{description}; $main::lxdebug->leave_sub(); diff --git a/bin/mozilla/wh.pl b/bin/mozilla/wh.pl index fbe6624f8..69aa541ca 100644 --- a/bin/mozilla/wh.pl +++ b/bin/mozilla/wh.pl @@ -600,7 +600,7 @@ sub generate_journal { $form->{sort} ||= 'date'; my %filter; - my @columns = qw(trans_id date warehouse_from bin_from warehouse_to bin_to partnumber partdescription chargenumber trans_type comment qty employee projectnumber); + my @columns = qw(trans_id date warehouse_from bin_from warehouse_to bin_to partnumber partdescription chargenumber trans_type comment qty employee oe_id projectnumber); # filter stuff map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partnumber description chargenumber); @@ -635,6 +635,7 @@ sub generate_journal { 'qty' => { 'text' => $locale->text('Qty'), }, 'employee' => { 'text' => $locale->text('Employee'), }, 'projectnumber' => { 'text' => $locale->text('Project Number'), }, + 'oe_id' => { 'text' => $locale->text('Document'), }, ); my $href = build_std_url('action=generate_journal', grep { $form->{$_} } @hidden_variables); @@ -659,6 +660,16 @@ sub generate_journal { my $all_units = AM->retrieve_units(\%myconfig, $form); my @contents = WH->get_warehouse_journal(%filter); + my %doc_types = ( 'sales_quotation' => { script => 'oe', title => $locale->text('Sales quotation') }, + 'sales_order' => { script => 'oe', title => $locale->text('Sales Order') }, + 'request_quotation' => { script => 'oe', title => $locale->text('Request quotation') }, + 'purchase_order' => { script => 'oe', title => $locale->text('Purchase Order') }, + 'sales_delivery_order' => { script => 'do', title => $locale->text('Sales delivery order') }, + 'purchase_delivery_order' => { script => 'do', title => $locale->text('Purchase delivery order') }, + 'sales_invoice' => { script => 'is', title => $locale->text('Sales Invoice') }, + 'purchase_invoice' => { script => 'ir', title => $locale->text('Purchase Invoice') }, + ); + foreach $entry (@contents) { $entry->{qty} = $form->format_amount_units('amount' => $entry->{qty}, 'part_unit' => $entry->{partunit}, @@ -681,6 +692,16 @@ sub generate_journal { 'align' => $column_alignment{trans_type}, }; + if ($form->{l_oe_id}) { + $row->{oe_id}->{data} = ''; + my $info = $entry->{oe_id_info}; + + if ($info && $info->{id} && $info->{type} && $doc_types{$info->{type}}) { + $row->{oe_id} = { data => $doc_types{ $info->{type} }->{title} . ' ' . $info->{number}, + link => build_std_url('script=' . $doc_types{ $info->{type} }->{script} . '.pl', 'action=edit', 'id=' . $info->{id}, 'type=' . $info->{type}) }; + } + } + $report->add_data($row); } diff --git a/locale/de/all b/locale/de/all index b40c13a47..e04504e80 100644 --- a/locale/de/all +++ b/locale/de/all @@ -536,6 +536,7 @@ $self->{texts} = { 'Do you want to limit your search?' => 'Wollen Sie Ihre Suche spezialisieren?', 'Do you want to carry this shipping address over to the new purchase order so that the vendor can deliver the goods directly to your customer?' => 'Wollen Sie diese Lieferadresse in den neuen Lieferantenauftrag übernehmen, damit der Händler die Waren direkt an Ihren Kunden liefern kann?', 'Do you want to store the existing onhand values into a new warehouse?' => 'Möchten Sie die vorhandenen Mengendaten in ein Lager übertragen?', + 'Document' => 'Dokument', 'Documents in the WebDAV repository' => 'Dokumente im WebDAV-Repository', 'Done' => 'Fertig', 'Download the backup' => 'Die Sicherungsdatei herunterladen', @@ -1206,10 +1207,12 @@ $self->{texts} = { 'Projects' => 'Projekte', 'Projecttransactions' => 'Projektbuchungen', 'Prozentual/Absolut' => 'Prozentual/Absolut', + 'Purchase Invoice' => 'Einkaufsrechnung', 'Purchase Order' => 'Lieferantenauftrag', 'Purchase Orders' => 'Lieferantenaufträge', 'Purchase Price' => 'Einkaufspreis', 'Purchase Prices' => 'Einkaufspreise', + 'Purchase delivery order' => 'Lieferschein (Einkauf)', 'Purchase invoices' => 'Einkaufsrechnungen', 'Qty' => 'Menge', 'Qty according to delivery order' => 'Menge laut Lieferschein', @@ -1291,6 +1294,7 @@ $self->{texts} = { 'Sales Order' => 'Kundenauftrag', 'Sales Orders' => 'Aufträge', 'Sales and purchase invoices with inventory transactions with taxkeys' => 'Einkaufs- und Verkaufsrechnungen mit Warenbestandsbuchungen mit Steuerschlüsseln', + 'Sales delivery order' => 'Lieferschein (Verkauf)', 'Sales invoice number' => 'Ausgangsrechnungsnummer', 'Sales invoices' => 'Verkaufsrechnungen', 'Sales quotation' => 'Angebot', diff --git a/locale/de/wh b/locale/de/wh index beb9a1cac..ba868404f 100644 --- a/locale/de/wh +++ b/locale/de/wh @@ -68,6 +68,7 @@ $self->{texts} = { 'Dependency loop detected:' => 'Schleife in den Abhängigkeiten entdeckt:', 'Description' => 'Beschreibung', 'Directory' => 'Verzeichnis', + 'Document' => 'Dokument', 'Dunning' => 'Mahnung', 'ELSE' => 'Zusatz', 'Employee' => 'Bearbeiter', @@ -120,7 +121,9 @@ $self->{texts} = { 'Produce Assembly' => 'Erzeugnis fertigen', 'Proforma Invoice' => 'Proformarechnung', 'Project Number' => 'Projektnummer', + 'Purchase Invoice' => 'Einkaufsrechnung', 'Purchase Order' => 'Lieferantenauftrag', + 'Purchase delivery order' => 'Lieferschein (Einkauf)', 'Qty' => 'Menge', 'Quantity missing.' => 'Die Mengenangabe fehlt.', 'Quotation' => 'Angebot', @@ -136,6 +139,7 @@ $self->{texts} = { 'SCREENED' => 'Angezeigt', 'Sales Invoice' => 'Rechnung', 'Sales Order' => 'Kundenauftrag', + 'Sales delivery order' => 'Lieferschein (Verkauf)', 'Sales quotation' => 'Angebot', 'Select a Customer' => 'Endkunde auswählen', 'Select a customer' => 'Einen Kunden auswählen', diff --git a/templates/webpages/wh/journal_filter_de.html b/templates/webpages/wh/journal_filter_de.html index 1093e22a8..2c4765466 100644 --- a/templates/webpages/wh/journal_filter_de.html +++ b/templates/webpages/wh/journal_filter_de.html @@ -181,6 +181,8 @@ + + diff --git a/templates/webpages/wh/journal_filter_master.html b/templates/webpages/wh/journal_filter_master.html index ea3c89276..c76c06cb0 100644 --- a/templates/webpages/wh/journal_filter_master.html +++ b/templates/webpages/wh/journal_filter_master.html @@ -181,6 +181,8 @@ + + -- 2.20.1