Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5d7aadc1

Von Sven Schöling vor mehr als 3 Jahren hinzugefügt

  • ID 5d7aadc1f54825821263c6cc6e405e124f09af3d
  • Vorgänger a910619e
  • Nachfolger a3c72312

Inventory::Allocation: transfer_object

Unterschiede anzeigen:

SL/Helper/Inventory.pm
330 330
  my @transfers;
331 331
  for my $allocation (@$allocations) {
332 332
    my $oe_id = delete $allocation->{for_object_id};
333
    push @transfers, SL::DB::Inventory->new(
333
    push @transfers, $allocation->transfer_object(
334 334
      trans_id     => $trans_id,
335
      %$allocation,
336 335
      qty          => -$allocation->qty,
337 336
      trans_type   => $trans_type_out,
338 337
      shippingdate => $shippingdate,
339 338
      employee     => SL::DB::Manager::Employee->current,
340
      oe_id        => $allocation->for_object_id,
341 339
    );
342 340
  }
343 341

  
......
375 373
package SL::Helper::Inventory::Allocation {
376 374
  my @attributes = qw(parts_id qty bin_id warehouse_id chargenumber bestbefore comment for_object_id);
377 375
  my %attributes = map { $_ => 1 } @attributes;
376
  my %mapped_attributes = (
377
    for_object_id => 'oe_id',
378
  );
378 379

  
379 380
  for my $name (@attributes) {
380 381
    no strict 'refs';
......
391 392

  
392 393
    bless { %params }, $class;
393 394
  }
395

  
396
  sub transfer_object {
397
    my ($self, %params) = @_;
398

  
399
    SL::DB::Inventory->new(
400
      (map {
401
        my $attr = $mapped_attributes{$_} // $_;
402
        $attr => $self->{$attr}
403
      } @attributes),
404
      %params,
405
    );
406
  }
394 407
}
395 408

  
396 409
1;
......
725 738

  
726 739
=back
727 740

  
728
C<chargenumber>, C<bestbefore> and C<for_object_id> may be C<undef> (but must
729
still be present at creation time). Instances are considered immutable.
741
C<chargenumber>, C<bestbefore> and C<for_object_id> and C<comment> may be
742
C<undef> (but must still be present at creation time). Instances are considered
743
immutable.
730 744

  
745
Allocations also provide the method C<transfer_object> which will create a new
746
C<SL::DB::Inventory> bject with all the playload.
731 747

  
732 748
=head1 CONSTRAINTS
733 749

  

Auch abrufbar als: Unified diff