Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3e1190f9

Von Jan Büren vor mehr als 3 Jahren hinzugefügt

  • ID 3e1190f98d050e5a1fe189791d7d553f49eae91b
  • Vorgänger cb3ae7d0
  • Nachfolger 4a852cb1

S/H/Inventory auto_allocate und strict_wh für Erzeugnis fertigen

Prüft ob die Ware sich im selben Lager wie das Ziellager befindet.

Unterschiede anzeigen:

SL/Helper/Inventory.pm
213 213

  
214 214
  my $part = $params{part} or Carp::croak('allocate needs a part');
215 215
  my $qty  = $params{qty}  or Carp::croak('allocate needs a qty');
216
  my $wh   = $params{warehouse};
217
  my $wh_strict = $::instance_conf->get_produce_assembly_same_warehouse;
216 218

  
217
  Carp::croak('not an assembly') unless $part->is_assembly;
219
  Carp::croak('not an assembly')       unless $part->is_assembly;
220
  Carp::croak('No warehouse selected') if $wh_strict && !$wh;
218 221

  
219 222
  my %parts_to_allocate;
220 223

  
......
228 231
  for my $part_id (keys %parts_to_allocate) {
229 232
    my $part = SL::DB::Part->load_cached($part_id);
230 233
    push @allocations, allocate(%params, part => $part, qty => $parts_to_allocate{$part_id});
234
    if ($wh_strict) {
235
      die SL::X::Inventory::Allocation->new(
236
        code    => "wrong warehouse for part",
237
        message => t8('Part #1 exists in warehouse #2, but not in warehouse #3 ',
238
                        $part->partnumber . ' ' . $part->description,
239
                        SL::DB::Manager::Warehouse->find_by(id => $allocations[-1]->{warehouse_id})->description,
240
                        $wh->description),
241
      ) unless $allocations[-1]->{warehouse_id} == $wh->id;
242
    }
231 243
  }
232 244

  
233 245
  @allocations;
......
288 300
  my $bin  = $params{bin}  or Carp::croak("need target bin");
289 301

  
290 302
  my $allocations = $params{allocations};
303
  my $strict_wh = $::instance_conf->get_produce_assembly_same_warehouse ? $bin->warehouse : undef;
291 304
  if ($params{auto_allocate}) {
292 305
    Carp::croak("produce_assembly: can't have both allocations and auto_allocate") if $params{allocations};
293
    $allocations = [ allocate_for_assembly(part => $part, qty => $qty) ];
306
    $allocations = [ allocate_for_assembly(part => $part, qty => $qty, warehouse => $strict_wh) ];
294 307
  } else {
295 308
    Carp::croak("produce_assembly: need allocations or auto_allocate to produce something") if !$params{allocations};
296 309
    $allocations = $params{allocations};
......
308 321
  ($trans_id) = selectrow_query($::form, SL::DB->client->dbh, qq|SELECT nextval('id')| ) unless $trans_id;
309 322

  
310 323
  my $trans_type_out = SL::DB::Manager::TransferType->find_by(direction => 'out', description => 'used');
311
  my $trans_type_in  = SL::DB::Manager::TransferType->find_by(direction => 'in', description => 'assembled');
324
  my $trans_type_in  = SL::DB::Manager::TransferType->find_by(direction => 'in',  description => 'assembled');
312 325

  
313 326
  # check whether allocations are sane
314 327
  if (!$params{no_check_allocations} && !$params{auto_allocate}) {

Auch abrufbar als: Unified diff