Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c94dbd0e

Von Tamino Steinert vor 11 Monaten hinzugefügt

  • ID c94dbd0eccee66a266ddff4d3f3678766a6da6c4
  • Vorgänger 1c3e55fd
  • Nachfolger 3141d35a

Order: Nutze Type und ID zum Erstellen von verknüpften Belegen

Unterschiede anzeigen:

SL/DB/Order.pm
526 526
    any { $from_to->{abbr} eq $_ } @abbrs;
527 527
  };
528 528

  
529
  my ($item_parent_id_column, $item_parent_column);
530

  
531
  if (ref($source) eq 'SL::DB::Order') {
532
    $item_parent_id_column = 'trans_id';
533
    $item_parent_column    = 'order';
534
  } elsif ( ref($source) eq 'SL::DB::Reclamation') {
535
    $item_parent_id_column = 'reclamation_id';
536
    $item_parent_column    = 'reclamation';
537
  }
538

  
539 529
  my %args;
540 530
  if (ref($source) eq 'SL::DB::Order') {
541 531
    %args = ( map({ ( $_ => $source->$_ ) } qw(amount cp_id currency_id cusordnumber customer_id delivery_customer_id delivery_term_id delivery_vendor_id
......
627 617
  $order->assign_attributes(%{ $params{attributes} }) if $params{attributes};
628 618
  my $items = delete($params{items}) || $source->items_sorted;
629 619

  
630
  my %item_parents;
631

  
632 620
  my @items = map {
633 621
    my $source_item      = $_;
634
    my $source_item_id   = $_->$item_parent_id_column;
635 622
    my @custom_variables = map { _clone_orderitem_cvar($_) } @{ $source_item->custom_variables };
636 623

  
637
    $item_parents{$source_item_id} ||= $source_item->$item_parent_column;
638
    my $item_parent                  = $item_parents{$source_item_id};
639

  
640 624
    my $current_oe_item;
641 625
    if (ref($source) eq 'SL::DB::Order') {
642 626
      $current_oe_item = SL::DB::OrderItem->new(map({ ( $_ => $source_item->$_ ) }
......
668 652
      $current_oe_item->lastcost($source_item->sellprice);
669 653
    }
670 654
    unless ($params{no_linked_records}) {
671
      $current_oe_item->{ RECORD_ITEM_ID() } = $_->{id};
655
      $current_oe_item->{ RECORD_ITEM_ID() } = $source_item->{id};
672 656
      $current_oe_item->{ RECORD_ITEM_TYPE_REF() } = ref($source_item);
673 657
    }
674 658
    $current_oe_item;
......
756 740
                               attributes       => \%attributes,
757 741
                               items            => \@items,
758 742
                               %params);
743
  $order->{RECORD_ID()} = join ' ', map { $_->id } @$sources; # link all sources
759 744

  
760 745
  return $order;
761 746
}

Auch abrufbar als: Unified diff