use of de.metas.bpartner.BPartnerId in project metasfresh-webui-api by metasfresh.
the class PurchaseRowId method fromJson.
/**
* NOTE: keep in sync with {@link #createDocumentId()}
*/
private static final PurchaseRowId fromJson(@NonNull final String json, @Nullable final DocumentId documentId) {
final List<String> parts = PARTS_SPLITTER.splitToList(json);
final int partsCount = parts.size();
if (// we expect at least the type and purchaseDemandId to be encoded in the json string
partsCount < 2) {
throw new AdempiereException("Invalid format: " + json);
}
try {
final PurchaseRowType type = PurchaseRowType.ofCode(parts.get(0));
final PurchaseDemandId purchaseDemandId = PurchaseDemandId.ofId(Integer.parseInt(parts.get(1)));
if (type == PurchaseRowType.GROUP) {
return new PurchaseRowId(purchaseDemandId, documentId);
}
final BPartnerId vendorId = BPartnerId.ofRepoId(Integer.parseInt(parts.get(2)));
if (type == PurchaseRowType.LINE) {
final boolean readonly = decodeReadonly(parts.get(3));
return new PurchaseRowId(purchaseDemandId, vendorId, readonly, documentId);
}
final Type availabilityType = Type.valueOf(parts.get(3));
final String availabilityDistinguisher = parts.get(4);
if (type == PurchaseRowType.AVAILABILITY_DETAIL) {
return new PurchaseRowId(purchaseDemandId, vendorId, availabilityType, availabilityDistinguisher, documentId);
}
//
throw new AdempiereException("Type " + type + " is not supported");
} catch (final Exception ex) {
throw new AdempiereException("Cannot convert '" + json + "' to " + PurchaseRowId.class, ex);
}
}
use of de.metas.bpartner.BPartnerId in project metasfresh-webui-api by metasfresh.
the class PackingInfoProcessParams method getM_HU_PI_Item_Products.
/**
* @return a list of PI item products that match the selected CU's product and partner, sorted by name.
*/
public LookupValuesList getM_HU_PI_Item_Products() {
final I_M_HU_LUTU_Configuration defaultLUTUConfig = getDefaultLUTUConfig();
final ProductId productId = ProductId.ofRepoId(defaultLUTUConfig.getM_Product_ID());
final BPartnerId bpartnerId = ILUTUConfigurationFactory.extractBPartnerIdOrNull(defaultLUTUConfig);
final boolean includeVirtualItem = !enforcePhysicalTU;
final LookupValuesList huPIItemProducts = WEBUI_ProcessHelper.retrieveHUPIItemProducts(Env.getCtx(), productId, bpartnerId, includeVirtualItem);
return huPIItemProducts;
}
use of de.metas.bpartner.BPartnerId in project metasfresh-webui-api by metasfresh.
the class PackingInfoProcessParams method insertPhysicalFallbackTU.
private void insertPhysicalFallbackTU(@NonNull final I_M_HU_LUTU_Configuration defaultLUTUConfig) {
final BPartnerId bpartnerId = ILUTUConfigurationFactory.extractBPartnerIdOrNull(defaultLUTUConfig);
final ProductId productId = ProductId.ofRepoId(defaultLUTUConfig.getM_Product_ID());
final List<I_M_HU_PI_Item_Product> availableHUPIItemProductRecords = WEBUI_ProcessHelper.retrieveHUPIItemProductRecords(Env.getCtx(), productId, bpartnerId, // includeVirtualItem == false
false);
Check.errorIf(availableHUPIItemProductRecords.isEmpty(), "There is no non-virtual M_HU_PI_Item_Product value for the given product and bPartner; product={}; bPartner={}", productId, bpartnerId);
final I_M_HU_PI_Item_Product pip = availableHUPIItemProductRecords.get(0);
defaultLUTUConfig.setM_HU_PI_Item_Product_ID(pip.getM_HU_PI_Item_Product_ID());
defaultLUTUConfig.setM_TU_HU_PI_ID(pip.getM_HU_PI_Item().getM_HU_PI_Version().getM_HU_PI_ID());
defaultLUTUConfig.setQtyCU(pip.getQty());
final List<I_M_HU_PI_Item> luPIItems = getAvailableLuPIItems(pip, bpartnerId);
if (luPIItems.isEmpty()) {
defaultLUTUConfig.setM_LU_HU_PI_Item(null);
defaultLUTUConfig.setM_LU_HU_PI(null);
} else {
final I_M_HU_PI_Item luPiItem = luPIItems.get(0);
defaultLUTUConfig.setM_LU_HU_PI_Item(luPiItem);
defaultLUTUConfig.setQtyTU(luPiItem.getQty());
defaultLUTUConfig.setM_LU_HU_PI_ID(luPiItem.getM_HU_PI_Version().getM_HU_PI_ID());
}
}
use of de.metas.bpartner.BPartnerId 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();
}
use of de.metas.bpartner.BPartnerId in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_HU_Pick_ParametersFiller method createPickingSlotLabel.
private String createPickingSlotLabel(@NonNull final I_M_PickingSlot pickingslot) {
final StringBuilder result = new StringBuilder(pickingslot.getPickingSlot());
final BPartnerId bpartnerId = BPartnerId.ofRepoIdOrNull(pickingslot.getC_BPartner_ID());
if (bpartnerId != null) {
final IBPartnerDAO bpartnersRepo = Services.get(IBPartnerDAO.class);
final I_C_BPartner bpartner = bpartnersRepo.getById(bpartnerId);
result.append("_").append(bpartner.getName()).append("_").append(bpartner.getValue());
}
return result.toString();
}
Aggregations