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/Controller/Order.pm
33 33
use SL::DB::Shipto;
34 34
use SL::DB::Translation;
35 35
use SL::DB::ValidityToken;
36
use SL::DB::Helper::RecordLink qw(set_record_link_conversions RECORD_ID RECORD_ITEM_ID);
36
use SL::DB::Helper::RecordLink qw(set_record_link_conversions RECORD_ID RECORD_TYPE_REF RECORD_ITEM_ID RECORD_ITEM_TYPE_REF);
37 37
use SL::DB::Helper::TypeDataProxy;
38 38
use SL::DB::Helper::Record qw(get_object_name_from_type get_class_from_type);
39 39
use SL::Model::Record;
......
120 120
  my $order = SL::Model::Record->new_from_workflow($record, $self->type, %flags);
121 121
  $self->order($order);
122 122

  
123
  if (ref($record) eq 'SL::DB::Reclamation') {
124
    $self->{converted_from_reclamation_id}       = $order->{ RECORD_ID()      };
125
    $_   ->{converted_from_reclamation_items_id} = $_    ->{ RECORD_ITEM_ID() } for @{ $order->items_sorted };
126
  }
127
  if (ref($record) eq 'SL::DB::Order') {
128
    $self->{converted_from_oe_id}       = $order->{ RECORD_ID()      };
129
    $_   ->{converted_from_oe_items_id} = $_    ->{ RECORD_ITEM_ID() } for @{ $order->items_sorted };
130
  }
131

  
132

  
133 123
  $self->recalc();
134 124
  $self->pre_render();
135 125

  
......
230 220

  
231 221
  # make new order from given orders
232 222
  my @multi_orders = map { SL::DB::Order->new(id => $_)->load } @multi_ids;
233
  $self->{converted_from_oe_id} = join ' ', map { $_->id } @multi_orders;
234
  my $target_type = "sales_order";
223
  my $target_type = SALES_ORDER_TYPE();
235 224
  my $order = SL::Model::Record->new_from_workflow_multi(\@multi_orders, $target_type, sort_sources_by => 'transdate');
236 225
  $self->order($order);
237 226

  
......
1588 1577

  
1589 1578
  $self->js
1590 1579
    ->val('#id', $self->order->id)
1591
    ->val('#converted_from_oe_id', '')
1592
    ->val('#converted_from_reclamation_id', '')
1580
    ->val('#converted_from_record_type_ref', '')
1581
    ->val('#converted_from_record_id',  '')
1593 1582
    ->val('#order_' . $self->nr_key(), $self->order->number);
1594 1583

  
1595 1584
  my $idx = 0;
......
1603 1592
  } continue {
1604 1593
    $idx++;
1605 1594
  }
1606
  $self->js->val('[name="converted_from_orderitems_ids[+]"]', '');
1607
  $self->js->val('[name="converted_from_reclamation_items_ids[+]"]', '');
1595
  $self->js->val('[name="converted_from_record_item_type_refs[+]"]', '');
1596
  $self->js->val('[name="converted_from_record_item_ids[+]"]', '');
1608 1597
  $self->js->val('[name="basket_item_ids[+]"]', '');
1609 1598
}
1610 1599

  
......
2059 2048
sub save {
2060 2049
  my ($self) = @_;
2061 2050

  
2051
  my $is_new = !$self->order->id;
2052

  
2062 2053
  $self->parse_phone_note if $::form->{phone_note}->{subject} || $::form->{phone_note}->{body};
2063 2054

  
2064 2055
  # create first version if none exists
2065 2056
  $self->order->add_order_version(SL::DB::OrderVersion->new(version => 1)) if !$self->order->order_version;
2066 2057

  
2058
  set_record_link_conversions($self->order,
2059
    delete $::form->{RECORD_TYPE_REF()}
2060
      => delete $::form->{RECORD_ID()},
2061
    delete $::form->{RECORD_ITEM_TYPE_REF()}
2062
      => delete $::form->{RECORD_ITEM_ID()},
2063
  );
2064

  
2067 2065
  my @converted_from_oe_ids;
2068
  if ($::form->{converted_from_oe_id}) {
2069
    @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id};
2070
    set_record_link_conversions(
2071
      $self->order,
2072
      'SL::DB::Order'     => \@converted_from_oe_ids,
2073
      'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids},
2074
    );
2075
  }
2076
  if ($::form->{converted_from_reclamation_id}) {
2077
    my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id};
2078
    set_record_link_conversions(
2079
      $self->order,
2080
      'SL::DB::Reclamation'     => \@converted_from_reclamation_ids,
2081
      'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids},
2082
    );
2066
  if ($self->order->{RECORD_TYPE_REF()} eq 'SL::DB::Order'
2067
      && $self->order->{RECORD_ID()}) {
2068
    @converted_from_oe_ids = split ' ', $self->order->{RECORD_ID()};
2083 2069
  }
2084 2070

  
2085 2071
  # check for purchase basket items
......
2103 2089
    }
2104 2090
  }
2105 2091

  
2106
  my $is_new = !$self->order->id;
2107

  
2108 2092
  my $objects_to_close = scalar @converted_from_oe_ids
2109 2093
                       ? SL::DB::Manager::Order->get_all(where => [
2110 2094
                           id => \@converted_from_oe_ids,

Auch abrufbar als: Unified diff