Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3c26da16

Von Sven Schöling vor fast 3 Jahren hinzugefügt

  • ID 3c26da167356081ade320617f1fcd6e7f7bd76aa
  • Vorgänger 718ef0d7
  • Nachfolger 968ee0f4

DeliveryOrder: format_number_units wieder zurück auf format_number refactored

format_number_units sollte das verhalten von format_number_unit in Form
emulieren. Das war aber buggy, und das originale Verhalten hat Bernd im
September eh entfernt. Also jetzt ganz normal anzeigen.

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
4 4
use parent qw(SL::Controller::Base);
5 5

  
6 6
use SL::Helper::Flash qw(flash_later);
7
use SL::Helper::Number qw(_format_number_units _parse_number);
7
use SL::Helper::Number qw(_format_number _parse_number);
8 8
use SL::Presenter::Tag qw(select_tag hidden_tag div_tag);
9 9
use SL::Presenter::DeliveryOrder qw(delivery_order_status_line);
10 10
use SL::Locale::String qw(t8);
......
897 897
  my ($self) = @_;
898 898

  
899 899
  my $part    = SL::DB::Part->load_cached($::form->{parts_id}) or die "need parts_id";
900
  my $unit    = SL::DB::Unit->load_cached($::form->{unit}) or die "need unit";
900 901
  my $stock   = $::form->{stock};
901
  my $unit    = $::form->{unit};
902 902
  my $row     = $::form->{row};
903 903
  my $item_id = $::form->{item_id};
904 904
  my $qty     = _parse_number($::form->{qty_as_number});
......
908 908
  my @contents   = DO->get_item_availability(parts_id => $part->id);
909 909
  my $stock_info = DO->unpack_stock_information(packed => $stock);
910 910

  
911
  $self->merge_stock_data($stock_info, \@contents, $part);
911
  $self->merge_stock_data($stock_info, \@contents, $part, $unit);
912 912

  
913 913
  $self->render("delivery_order/stock_dialog", { layout => 0 },
914 914
    WHCONTENTS => $self->order->delivered ? $stock_info : \@contents,
915 915
    part       => $part,
916 916
    do_qty     => $qty,
917
    do_unit    => $unit,
917
    do_unit    => $unit->unit,
918 918
    delivered  => $self->order->delivered,
919 919
    row        => $row,
920 920
    item_id    => $item_id,
......
938 938
}
939 939

  
940 940
sub merge_stock_data {
941
  my ($self, $stock_info, $contents, $part) = @_;
941
  my ($self, $stock_info, $contents, $part, $unit) = @_;
942 942
  # TODO rewrite to mapping
943 943

  
944 944
  if (!$self->order->delivered) {
945 945
    for my $row (@$contents) {
946
      $row->{available_qty} = _format_number_units($row->{qty}, $row->{unit}, $part->unit);
946
      # row here is in parts units. stock is in item units
947
      $row->{available_qty} = _format_number($part->unit_obj->convert_to($row->{qty}, $unit));
947 948

  
948 949
      for my $sinfo (@{ $stock_info }) {
949 950
        next if $row->{bin_id}       != $sinfo->{bin_id} ||
......
2151 2152
    $units_by_name{$_->{unit}}->convert_to($_->{qty}, $units_by_name{$unit})
2152 2153
  } @$stock_info;
2153 2154

  
2154
  my $content  = _format_number_units($sum, 2, $units_by_name{$unit}, $units_by_name{$unit});
2155
  my $content  = _format_number($sum, 2);
2155 2156

  
2156 2157
  return $content;
2157 2158
}
......
2165 2166
    $_->unit_obj->convert_to($_->qty, $item->unit_obj)
2166 2167
  } $item->delivery_order_stock_entries;
2167 2168

  
2168
  my $content  = _format_number_units($sum, 2, $item->unit_obj, $item->part->unit_obj);
2169
  my $content  = _format_number($sum, 2);
2169 2170

  
2170 2171
  return $content;
2171 2172
}

Auch abrufbar als: Unified diff