Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b0869fe8

Von Tamino Steinert vor 8 Monaten hinzugefügt

  • ID b0869fe833caee189142bddb16b54413ee763f9c
  • Vorgänger 12007b8a
  • Nachfolger f0405d5a

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

Unterschiede anzeigen:

SL/DB/Order.pm
514 514
    any { $from_to->{abbr} eq $_ } @_;
515 515
  };
516 516

  
517
  my ($item_parent_id_column, $item_parent_column);
518

  
519
  if (ref($source) eq 'SL::DB::Order') {
520
    $item_parent_id_column = 'trans_id';
521
    $item_parent_column    = 'order';
522
  } elsif ( ref($source) eq 'SL::DB::Reclamation') {
523
    $item_parent_id_column = 'reclamation_id';
524
    $item_parent_column    = 'reclamation';
525
  }
526

  
527 517
  my %args;
528 518
  if (ref($source) eq 'SL::DB::Order') {
529 519
    %args = ( map({ ( $_ => $source->$_ ) } qw(amount cp_id currency_id cusordnumber customer_id delivery_customer_id delivery_term_id delivery_vendor_id
......
613 603
  $order->assign_attributes(%{ $params{attributes} }) if $params{attributes};
614 604
  my $items = delete($params{items}) || $source->items_sorted;
615 605

  
616
  my %item_parents;
617

  
618 606
  my @items = map {
619 607
    my $source_item      = $_;
620
    my $source_item_id   = $_->$item_parent_id_column;
621 608
    my @custom_variables = map { _clone_orderitem_cvar($_) } @{ $source_item->custom_variables };
622 609

  
623
    $item_parents{$source_item_id} ||= $source_item->$item_parent_column;
624
    my $item_parent                  = $item_parents{$source_item_id};
625

  
626 610
    my $current_oe_item;
627 611
    if (ref($source) eq 'SL::DB::Order') {
628 612
      $current_oe_item = SL::DB::OrderItem->new(map({ ( $_ => $source_item->$_ ) }
......
654 638
      $current_oe_item->lastcost($source_item->sellprice);
655 639
    }
656 640
    unless ($params{no_linked_records}) {
657
      $current_oe_item->{ RECORD_ITEM_ID() } = $_->{id};
641
      $current_oe_item->{ RECORD_ITEM_ID() } = $source_item->{id};
658 642
      $current_oe_item->{ RECORD_ITEM_TYPE_REF() } = ref($source_item);
659 643
    }
660 644
    $current_oe_item;
......
742 726
                               attributes       => \%attributes,
743 727
                               items            => \@items,
744 728
                               %params);
729
  $order->{RECORD_ID()} = join ' ', map { $_->id } @$sources; # link all sources
745 730

  
746 731
  return $order;
747 732
}

Auch abrufbar als: Unified diff