use Carp;
+use Rose::DB::Object::Helpers ();
+
use SL::DB::MetaSetup::DeliveryOrder;
use SL::DB::Manager::DeliveryOrder;
use SL::DB::Helper::FlattenToForm;
goto &transdate;
}
+sub _clone_orderitem_cvar {
+ my ($cvar) = @_;
+
+ my $cloned = Rose::DB::Object::Helpers::clone_and_reset($_);
+ $cloned->sub_module('delivery_order_items');
+
+ return $cloned;
+}
+
sub new_from {
my ($class, $source, %params) = @_;
my $delivery_order = $class->new(%args, %params);
my @items = map {
- my $source_item = $_;
+ my $source_item = $_;
+ my @custom_variables = map { _clone_orderitem_cvar($_) } @{ $source_item->custom_variables };
+
SL::DB::DeliveryOrderItem->new(map({ ( $_ => $source_item->$_ ) }
- qw(base_qty cusordnumber description discount lastcost longdescription marge_price_factor ordnumber parts_id price_factor price_factor_id
- project_id qty reqdate sellprice serialnumber transdate unit
- )));
+ qw(base_qty cusordnumber description discount lastcost longdescription marge_price_factor ordnumber parts_id price_factor price_factor_id
+ project_id qty reqdate sellprice serialnumber transdate unit
+ )),
+ custom_variables => \@custom_variables);
+
} @{ $source->items_sorted };
$delivery_order->items(\@items);
use Carp;
use List::Util qw(first);
+use Rose::DB::Object::Helpers ();
+
use SL::DB::MetaSetup::Invoice;
use SL::DB::Manager::Invoice;
use SL::DB::Helper::FlattenToForm;
return $self->paid >= $self->amount;
}
+sub _clone_orderitem_delivery_order_item_cvar {
+ my ($cvar) = @_;
+
+ my $cloned = Rose::DB::Object::Helpers::clone_and_reset($_);
+ $cloned->sub_module('invoice');
+
+ return $cloned;
+}
+
sub new_from {
my ($class, $source, %params) = @_;
my $invoice = $class->new(%args, %params);
my @items = map {
- my $source_item = $_;
+ my $source_item = $_;
+ my @custom_variables = map { _clone_orderitem_delivery_order_item_cvar($_) } @{ $source_item->custom_variables };
+
SL::DB::InvoiceItem->new(map({ ( $_ => $source_item->$_ ) }
qw(parts_id description qty sellprice discount project_id serialnumber pricegroup_id ordnumber transdate cusordnumber unit
base_qty longdescription lastcost price_factor_id), @item_columns),
- deliverydate => $source_item->reqdate,
- fxsellprice => $source_item->sellprice,);
+ deliverydate => $source_item->reqdate,
+ fxsellprice => $source_item->sellprice,
+ custom_variables => \@custom_variables,
+ );
+
} @{ $source->items_sorted };
$invoice->invoiceitems(\@items);