Revision dc28c289
SL/DB/Inventory.pm | ||
---|---|---|
10 | 10 |
use SL::DBUtils qw(selectrow_query); |
11 | 11 |
use SL::DB::MetaSetup::Inventory; |
12 | 12 |
use SL::DB::Manager::Inventory; |
13 |
use SL::Locale::String qw(t8); |
|
13 | 14 |
|
14 | 15 |
__PACKAGE__->meta->initialize; |
15 | 16 |
|
16 | 17 |
__PACKAGE__->before_save(\&_before_save_create_trans_id); |
17 | 18 |
__PACKAGE__->before_save(\&_before_save_set_shippingdate); |
18 | 19 |
__PACKAGE__->before_save(\&_before_save_set_employee); |
20 |
__PACKAGE__->before_save(\&_before_save_check_valid_qty); |
|
19 | 21 |
|
20 | 22 |
# part accessor is badly named |
21 | 23 |
sub part { |
... | ... | |
81 | 83 |
|
82 | 84 |
return 1; |
83 | 85 |
} |
86 |
|
|
87 |
sub _before_save_check_valid_qty { |
|
88 |
my ($self) = @_; |
|
89 |
|
|
90 |
return 1 if $self->trans_type->direction eq 'in'; # also catches produce assembly |
|
91 |
return 1 if $::instance_conf->get_transfer_default_ignore_onhand; |
|
92 |
|
|
93 |
my $qty = SL::Helper::Inventory->get_stock($self, bin => $self->bin_id, part => $self->parts_id); |
|
94 |
|
|
95 |
die t8("Cannot transfer #1 qty for #2 from warehouse #3 at bin #4", |
|
96 |
$self->qty, $self->part->partnumber, $self->warehouse->description, $self->bin->description) |
|
97 |
if $qty + $self->qty < 0; |
|
98 |
|
|
99 |
return 1; |
|
100 |
} |
|
101 |
|
|
84 | 102 |
1; |
Auch abrufbar als: Unified diff
Totmann-Schalter für Lagerbewegungen, die den Bestand negativ machen
Letzter Rettungsanker, falls die UI versagt. Prüft bei Transfertyp
out und der Mandanteneinstellung "negative Bestände nicht zulassen"
ob es auf dem Lagerplatz aktuell überhaupt genügend Teile gibt.
TODO Chargennummer und MHD wird nicht berücksichtigt