From: Moritz Bunkus Date: Tue, 10 Jun 2008 15:28:39 +0000 (+0000) Subject: Anzeige der bereits gelieferten Menge in Aufträgen im Ein- und Verkauf. X-Git-Tag: release-2.6.0beta1~142 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=480d9a56bed666562d3c115fa2da4c09ba66ac8d;p=kivitendo-erp.git Anzeige der bereits gelieferten Menge in Aufträgen im Ein- und Verkauf. --- diff --git a/SL/DO.pm b/SL/DO.pm index 2e61270d5..7f547f0b9 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -161,6 +161,7 @@ sub transactions { my $sth = prepare_query($form, $dbh, $query); foreach my $dord (@{ $form->{DO} }) { + next unless ($dord->{ordnumber}); do_statement($form, $sth, $query, $dord->{ordnumber}); ($dord->{oe_id}) = $sth->fetchrow_array(); } @@ -903,4 +904,46 @@ sub transfer_in_out { $main::lxdebug->leave_sub(); } +sub get_shipped_qty { + $main::lxdebug->enter_sub(); + + my $self = shift; + my %params = @_; + + Common::check_params(\%params, qw(type ordnumber)); + + my $myconfig = \%main::myconfig; + my $form = $main::form; + + my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); + + my $notsales = $params{type} eq 'sales' ? '' : 'NOT'; + + my $query = + qq|SELECT doi.parts_id, doi.qty, doi.unit, p.unit AS partunit + FROM delivery_order_items doi + LEFT JOIN delivery_orders o ON (doi.delivery_order_id = o.id) + LEFT JOIN parts p ON (doi.parts_id = p.id) + WHERE ($notsales o.is_sales) + AND (o.ordnumber = ?)|; + + my %ship = (); + my $entries = selectall_hashref_query($form, $dbh, $query, $params{ordnumber}); + my $all_units = AM->retrieve_all_units(); + + foreach my $entry (@{ $entries }) { + $entry->{qty} *= $all_units->{$entry->{unit}}->{factor} / $all_units->{$entry->{partunit}}->{factor}; + + if (!$ship{$entry->{parts_id}}) { + $ship{$entry->{parts_id}} = $entry; + } else { + $ship{$entry->{parts_id}}->{qty} += $entry->{qty}; + } + } + + $main::lxdebug->leave_sub(); + + return %ship; +} + 1; diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index eb9ca0f62..f5e3fdc81 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -35,7 +35,7 @@ use CGI; use CGI::Ajax; -use List::Util qw(max first); +use List::Util qw(min max first); use SL::CVar; use SL::Common; @@ -111,6 +111,7 @@ sub display_row { my $is_purchase = (first { $_ eq $form->{type} } qw(request_quotation purchase_order purchase_delivery_order)) || ($form->{script} eq 'ir.pl'); my $show_min_order_qty = first { $_ eq $form->{type} } qw(request_quotation purchase_order); my $is_delivery_order = $form->{type} =~ /_delivery_order$/; + my $is_s_p_order = (first { $_ eq $form->{type} } qw(sales_order purchase_order)); if ($is_delivery_order) { $readonly = ' readonly' if ($form->{closed}); @@ -132,8 +133,7 @@ sub display_row { { id => 'runningnumber', width => 5, value => $locale->text('No.'), display => 1, }, { id => 'partnumber', width => 8, value => $locale->text('Number'), display => 1, }, { id => 'description', width => 30, value => $locale->text('Part Description'), display => 1, }, - { id => 'ship', width => 5, value => ($form->{type} eq 'purchase_order' ? $locale->text('Ship rcvd') : $locale->text('Ship')), - display => $form->{type} =~ /sales_order/ || ($form->{type} =~ /purchase_order/ && !($lizenzen && $form->{vc} eq "customer")) , }, + { id => 'ship', width => 5, value => $locale->text('Delivered'), display => $is_s_p_order, }, { id => 'qty', width => 5, value => $locale->text('Qty'), display => 1, }, { id => 'price_factor', width => 5, value => $locale->text('Price Factor'), display => !$is_delivery_order, }, { id => 'unit', width => 5, value => $locale->text('Unit'), display => 1, }, @@ -188,11 +188,14 @@ sub display_row { $projectnumber_labels{$item->{"id"}} = $item->{"projectnumber"}; } + _update_part_information(); + _update_ship() if ($is_s_p_order); + # rows for $i (1 .. $numrows) { # undo formatting - map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(qty ship discount sellprice price_new price_old) unless ($form->{simple_save}); + map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(qty discount sellprice price_new price_old) unless ($form->{simple_save}); # unit begin $form->{"unit_old_$i"} ||= $form->{"unit_$i"}; @@ -250,7 +253,9 @@ sub display_row { $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)", -value => $locale->text('*/')) . $cgi->hidden(-name => "formel_$i", -value => $form->{"formel_$i"}) . $cgi->hidden("-name" => "alu_$i", "-value" => $form->{"alu_$i"}) if $form->{"formel_$i"}; - $column_data{ship} = $cgi->textfield(-name => "ship_$i", -size => 5, -value => $form->format_amount(\%myconfig, $form->{"ship_$i"})); + $column_data{ship} = !$form->{"id_$i"} ? '' : $form->format_amount_units('amount' => $form->{"ship_$i"} * 1, + 'part_unit' => $form->{"partunit_$i"}, + 'max_places' => 2,); # build in drop down list for pricesgroups if ($form->{"prices_$i"}) { @@ -1844,3 +1849,66 @@ sub set_duedate { $lxdebug->leave_sub(); } +sub _update_part_information { + $lxdebug->enter_sub(); + + my %part_information = IC->get_basic_part_info('id' => [ grep { $_ } map { $form->{"id_${_}"} } (1..$form->{rowcount}) ], + 'vendor_id' => $form->{vendor_id}); + + $form->{PART_INFORMATION} = \%part_information; + + foreach my $i (1..$form->{rowcount}) { + next unless ($form->{"id_${i}"}); + + my $info = $form->{PART_INFORMATION}->{$form->{"id_${i}"}} || { }; + $form->{"partunit_${i}"} = $info->{unit}; + } + + $lxdebug->leave_sub(); +} + +sub _update_ship { + $lxdebug->enter_sub(); + + if (!$form->{ordnumber}) { + map { $form->{"ship_$_"} = 0 } (1..$form->{rowcount}); + $lxdebug->leave_sub(); + return; + } + + AM->retrieve_all_units(); + + my %ship = DO->get_shipped_qty('type' => ($form->{type} eq 'purchase_order') ? 'purchase' : 'sales', + 'ordnumber' => $form->{ordnumber},); + + foreach my $i (1..$form->{rowcount}) { + next unless ($form->{"id_${i}"}); + + $form->{"ship_$i"} = 0; + + my $ship_entry = $ship{$form->{"id_$i"}}; + + next if (!$ship_entry || ($ship_entry->{qty} <= 0)); + + my $rowqty = + $form->parse_amount(\%myconfig, $form->{"qty_$i"}) + * $all_units->{$form->{"unit_$i"}}->{factor} + / $all_units->{$form->{"partunit_$i"}}->{factor}; + + $form->{"ship_$i"} = min($rowqty, $ship_entry->{qty}); + $ship_entry->{qty} -= $form->{"ship_$i"}; + } + + foreach my $i (1..$form->{rowcount}) { + next unless ($form->{"id_${i}"}); + + my $ship_entry = $ship{$form->{"id_$i"}}; + + next if (!$ship_entry || ($ship_entry->{qty} <= 0.01)); + + $form->{"ship_$i"} += $ship_entry->{qty}; + $ship_entry->{qty} = 0; + } + + $lxdebug->leave_sub(); +} diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 93f28f020..d121ae9e7 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -33,6 +33,7 @@ use POSIX qw(strftime); +use SL::DO; use SL::FU; use SL::OE; use SL::IR; diff --git a/locale/de/dn b/locale/de/dn index b25e507e1..152f9ffbd 100644 --- a/locale/de/dn +++ b/locale/de/dn @@ -65,6 +65,7 @@ $self->{texts} = { 'Date' => 'Datum', 'Dec' => 'Dez', 'December' => 'Dezember', + 'Delivered' => 'Geliefert', 'Delivery Date' => 'Lieferdatum', 'Delivery Order' => 'Lieferschein', 'Department' => 'Abteilung', @@ -209,8 +210,6 @@ $self->{texts} = { 'September' => 'September', 'Serial No.' => 'Seriennummer', 'Set eMail text' => 'eMail Text eingeben', - 'Ship' => 'Lagerausgang', - 'Ship rcvd' => 'Lagereingang', 'Ship to' => 'Lieferadresse', 'Shipping Address' => 'Lieferadresse', 'Start Dunning Process' => 'Mahnprozess starten', @@ -282,6 +281,8 @@ $self->{subs} = { 'NTI' => 'NTI', 'Q' => 'Q', '_check_io_auth' => '_check_io_auth', + '_update_part_information' => '_update_part_information', + '_update_ship' => '_update_ship', 'add' => 'add', 'build_std_url' => 'build_std_url', 'calculate_qty' => 'calculate_qty', diff --git a/locale/de/do b/locale/de/do index 0e7d3d99a..5b9387676 100644 --- a/locale/de/do +++ b/locale/de/do @@ -302,6 +302,8 @@ $self->{subs} = { 'NTI' => 'NTI', 'Q' => 'Q', '_check_io_auth' => '_check_io_auth', + '_update_part_information' => '_update_part_information', + '_update_ship' => '_update_ship', 'add' => 'add', 'build_std_url' => 'build_std_url', 'calculate_qty' => 'calculate_qty', diff --git a/locale/de/ic b/locale/de/ic index 9f77e79e7..fa8b3698d 100644 --- a/locale/de/ic +++ b/locale/de/ic @@ -74,6 +74,7 @@ $self->{texts} = { 'Dec' => 'Dez', 'December' => 'Dezember', 'Delete' => 'Löschen', + 'Delivered' => 'Geliefert', 'Delivery Date' => 'Lieferdatum', 'Delivery Order' => 'Lieferschein', 'Department' => 'Abteilung', @@ -333,6 +334,8 @@ $self->{subs} = { 'NTI' => 'NTI', 'Q' => 'Q', '_check_io_auth' => '_check_io_auth', + '_update_part_information' => '_update_part_information', + '_update_ship' => '_update_ship', 'acc_menu' => 'acc_menu', 'add' => 'add', 'addtop100' => 'addtop100', diff --git a/locale/de/io b/locale/de/io index 81aa77a08..e995b15e0 100644 --- a/locale/de/io +++ b/locale/de/io @@ -58,6 +58,7 @@ $self->{texts} = { 'Date' => 'Datum', 'Dec' => 'Dez', 'December' => 'Dezember', + 'Delivered' => 'Geliefert', 'Delivery Date' => 'Lieferdatum', 'Delivery Order' => 'Lieferschein', 'Department' => 'Abteilung', @@ -246,6 +247,8 @@ $self->{subs} = { 'NTI' => 'NTI', 'Q' => 'Q', '_check_io_auth' => '_check_io_auth', + '_update_part_information' => '_update_part_information', + '_update_ship' => '_update_ship', 'build_std_url' => 'build_std_url', 'calculate_qty' => 'calculate_qty', 'call_sub' => 'call_sub', diff --git a/locale/de/ir b/locale/de/ir index 799163476..abe868ef8 100644 --- a/locale/de/ir +++ b/locale/de/ir @@ -76,6 +76,7 @@ $self->{texts} = { 'December' => 'Dezember', 'Delete' => 'Löschen', 'Delete drafts' => 'Entwürfe löschen', + 'Delivered' => 'Geliefert', 'Delivery Date' => 'Lieferdatum', 'Delivery Order' => 'Lieferschein', 'Department' => 'Abteilung', @@ -317,6 +318,8 @@ $self->{subs} = { 'NTI' => 'NTI', 'Q' => 'Q', '_check_io_auth' => '_check_io_auth', + '_update_part_information' => '_update_part_information', + '_update_ship' => '_update_ship', 'add' => 'add', 'build_std_url' => 'build_std_url', 'calculate_qty' => 'calculate_qty', diff --git a/locale/de/is b/locale/de/is index a4592f80e..78cb98cf8 100644 --- a/locale/de/is +++ b/locale/de/is @@ -86,6 +86,7 @@ $self->{texts} = { 'December' => 'Dezember', 'Delete' => 'Löschen', 'Delete drafts' => 'Entwürfe löschen', + 'Delivered' => 'Geliefert', 'Delivery Date' => 'Lieferdatum', 'Delivery Order' => 'Lieferschein', 'Department' => 'Abteilung', @@ -342,6 +343,8 @@ $self->{subs} = { 'NTI' => 'NTI', 'Q' => 'Q', '_check_io_auth' => '_check_io_auth', + '_update_part_information' => '_update_part_information', + '_update_ship' => '_update_ship', 'add' => 'add', 'build_std_url' => 'build_std_url', 'calculate_qty' => 'calculate_qty', diff --git a/locale/de/login b/locale/de/login index 8db11e03d..5b811b02d 100644 --- a/locale/de/login +++ b/locale/de/login @@ -388,6 +388,8 @@ $self->{subs} = { 'Q' => 'Q', '_check_io_auth' => '_check_io_auth', '_collect_links' => '_collect_links', + '_update_part_information' => '_update_part_information', + '_update_ship' => '_update_ship', 'add' => 'add', 'backorder_exchangerate' => 'backorder_exchangerate', 'build_std_url' => 'build_std_url', diff --git a/locale/de/oe b/locale/de/oe index ad90ba927..983c24fd4 100644 --- a/locale/de/oe +++ b/locale/de/oe @@ -354,6 +354,8 @@ $self->{subs} = { 'NTI' => 'NTI', 'Q' => 'Q', '_check_io_auth' => '_check_io_auth', + '_update_part_information' => '_update_part_information', + '_update_ship' => '_update_ship', 'add' => 'add', 'backorder_exchangerate' => 'backorder_exchangerate', 'build_std_url' => 'build_std_url', diff --git a/locale/de/todo b/locale/de/todo index 0b93d9e1a..4189b2b26 100644 --- a/locale/de/todo +++ b/locale/de/todo @@ -381,6 +381,8 @@ $self->{subs} = { 'Q' => 'Q', '_check_io_auth' => '_check_io_auth', '_collect_links' => '_collect_links', + '_update_part_information' => '_update_part_information', + '_update_ship' => '_update_ship', 'add' => 'add', 'backorder_exchangerate' => 'backorder_exchangerate', 'build_std_url' => 'build_std_url',