Search in sources :

Example 1 with MWMInOutBoundLineMA

use of org.eevolution.model.MWMInOutBoundLineMA in project adempiere by adempiere.

the class ExpressReceiptScanBar method loadData.

protected void loadData() {
    data = new LinkedHashMap<String, Vector>();
    for (MWMInOutBoundLine inBoundline : getInOutBoundLines()) {
        inBoundline.setMovementQty(Env.ZERO);
        inBoundline.saveEx();
    }
    for (MWMInOutBoundLineMA inBoundlineMA : getDocumentLines()) {
        MProduct product = null;
        MAttributeSetInstance asi = null;
        String lotNo = null;
        String serNo = null;
        Integer referenceId = null;
        BigDecimal qty = null;
        boolean reset = false;
        MWMInOutBoundLine inBoundline = (MWMInOutBoundLine) inBoundlineMA.getWM_InOutBoundLine();
        // inBoundline.setMovementQty(Env.ZERO);
        // inBoundline.saveEx();
        int M_Product_ID = inBoundline.getM_Product_ID();
        int M_AttributeSetInstance_ID = inBoundlineMA.getM_AttributeSetInstance_ID();
        if (M_Product_ID > 0)
            product = MProduct.get(Env.getCtx(), M_Product_ID);
        else
            continue;
        if (M_AttributeSetInstance_ID > 0) {
            asi = new MAttributeSetInstance(Env.getCtx(), M_AttributeSetInstance_ID, null);
            lotNo = asi.getLot();
            serNo = asi.getSerNo();
        } else {
            M_AttributeSetInstance_ID = 0;
            reset = true;
        }
        //referenceId = inBoundline.getC_OrderLine_ID();
        qty = inBoundlineMA.getMovementQty();
        ArrayList<Object> values = null;
        while (qty.signum() != 0) {
            if (getSource() != null && source.size() > 0) {
                values = checkProduct(product, qty, reset);
                if (values == null)
                    throw new AdempiereException("@M_Product_ID@ ; " + product.getName() + " @InValid@");
            }
            referenceId = (Integer) values.get(ID);
            String key = product.getValue();
            if (lotNo != null && lotNo.length() > 0)
                key = key + lotNo;
            if (serNo != null && serNo.length() > 0)
                key = key + serNo;
            if (serNo == null)
                key = key + "#" + referenceId;
            Vector<Object> line = new Vector<Object>(6);
            line.add(product.getValue());
            line.add(product.getName());
            line.add(lotNo);
            line.add(serNo);
            BigDecimal qtyDelivered = (BigDecimal) values.get(QTY_DELIVERED);
            qty = qty.subtract(qtyDelivered);
            line.add(qtyDelivered);
            line.add(inBoundline.get_ID());
            line.add(referenceId != null ? referenceId.intValue() : 0);
            data.put(key, line);
        }
    }
}
Also used : MWMInOutBoundLine(org.eevolution.model.MWMInOutBoundLine) MProduct(org.compiere.model.MProduct) MAttributeSetInstance(org.compiere.model.MAttributeSetInstance) MWMInOutBoundLineMA(org.eevolution.model.MWMInOutBoundLineMA) BigDecimal(java.math.BigDecimal) AdempiereException(org.adempiere.exceptions.AdempiereException) Vector(java.util.Vector)

Example 2 with MWMInOutBoundLineMA

use of org.eevolution.model.MWMInOutBoundLineMA in project adempiere by adempiere.

the class ExpressReceiptScanBar method createLines.

public void createLines() {
    for (Vector<Object> line : getData().values()) {
        int id = (Integer) line.get(5);
        MWMInOutBoundLine ioBoundLine = new MWMInOutBoundLine(Env.getCtx(), id, null);
        for (MWMInOutBoundLineMA ioBoundLineMA : getLinesMA(ioBoundLine)) {
            ioBoundLineMA.deleteEx(true);
        }
    }
    for (Vector<Object> line : getData().values()) {
        String value = (String) line.get(0);
        String lotNo = (String) line.get(2);
        String serNo = (String) line.get(3);
        Boolean isASI = (lotNo != null && lotNo.length() > 0) || (serNo != null && serNo.length() > 0) ? true : false;
        BigDecimal qty = (BigDecimal) line.get(4);
        int id = (Integer) line.get(5);
        Integer referenceId = (Integer) line.get(6);
        MWMInOutBoundLine boundLine = null;
        MAttributeSetInstance asi = null;
        MProduct product = new Query(Env.getCtx(), I_M_Product.Table_Name, "Value = ? ", null).setClient_ID().setParameters(value).firstOnly();
        String desc = null;
        if (referenceId > 0)
            boundLine = getMWMInOutBoundLine(referenceId, product.get_ID());
        if (product.getM_AttributeSet_ID() > 0 && isASI) {
            asi = getASI(product, lotNo, serNo);
            if (asi == null)
                asi = getAttributeSetInstance(product, lotNo, serNo, getM_Locater_ID(), null);
        }
        MWMInOutBoundLineMA boundLineMA = new MWMInOutBoundLineMA(Env.getCtx(), 0, null);
        if (asi == null && isASI) {
            asi = new MAttributeSetInstance(Env.getCtx(), 0, product.getM_AttributeSet_ID(), null);
            if (lotNo != null) {
                asi.setLot(lotNo);
                desc = lotNo;
            }
            if (serNo != null) {
                asi.setSerNo(serNo);
                if (desc != null)
                    desc = desc + " - " + serNo;
                else
                    desc = serNo;
            }
            asi.setDescription(desc);
            asi.saveEx();
        }
        boundLineMA.setWM_InOutBoundLine_ID(boundLine.get_ID());
        boundLineMA.setM_AttributeSetInstance_ID(asi == null ? 0 : asi.getM_AttributeSetInstance_ID());
        boundLineMA.setMovementQty(qty);
        boundLineMA.saveEx();
        boundLine.setMovementQty(boundLine.getMovementQty().add(qty));
        boundLine.saveEx();
    }
}
Also used : MWMInOutBoundLine(org.eevolution.model.MWMInOutBoundLine) MProduct(org.compiere.model.MProduct) Query(org.compiere.model.Query) MAttributeSetInstance(org.compiere.model.MAttributeSetInstance) MWMInOutBoundLineMA(org.eevolution.model.MWMInOutBoundLineMA) BigDecimal(java.math.BigDecimal)

Aggregations

BigDecimal (java.math.BigDecimal)2 MAttributeSetInstance (org.compiere.model.MAttributeSetInstance)2 MProduct (org.compiere.model.MProduct)2 MWMInOutBoundLine (org.eevolution.model.MWMInOutBoundLine)2 MWMInOutBoundLineMA (org.eevolution.model.MWMInOutBoundLineMA)2 Vector (java.util.Vector)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 Query (org.compiere.model.Query)1