Revision c84c3960
Von Sven Schöling vor etwa 1 Jahr hinzugefügt
SL/DB/DeliveryOrder.pm | ||
---|---|---|
249 | 249 |
my $items = delete($params{items}) || $source->items_sorted; |
250 | 250 |
my @items = ( $delivery_order->is_type(SUPPLIER_DELIVERY_ORDER_TYPE) && ref($source) ne 'SL::DB::Reclamation' ) ? |
251 | 251 |
() |
252 |
: map { SL::DB::DeliveryOrderItem->new_from($_) } @{ $items }; |
|
252 |
: map { SL::DB::DeliveryOrderItem->new_from($_, %params) } @{ $items };
|
|
253 | 253 |
|
254 | 254 |
@items = grep { $params{item_filter}->($_) } @items if $params{item_filter}; |
255 | 255 |
@items = grep { $_->qty * 1 } @items if $params{skip_items_zero_qty}; |
... | ... | |
257 | 257 |
|
258 | 258 |
$delivery_order->items(\@items); |
259 | 259 |
|
260 |
unless ($params{no_linked_records}) { |
|
261 |
$delivery_order->{ RECORD_ID() } = $source->id; |
|
262 |
$delivery_order->{ RECORD_TYPE_REF() } = ref $source; |
|
263 |
} |
|
264 |
|
|
260 | 265 |
return $delivery_order; |
261 | 266 |
} |
262 | 267 |
|
... | ... | |
405 | 410 |
if (!$self->db->with_transaction(sub { |
406 | 411 |
require SL::DB::Invoice; |
407 | 412 |
$invoice = SL::DB::Invoice->new_from($self, %params)->post || die; |
408 |
$self->link_to_record($invoice); |
|
409 |
# TODO extend link_to_record for items, otherwise long-term no d.r.y. |
|
410 |
foreach my $item (@{ $invoice->items }) { |
|
411 |
foreach (qw(delivery_order_items)) { # expand if needed (orderitems) |
|
412 |
if ($item->{"converted_from_${_}_id"}) { |
|
413 |
die unless $item->{id}; |
|
414 |
RecordLinks->create_links('mode' => 'ids', |
|
415 |
'from_table' => $_, |
|
416 |
'from_ids' => $item->{"converted_from_${_}_id"}, |
|
417 |
'to_table' => 'invoice', |
|
418 |
'to_id' => $item->{id}, |
|
419 |
) || die; |
|
420 |
delete $item->{"converted_from_${_}_id"}; |
|
421 |
} |
|
422 |
} |
|
423 |
} |
|
424 | 413 |
$self->update_attributes(closed => 1); |
425 | 414 |
1; |
426 | 415 |
})) { |
Auch abrufbar als: Unified diff
RecordLink: converted_from_* Felder in allen convert_to und new_from korrekt setzen.
Das hier benutzt jetzt das neue Reclamation Format. Statt
wird jetzt
benutzt.