use of com.qcadoo.mes.materialFlowResources.constants.DocumentType in project mes by qcadoo.
the class DocumentValidators method hasDifferentWarehouses.
public boolean hasDifferentWarehouses(final DataDefinition documentDD, final Entity document) {
DocumentType documentType = DocumentType.of(document);
if (DocumentType.TRANSFER.equals(documentType)) {
Entity locationFrom = document.getBelongsToField(DocumentFields.LOCATION_FROM);
Entity locationTo = document.getBelongsToField(DocumentFields.LOCATION_TO);
if (locationFrom == null || locationTo == null) {
return true;
}
if (locationFrom.getId().equals(locationTo.getId())) {
document.addGlobalError("materialFlow.error.document.warehouse.sameForTransfer");
return false;
}
}
return true;
}
use of com.qcadoo.mes.materialFlowResources.constants.DocumentType in project mes by qcadoo.
the class PositionValidators method checkAttributesRequirement.
public boolean checkAttributesRequirement(final DataDefinition dataDefinition, final Entity position) {
Entity document = position.getBelongsToField(PositionFields.DOCUMENT);
if (document != null) {
DocumentType documentType = DocumentType.of(document);
DocumentState documentState = DocumentState.of(document);
if (documentState == DocumentState.ACCEPTED && (documentType == DocumentType.RECEIPT || documentType == DocumentType.INTERNAL_INBOUND)) {
Entity warehouseTo = document.getBelongsToField(DocumentFields.LOCATION_TO);
return validatePositionAttributes(dataDefinition, position, warehouseTo.getBooleanField(LocationFieldsMFR.REQUIRE_PRICE), warehouseTo.getBooleanField(LocationFieldsMFR.REQUIRE_BATCH), warehouseTo.getBooleanField(LocationFieldsMFR.REQUIRE_PRODUCTION_DATE), warehouseTo.getBooleanField(LocationFieldsMFR.REQUIRE_EXPIRATION_DATE));
}
}
return true;
}
Aggregations