Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 480d9a56

Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt

  • ID 480d9a56bed666562d3c115fa2da4c09ba66ac8d
  • Vorgänger c3c267fe
  • Nachfolger 0bb98f3e

Anzeige der bereits gelieferten Menge in Aufträgen im Ein- und Verkauf.

Unterschiede anzeigen:

bin/mozilla/io.pl
35 35

  
36 36
use CGI;
37 37
use CGI::Ajax;
38
use List::Util qw(max first);
38
use List::Util qw(min max first);
39 39

  
40 40
use SL::CVar;
41 41
use SL::Common;
......
111 111
  my $is_purchase        = (first { $_ eq $form->{type} } qw(request_quotation purchase_order purchase_delivery_order)) || ($form->{script} eq 'ir.pl');
112 112
  my $show_min_order_qty =  first { $_ eq $form->{type} } qw(request_quotation purchase_order);
113 113
  my $is_delivery_order  = $form->{type} =~ /_delivery_order$/;
114
  my $is_s_p_order       = (first { $_ eq $form->{type} } qw(sales_order purchase_order));
114 115

  
115 116
  if ($is_delivery_order) {
116 117
    $readonly             = ' readonly' if ($form->{closed});
......
132 133
    {  id => 'runningnumber', width => 5,     value => $locale->text('No.'),                  display => 1, },
133 134
    {  id => 'partnumber',    width => 8,     value => $locale->text('Number'),               display => 1, },
134 135
    {  id => 'description',   width => 30,    value => $locale->text('Part Description'),     display => 1, },
135
    {  id => 'ship',          width => 5,     value => ($form->{type} eq 'purchase_order' ? $locale->text('Ship rcvd') : $locale->text('Ship')),                 
136
       display => $form->{type} =~ /sales_order/ || ($form->{type} =~ /purchase_order/ && !($lizenzen && $form->{vc} eq "customer")) , },
136
    {  id => 'ship',          width => 5,     value => $locale->text('Delivered'),            display => $is_s_p_order, },
137 137
    {  id => 'qty',           width => 5,     value => $locale->text('Qty'),                  display => 1, },
138 138
    {  id => 'price_factor',  width => 5,     value => $locale->text('Price Factor'),         display => !$is_delivery_order, },
139 139
    {  id => 'unit',          width => 5,     value => $locale->text('Unit'),                 display => 1, },
......
188 188
    $projectnumber_labels{$item->{"id"}} = $item->{"projectnumber"};
189 189
  }
190 190

  
191
  _update_part_information();
192
  _update_ship() if ($is_s_p_order);
193

  
191 194
  # rows
192 195
  for $i (1 .. $numrows) {
193 196

  
194 197
    # undo formatting
195
    map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(qty ship discount sellprice price_new price_old) unless ($form->{simple_save});
198
    map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(qty discount sellprice price_new price_old) unless ($form->{simple_save});
196 199

  
197 200
# unit begin
198 201
    $form->{"unit_old_$i"}      ||= $form->{"unit_$i"};
......
250 253
    $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)", -value => $locale->text('*/'))
251 254
                       . $cgi->hidden(-name => "formel_$i", -value => $form->{"formel_$i"}) . $cgi->hidden("-name" => "alu_$i", "-value" => $form->{"alu_$i"})
252 255
      if $form->{"formel_$i"};
253
    $column_data{ship} = $cgi->textfield(-name => "ship_$i", -size => 5, -value => $form->format_amount(\%myconfig, $form->{"ship_$i"}));
256
    $column_data{ship} = !$form->{"id_$i"} ? '' : $form->format_amount_units('amount'     => $form->{"ship_$i"} * 1,
257
                                                                             'part_unit'  => $form->{"partunit_$i"},
258
                                                                             'max_places' => 2,);
254 259

  
255 260
    # build in drop down list for pricesgroups
256 261
    if ($form->{"prices_$i"}) {
......
1844 1849
  $lxdebug->leave_sub();
1845 1850
}
1846 1851

  
1852
sub _update_part_information {
1853
  $lxdebug->enter_sub();
1854

  
1855
  my %part_information = IC->get_basic_part_info('id'        => [ grep { $_ } map { $form->{"id_${_}"} } (1..$form->{rowcount}) ],
1856
                                                 'vendor_id' => $form->{vendor_id});
1857

  
1858
  $form->{PART_INFORMATION} = \%part_information;
1859

  
1860
  foreach my $i (1..$form->{rowcount}) {
1861
    next unless ($form->{"id_${i}"});
1862

  
1863
    my $info                 = $form->{PART_INFORMATION}->{$form->{"id_${i}"}} || { };
1864
    $form->{"partunit_${i}"} = $info->{unit};
1865
  }
1866

  
1867
  $lxdebug->leave_sub();
1868
}
1869

  
1870
sub _update_ship {
1871
  $lxdebug->enter_sub();
1872

  
1873
  if (!$form->{ordnumber}) {
1874
    map { $form->{"ship_$_"} = 0 } (1..$form->{rowcount});
1875
    $lxdebug->leave_sub();
1876
    return;
1877
  }
1878

  
1879
  AM->retrieve_all_units();
1880

  
1881
  my %ship = DO->get_shipped_qty('type'      => ($form->{type} eq 'purchase_order') ? 'purchase' : 'sales',
1882
                                 'ordnumber' => $form->{ordnumber},);
1883

  
1884
  foreach my $i (1..$form->{rowcount}) {
1885
    next unless ($form->{"id_${i}"});
1886

  
1887
    $form->{"ship_$i"} = 0;
1888

  
1889
    my $ship_entry = $ship{$form->{"id_$i"}};
1890

  
1891
    next if (!$ship_entry || ($ship_entry->{qty} <= 0));
1892

  
1893
    my $rowqty =
1894
      $form->parse_amount(\%myconfig, $form->{"qty_$i"})
1895
      * $all_units->{$form->{"unit_$i"}}->{factor}
1896
      / $all_units->{$form->{"partunit_$i"}}->{factor};
1897

  
1898
    $form->{"ship_$i"}  = min($rowqty, $ship_entry->{qty});
1899
    $ship_entry->{qty} -= $form->{"ship_$i"};
1900
  }
1901

  
1902
  foreach my $i (1..$form->{rowcount}) {
1903
    next unless ($form->{"id_${i}"});
1904

  
1905
    my $ship_entry = $ship{$form->{"id_$i"}};
1906

  
1907
    next if (!$ship_entry || ($ship_entry->{qty} <= 0.01));
1908

  
1909
    $form->{"ship_$i"} += $ship_entry->{qty};
1910
    $ship_entry->{qty}  = 0;
1911
  }
1912

  
1913
  $lxdebug->leave_sub();
1914
}

Auch abrufbar als: Unified diff