Search in sources :

Example 6 with MAttributeSetInstance

use of org.compiere.model.MAttributeSetInstance in project adempiere by adempiere.

the class HTMLMessenger method getBOMLineInfo.

public String getBOMLineInfo(BOMLineWrapper mpbl) {
    SimpleDateFormat df = Env.getLanguage(Env.getCtx()).getDateFormat();
    MProduct p = new MProduct(Env.getCtx(), mpbl.getM_Product_ID(), MProduct.Table_Name);
    MAttributeSetInstance asi = new MAttributeSetInstance(Env.getCtx(), mpbl.getM_AttributeSetInstance_ID(), MAttributeSetInstance.Table_Name);
    Object[] obj = new Object[] { new Integer(mpbl.getPo()), mpbl.getComponentType(), mpbl.getValidFrom() == null ? "" : df.format(mpbl.getValidFrom()), mpbl.getValidTo() == null ? "" : df.format(mpbl.getValidTo()), mpbl.getQtyBOM(), p.getName(), getAttributeSetInstanceInfo(asi, false), getStorageInfo(p, asi) };
    return MessageFormat.format(BOMLINE_INFO_PATTERN, obj);
}
Also used : MProduct(org.compiere.model.MProduct) MAttributeSetInstance(org.compiere.model.MAttributeSetInstance) SimpleDateFormat(java.text.SimpleDateFormat)

Example 7 with MAttributeSetInstance

use of org.compiere.model.MAttributeSetInstance in project adempiere by adempiere.

the class StorageReasoner method getSumQtyRequired.

public BigDecimal getSumQtyRequired(BOMLineWrapper line) {
    MProduct p = new MProduct(Env.getCtx(), line.getM_Product_ID(), null);
    MAttributeSetInstance asi = new MAttributeSetInstance(Env.getCtx(), line.getM_AttributeSetInstance_ID(), null);
    return getSumQtyAvailable(p, asi).subtract(line.getQtyBOM()).negate();
}
Also used : MProduct(org.compiere.model.MProduct) MAttributeSetInstance(org.compiere.model.MAttributeSetInstance)

Example 8 with MAttributeSetInstance

use of org.compiere.model.MAttributeSetInstance in project adempiere by adempiere.

the class StorageReasoner method isQtyAvailable.

public boolean isQtyAvailable(BOMLineWrapper line) {
    MProduct p = new MProduct(Env.getCtx(), line.getM_Product_ID(), null);
    MAttributeSetInstance asi = new MAttributeSetInstance(Env.getCtx(), line.getM_AttributeSetInstance_ID(), null);
    return isQtyAvailable(p, asi);
}
Also used : MProduct(org.compiere.model.MProduct) MAttributeSetInstance(org.compiere.model.MAttributeSetInstance)

Example 9 with MAttributeSetInstance

use of org.compiere.model.MAttributeSetInstance in project adempiere by adempiere.

the class ScanBar method loadData.

protected void loadData() {
    data = new LinkedHashMap<String, Vector>();
    for (PO po : getDocumentLines()) {
        MProduct product = null;
        MAttributeSetInstance asi = null;
        String lotNo = null;
        String serNo = null;
        Integer referenceId = null;
        BigDecimal qty = null;
        boolean reset = false;
        int M_Product_ID = po.get_ValueAsInt(MProduct.COLUMNNAME_M_Product_ID);
        int M_AttributeSetInstance_ID = po.get_ValueAsInt(MAttributeSetInstance.COLUMNNAME_M_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;
            lotNo = null;
            serNo = null;
        }
        if (po instanceof MInOutLine) {
            MInOutLine ioLine = (MInOutLine) po;
            referenceId = ioLine.getC_OrderLine_ID();
            qty = ioLine.getMovementQty();
        }
        if (po instanceof MInventoryLine) {
            MInventoryLine invenotryLine = (MInventoryLine) po;
            qty = invenotryLine.getQtyCount();
        }
        if (getSource() != null && source.size() > 0) {
            ArrayList<Object> values = checkProduct(product, qty, reset);
            if (values == null)
                throw new AdempiereException("@M_Product_ID@ ; " + product.getName() + " @InValid@");
        }
        String key = product.getValue();
        if (lotNo != null && lotNo.length() > 0)
            key = key + lotNo;
        if (serNo != null && serNo.length() > 0)
            key = key + serNo;
        Vector<Object> line = new Vector<Object>(6);
        // 0
        line.add(product.getValue());
        // 1
        line.add(product.getName());
        // 2
        line.add(lotNo);
        // 3
        line.add(serNo);
        // 4
        line.add(qty);
        // 5
        line.add(po.get_ID());
        // 6
        line.add(referenceId != null ? referenceId.intValue() : 0);
        data.put(key, line);
    }
}
Also used : MProduct(org.compiere.model.MProduct) MInOutLine(org.compiere.model.MInOutLine) MInventoryLine(org.compiere.model.MInventoryLine) MAttributeSetInstance(org.compiere.model.MAttributeSetInstance) BigDecimal(java.math.BigDecimal) AdempiereException(org.adempiere.exceptions.AdempiereException) Vector(java.util.Vector) PO(org.compiere.model.PO)

Example 10 with MAttributeSetInstance

use of org.compiere.model.MAttributeSetInstance in project adempiere by adempiere.

the class ScanBar method createLine.

public void createLine() {
    int lineNo = DB.getSQLValueEx(null, "SELECT Line FROM " + tableLine.getTableName() + " WHERE " + table.getTableName() + "_ID=?", getRecord_ID());
    if (lineNo <= 0)
        lineNo = 10;
    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);
        PO poLine = 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;
        poLine = tableLine.getPO(id, null);
        if (product.getM_AttributeSet_ID() > 0 && isASI) {
            if (poLine != null && poLine.get_ValueAsInt(I_M_AttributeSetInstance.COLUMNNAME_M_AttributeSetInstance_ID) > 0)
                asi = new MAttributeSetInstance(Env.getCtx(), poLine.get_ValueAsInt(I_M_AttributeSetInstance.COLUMNNAME_M_AttributeSetInstance_ID), null);
            else
                asi = getAttributeSetInstance(product, lotNo, serNo, getM_Locater_ID(), null);
        }
        poLine.set_ValueOfColumn(table.getKeyColumns()[0], getRecord_ID());
        poLine.set_ValueOfColumn(I_M_Product.COLUMNNAME_M_Product_ID, product.get_ID());
        poLine.set_ValueOfColumn(I_M_Product.COLUMNNAME_C_UOM_ID, product.getC_UOM_ID());
        poLine.set_ValueOfColumn(I_M_InOutLine.COLUMNNAME_Line, lineNo);
        poLine.set_ValueOfColumn(I_M_InOutLine.COLUMNNAME_IsActive, true);
        int locatorColumnId = poLine.get_ColumnIndex(I_M_InOutLine.COLUMNNAME_M_Locator_ID);
        if (locatorColumnId > 0 && getM_Locater_ID() > 0)
            poLine.set_ValueOfColumn(I_M_InOutLine.COLUMNNAME_M_Locator_ID, getM_Locater_ID());
        if (asi == null && isASI) {
            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();
            }
        }
        if (poLine instanceof MInventoryLine) {
            MStorage storage = MStorage.get(Env.getCtx(), getM_Locater_ID(), product.getM_Product_ID(), asi == null ? 0 : asi.getM_AttributeSetInstance_ID(), null);
            poLine.set_CustomColumn(I_M_InventoryLine.COLUMNNAME_QtyCount, qty);
            poLine.set_CustomColumn(I_M_InventoryLine.COLUMNNAME_QtyBook, storage == null ? Env.ZERO : storage.getQtyOnHand());
        } else if (poLine instanceof MInOutLine) {
            MInOutLine ioLine = (MInOutLine) poLine;
            ioLine.setQty(qty);
            ioLine.setC_OrderLine_ID(referenceId);
        } else if (poLine instanceof MMovementLine) {
            MMovementLine movementLine = (MMovementLine) poLine;
            movementLine.setM_LocatorTo_ID(getM_LocaterTo_ID());
            movementLine.setMovementQty(qty);
        } else
            poLine.set_ValueOfColumn(I_M_InOutLine.COLUMNNAME_MovementQty, qty);
        poLine.set_ValueOfColumn(MAttributeSetInstance.COLUMNNAME_M_AttributeSetInstance_ID, asi == null ? 0 : asi.get_ID());
        if (poLine.is_Changed())
            poLine.saveEx();
        lineNo = lineNo + 10;
    }
}
Also used : MProduct(org.compiere.model.MProduct) Query(org.compiere.model.Query) MInventoryLine(org.compiere.model.MInventoryLine) MInOutLine(org.compiere.model.MInOutLine) MAttributeSetInstance(org.compiere.model.MAttributeSetInstance) MStorage(org.compiere.model.MStorage) BigDecimal(java.math.BigDecimal) MMovementLine(org.compiere.model.MMovementLine) PO(org.compiere.model.PO)

Aggregations

MAttributeSetInstance (org.compiere.model.MAttributeSetInstance)19 MProduct (org.compiere.model.MProduct)13 BigDecimal (java.math.BigDecimal)8 MAttributeSet (org.compiere.model.MAttributeSet)5 MAttribute (org.compiere.model.MAttribute)4 Timestamp (java.sql.Timestamp)3 MInventoryLine (org.compiere.model.MInventoryLine)3 MStorage (org.compiere.model.MStorage)3 KeyNamePair (org.compiere.util.KeyNamePair)3 SimpleDateFormat (java.text.SimpleDateFormat)2 Vector (java.util.Vector)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 MAttributeInstance (org.compiere.model.MAttributeInstance)2 MInOutLine (org.compiere.model.MInOutLine)2 PO (org.compiere.model.PO)2 Query (org.compiere.model.Query)2 MWMInOutBoundLine (org.eevolution.model.MWMInOutBoundLine)2 MWMInOutBoundLineMA (org.eevolution.model.MWMInOutBoundLineMA)2 Dimension (java.awt.Dimension)1 PreparedStatement (java.sql.PreparedStatement)1