Revision 9c2d09b8
Von Bernd Bleßmann vor mehr als 3 Jahren hinzugefügt
SL/BackgroundJob/ConvertTimeRecordings.pm | ||
---|---|---|
193 | 193 |
$do->save; |
194 | 194 |
$_->update_attributes(booked => 1) for @{$time_recordings_by_order_id->{$related_order_id}}; |
195 | 195 |
|
196 |
$related_order->link_to_record($do); |
|
197 |
|
|
198 |
# TODO extend link_to_record for items, otherwise long-term no d.r.y. |
|
199 |
foreach my $item (@{ $do->items }) { |
|
200 |
foreach (qw(orderitems)) { |
|
201 |
if ($item->{"converted_from_${_}_id"}) { |
|
202 |
die unless $item->{id}; |
|
203 |
RecordLinks->create_links('mode' => 'ids', |
|
204 |
'from_table' => $_, |
|
205 |
'from_ids' => $item->{"converted_from_${_}_id"}, |
|
206 |
'to_table' => 'delivery_order_items', |
|
207 |
'to_id' => $item->{id}, |
|
208 |
) || die; |
|
209 |
delete $item->{"converted_from_${_}_id"}; |
|
210 |
} |
|
211 |
} |
|
212 |
} |
|
213 |
|
|
196 | 214 |
# Todo: reduce qty on related order |
215 |
|
|
197 | 216 |
1; |
198 | 217 |
})) { |
199 | 218 |
$::lxdebug->message(LXDebug->WARN(), |
SL/DB/DeliveryOrder.pm | ||
---|---|---|
262 | 262 |
my $delivery_order; |
263 | 263 |
|
264 | 264 |
if ($params{related_order}) { |
265 |
$delivery_order = SL::DB::DeliveryOrder->new_from($params{related_order}, items => \@items, %params); |
|
265 |
# collect suitable items in related order |
|
266 |
my @items_to_use; |
|
267 |
foreach my $item (@items) { |
|
268 |
my $item_to_use = first {$item->parts_id == $_->parts_id} @{ $params{related_order}->items_sorted }; |
|
269 |
|
|
270 |
die "no suitable item found in related order" if !$item_to_use; |
|
271 |
|
|
272 |
my %new_attributes; |
|
273 |
$new_attributes{$_} = $item->$_ for qw(qty unit_obj longdescription); |
|
274 |
$item_to_use->assign_attributes(%new_attributes); |
|
275 |
push @items_to_use, $item_to_use; |
|
276 |
} |
|
277 |
$delivery_order = SL::DB::DeliveryOrder->new_from($params{related_order}, items => \@items_to_use, %params); |
|
266 | 278 |
|
267 | 279 |
} else { |
268 | 280 |
my %args = ( |
Auch abrufbar als: Unified diff
Zeiterfassung: Konvertierung: Position aus zugehörigem Auftrag