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;
}
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;
}
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;
}
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;
}
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 "";
}
Aggregations