Search in sources :

Example 6 with MDocType

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

the class MWMInOutBound method prepareIt.

//	processIt
/**************************************************************************
	 *	Prepare Document
	 * 	@return new status (In Progress or Invalid) 
	 */
public String prepareIt() {
    log.info(toString());
    m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE);
    if (m_processMsg != null)
        return DocAction.STATUS_Invalid;
    MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
    //	Std Period open?
    /*if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID()))
		{
			m_processMsg = "@PeriodClosed@";
			return DocAction.STATUS_Invalid;
		}*/
    //	Lines
    List<MWMInOutBoundLine> lines = getLines(true, MWMInOutBoundLine.COLUMNNAME_Line);
    if (lines.size() == 0) {
        m_processMsg = "@NoLines@";
        return DocAction.STATUS_Invalid;
    }
    // Bug 1564431
    if (getDeliveryRule() != null && getDeliveryRule().equals(MWMInOutBound.DELIVERYVIARULE_Delivery)) {
        for (MWMInOutBoundLine line : lines) {
            MProduct product = line.getMProduct();
            if (product != null && product.isExcludeAutoDelivery()) {
                m_processMsg = "@M_Product_ID@ " + product.getValue() + " @IsExcludeAutoDelivery@";
                return DocAction.STATUS_Invalid;
            }
        }
    }
    m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE);
    if (m_processMsg != null)
        return DocAction.STATUS_Invalid;
    m_justPrepared = true;
    return DocAction.STATUS_InProgress;
}
Also used : MDocType(org.compiere.model.MDocType) MProduct(org.compiere.model.MProduct)

Example 7 with MDocType

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

the class ReplenishReport method doIt.

//	prepare
/**
	 *  Perform process.
	 *  @return Message 
	 *  @throws Exception if not successful
	 */
protected String doIt() throws Exception {
    log.info("M_Warehouse_ID=" + p_M_Warehouse_ID + ", C_BPartner_ID=" + p_C_BPartner_ID + " - ReplenishmentCreate=" + p_ReplenishmentCreate + ", C_DocType_ID=" + p_C_DocType_ID);
    if (p_ReplenishmentCreate != null && p_C_DocType_ID == 0)
        throw new AdempiereUserError("@FillMandatory@ @C_DocType_ID@");
    MWarehouse wh = MWarehouse.get(getCtx(), p_M_Warehouse_ID);
    if (wh.get_ID() == 0)
        throw new AdempiereSystemError("@FillMandatory@ @M_Warehouse_ID@");
    //
    prepareTable();
    fillTable(wh);
    //
    if (p_ReplenishmentCreate == null)
        return "OK";
    //
    MDocType dt = MDocType.get(getCtx(), p_C_DocType_ID);
    if (!dt.getDocBaseType().equals(p_ReplenishmentCreate))
        throw new AdempiereSystemError("@C_DocType_ID@=" + dt.getName() + " <> " + p_ReplenishmentCreate);
    //
    if (p_ReplenishmentCreate.equals("POO"))
        createPO();
    else if (p_ReplenishmentCreate.equals("POR"))
        createRequisition();
    else if (p_ReplenishmentCreate.equals("MMM"))
        createMovements();
    else if (p_ReplenishmentCreate.equals("DOO"))
        createDO();
    return m_info;
}
Also used : MDocType(org.compiere.model.MDocType) AdempiereUserError(org.compiere.util.AdempiereUserError) AdempiereSystemError(org.compiere.util.AdempiereSystemError) MWarehouse(org.compiere.model.MWarehouse)

Example 8 with MDocType

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

the class MPPOrder method completeIt.

//	rejectIt
public String completeIt() {
    //	Just prepare
    if (DOCACTION_Prepare.equals(getDocAction())) {
        setProcessed(false);
        return DocAction.STATUS_InProgress;
    }
    //	Re-Check
    if (!m_justPrepared) {
        String status = prepareIt();
        if (!DocAction.STATUS_InProgress.equals(status))
            return status;
    }
    m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
    if (m_processMsg != null) {
        return DocAction.STATUS_Invalid;
    }
    //	Implicit Approval
    if (!isApproved()) {
        setIsApproved(approveIt());
        MDocType doc = MDocType.get(getCtx(), getC_DocType_ID());
        if (isApproved() && MDocType.DOCBASETYPE_QualityOrder.equals(doc.getDocBaseType())) {
            setProcessed(true);
            setDocAction(DOCACTION_Complete);
            String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
            if (valid != null) {
                m_processMsg = valid;
                return DocAction.STATUS_Invalid;
            }
            return DocAction.STATUS_Completed;
        } else if (MDocType.DOCBASETYPE_QualityOrder.equals(doc.getDocBaseType())) {
            setProcessed(true);
            setDocAction(DOCACTION_Complete);
            String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
            if (valid != null) {
                m_processMsg = valid;
                return DocAction.STATUS_Invalid;
            }
            return DocAction.STATUS_Completed;
        }
    }
    createStandardCosts();
    //Create the Activity Control
    autoReportActivities();
    //setProcessed(true);
    setDocAction(DOCACTION_Close);
    String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
    if (valid != null) {
        m_processMsg = valid;
        return DocAction.STATUS_Invalid;
    }
    return DocAction.STATUS_Completed;
}
Also used : MDocType(org.compiere.model.MDocType)

Example 9 with MDocType

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

the class MPPOrder method approveIt.

//	reserveStock
public boolean approveIt() {
    log.info("approveIt - " + toString());
    MDocType doc = MDocType.get(getCtx(), getC_DocType_ID());
    if (MDocType.DOCBASETYPE_QualityOrder.equals(doc.getDocBaseType())) {
        String whereClause = COLUMNNAME_PP_Product_BOM_ID + "=? AND " + COLUMNNAME_AD_Workflow_ID + "=?";
        MQMSpecification qms = new Query(getCtx(), MQMSpecification.Table_Name, whereClause, get_TrxName()).setParameters(new Object[] { getPP_Product_BOM_ID(), getAD_Workflow_ID() }).firstOnly();
        return qms != null ? qms.isValid(getM_AttributeSetInstance_ID()) : true;
    } else {
        setIsApproved(true);
    }
    return true;
}
Also used : MDocType(org.compiere.model.MDocType) Query(org.compiere.model.Query)

Example 10 with MDocType

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

the class CreateFromInvoice method getDocBaseType.

/**
	 * Get Document Base Type from Document Type of Invoice
	 * @return
	 */
protected String getDocBaseType() {
    if (m_Record_ID <= 0)
        return "";
    //	For other
    MInvoice invoice = new MInvoice(Env.getCtx(), m_Record_ID, null);
    MDocType docType = MDocType.get(Env.getCtx(), invoice.getC_DocTypeTarget_ID());
    if (docType != null) {
        return docType.getDocBaseType();
    }
    //	Default
    return "";
}
Also used : MDocType(org.compiere.model.MDocType) MInvoice(org.compiere.model.MInvoice)

Aggregations

MDocType (org.compiere.model.MDocType)29 MInvoice (org.compiere.model.MInvoice)5 ResultSet (java.sql.ResultSet)4 Timestamp (java.sql.Timestamp)4 MBPartner (org.compiere.model.MBPartner)4 BigDecimal (java.math.BigDecimal)3 PreparedStatement (java.sql.PreparedStatement)3 AdempiereException (org.adempiere.exceptions.AdempiereException)3 MClient (org.compiere.model.MClient)3 MInvoiceLine (org.compiere.model.MInvoiceLine)3 MLocation (org.compiere.model.MLocation)3 MOrder (org.compiere.model.MOrder)3 Query (org.compiere.model.Query)3 MInOutLine (org.compiere.model.MInOutLine)2 MMatchInv (org.compiere.model.MMatchInv)2 MOrderLine (org.compiere.model.MOrderLine)2 MProduct (org.compiere.model.MProduct)2 MWarehouse (org.compiere.model.MWarehouse)2 ProcessInfo (org.compiere.process.ProcessInfo)2 AdempiereSystemError (org.compiere.util.AdempiereSystemError)2