Search in sources :

Example 1 with HUEditorRowAttributes

use of de.metas.ui.web.handlingunits.HUEditorRowAttributes in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_HU_CreateReceipt_Base method rejectIfMandatoryAttributesAreNotFilled.

private ProcessPreconditionsResolution rejectIfMandatoryAttributesAreNotFilled(final HUEditorRow document) {
    // 
    // Make sure all mandatory attributes are filled
    final HUEditorRowAttributes attributes = document.getAttributes();
    for (final String mandatoryAttributeName : attributes.getMandatoryAttributeNames()) {
        final Object value = attributes.getValue(mandatoryAttributeName);
        if (Check.isEmpty(value)) {
            final I_M_Attribute attribute = attributeDAO.retrieveAttributeByValue(mandatoryAttributeName);
            final I_M_Attribute translatedAttribute = InterfaceWrapperHelper.translate(attribute, I_M_Attribute.class);
            final ITranslatableString msg = msgBL.getTranslatableMsgText(MSG_MissingMandatoryHUAttribute, translatedAttribute.getName());
            return ProcessPreconditionsResolution.reject(msg);
        }
    }
    return ProcessPreconditionsResolution.accept();
}
Also used : HUEditorRowAttributes(de.metas.ui.web.handlingunits.HUEditorRowAttributes) ITranslatableString(de.metas.i18n.ITranslatableString) I_M_Attribute(org.compiere.model.I_M_Attribute) ITranslatableString(de.metas.i18n.ITranslatableString)

Example 2 with HUEditorRowAttributes

use of de.metas.ui.web.handlingunits.HUEditorRowAttributes in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_HU_CreateReceipt_Base method rejectIfSecurPharmAttributesAreNotOK.

private ProcessPreconditionsResolution rejectIfSecurPharmAttributesAreNotOK(final HUEditorRow document) {
    // 
    // OK if this is not a Pharma product
    final HUEditorRowAttributes attributes = document.getAttributes();
    if (!attributes.hasAttribute(AttributeConstants.ATTR_SecurPharmScannedStatus)) {
        return ProcessPreconditionsResolution.accept();
    }
    // NOK if SecurPharm connection is not configured and we deal with a pharma product
    if (!securPharmService.hasConfig()) {
        return ProcessPreconditionsResolution.reject("SecurPharm not configured");
    }
    // 
    // NOK if not scanned and vendor != manufacturer
    final BPartnerId vendorId = document.getBPartnerId();
    final BPartnerId manufacturerId = productRepository.getById(document.getProductId()).getManufacturerId();
    if (!BPartnerId.equals(vendorId, manufacturerId)) {
        final SecurPharmAttributesStatus status = SecurPharmAttributesStatus.ofNullableCodeOrKnown(attributes.getValueAsString(AttributeConstants.ATTR_SecurPharmScannedStatus));
        if (status.isUnknown()) {
            return ProcessPreconditionsResolution.reject(Services.get(IMsgBL.class).getTranslatableMsgText(MSG_ScanRequired));
        }
    }
    // OK
    return ProcessPreconditionsResolution.accept();
}
Also used : SecurPharmAttributesStatus(de.metas.vertical.pharma.securpharm.attribute.SecurPharmAttributesStatus) HUEditorRowAttributes(de.metas.ui.web.handlingunits.HUEditorRowAttributes) BPartnerId(de.metas.bpartner.BPartnerId)

Aggregations

HUEditorRowAttributes (de.metas.ui.web.handlingunits.HUEditorRowAttributes)2 BPartnerId (de.metas.bpartner.BPartnerId)1 ITranslatableString (de.metas.i18n.ITranslatableString)1 SecurPharmAttributesStatus (de.metas.vertical.pharma.securpharm.attribute.SecurPharmAttributesStatus)1 I_M_Attribute (org.compiere.model.I_M_Attribute)1