Search in sources :

Example 1 with DocumentType

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;
}
Also used : Entity(com.qcadoo.model.api.Entity) DocumentType(com.qcadoo.mes.materialFlowResources.constants.DocumentType)

Example 2 with DocumentType

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;
}
Also used : Entity(com.qcadoo.model.api.Entity) DocumentState(com.qcadoo.mes.materialFlowResources.constants.DocumentState) DocumentType(com.qcadoo.mes.materialFlowResources.constants.DocumentType)

Aggregations

DocumentType (com.qcadoo.mes.materialFlowResources.constants.DocumentType)2 Entity (com.qcadoo.model.api.Entity)2 DocumentState (com.qcadoo.mes.materialFlowResources.constants.DocumentState)1