my $part = $params{part} or Carp::croak('allocate needs a part');
my $qty = $params{qty} or Carp::croak('allocate needs a qty');
my $wh = $params{warehouse};
- my $wh_strict = $::instance_conf->get_produce_assembly_same_warehouse;
+ my $wh_strict = $::instance_conf->get_produce_assembly_same_warehouse;
+ my $consume_service = $::instance_conf->get_produce_assembly_transfer_service;
Carp::croak('not an assembly') unless $part->is_assembly;
Carp::croak('No warehouse selected') if $wh_strict && !$wh;
my %parts_to_allocate;
for my $assembly ($part->assemblies) {
+ next if $assembly->part->type eq 'service' && !$consume_service;
$parts_to_allocate{ $assembly->part->id } //= 0;
$parts_to_allocate{ $assembly->part->id } += $assembly->qty * $qty;
}
my $strict_wh = $::instance_conf->get_produce_assembly_same_warehouse ? $bin->warehouse : undef;
if ($params{auto_allocate}) {
Carp::croak("produce_assembly: can't have both allocations and auto_allocate") if $params{allocations};
- $allocations = [ allocate_for_assembly(part => $part, qty => $qty, warehouse => $strict_wh) ];
+ $allocations = [ allocate_for_assembly(part => $part, qty => $qty, warehouse => $strict_wh, chargenumber => $params{chargenumber}) ];
} else {
Carp::croak("produce_assembly: need allocations or auto_allocate to produce something") if !$params{allocations};
$allocations = $params{allocations};