Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 47dc096c

Von Sven Schöling vor fast 2 Jahren hinzugefügt

  • ID 47dc096c85d3dd5b19900234e033166c77b63bc2
  • Vorgänger 27441deb
  • Nachfolger 3aaba5ca

RecordLink: conversions nicht mehr manuell in Controllern machen

stattdessen per Helper setzen lassen

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
32 32
use SL::DB::TransferType;
33 33
use SL::DB::ValidityToken;
34 34
use SL::DB::Warehouse;
35
use SL::DB::Helper::RecordLink qw(set_record_link_conversions);
35 36
use SL::Model::Record;
36 37

  
37 38
use SL::Helper::CreatePDF qw(:all);
......
1664 1665
    # link records
1665 1666
    if ($::form->{converted_from_oe_id}) {
1666 1667
      my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id};
1667
      foreach my $converted_from_oe_id (@converted_from_oe_ids) {
1668
        my $src = SL::DB::Order->new(id => $converted_from_oe_id)->load;
1669
        $src->update_attributes(closed => 1) if $src->type =~ /_quotation$/ && $self->order->is_type(PURCHASE_DELIVERY_ORDER_TYPE);
1670
        $src->link_to_record($self->order);
1671
      }
1672
      if (scalar @{ $::form->{converted_from_orderitems_ids} || [] }) {
1673
        my $idx = 0;
1674
        foreach (@{ $self->order->items_sorted }) {
1675
          my $from_id = $::form->{converted_from_orderitems_ids}->[$idx];
1676
          next if !$from_id;
1677
          SL::DB::RecordLink->new(from_table => 'orderitems',
1678
                                  from_id    => $from_id,
1679
                                  to_table   => 'orderitems',
1680
                                  to_id      => $_->id
1681
          )->save;
1682
          $idx++;
1683
        }
1684
      }
1668
      set_record_link_conversions(
1669
        $self->order,
1670
        'SL::DB::Order'     => \@converted_from_oe_ids,
1671
        'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids},
1672
      );
1685 1673
    }
1686 1674
    if ($::form->{converted_from_reclamation_id}) {
1687 1675
      my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id};
1688
      foreach my $converted_from_reclamation_id (@converted_from_reclamation_ids) {
1689
        my $src = SL::DB::Reclamation->new(id => $converted_from_reclamation_id)->load;
1690
        if(!$::instance_conf->get_shipped_qty_require_stock_out || $self->order->delivered) {
1691
          $src->update_attributes(delivered => 1);
1692
        }
1693
        $src->link_to_record($self->order);
1694
      }
1695
      if (scalar @{ $::form->{converted_from_reclamation_items_ids} || [] }) {
1696
        my $idx = 0;
1697
        foreach (@{ $self->order->items_sorted }) {
1698
          my $from_id = $::form->{converted_from_reclamation_items_ids}->[$idx];
1699
          next if !$from_id;
1700
          SL::DB::RecordLink->new(from_table => 'reclamation_items',
1701
                                  from_id    => $from_id,
1702
                                  to_table   => 'orderitems',
1703
                                  to_id      => $_->id
1704
          )->save;
1705
          $idx++;
1706
        }
1707
      }
1676
      set_record_link_conversions(
1677
        $self->order,
1678
        'SL::DB::Reclamation'     => \@converted_from_reclamation_ids,
1679
        'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids},
1680
      );
1708 1681
    }
1709 1682

  
1710 1683
    $self->save_history('SAVED');

Auch abrufbar als: Unified diff