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();
}
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();
}
Aggregations