Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e9c278f5

Von Bernd Bleßmann vor mehr als 2 Jahren hinzugefügt

  • ID e9c278f575991e65c294f451dc4f025d0a306022
  • Vorgänger a880fff6
  • Nachfolger d51907d6

Auftragzentrische verknüpfte Belege: Routine aus Controller in Helper verschoben

Unterschiede anzeigen:

SL/Controller/RecordLinks.pm
69 69

  
70 70
  eval {
71 71
    my $linked_records = ($::instance_conf->get_always_record_links_from_order && ref $self->object ne 'SL::DB::Order')
72
                       ?  $self->get_order_centric_linked_records
72
                       ?  $self->object->order_centric_linked_records()
73 73
                       :  $self->object->linked_records(direction => 'both', recursive => 1, save_path => 1);
74 74

  
75 75
    push @{ $linked_records }, $self->object->sepa_export_items if $self->object->can('sepa_export_items');
......
248 248
  $::auth->assert('record_links');
249 249
}
250 250

  
251
# internal
252

  
253
sub get_order_centric_linked_records {
254
  my ($self) = @_;
255

  
256
  my $all_linked_records = $self->object->linked_records(direction => 'from', recursive => 1);
257
  my $filtered_orders = [ grep { 'SL::DB::Order' eq ref $_ && $_->is_type('sales_order') } @$all_linked_records ];
258

  
259
  # no orders no call to linked_records via batch mode
260
  # but instead return default list
261
  return $self->object->linked_records(direction => 'both', recursive => 1, save_path => 1)
262
    unless scalar @$filtered_orders;
263

  
264
  # we have a order, therefore get the tree view from the top (order)
265
  my $id_ref = [ map { $_->id } @$filtered_orders ];
266
  my $linked_records = SL::DB::Order->new->linked_records(direction => 'to', recursive => 1, batch => $id_ref);
267
  push @{ $linked_records }, @$filtered_orders;
268

  
269
  return $linked_records;
270
}
271 251
1;
SL/DB/Helper/LinkedRecords.pm
4 4

  
5 5
require Exporter;
6 6
our @ISA    = qw(Exporter);
7
our @EXPORT = qw(linked_records link_to_record);
7
our @EXPORT = qw(linked_records link_to_record order_centric_linked_records);
8 8

  
9 9
use Carp;
10 10
use List::MoreUtils qw(any);
......
395 395
  return \@records;
396 396
}
397 397

  
398
sub order_centric_linked_records {
399
  my ($self) = @_;
400

  
401
  my $all_linked_records = $self->linked_records(direction => 'from', recursive => 1);
402
  my $filtered_orders = [ grep { 'SL::DB::Order' eq ref $_ && $_->is_type('sales_order') } @$all_linked_records ];
403

  
404
  # no orders no call to linked_records via batch mode
405
  # but instead return default list
406
  return $self->linked_records(direction => 'both', recursive => 1, save_path => 1)
407
    unless scalar @$filtered_orders;
408

  
409
  # we have a order, therefore get the tree view from the top (order)
410
  my $id_ref = [ map { $_->id } @$filtered_orders ];
411
  my $linked_records = SL::DB::Order->new->linked_records(direction => 'to', recursive => 1, batch => $id_ref);
412
  push @{ $linked_records }, @$filtered_orders;
413

  
414
  return $linked_records;
415
}
416

  
398 417
1;
399 418

  
400 419
__END__

Auch abrufbar als: Unified diff