Die Idee war, bei einem leeren Wert in der Eingabezeile ein default zu
nehmen (Menge => 1, Preis => "bester" Preis, Rabatt => "bester" Rabatt).
Bisher wurde aber nicht zwischen leer und 0 bzw. 0,00 unterschieden, so dass
dann auch die default-Werte genommen wurden.
Das wird jetzt unterschieden.
my ($record, $attr) = @_;
my $item = SL::DB::OrderItem->new;
my ($record, $attr) = @_;
my $item = SL::DB::OrderItem->new;
+
+ # Remove attributes where the user left or set the inputs empty.
+ # So these attributes will be undefined and we can distinguish them
+ # from zero later on.
+ for (qw(qty_as_number sellprice_as_number discount_as_percent)) {
+ delete $attr->{$_} if $attr->{$_} eq '';
+ }
+
$item->assign_attributes(%$attr);
my $part = SL::DB::Part->new(id => $attr->{parts_id})->load;
$item->assign_attributes(%$attr);
my $part = SL::DB::Part->new(id => $attr->{parts_id})->load;
# add assortment items with price 0, as the components carry the price
$price_src = $price_source->price_from_source("");
$price_src->price(0);
# 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) {
+ } elsif (defined $item->sellprice) {
$price_src = $price_source->price_from_source("");
$price_src->price($item->sellprice);
} else {
$price_src = $price_source->price_from_source("");
$price_src->price($item->sellprice);
} else {
+ if (defined $item->discount) {
$discount_src = $price_source->discount_from_source("");
$discount_src->discount($item->discount);
} else {
$discount_src = $price_source->discount_from_source("");
$discount_src->discount($item->discount);
} else {