Search in sources :

Example 16 with MMovement

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

the class VOrderDistributionReceipt method generateMovements.

//	saveSelection
/**************************************************************************
	 *	Generate Shipments
	 */
private void generateMovements() {
    log.info("DD_Order_ID=" + m_DD_Order_ID);
    log.info("MovementDate" + m_MovementDate);
    String trxName = Trx.createTrxName("IOG");
    //trx needs to be committed too
    Trx trx = Trx.get(trxName, true);
    //  prevents from being called twice
    m_selectionActive = false;
    statusBar.setStatusLine(Msg.translate(Env.getCtx(), "M_Movement_ID"));
    statusBar.setStatusDB(String.valueOf(selection.size()));
    if (selection.size() <= 0)
        return;
    Properties m_ctx = Env.getCtx();
    Timestamp MovementDate = (Timestamp) m_MovementDate;
    MDDOrder order = new MDDOrder(m_ctx, Integer.parseInt(m_DD_Order_ID.toString()), trxName);
    MMovement movement = new MMovement(m_ctx, 0, trxName);
    movement.setDD_Order_ID(order.getDD_Order_ID());
    movement.setAD_User_ID(order.getAD_User_ID());
    movement.setPOReference(order.getPOReference());
    movement.setReversal_ID(0);
    movement.setM_Shipper_ID(order.getM_Shipper_ID());
    movement.setDescription(order.getDescription());
    movement.setC_BPartner_ID(order.getC_BPartner_ID());
    movement.setC_BPartner_Location_ID(order.getC_BPartner_Location_ID());
    movement.setAD_Org_ID(order.getAD_Org_ID());
    movement.setAD_OrgTrx_ID(order.getAD_OrgTrx_ID());
    movement.setAD_User_ID(order.getAD_User_ID());
    movement.setC_Activity_ID(order.getC_Activity_ID());
    movement.setC_Campaign_ID(order.getC_Campaign_ID());
    movement.setC_Project_ID(order.getC_Project_ID());
    movement.setMovementDate(MovementDate);
    movement.setDeliveryRule(order.getDeliveryRule());
    movement.setDeliveryViaRule(order.getDeliveryViaRule());
    movement.setDocAction(MMovement.ACTION_Prepare);
    movement.setDocStatus(MMovement.DOCSTATUS_Drafted);
    //Look the document type for the organization
    int docTypeDO_ID = getDocType(MDocType.DOCBASETYPE_MaterialMovement, order.getAD_Org_ID());
    if (docTypeDO_ID > 0)
        movement.setC_DocType_ID(docTypeDO_ID);
    movement.saveEx();
    for (int i = 0; i < selection.size(); i++) {
        int DD_OrderLine_ID = selection.get(i);
        MDDOrderLine oline = new MDDOrderLine(m_ctx, DD_OrderLine_ID, trxName);
        MMovementLine line = new MMovementLine(movement);
        line.setM_Product_ID(oline.getM_Product_ID());
        BigDecimal QtyDeliver = (BigDecimal) miniTable.getValueAt(i, 1);
        if (QtyDeliver == null | QtyDeliver.compareTo(oline.getQtyInTransit()) > 0)
            throw new AdempiereException("Error in Qty");
        line.setOrderLine(oline, QtyDeliver, true);
        line.saveEx();
    }
    movement.setDocAction(MMovement.DOCACTION_Close);
    movement.setDocStatus(movement.completeIt());
    movement.saveEx();
    trx.commit();
    generateMovements_complete(movement);
//
}
Also used : MDDOrderLine(org.eevolution.model.MDDOrderLine) AdempiereException(org.adempiere.exceptions.AdempiereException) Trx(org.compiere.util.Trx) MDDOrder(org.eevolution.model.MDDOrder) Properties(java.util.Properties) MMovementLine(org.compiere.model.MMovementLine) Timestamp(java.sql.Timestamp) MMovement(org.compiere.model.MMovement) BigDecimal(java.math.BigDecimal)

Example 17 with MMovement

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

the class Doc_Movement method loadDocumentDetails.

//  Doc_Movement
/**
	 *  Load Document Details
	 *  @return error message or null
	 */
protected String loadDocumentDetails() {
    setC_Currency_ID(NO_CURRENCY);
    MMovement move = (MMovement) getPO();
    setDateDoc(move.getMovementDate());
    setDateAcct(move.getMovementDate());
    //store original (voided/reversed) document
    m_Reversal_ID = move.getReversal_ID();
    m_DocStatus = move.getDocStatus();
    //	Contained Objects
    p_lines = loadLines(move);
    log.fine("Lines=" + p_lines.length);
    return null;
}
Also used : MMovement(org.compiere.model.MMovement)

Example 18 with MMovement

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

the class ImportInventoryMove method importInventoryMovement.

/**
	 * Import Inventory Move using X_I_M_Movement table
	 * @param movementImport X_I_Movement
	 * @return MMovement
	 */
private MMovement importInventoryMovement(X_I_Movement movementImport) {
    StringBuilder whereClause = new StringBuilder();
    whereClause.append("TRUNC(").append(I_M_Movement.COLUMNNAME_MovementDate).append(",'DD') = " + DB.TO_DATE(movementImport.getMovementDate()) + " AND ").append(I_M_Movement.COLUMNNAME_DocumentNo).append("=? AND ").append(I_M_Movement.COLUMNNAME_C_DocType_ID).append("=?");
    int movementId = new Query(Env.getCtx(), I_M_Movement.Table_Name, whereClause.toString(), get_TrxName()).setClient_ID().setParameters(movementImport.getDocumentNo(), movementImport.getC_DocType_ID()).firstId();
    MMovement movement = null;
    if (movementId <= 0)
        movementId = 0;
    movement = new MMovement(getCtx(), movementId, get_TrxName());
    try {
        movement.setDocumentNo(movementImport.getDocumentNo());
        movement.setC_DocType_ID(movementImport.getC_DocType_ID());
        movement.setAD_Org_ID(movementImport.getAD_Org_ID());
        movement.setMovementDate(movementImport.getMovementDate());
        movement.setC_DocType_ID(movementImport.getC_DocType_ID());
        movement.setDocumentNo(movementImport.getDocumentNo());
        movement.setC_BPartner_ID(movementImport.getC_BPartner_ID());
        movement.setM_Shipper_ID(movementImport.getM_Shipper_ID());
        movement.setC_Project_ID(movementImport.getC_Project_ID());
        movement.setC_Campaign_ID(movementImport.getC_Campaign_ID());
        movement.setAD_OrgTrx_ID(movementImport.getAD_OrgTrx_ID());
        movement.saveEx();
    } catch (Exception e) {
        movementImport.setI_ErrorMsg(e.getMessage());
        isImported = false;
    }
    return movement;
}
Also used : Query(org.compiere.model.Query) MMovement(org.compiere.model.MMovement)

Aggregations

MMovement (org.compiere.model.MMovement)18 MMovementLine (org.compiere.model.MMovementLine)10 BigDecimal (java.math.BigDecimal)6 AdempiereException (org.adempiere.exceptions.AdempiereException)5 Properties (java.util.Properties)4 MProduct (org.compiere.model.MProduct)4 Timestamp (java.sql.Timestamp)3 MLocator (org.compiere.model.MLocator)3 MStorage (org.compiere.model.MStorage)3 MWarehouse (org.compiere.model.MWarehouse)3 MDDOrder (org.eevolution.model.MDDOrder)3 MClient (org.compiere.model.MClient)2 MInOut (org.compiere.model.MInOut)2 MInOutLine (org.compiere.model.MInOutLine)2 MOrder (org.compiere.model.MOrder)2 MOrderLine (org.compiere.model.MOrderLine)2 Query (org.compiere.model.Query)2 X_T_Replenish (org.compiere.model.X_T_Replenish)2 ProcessInfo (org.compiere.process.ProcessInfo)2 Trx (org.compiere.util.Trx)2