Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a12969f8

Von Bernd Bleßmann vor etwa 2 Jahren hinzugefügt

  • ID a12969f8c75f10b0728219367935dbb2b5a7a546
  • Vorgänger d51907d6
  • Nachfolger a42b2b66

Auftragszentrische verknüpfte Belege überarbeitet

- alle über den Auftrag gefundenen Verknüpfungen sind mindestens
zwei Verknüpfungen weiter entfernt
- auch die Verknüpfungen in die Richtung "to" (also vom Beleg weg)
werden angezeigt
- Möglichkeit, um auch Verkaufsangebote zu liefern, die vor dem Auftrag
liegen
- Möglichkeit, auch den aktuellen Beleg zu liefern. Dieser wird besonders
markiert. Das war auch schon vorher so, aber es war nicht klar, das es der
Beleg selbst ist. Zudem ist dieses Verhalten jetzt nicht per default an.

Unterschiede anzeigen:

SL/Controller/RecordLinks.pm
68 68
  my ($self) = @_;
69 69

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

  
SL/DB/Helper/LinkedRecords.pm
7 7
our @EXPORT = qw(linked_records link_to_record sales_order_centric_linked_records);
8 8

  
9 9
use Carp;
10
use List::MoreUtils qw(any);
10
use List::MoreUtils qw(any none);
11 11
use List::UtilsBy qw(uniq_by);
12 12
use Sort::Naturally;
13 13
use SL::DBUtils;
......
396 396
}
397 397

  
398 398
sub sales_order_centric_linked_records {
399
  my ($self) = @_;
399
  my ($self, %params) = @_;
400

  
401
  my $with_sales_quotations = $params{with_sales_quotations};
402
  my $with_myself           = $params{with_myself};
403

  
404
  my $all_linked_records = $self->linked_records(direction => 'both', recursive => 1, save_path => 1);
405

  
406
  if (!$with_sales_quotations) {
407
    $all_linked_records = [ grep { !('SL::DB::Order' eq ref $_ && $_->is_sales && $_->quotation) } @$all_linked_records ];
408
  }
409

  
410
  if ($with_myself) {
411
    $self->{_record_link_to_myself} = 1;
412
    push @$all_linked_records, $self;
413
  }
400 414

  
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 ];
415
  my $filtered_orders = [ grep { 'SL::DB::Order' eq ref $_ && $_->is_type('sales_order') && $_->{_record_link_direction} eq 'from' } @$all_linked_records ];
403 416

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

  
409
  # we have a order, therefore get the tree view from the top (order)
421
  # we have an order, therefore get the tree view from the top (order)
410 422
  my $id_ref = [ map { $_->id } @$filtered_orders ];
423

  
411 424
  my $linked_records = SL::DB::Order->new->linked_records(direction => 'to', recursive => 1, batch => $id_ref);
412
  push @{ $linked_records }, @$filtered_orders;
425

  
426
  # Remove entries that are already in all_linked_records.
427
  $linked_records = [ grep { my $id = $_->id; none { $_->id == $id } @$all_linked_records } @$linked_records ];
428

  
429
  # Remove quotations if requested.
430
  if (!$with_sales_quotations) {
431
    $linked_records = [ grep { !('SL::DB::Order' eq ref $_ && $_->is_sales && $_->quotation) } @$linked_records ];
432
  }
433

  
434
  # Mark or remove myself.
435
  if ($with_myself) {
436
    $_->{_record_link_to_myself}  = 1 for grep { $_->id == $self->id } @$linked_records;
437
  } else {
438
    $linked_records = [ grep { $_->id != $self->id } @$linked_records ];
439
  }
440

  
441
  # All remaining links found via order are two more steps away from myself.
442
  $_->{_record_link_depth} += 2 for @{ $linked_records };
443

  
444
  push @{ $linked_records }, @$all_linked_records;
413 445

  
414 446
  return $linked_records;
415 447
}
......
477 509
    %params,
478 510
  );
479 511

  
512
  # get order centric linked records
513
  $invoice->sales_order_centric_linked_records(
514
    with_myself           => 1,
515
    with_sales_quotations => 1
516
  );
517

  
480 518
  # add a new link
481 519
  $order->link_to_record($invoice);
482 520
  $order->link_to_record($purchase_order, bidirectional => 1);
......
701 739

  
702 740
Can only be called as a class function since it is not exported.
703 741

  
742
=item C<sales_order_centric_linked_records %params>
743

  
744
Get linked records from the view of a reachable sales order in the path
745
prior to this record. If no sales order is found, recursive linked records
746
for both directions are returned.
747

  
748
=over 2
749

  
750
=item * C<with_sales_quotations>
751

  
752
Since the view from a sales order is requested, normally no sales quotation
753
prior to the sales order will be returned. If this parameter is truish, then
754
a sales quotation would be included.
755
This parameter is optional and defaults to false.
756

  
757
=item * C<with_myself>
758

  
759
The records returned by L</linked_records> do not include the requesting record
760
itself. However, if you want to display the same linked records for every
761
record in the same workflow, it can be usefull to include the record itself.
762
C<_record_link_to_myself> will be set to a truish value in that record in
763
that case.
764
This parameter is optional and defaults to false.
765

  
766
=back
767

  
704 768
=back
705 769

  
706 770
=head1 EXPORTS
707 771

  
708
This mixin exports the functions L</linked_records> and
772
This mixin exports the functions L</linked_records>,
773
L</sales_order_centric_linked_records> and
709 774
L</link_to_record>.
710 775

  
711 776
=head1 BUGS
SL/Presenter/Record.pm
108 108
    push @columns, {
109 109
      title => $::locale->text('Link direction'),
110 110
      data  => sub {
111
          $_[0]->{_record_link_depth} > 1
111
          $_[0]->{_record_link_to_myself}
112
        ? $::locale->text('Row is the record itself')
113
        : $_[0]->{_record_link_depth} > 1
112 114
        ? $::locale->text('Row was linked to another record')
113 115
        : $_[0]->{_record_link_direction} eq 'from'
114 116
        ? $::locale->text('Row was source for current record')
locale/de/all
2963 2963
  'Rounding Loss'               => 'Rundungsaufwendungen',
2964 2964
  'Row'                         => 'Zeile',
2965 2965
  'Row #1: amount has to be different from zero.' => 'Zeile #1: Der Wert darf nicht 0 sein.',
2966
  'Row is the record itself'    => 'Zeile ist der Beleg selbst',
2966 2967
  'Row number'                  => 'Zeilennummer',
2967 2968
  'Row was created from current record' => 'Zeile wurde aus aktuellem Beleg erstellt',
2968 2969
  'Row was linked to another record' => 'Zeile wurde über einen anderen Beleg verlinkt',
locale/en/all
2963 2963
  'Rounding Loss'               => '',
2964 2964
  'Row'                         => '',
2965 2965
  'Row #1: amount has to be different from zero.' => '',
2966
  'Row is the record itself'    => '',
2966 2967
  'Row number'                  => '',
2967 2968
  'Row was created from current record' => '',
2968 2969
  'Row was linked to another record' => '',

Auch abrufbar als: Unified diff