Search in sources :

Example 1 with DocumentState

use of com.qcadoo.mes.materialFlowResources.constants.DocumentState in project mes by qcadoo.

the class DocumentDetailsHooks method initializeDocument.

public void initializeDocument(final ViewDefinitionState view) {
    showFieldsByDocumentType(view);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    FormComponent documentForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long documentId = documentForm.getEntityId();
    Entity document = documentForm.getPersistedEntityWithIncludedFormValues();
    DocumentState state = DocumentState.of(document);
    if (documentId == null) {
        changeAcceptButtonState(window, false);
        changePrintButtonState(window, false);
        changeFillResourceButtonState(window, false);
        changeCheckResourcesStockButtonState(window, false);
        changeAddMultipleResourcesButtonState(window, false);
        FieldComponent dateField = (FieldComponent) view.getComponentByReference(DocumentFields.TIME);
        FieldComponent userField = (FieldComponent) view.getComponentByReference(DocumentFields.USER);
        if (dateField.getFieldValue() == null) {
            dateField.setFieldValue(setDateToField(new Date()));
        }
        userField.setFieldValue(userService.getCurrentUserEntity().getId());
    } else if (DocumentState.DRAFT.equals(state)) {
        changeAcceptButtonState(window, true);
        changePrintButtonState(window, true);
        changeFillResourceButtonState(window, reservationsService.reservationsEnabledForDocumentPositions(document));
        changeCheckResourcesStockButtonState(window, DocumentType.isOutbound(document.getStringField(DocumentFields.TYPE)) && !reservationsService.reservationsEnabledForDocumentPositions(document));
        changeAddMultipleResourcesButtonState(window, DocumentType.isOutbound(document.getStringField(DocumentFields.TYPE)));
        if (pluginManager.isPluginEnabled(ESILCO)) {
            if (document.getBooleanField(DocumentFields.WMS) && !document.getBooleanField(DocumentFields.EDIT_IN_WMS)) {
                toggleRibbon(window, false);
                changeFillResourceButtonState(window, false);
                changeAddMultipleResourcesButtonState(window, false);
            } else {
                toggleRibbon(window, true);
            }
        }
    } else if (DocumentState.ACCEPTED.equals(state)) {
        documentForm.setFormEnabled(false);
        toggleRibbon(window, false);
        changePrintButtonState(window, true);
        changeFillResourceButtonState(window, false);
        changeCheckResourcesStockButtonState(window, false);
        changeAddMultipleResourcesButtonState(window, false);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) DocumentState(com.qcadoo.mes.materialFlowResources.constants.DocumentState) WindowComponent(com.qcadoo.view.api.components.WindowComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 2 with DocumentState

use of com.qcadoo.mes.materialFlowResources.constants.DocumentState 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

DocumentState (com.qcadoo.mes.materialFlowResources.constants.DocumentState)2 Entity (com.qcadoo.model.api.Entity)2 DocumentType (com.qcadoo.mes.materialFlowResources.constants.DocumentType)1 FieldComponent (com.qcadoo.view.api.components.FieldComponent)1 FormComponent (com.qcadoo.view.api.components.FormComponent)1 WindowComponent (com.qcadoo.view.api.components.WindowComponent)1