X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FInventory.pm;h=0a41f0b7df470f565a851a95dbcb1f9509b87b4f;hb=7ed4b336b89b861479a1fc2670b9456334b0d1be;hp=3f406ee480b2876d2f3821f494b713572c45ef14;hpb=a3be8322f450ab8d60653e54bdbd28273cbd1030;p=kivitendo-erp.git diff --git a/SL/Controller/Inventory.pm b/SL/Controller/Inventory.pm index 3f406ee48..0a41f0b7d 100644 --- a/SL/Controller/Inventory.pm +++ b/SL/Controller/Inventory.pm @@ -44,28 +44,35 @@ sub action_stock_in { sub action_stock { my ($self) = @_; - # do stock - WH->transfer({ - parts => $self->part, - dst_bin => $self->bin, - dst_wh => $self->warehouse, - qty => $::form->parse_amount(\%::myconfig, $::form->{qty}), - unit => $self->unit, - transfer_type => 'stock', - chargenumber => $::form->{chargenumber}, - ean => $::form->{ean}, - comment => $::form->{comment}, - }); - - if ($::form->{write_default_bin}) { - $self->part->load; # onhand is calculated in between. don't mess that up - $self->part->bin($self->bin); - $self->part->warehouse($self->warehouse); - $self->part->save; + my $qty = $::form->parse_amount(\%::myconfig, $::form->{qty}); + if (!$qty) { + flash_later('error', t8('Cannot stock without amount')); + } elsif ($qty < 0) { + flash_later('error', t8('Cannot stock negative amounts')); + } else { + # do stock + WH->transfer({ + parts => $self->part, + dst_bin => $self->bin, + dst_wh => $self->warehouse, + qty => $qty, + unit => $self->unit, + transfer_type => 'stock', + chargenumber => $::form->{chargenumber}, + ean => $::form->{ean}, + comment => $::form->{comment}, + }); + + if ($::form->{write_default_bin}) { + $self->part->load; # onhand is calculated in between. don't mess that up + $self->part->bin($self->bin); + $self->part->warehouse($self->warehouse); + $self->part->save; + } + + flash_later('info', t8('Transfer successful')); } - flash_later('info', t8('Transfer successful')); - # redirect $self->redirect_to( action => 'stock_in',