Revision 3aaba5ca
Von Sven Schöling vor fast 2 Jahren hinzugefügt
SL/BackgroundJob/ConvertTimeRecordings.pm | ||
---|---|---|
235 | 235 |
$do->save; |
236 | 236 |
$_->update_attributes(booked => 1) for @{$time_recordings_by_order_id->{$related_order_id}}; |
237 | 237 |
|
238 |
$related_order->link_to_record($do); |
|
239 |
|
|
240 |
# TODO extend link_to_record for items, otherwise long-term no d.r.y. |
|
241 |
foreach my $item (@{ $do->items }) { |
|
242 |
foreach (qw(orderitems)) { |
|
243 |
if ($item->{"converted_from_${_}_id"}) { |
|
244 |
die unless $item->{id}; |
|
245 |
RecordLinks->create_links('mode' => 'ids', |
|
246 |
'from_table' => $_, |
|
247 |
'from_ids' => $item->{"converted_from_${_}_id"}, |
|
248 |
'to_table' => 'delivery_order_items', |
|
249 |
'to_id' => $item->{id}, |
|
250 |
) || die; |
|
251 |
delete $item->{"converted_from_${_}_id"}; |
|
252 |
} |
|
253 |
} |
|
254 |
} |
|
255 |
|
|
256 | 238 |
# update delivered and item's ship for related order |
257 | 239 |
my $helper = SL::Helper::ShippedQty->new->calculate($related_order)->write_to_objects; |
258 | 240 |
$related_order->delivered($related_order->{delivered}); |
SL/BackgroundJob/CreatePeriodicInvoices.pm | ||
---|---|---|
257 | 257 |
|
258 | 258 |
$invoice->post(ar_id => $config->ar_chart_id) || die; |
259 | 259 |
|
260 |
$order->link_to_record($invoice); |
|
261 |
|
|
262 |
foreach my $item (@{ $invoice->items }) { |
|
263 |
foreach (qw(orderitems)) { # expand if needed (delivery_order_items) |
|
264 |
if ($item->{"converted_from_${_}_id"}) { |
|
265 |
die unless $item->{id}; |
|
266 |
RecordLinks->create_links('mode' => 'ids', |
|
267 |
'from_table' => $_, |
|
268 |
'from_ids' => $item->{"converted_from_${_}_id"}, |
|
269 |
'to_table' => 'invoice', |
|
270 |
'to_id' => $item->{id}, |
|
271 |
) || die; |
|
272 |
delete $item->{"converted_from_${_}_id"}; |
|
273 |
} |
|
274 |
} |
|
275 |
} |
|
276 |
|
|
277 | 260 |
foreach my $item (grep { ($_->recurring_billing_mode eq 'once') && !$_->recurring_billing_invoice_id } @{ $order->orderitems }) { |
278 | 261 |
$item->update_attributes(recurring_billing_invoice_id => $invoice->id); |
279 | 262 |
} |
Auch abrufbar als: Unified diff
RecordLink: in BackgroundJobs nicht mehr manuell setzen