- my $part = SL::DB::Part->new(id => $form_attr->{parts_id})->load;
- my $cv_method = $self->cv;
- my $cv_discount = $self->order->$cv_method? $self->order->$cv_method->discount : 0.0;
+ my $part = SL::DB::Part->new(id => $form_attr->{parts_id})->load;
+
+ my $price_source = SL::PriceSource->new(record_item => $item, record => $self->order);
+
+ my $price_src;
+ if ($item->sellprice) {
+ $price_src = $price_source->price_from_source("");
+ $price_src->price($item->sellprice);
+ } else {
+ $price_src = $price_source->best_price
+ ? $price_source->best_price
+ : $price_source->price_from_source("");
+ $price_src->price(0) if !$price_source->best_price;
+ }
+
+ # bb: not sure but: maybe there should be a $price_source->discount_from_source
+ # which can also return an empty_discout if source is "".
+ my $discount;
+ my $discount_src;
+ if ($item->discount) {
+ $discount = $item->discount;
+ } else {
+ $discount = $price_source->best_discount
+ ? $price_source->best_discount->discount
+ : 0;
+ $discount_src = $price_source->best_discount->source if $price_source->best_discount;
+ }