Skip to content

Commit

Permalink
fixed bug caused by checkout of last well on plate
Browse files Browse the repository at this point in the history
  • Loading branch information
af11-sanger committed May 11, 2015
1 parent 2c26301 commit e6d23ba
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/LIMS2/Model/Util/BarcodeActions.pm
Expand Up @@ -754,6 +754,25 @@ sub create_barcoded_plate_copy{
]
}

# Special case. When the last barcode is removed from a plate this method will create
# an empty plate so we can't get to the previous plate's type and species via the wells
# We need to find the previous plate by name to get type and species.
unless(@wells){
my $new_plate_name = $validated_params->{new_plate_name};

DEBUG "Plate $new_plate_name has no wells. Getting species and type from old plate version.";

my $previous_plate = $model->schema->resultset('Plate')->search({
name => $new_plate_name,
})->first;

die "Cannot find parent wells or parent plate for plate $new_plate_name"
unless $previous_plate;

$create_params->{species} = $previous_plate->species_id;
$create_params->{type} = $previous_plate->type_id;
}

my $new_plate = $model->create_plate($create_params);

# If tubes have been transferred from other (non virtual) plates then
Expand Down

0 comments on commit e6d23ba

Please sign in to comment.