Search in sources :

Example 6 with MStorage

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

the class WMRuleEngine method getStorage.

/**
	 * Get Storage list based on strategy , product id , attribute set instance id , area type , section type
	 * @param strategy
	 * @param productId
	 * @param attributeSetInstanceId
	 * @param qtyToDeliver
	 * @param warehouseAreaTypeId
	 * @param warehouseSectionTypeId    @return List of Storage
	 */
public static List<MStorage> getStorage(MWMStrategy strategy, int productId, int attributeSetInstanceId, BigDecimal qtyToDeliver, int warehouseAreaTypeId, int warehouseSectionTypeId) {
    ArrayList<MStorage> targetStorages = new ArrayList();
    WMRuleEngine engine = WMRuleEngine.get();
    for (MWMStrategyDetail detail : strategy.getStrategyDetail()) {
        MWMRule rule = (MWMRule) detail.getWM_Rule();
        WMRuleInterface implementation = engine.getWMRuleFactory(engine.getClassName(rule));
        List<MStorage> storages = implementation.getStorage(strategy.getCtx(), strategy.getM_Warehouse_ID(), productId, attributeSetInstanceId, qtyToDeliver, warehouseAreaTypeId, warehouseSectionTypeId, strategy.get_TrxName());
        for (MStorage storage : storages) {
            targetStorages.add(storage);
        }
    }
    return targetStorages;
}
Also used : MWMStrategyDetail(org.eevolution.model.MWMStrategyDetail) MWMRule(org.eevolution.model.MWMRule) ArrayList(java.util.ArrayList) MStorage(org.compiere.model.MStorage)

Example 7 with MStorage

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

the class InOutGenerate method createLine.

//	generate
/**************************************************************************
	 * 	Create Line
	 *	@param order order
	 *	@param orderLine line
	 *	@param qty qty
	 *	@param storages storage info
	 *	@param force force delivery
	 */
private void createLine(MOrder order, MOrderLine orderLine, BigDecimal qty, MStorage[] storages, boolean force) {
    //	Complete last Shipment - can have multiple shipments
    if (m_lastC_BPartner_Location_ID != orderLine.getC_BPartner_Location_ID())
        completeShipment();
    m_lastC_BPartner_Location_ID = orderLine.getC_BPartner_Location_ID();
    //	Create New Shipment
    if (m_shipment == null) {
        m_shipment = new MInOut(order, 0, m_movementDate);
        //	sets Org too
        m_shipment.setM_Warehouse_ID(orderLine.getM_Warehouse_ID());
        if (order.getC_BPartner_ID() != orderLine.getC_BPartner_ID())
            m_shipment.setC_BPartner_ID(orderLine.getC_BPartner_ID());
        if (order.getC_BPartner_Location_ID() != orderLine.getC_BPartner_Location_ID())
            m_shipment.setC_BPartner_Location_ID(orderLine.getC_BPartner_Location_ID());
        if (!m_shipment.save())
            throw new IllegalStateException("Could not create Shipment");
    }
    //	Non Inventory Lines
    if (storages == null) {
        MInOutLine line = new MInOutLine(m_shipment);
        line.setOrderLine(orderLine, 0, Env.ZERO);
        //	Correct UOM
        line.setQty(qty);
        if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0)
            line.setQtyEntered(qty.multiply(orderLine.getQtyEntered()).divide(orderLine.getQtyOrdered(), 12, BigDecimal.ROUND_HALF_UP));
        line.setLine(m_line + orderLine.getLine());
        if (!line.save())
            throw new IllegalStateException("Could not create Shipment Line");
        log.fine(line.toString());
        return;
    }
    //	Inventory Lines
    ArrayList<MInOutLine> list = new ArrayList<MInOutLine>();
    BigDecimal toDeliver = qty;
    for (int i = 0; i < storages.length; i++) {
        MStorage storage = storages[i];
        BigDecimal deliver = toDeliver;
        //skip negative storage record
        if (storage.getQtyOnHand().signum() < 0)
            continue;
        //	Not enough On Hand
        if (deliver.compareTo(storage.getQtyOnHand()) > 0 && //	positive storage
        storage.getQtyOnHand().signum() >= 0) {
            if (//	Adjust to OnHand Qty  
            !force || //	if force not on last location
            (force && i + 1 != storages.length))
                deliver = storage.getQtyOnHand();
        }
        if (//	zero deliver
        deliver.signum() == 0)
            continue;
        int M_Locator_ID = storage.getM_Locator_ID();
        //
        MInOutLine line = null;
        if (//      find line with Locator
        orderLine.getM_AttributeSetInstance_ID() == 0) {
            for (int ll = 0; ll < list.size(); ll++) {
                MInOutLine test = (MInOutLine) list.get(ll);
                if (test.getM_Locator_ID() == M_Locator_ID && test.getM_AttributeSetInstance_ID() == 0) {
                    line = test;
                    break;
                }
            }
        }
        if (//	new line
        line == null) {
            line = new MInOutLine(m_shipment);
            line.setOrderLine(orderLine, M_Locator_ID, order.isSOTrx() ? deliver : Env.ZERO);
            line.setQty(deliver);
            list.add(line);
        } else
            //	existing line
            line.setQty(line.getMovementQty().add(deliver));
        if (orderLine.getQtyEntered().compareTo(orderLine.getQtyOrdered()) != 0)
            line.setQtyEntered(line.getMovementQty().multiply(orderLine.getQtyEntered()).divide(orderLine.getQtyOrdered(), 12, BigDecimal.ROUND_HALF_UP));
        line.setLine(m_line + orderLine.getLine());
        if (!line.save())
            throw new IllegalStateException("Could not create Shipment Line");
        log.fine("ToDeliver=" + qty + "/" + deliver + " - " + line);
        toDeliver = toDeliver.subtract(deliver);
        //      Temp adjustment, actual update happen in MInOut.completeIt
        storage.setQtyOnHand(storage.getQtyOnHand().subtract(deliver));
        //
        if (toDeliver.signum() == 0)
            break;
    }
    if (toDeliver.signum() != 0) {
        if (!force) {
            throw new IllegalStateException("Not All Delivered - Remainder=" + toDeliver);
        } else {
            MInOutLine line = new MInOutLine(m_shipment);
            line.setOrderLine(orderLine, 0, order.isSOTrx() ? toDeliver : Env.ZERO);
            line.setQty(toDeliver);
            if (!line.save())
                throw new IllegalStateException("Could not create Shipment Line");
        }
    }
}
Also used : MInOut(org.compiere.model.MInOut) MInOutLine(org.compiere.model.MInOutLine) ArrayList(java.util.ArrayList) MStorage(org.compiere.model.MStorage) BigDecimal(java.math.BigDecimal)

Example 8 with MStorage

use of org.compiere.model.MStorage 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)

Example 9 with MStorage

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

the class MovementGenerate method generate.

//	doIt
/**
	 * 	Generate Shipments
	 * 	@param pstmt Order Query
	 *	@return info
	 */
private String generate(PreparedStatement pstmt) {
    MClient client = MClient.get(getCtx());
    try {
        ResultSet rs = pstmt.executeQuery();
        while (//	Order
        rs.next()) {
            MDDOrder order = new MDDOrder(getCtx(), rs, get_TrxName());
            //	New Header different Shipper, Shipment Location
            if (!p_ConsolidateDocument || (m_movement != null && (m_movement.getC_BPartner_Location_ID() != order.getC_BPartner_Location_ID() || m_movement.getM_Shipper_ID() != order.getM_Shipper_ID()))) {
                completeMovement();
            }
            log.fine("check: " + order + " - DeliveryRule=" + order.getDeliveryRule());
            //
            Timestamp minGuaranteeDate = m_movementDate;
            boolean completeOrder = MDDOrder.DELIVERYRULE_CompleteOrder.equals(order.getDeliveryRule());
            //	OrderLine WHERE
            String where = " " + p_M_Warehouse_ID + " IN (SELECT l.M_Warehouse_ID FROM M_Locator l WHERE l.M_Locator_ID=M_Locator_ID) ";
            if (p_DatePromised != null)
                where += " AND (TRUNC(DatePromised)<=" + DB.TO_DATE(p_DatePromised, true) + " OR DatePromised IS NULL)";
            //	Exclude Auto Delivery if not Force
            if (!MDDOrder.DELIVERYRULE_Force.equals(order.getDeliveryRule()))
                where += " AND (DD_OrderLine.M_Product_ID IS NULL" + " OR EXISTS (SELECT * FROM M_Product p " + "WHERE DD_OrderLine.M_Product_ID=p.M_Product_ID" + " AND IsExcludeAutoDelivery='N'))";
            //	Exclude Unconfirmed
            if (!p_IsUnconfirmedInOut)
                where += " AND NOT EXISTS (SELECT * FROM M_MovementLine iol" + " INNER JOIN M_Movement io ON (iol.M_Movement_ID=io.M_Movement_ID) " + "WHERE iol.DD_OrderLine_ID=DD_OrderLine.DD_OrderLine_ID AND io.DocStatus IN ('IP','WC'))";
            //	Deadlock Prevention - Order by M_Product_ID
            MDDOrderLine[] lines = order.getLines(where, "M_Product_ID");
            for (int i = 0; i < lines.length; i++) {
                MDDOrderLine line = lines[i];
                MLocator l = new MLocator(getCtx(), line.getM_Locator_ID(), get_TrxName());
                if (l.getM_Warehouse_ID() != p_M_Warehouse_ID)
                    continue;
                log.fine("check: " + line);
                BigDecimal onHand = Env.ZERO;
                //BigDecimal toDeliver = line.getQtyOrdered()
                //.subtract(line.getQtyDelivered());
                BigDecimal toDeliver = line.getConfirmedQty();
                MProduct product = line.getProduct();
                //	Nothing to Deliver
                if (product != null && toDeliver.signum() == 0)
                    continue;
                // or it's a charge - Bug#: 1603966 
                if (line.getC_Charge_ID() != 0 && toDeliver.signum() == 0)
                    continue;
                //	Check / adjust for confirmations
                BigDecimal unconfirmedShippedQty = Env.ZERO;
                if (p_IsUnconfirmedInOut && product != null && toDeliver.signum() != 0) {
                    String where2 = "EXISTS (SELECT * FROM M_Movement io WHERE io.M_Movement_ID=M_MovementLine.M_Movement_ID AND io.DocStatus IN ('IP','WC'))";
                    MMovementLine[] iols = MMovementLine.getOfOrderLine(getCtx(), line.getDD_OrderLine_ID(), where2, null);
                    for (int j = 0; j < iols.length; j++) unconfirmedShippedQty = unconfirmedShippedQty.add(iols[j].getMovementQty());
                    String logInfo = "Unconfirmed Qty=" + unconfirmedShippedQty + " - ToDeliver=" + toDeliver + "->";
                    toDeliver = toDeliver.subtract(unconfirmedShippedQty);
                    logInfo += toDeliver;
                    if (toDeliver.signum() < 0) {
                        toDeliver = Env.ZERO;
                        logInfo += " (set to 0)";
                    }
                    //	Adjust On Hand
                    onHand = onHand.subtract(unconfirmedShippedQty);
                    log.fine(logInfo);
                }
                //	Comments & lines w/o product & services
                if ((product == null || !product.isStocked()) && (//	comments
                line.getQtyOrdered().signum() == 0 || //	lines w/o product
                toDeliver.signum() != 0)) {
                    if (//	printed later
                    !MDDOrder.DELIVERYRULE_CompleteOrder.equals(order.getDeliveryRule()))
                        createLine(order, line, toDeliver, null, false);
                    continue;
                }
                //	Stored Product
                MProductCategory pc = MProductCategory.get(order.getCtx(), product.getM_Product_Category_ID());
                String MMPolicy = pc.getMMPolicy();
                if (MMPolicy == null || MMPolicy.length() == 0)
                    MMPolicy = client.getMMPolicy();
                //
                MStorage[] storages = getStorages(l.getM_Warehouse_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), product.getM_AttributeSet_ID(), line.getM_AttributeSetInstance_ID() == 0, minGuaranteeDate, MClient.MMPOLICY_FiFo.equals(MMPolicy));
                for (int j = 0; j < storages.length; j++) {
                    MStorage storage = storages[j];
                    onHand = onHand.add(storage.getQtyOnHand());
                }
                boolean fullLine = onHand.compareTo(toDeliver) >= 0 || toDeliver.signum() < 0;
                //	Complete Order
                if (completeOrder && !fullLine) {
                    log.fine("Failed CompleteOrder - OnHand=" + onHand + " (Unconfirmed=" + unconfirmedShippedQty + "), ToDeliver=" + toDeliver + " - " + line);
                    completeOrder = false;
                    break;
                } else //	Complete Line
                if (fullLine && MDDOrder.DELIVERYRULE_CompleteLine.equals(order.getDeliveryRule())) {
                    log.fine("CompleteLine - OnHand=" + onHand + " (Unconfirmed=" + unconfirmedShippedQty + ", ToDeliver=" + toDeliver + " - " + line);
                    //	
                    createLine(order, line, toDeliver, storages, false);
                } else //	Availability
                if (MDDOrder.DELIVERYRULE_Availability.equals(order.getDeliveryRule()) && (onHand.signum() > 0 || toDeliver.signum() < 0)) {
                    BigDecimal deliver = toDeliver;
                    if (deliver.compareTo(onHand) > 0)
                        deliver = onHand;
                    log.fine("Available - OnHand=" + onHand + " (Unconfirmed=" + unconfirmedShippedQty + "), ToDeliver=" + toDeliver + ", Delivering=" + deliver + " - " + line);
                    //	
                    createLine(order, line, deliver, storages, false);
                } else //	Force
                if (MDDOrder.DELIVERYRULE_Force.equals(order.getDeliveryRule())) {
                    BigDecimal deliver = toDeliver;
                    log.fine("Force - OnHand=" + onHand + " (Unconfirmed=" + unconfirmedShippedQty + "), ToDeliver=" + toDeliver + ", Delivering=" + deliver + " - " + line);
                    //	
                    createLine(order, line, deliver, storages, true);
                } else //	Manual
                if (MDDOrder.DELIVERYRULE_Manual.equals(order.getDeliveryRule()))
                    log.fine("Manual - OnHand=" + onHand + " (Unconfirmed=" + unconfirmedShippedQty + ") - " + line);
                else
                    log.fine("Failed: " + order.getDeliveryRule() + " - OnHand=" + onHand + " (Unconfirmed=" + unconfirmedShippedQty + "), ToDeliver=" + toDeliver + " - " + line);
            }
            //	Complete Order successful
            if (completeOrder && MDDOrder.DELIVERYRULE_CompleteOrder.equals(order.getDeliveryRule())) {
                for (int i = 0; i < lines.length; i++) {
                    MDDOrderLine line = lines[i];
                    MLocator l = new MLocator(getCtx(), line.getM_Locator_ID(), get_TrxName());
                    if (l.getM_Warehouse_ID() != p_M_Warehouse_ID)
                        continue;
                    MProduct product = line.getProduct();
                    BigDecimal toDeliver = line.getQtyOrdered().subtract(line.getQtyDelivered());
                    //
                    MStorage[] storages = null;
                    if (product != null && product.isStocked()) {
                        MProductCategory pc = MProductCategory.get(order.getCtx(), product.getM_Product_Category_ID());
                        String MMPolicy = pc.getMMPolicy();
                        if (MMPolicy == null || MMPolicy.length() == 0)
                            MMPolicy = client.getMMPolicy();
                        //
                        storages = getStorages(l.getM_Warehouse_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), product.getM_AttributeSet_ID(), line.getM_AttributeSetInstance_ID() == 0, minGuaranteeDate, MClient.MMPOLICY_FiFo.equals(MMPolicy));
                    }
                    //	
                    createLine(order, line, toDeliver, storages, false);
                }
            }
            m_line += 1000;
        }
        //	while order
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, m_sql, e);
    }
    try {
        if (pstmt != null)
            pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        pstmt = null;
    }
    completeMovement();
    return "@Created@ = " + m_created;
}
Also used : MProduct(org.compiere.model.MProduct) Timestamp(java.sql.Timestamp) MStorage(org.compiere.model.MStorage) BigDecimal(java.math.BigDecimal) AdempiereException(org.adempiere.exceptions.AdempiereException) MClient(org.compiere.model.MClient) MDDOrderLine(org.eevolution.model.MDDOrderLine) MProductCategory(org.compiere.model.MProductCategory) MLocator(org.compiere.model.MLocator) ResultSet(java.sql.ResultSet) MDDOrder(org.eevolution.model.MDDOrder) MMovementLine(org.compiere.model.MMovementLine)

Example 10 with MStorage

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

the class ReplenishReport method createMovements.

//	createRequisition
/**
	 * 	Create Inventory Movements
	 */
private void createMovements() {
    int noMoves = 0;
    String info = "";
    //
    MClient client = null;
    MMovement move = null;
    int M_Warehouse_ID = 0;
    int M_WarehouseSource_ID = 0;
    MWarehouse whSource = null;
    MWarehouse wh = null;
    X_T_Replenish[] replenishs = getReplenish("M_WarehouseSource_ID IS NOT NULL");
    for (int i = 0; i < replenishs.length; i++) {
        X_T_Replenish replenish = replenishs[i];
        if (whSource == null || whSource.getM_WarehouseSource_ID() != replenish.getM_WarehouseSource_ID())
            whSource = MWarehouse.get(getCtx(), replenish.getM_WarehouseSource_ID());
        if (wh == null || wh.getM_Warehouse_ID() != replenish.getM_Warehouse_ID())
            wh = MWarehouse.get(getCtx(), replenish.getM_Warehouse_ID());
        if (client == null || client.getAD_Client_ID() != whSource.getAD_Client_ID())
            client = MClient.get(getCtx(), whSource.getAD_Client_ID());
        //
        if (move == null || M_WarehouseSource_ID != replenish.getM_WarehouseSource_ID() || M_Warehouse_ID != replenish.getM_Warehouse_ID()) {
            M_WarehouseSource_ID = replenish.getM_WarehouseSource_ID();
            M_Warehouse_ID = replenish.getM_Warehouse_ID();
            move = new MMovement(getCtx(), 0, get_TrxName());
            move.setC_DocType_ID(p_C_DocType_ID);
            move.setDescription(Msg.getMsg(getCtx(), "Replenishment") + ": " + whSource.getName() + "->" + wh.getName());
            //	Set Org
            move.setAD_Org_ID(whSource.getAD_Org_ID());
            if (!move.save())
                return;
            log.fine(move.toString());
            noMoves++;
            info += " - " + move.getDocumentNo();
        }
        //	To
        int M_LocatorTo_ID = wh.getDefaultLocator().getM_Locator_ID();
        //	From: Look-up Storage
        MProduct product = MProduct.get(getCtx(), replenish.getM_Product_ID());
        String MMPolicy = product.getMMPolicy();
        MStorage[] storages = MStorage.getWarehouse(getCtx(), whSource.getM_Warehouse_ID(), replenish.getM_Product_ID(), 0, 0, true, null, MClient.MMPOLICY_FiFo.equals(MMPolicy), get_TrxName());
        //
        BigDecimal target = replenish.getQtyToOrder();
        for (int j = 0; j < storages.length; j++) {
            MStorage storage = storages[j];
            if (storage.getQtyOnHand().signum() <= 0)
                continue;
            BigDecimal moveQty = target;
            if (storage.getQtyOnHand().compareTo(moveQty) < 0)
                moveQty = storage.getQtyOnHand();
            //
            MMovementLine line = new MMovementLine(move);
            line.setM_Product_ID(replenish.getM_Product_ID());
            line.setMovementQty(moveQty);
            if (replenish.getQtyToOrder().compareTo(moveQty) != 0)
                line.setDescription("Total: " + replenish.getQtyToOrder());
            //	from
            line.setM_Locator_ID(storage.getM_Locator_ID());
            line.setM_AttributeSetInstance_ID(storage.getM_AttributeSetInstance_ID());
            //	to
            line.setM_LocatorTo_ID(M_LocatorTo_ID);
            line.setM_AttributeSetInstanceTo_ID(storage.getM_AttributeSetInstance_ID());
            line.saveEx();
            //
            target = target.subtract(moveQty);
            if (target.signum() == 0)
                break;
        }
    }
    if (replenishs.length == 0) {
        m_info = "No Source Warehouse";
        log.warning(m_info);
    } else {
        m_info = "#" + noMoves + info;
        log.info(m_info);
    }
}
Also used : MProduct(org.compiere.model.MProduct) X_T_Replenish(org.compiere.model.X_T_Replenish) MMovementLine(org.compiere.model.MMovementLine) MMovement(org.compiere.model.MMovement) MStorage(org.compiere.model.MStorage) MWarehouse(org.compiere.model.MWarehouse) BigDecimal(java.math.BigDecimal) MClient(org.compiere.model.MClient)

Aggregations

MStorage (org.compiere.model.MStorage)33 BigDecimal (java.math.BigDecimal)27 MProduct (org.compiere.model.MProduct)16 ArrayList (java.util.ArrayList)11 Timestamp (java.sql.Timestamp)9 MLocator (org.compiere.model.MLocator)8 MMovementLine (org.compiere.model.MMovementLine)7 ResultSet (java.sql.ResultSet)6 AdempiereException (org.adempiere.exceptions.AdempiereException)5 MInOutLine (org.compiere.model.MInOutLine)5 PreparedStatement (java.sql.PreparedStatement)4 MClient (org.compiere.model.MClient)4 MMovement (org.compiere.model.MMovement)4 MOrderLine (org.compiere.model.MOrderLine)4 MWarehouse (org.compiere.model.MWarehouse)4 KeyNamePair (org.compiere.util.KeyNamePair)4 MDDOrderLine (org.eevolution.model.MDDOrderLine)4 MAttributeSet (org.compiere.model.MAttributeSet)3 MAttributeSetInstance (org.compiere.model.MAttributeSetInstance)3 MInOut (org.compiere.model.MInOut)3