$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 {
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);
}
}
-# add item rows for multiple items add once
+# add item rows for multiple items at once
sub action_add_multi_items {
my ($self) = @_;
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);
$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) = @_;
# 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;
$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 {