+ if ($item->id) {
+ # load data from orderitems (db)
+ my $db_item = SL::DB::OrderItem->new(id => $item->id)->load;
+ $item->$_($db_item->$_) for qw(active_discount_source active_price_source longdescription);
+ } else {
+ # set data from part (or other sources)
+ $item->longdescription($item->part->notes);
+ #$item->active_price_source('');
+ #$item->active_discount_source('');
+ }
+
+ # autovivify all cvars that are not in the form (cvars_by_config can do it).
+ # workaround to pre-parse number-cvars (parse_custom_variable_values does not parse number values).
+ foreach my $var (@{ $item->cvars_by_config }) {
+ $var->unparsed_value($::form->parse_amount(\%::myconfig, $var->{__unparsed_value})) if ($var->config->type eq 'number' && exists($var->{__unparsed_value}));
+ }
+ $item->parse_custom_variable_values;