Search in sources :

Example 1 with HUToDistribute

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);
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) I_M_InOut(org.compiere.model.I_M_InOut) HUToDistribute(de.metas.handlingunits.ddorder.api.impl.HUs2DDOrderProducer.HUToDistribute) ArrayList(java.util.ArrayList) I_M_Product_LotNumber_Lock(de.metas.product.model.I_M_Product_LotNumber_Lock) ILotNumberDateAttributeDAO(org.adempiere.mm.attributes.api.ILotNumberDateAttributeDAO) AdempiereException(org.adempiere.exceptions.AdempiereException) I_M_Attribute(org.compiere.model.I_M_Attribute) IHUDDOrderBL(de.metas.handlingunits.ddorder.api.IHUDDOrderBL)

Aggregations

IHUDDOrderBL (de.metas.handlingunits.ddorder.api.IHUDDOrderBL)1 HUToDistribute (de.metas.handlingunits.ddorder.api.impl.HUs2DDOrderProducer.HUToDistribute)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 I_M_Product_LotNumber_Lock (de.metas.product.model.I_M_Product_LotNumber_Lock)1 ArrayList (java.util.ArrayList)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 ILotNumberDateAttributeDAO (org.adempiere.mm.attributes.api.ILotNumberDateAttributeDAO)1 I_M_Attribute (org.compiere.model.I_M_Attribute)1 I_M_InOut (org.compiere.model.I_M_InOut)1