Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 24e928a5

Von Martin Helmling martin.helmling@octosoft.eu vor mehr als 3 Jahren hinzugefügt

  • ID 24e928a5db664197697cdee8a0d65937845bea24
  • Vorgänger 3b322be4
  • Nachfolger 155b8aa4

Inventory-Helper: Restmenge auch runden, Stück immer ganzzahlig

Unterschiede anzeigen:

SL/Helper/Inventory.pm
7 7
use List::Util qw(min sum);
8 8
use List::UtilsBy qw(sort_by);
9 9
use List::MoreUtils qw(any);
10
use POSIX qw(ceil);
10 11

  
11 12
use SL::Locale::String qw(t8);
12 13
use SL::MoreCommon qw(listify);
......
210 211
        reserve_for_table => $chunk->{reserve_for_table},
211 212
        oe_id             => undef,
212 213
      );
213
      $rest_qty -= $qty;
214
      $rest_qty -=  _round_qty($qty);
214 215
    }
215

  
216
    $rest_qty = _round_qty($rest_qty);
216 217
    last if $rest_qty == 0;
217 218
  }
218 219
  if ($rest_qty > 0) {
219 220
    die SL::X::Inventory::Allocation->new(
220 221
      error => 'not enough to allocate',
221
      msg => t8("can not allocate #1 units of #2, missing #3 units", $qty, $part->displayable_name, $rest_qty),
222
      msg => t8("can not allocate #1 units of #2, missing #3 units", _qty($qty), $part->displayable_name, _qty($rest_qty)),
222 223
    );
223 224
  } else {
224 225
    if ($params{constraints}) {
......
239 240
  my %parts_to_allocate;
240 241

  
241 242
  for my $assembly ($part->assemblies) {
243
    next if $assembly->part->dispotype eq 'no_stock';
244

  
245
    my $tmpqty = $assembly->assembly_part->is_recipe   ? $assembly->qty * $qty / $assembly->assembly_part->scalebasis
246
               : $assembly->part->unit eq 'Stck' ? ceil($assembly->qty * $qty)
247
               : $assembly->qty * $qty;
242 248
    $parts_to_allocate{ $assembly->part->id } //= 0;
243
    $parts_to_allocate{ $assembly->part->id } += $assembly->qty * $qty; # TODO recipe factor
249
    $parts_to_allocate{ $assembly->part->id } += $tmpqty;
244 250
  }
245 251

  
246 252
  my @allocations;

Auch abrufbar als: Unified diff