X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/340b402aec62c199176bd58596a79353f7f56d70..6e0fe1dc46a643b80c36b21c4cb62c2f09227f45:/SL/Controller/Order.pm diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 5af72f50a..78e9e5436 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -326,7 +326,7 @@ sub action_save_and_delivery_order { $self->redirect_to(@redirect_params); } -# set form elements in respect of a changed customer or vendor +# set form elements in respect to a changed customer or vendor # # This action is called on an change of the customer/vendor picker. sub action_customer_vendor_changed { @@ -425,6 +425,10 @@ sub action_add_item { description => $assortment_item->part->description, }; my $item = _new_item($self->order, $attr); + + # set discount to 100% if item isn't supposed to be charged, overwriting any customer discount + $item->discount(1) unless $assortment_item->charge; + $self->order->add_items( $item ); $self->_recalc(); my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); @@ -477,7 +481,7 @@ sub action_multi_items_update_result { } } -# add item rows for multiple items add once +# add item rows for multiple items at once sub action_add_multi_items { my ($self) = @_; @@ -486,7 +490,22 @@ sub action_add_multi_items { my @items; foreach my $attr (@form_attr) { - push @items, _new_item($self->order, $attr); + my $item = _new_item($self->order, $attr); + push @items, $item; + if ( $item->part->is_assortment ) { + foreach my $assortment_item ( @{$item->part->assortment_items} ) { + my $attr = { parts_id => $assortment_item->parts_id, + qty => $assortment_item->qty * $item->qty, # TODO $form_attr->{unit} + unit => $assortment_item->unit, + description => $assortment_item->part->description, + }; + my $item = _new_item($self->order, $attr); + + # set discount to 100% if item isn't supposed to be charged, overwriting any customer discount + $item->discount(1) unless $assortment_item->charge; + push @items, $assortment_item; + } + } } $self->order->add_items(@items); @@ -525,7 +544,7 @@ sub action_recalc_amounts_and_taxes { $self->js->render(); } -# redisplay item rows if the are sorted by an attribute +# redisplay item rows if they are sorted by an attribute sub action_reorder_items { my ($self) = @_; @@ -563,7 +582,7 @@ sub action_price_popup { # longdescription was opened and the longdescription is empty # # If this item is new, get the longdescription from Part. -# Get it from OrderItem else. +# Otherwise get it from OrderItem. sub action_get_item_longdescription { my $longdescription; @@ -829,7 +848,11 @@ sub _new_item { $item->unit($part->unit) if !$item->unit; my $price_src; - if ($item->sellprice) { + if ( $part->is_assortment ) { + # add assortment items with price 0, as the components carry the price + $price_src = $price_source->price_from_source(""); + $price_src->price(0); + } elsif ($item->sellprice) { $price_src = $price_source->price_from_source(""); $price_src->price($item->sellprice); } else {