Search in sources :

Example 1 with StorageReasoner

use of org.eevolution.model.reasoner.StorageReasoner in project adempiere by adempiere.

the class HTMLMessenger method getAttributeSetInstanceInfo.

public String getAttributeSetInstanceInfo(MAttributeSetInstance asi, boolean singleRow) {
    MAttributeSet as = new MAttributeSet(Env.getCtx(), asi.getM_AttributeSet_ID(), null);
    StorageReasoner mr = new StorageReasoner();
    int[] ids = mr.getAttributeIDs(asi);
    MAttributeInstance ai = null;
    MAttribute a = null;
    MAttributeValue av = null;
    StringBuffer sb = new StringBuffer();
    String value = null;
    Object[] obj = null;
    for (int i = 0; i < ids.length; i++) {
        ai = new MAttributeInstance(Env.getCtx(), ids[i], asi.get_ID(), (String) null, null);
        ai.load(null);
        a = new MAttribute(Env.getCtx(), ai.getM_Attribute_ID(), null);
        av = new MAttributeValue(Env.getCtx(), ai.getM_AttributeValue_ID(), null);
        // e.g. the list validation type 'L'
        if (ai.getValue() == null) {
            value = av.getValue();
        } else // Takes the value of the M_AttributeInstance itself
        {
            // Round number values to a scale of 2, if type is 'N'
            if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(a.getAttributeValueType())) {
                BigDecimal number = ai.getValueNumber();
                value = number.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
            } else {
                value = ai.getValue();
            }
        }
        obj = new Object[] { a.getName(), value };
        sb.append(MessageFormat.format(ATTRIBUTE_INFO_PATTERN, obj));
        if (singleRow) {
            sb.append("&nbsp;");
        } else {
            sb.append("<br>");
        }
    }
    return sb.toString();
}
Also used : MAttributeInstance(org.compiere.model.MAttributeInstance) MAttributeValue(org.compiere.model.MAttributeValue) StorageReasoner(org.eevolution.model.reasoner.StorageReasoner) BigDecimal(java.math.BigDecimal) MAttributeSet(org.compiere.model.MAttributeSet) MAttribute(org.compiere.model.MAttribute)

Example 2 with StorageReasoner

use of org.eevolution.model.reasoner.StorageReasoner in project adempiere by adempiere.

the class HTMLMessenger method getStorageInfo.

public String getStorageInfo(MProduct p, MAttributeSetInstance asi) {
    StorageReasoner mr = new StorageReasoner();
    int[] ids = mr.getPOIDs(MLocator.Table_Name, null, null);
    MWarehouse warehouse = null;
    MStorage storage = null;
    MLocator locator = null;
    StringBuffer sb = new StringBuffer(STORAGE_HEADER_INFO_PATTERN);
    Object[] obj = null;
    BigDecimal sumQtyOnHand = BigDecimal.ZERO;
    BigDecimal sumQtyReserved = BigDecimal.ZERO;
    BigDecimal sumQtyOrdered = BigDecimal.ZERO;
    int count = 0;
    for (int i = 0; i < ids.length; i++) {
        storage = MStorage.get(Env.getCtx(), ids[i], p.get_ID(), asi.get_ID(), null);
        if (storage == null) {
            continue;
        }
        count++;
        warehouse = new MWarehouse(Env.getCtx(), storage.getM_Warehouse_ID(), null);
        locator = new MLocator(Env.getCtx(), storage.getM_Locator_ID(), null);
        sumQtyOnHand = sumQtyOnHand.add(storage.getQtyOnHand());
        sumQtyReserved = sumQtyReserved.add(storage.getQtyReserved());
        sumQtyOrdered = sumQtyOrdered.add(storage.getQtyOrdered());
        // the quantities of specific locator
        obj = new Object[] { locator.getX() + " - " + locator.getY() + " - " + locator.getZ(), warehouse.getName(), storage.getQtyOnHand(), storage.getQtyReserved(), storage.getQtyOrdered(), storage.getQtyOnHand().subtract(storage.getQtyReserved()) };
        sb.append(MessageFormat.format(STORAGE_LINE_INFO_PATTERN, obj));
    }
    // the sum of the single quantities, if there is more than one line
    if (count > 1) {
        obj = new Object[] { sumQtyOnHand, sumQtyReserved, sumQtyOrdered, sumQtyOnHand.subtract(sumQtyReserved) };
        sb.append(MessageFormat.format(STORAGE_SUM_LINE_INFO_PATTERN, obj));
    }
    double available = sumQtyOnHand.subtract(sumQtyReserved).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
    if (count == 0 || (available <= 0.00d)) {
        sb.append(MessageFormat.format(STORAGE_NOINVENTORY_INFO_PATTERN, obj));
    }
    sb.append(STORAGE_FOOTER_INFO_PATTERN);
    return sb.toString();
}
Also used : MLocator(org.compiere.model.MLocator) StorageReasoner(org.eevolution.model.reasoner.StorageReasoner) MStorage(org.compiere.model.MStorage) MWarehouse(org.compiere.model.MWarehouse) BigDecimal(java.math.BigDecimal)

Example 3 with StorageReasoner

use of org.eevolution.model.reasoner.StorageReasoner in project adempiere by adempiere.

the class CAbstractBOMTree method init.

public void init(int WindowNo, FormFrame frame) {
    super.init(WindowNo, frame);
    reasoner = new StorageReasoner();
    try {
        preInit();
        jbInit();
        getWindow().getContentPane().add(this, BorderLayout.CENTER);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : StorageReasoner(org.eevolution.model.reasoner.StorageReasoner)

Example 4 with StorageReasoner

use of org.eevolution.model.reasoner.StorageReasoner in project adempiere by adempiere.

the class BOMTreeFactory method get.

public static BOMTreeModel get(String bomType, PO po, StorageReasoner reasoner) {
    final StorageReasoner r = reasoner;
    final String type = bomType;
    BOMTreeFactory factory = new BOMTreeFactory() {

        protected String type() {
            return type;
        }

        ;
    };
    factory.buildTree(po, reasoner);
    return factory;
}
Also used : StorageReasoner(org.eevolution.model.reasoner.StorageReasoner)

Example 5 with StorageReasoner

use of org.eevolution.model.reasoner.StorageReasoner in project adempiere by adempiere.

the class BOMWrapper method getLines.

public BOMLineWrapper[] getLines() {
    int[] ids = null;
    String type = null;
    if (get() instanceof MPPProductBOM) {
        type = BOM_TYPE_PRODUCT;
    } else if (get() instanceof MPPOrderBOM) {
        type = BOM_TYPE_ORDER;
    }
    StorageReasoner mr = new StorageReasoner();
    ids = mr.getPOIDs(BOMLineWrapper.tableName(type), idColumn(type) + " = " + getID(), null);
    BOMLineWrapper[] lines = new BOMLineWrapper[ids.length];
    for (int i = 0; i < ids.length; i++) {
        lines[i] = new BOMLineWrapper(getCtx(), ids[i], null, type);
    }
    return lines;
}
Also used : MPPOrderBOM(org.eevolution.model.MPPOrderBOM) StorageReasoner(org.eevolution.model.reasoner.StorageReasoner) MPPProductBOM(org.eevolution.model.MPPProductBOM)

Aggregations

StorageReasoner (org.eevolution.model.reasoner.StorageReasoner)5 BigDecimal (java.math.BigDecimal)2 MAttribute (org.compiere.model.MAttribute)1 MAttributeInstance (org.compiere.model.MAttributeInstance)1 MAttributeSet (org.compiere.model.MAttributeSet)1 MAttributeValue (org.compiere.model.MAttributeValue)1 MLocator (org.compiere.model.MLocator)1 MStorage (org.compiere.model.MStorage)1 MWarehouse (org.compiere.model.MWarehouse)1 MPPOrderBOM (org.eevolution.model.MPPOrderBOM)1 MPPProductBOM (org.eevolution.model.MPPProductBOM)1