sub _clone_orderitem_cvar {
my ($cvar) = @_;
- my $cloned = Rose::DB::Object::Helpers::clone_and_reset($_);
+ my $cloned = $_->clone_and_reset;
$cloned->sub_module('delivery_order_items');
return $cloned;
# Custom shipto addresses (the ones specific to the sales/purchase
# record and not to the customer/vendor) are only linked from
- # shipto -> delivery_orders. Meaning delivery_orders.shipto_id
- # will not be filled in that case. Therefore we have to return the
- # new shipto object as a separate object so that the caller can
- # save it, too.
- my $custom_shipto;
+ # shipto → delivery_orders. Meaning delivery_orders.shipto_id
+ # will not be filled in that case.
if (!$source->shipto_id && $source->id) {
- my $old = $source->custom_shipto;
- if ($old) {
- $custom_shipto = SL::DB::Shipto->new(
- map { +($_ => $old->$_) }
- grep { !m{^ (?: itime | mtime | shipto_id | trans_id ) $}x }
- map { $_->name }
- @{ $old->meta->columns }
- );
- $custom_shipto->module('DO');
- }
+ $args{custom_shipto} = $source->custom_shipto->clone($class) if $source->can('custom_shipto') && $source->custom_shipto;
} else {
$args{shipto_id} = $source->shipto_id;
$delivery_order->items(\@items);
- return ($delivery_order, $custom_shipto);
+ return $delivery_order;
}
sub customervendor {
The conversion copies order items into delivery order items. Dates are copied
as appropriate, e.g. the C<transdate> field will be set to the current date.
-Returns one or two objects depending on the context. In list context
-the new delivery order instance and a shipto instance will be
-returned. In scalar instance only the delivery order instance is
-returned.
-
-Custom shipto addresses (the ones specific to the sales/purchase
-record and not to the customer/vendor) are only linked from C<shipto>
-to C<delivery_orders>. Meaning C<delivery_orders.shipto_id> will not
-be filled in that case. That's why a separate shipto object is created
-and returned.
-
-The objects returned are not saved.
+Returns the new delivery order instance. The object returned is not
+saved.
C<%params> can include the following options: