From: G. Richardson Date: Thu, 10 Nov 2016 15:37:06 +0000 (+0100) Subject: Order Controller - Sortimente hinzufügen + charge X-Git-Tag: release-3.5.4~1878 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=4b518cdb806bacd0493e2a23e8ae7e9d837dcd91;p=kivitendo-erp.git Order Controller - Sortimente hinzufügen + charge --- diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 741476603..f785a7eca 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -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); @@ -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);