Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OP-1339 Fix lots overlooking when they reach zero quantity #1441

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.isf.medicals.service.MedicalsIoOperations;
import org.isf.medicalstock.model.Lot;
import org.isf.medicalstock.model.Movement;
import org.isf.medicalstock.service.LotIoOperationRepository;
import org.isf.medicalstock.service.MedicalStockIoOperations;
import org.isf.utils.db.TranslateOHServiceException;
import org.isf.utils.exception.OHDataValidationException;
Expand All @@ -48,9 +49,13 @@ public class MovStockInsertingManager {

private MedicalsIoOperations ioOperationsMedicals;

public MovStockInsertingManager(MedicalStockIoOperations medicalStockIoOperations, MedicalsIoOperations medicalsIoOperations) {
private LotIoOperationRepository ioOperationsLots;

public MovStockInsertingManager(MedicalStockIoOperations medicalStockIoOperations, MedicalsIoOperations medicalsIoOperations,
LotIoOperationRepository ioOperationsLots) {
this.ioOperations = medicalStockIoOperations;
this.ioOperationsMedicals = medicalsIoOperations;
this.ioOperationsLots = ioOperationsLots;
}

/**
Expand Down Expand Up @@ -209,6 +214,17 @@ private void validateLot(List<OHExceptionMessage> errors, Lot lot, boolean check
}
}

/**
* Checks if the specified {@link Lot} exists.
*
* @param lotCode the lot code.
* @return {@code true} if exists, {@code false} otherwise.
* @throws OHServiceException if an error occurs during the check.
*/
public boolean lotExists(String lotCode) throws OHServiceException {
return ioOperationsLots.findById(String.valueOf(lotCode)).orElse(null) != null;
}

/**
* Verify if the referenceNumber is valid for CRUD and return a list of errors, if any
*
Expand Down