use of de.metas.handlingunits.ddorder.api.impl.HUs2DDOrderProducer.HUToDistribute in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_Product_LotNumber_Lock method quarantineHUsForLotNo.
private void quarantineHUsForLotNo(final int lotNoLockId) {
final I_M_Product_LotNumber_Lock lotNoLock = load(lotNoLockId, I_M_Product_LotNumber_Lock.class);
final I_M_Attribute lotNoAttribute = Services.get(ILotNumberDateAttributeDAO.class).getLotNumberAttribute(getCtx());
if (lotNoAttribute == null) {
throw new AdempiereException("Not lotNo attribute found.");
}
final int productId = lotNoLock.getM_Product_ID();
final String lotNoValue = lotNoLock.getLot();
final List<I_M_HU> husForAttributeStringValue = retrieveHUsForAttributeStringValue(productId, lotNoAttribute, lotNoValue);
final List<HUToDistribute> husToDistribute = new ArrayList<>();
for (final I_M_HU hu : husForAttributeStringValue) {
final List<de.metas.handlingunits.model.I_M_InOutLine> inOutLinesForHU = huInOutDAO.retrieveInOutLinesForHU(hu);
if (Check.isEmpty(inOutLinesForHU)) {
continue;
}
I_M_InOut firstReceipt = inOutLinesForHU.get(0).getM_InOut();
final int bpartnerId = firstReceipt.getC_BPartner_ID();
final int bpLocationId = firstReceipt.getC_BPartner_Location_ID();
husToDistribute.add(HUToDistribute.builder().hu(hu).lockLotNo(lotNoLock).bpartnerId(bpartnerId).bpartnerLocationId(bpLocationId).build());
}
Services.get(IHUDDOrderBL.class).createQuarantineDDOrderForHUs(husToDistribute);
setExistingInvoiceCandsInDispute(husForAttributeStringValue);
}
Aggregations