Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f4de41a2

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID f4de41a247f7d78958d9c6e7fb21d5480ba741c6
  • Vorgänger 6ee486a5
  • Nachfolger 9dd85105

SL::DB::DeliveryOrder->new_from: Positionsfeld ordnumber aus Quellbeleg setzen

…und nicht aus den Positionen kopieren.

Unterschiede anzeigen:

SL/DB/DeliveryOrder.pm
97 97

  
98 98
  croak("Unsupported source object type '" . ref($source) . "'") unless ref($source) eq 'SL::DB::Order';
99 99

  
100
  my ($item_parent_id_column, $item_parent_column);
101

  
102
  if (ref($source) eq 'SL::DB::Order') {
103
    $item_parent_id_column = 'trans_id';
104
    $item_parent_column    = 'order';
105
  }
106

  
100 107
  my $terms = $source->can('payment_id') && $source->payment_id ? $source->payment_terms->terms_netto : 0;
101 108

  
102 109
  my %args = ( map({ ( $_ => $source->$_ ) } qw(cp_id currency_id customer_id cusordnumber department_id employee_id globalproject_id intnotes language_id notes
......
134 141

  
135 142
  my $delivery_order = $class->new(%args, %{ $params{attributes} || {} });
136 143
  my $items          = delete($params{items}) || $source->items_sorted;
144
  my %item_parents;
137 145

  
138 146
  my @items = map {
139 147
    my $source_item      = $_;
148
    my $source_item_id   = $_->$item_parent_id_column;
140 149
    my @custom_variables = map { _clone_orderitem_cvar($_) } @{ $source_item->custom_variables };
141 150

  
151
    $item_parents{$source_item_id} ||= $source_item->$item_parent_column;
152
    my $item_parent                  = $item_parents{$source_item_id};
153

  
142 154
    SL::DB::DeliveryOrderItem->new(map({ ( $_ => $source_item->$_ ) }
143
                                         qw(base_qty cusordnumber description discount lastcost longdescription marge_price_factor ordnumber parts_id price_factor price_factor_id
155
                                         qw(base_qty cusordnumber description discount lastcost longdescription marge_price_factor parts_id price_factor price_factor_id
144 156
                                            project_id qty reqdate sellprice serialnumber transdate unit
145 157
                                         )),
146
                                   custom_variables => \@custom_variables);
158
                                   custom_variables => \@custom_variables,
159
                                   ordnumber        => ref($item_parent) eq 'SL::DB::Order' ? $item_parent->ordnumber : $source_item->ordnumber,
160
                                 );
147 161

  
148 162
  } @{ $items };
149 163

  

Auch abrufbar als: Unified diff