📄 mmovementconfirm.java
字号:
String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
if (valid != null)
{
m_processMsg = valid;
return DocAction.STATUS_Invalid;
}
//
m_justPrepared = true;
if (!DOCACTION_Complete.equals(getDocAction()))
setDocAction(DOCACTION_Complete);
return DocAction.STATUS_InProgress;
} // prepareIt
/**
* Approve Document
* @return true if success
*/
public boolean approveIt()
{
log.info("approveIt - " + toString());
setIsApproved(true);
return true;
} // approveIt
/**
* Reject Approval
* @return true if success
*/
public boolean rejectIt()
{
log.info("rejectIt - " + toString());
setIsApproved(false);
return true;
} // rejectIt
/**
* Complete Document
* @return new status (Complete, In Progress, Invalid, Waiting ..)
*/
public String completeIt()
{
// Re-Check
if (!m_justPrepared)
{
String status = prepareIt();
if (!DocAction.STATUS_InProgress.equals(status))
return status;
}
// Implicit Approval
if (!isApproved())
approveIt();
log.info("completeIt - " + toString());
//
MMovement move = new MMovement (getCtx(), getM_Movement_ID(), get_TrxName());
MMovementLineConfirm[] lines = getLines(false);
for (int i = 0; i < lines.length; i++)
{
MMovementLineConfirm confirm = lines[i];
confirm.set_TrxName(get_TrxName());
if (!confirm.processLine ())
{
m_processMsg = "ShipLine not saved - " + confirm;
return DocAction.STATUS_Invalid;
}
if (confirm.isFullyConfirmed())
{
confirm.setProcessed(true);
confirm.save(get_TrxName());
}
else
{
if (createDifferenceDoc (move, confirm))
{
confirm.setProcessed(true);
confirm.save(get_TrxName());
}
else
{
log.log(Level.SEVERE, "completeIt - Scrapped=" + confirm.getScrappedQty()
+ " - Difference=" + confirm.getDifferenceQty());
m_processMsg = "Differnce Doc not created";
return DocAction.STATUS_Invalid;
}
}
} // for all lines
if (m_inventoryInfo != null)
{
m_processMsg = " @M_Inventory_ID@: " + m_inventoryInfo;
addDescription(Msg.translate(getCtx(), "M_Inventory_ID")
+ ": " + m_inventoryInfo);
}
setProcessed(true);
setDocAction(DOCACTION_Close);
return DocAction.STATUS_Completed;
} // completeIt
/**
* Create Difference Document.
* Creates one or two inventory lines
* @param confirm confirm line
* @return true if created
*/
private boolean createDifferenceDoc (MMovement move, MMovementLineConfirm confirm)
{
MMovementLine mLine = confirm.getLine();
// Difference - Create Inventory Difference for Source Location
if (Env.ZERO.compareTo(confirm.getDifferenceQty()) != 0)
{
// Get Warehouse for Source
MLocator loc = MLocator.get(getCtx(), mLine.getM_Locator_ID());
if (m_inventoryFrom != null
&& m_inventoryFrom.getM_Warehouse_ID() != loc.getM_Warehouse_ID())
m_inventoryFrom = null;
if (m_inventoryFrom == null)
{
MWarehouse wh = MWarehouse.get(getCtx(), loc.getM_Warehouse_ID());
m_inventoryFrom = new MInventory (wh);
m_inventoryFrom.setDescription(Msg.translate(getCtx(), "M_MovementConfirm_ID") + " " + getDocumentNo());
if (!m_inventoryFrom.save(get_TrxName()))
{
m_processMsg += "Inventory not created";
return false;
}
// First Inventory
if (getM_Inventory_ID() == 0)
{
setM_Inventory_ID(m_inventoryFrom.getM_Inventory_ID());
m_inventoryInfo = m_inventoryFrom.getDocumentNo();
}
else
m_inventoryInfo += "," + m_inventoryFrom.getDocumentNo();
}
log.info("createDifferenceDoc - Difference=" + confirm.getDifferenceQty());
MInventoryLine line = new MInventoryLine (m_inventoryFrom,
mLine.getM_Locator_ID(), mLine.getM_Product_ID(), mLine.getM_AttributeSetInstance_ID(),
confirm.getDifferenceQty(), Env.ZERO);
line.setDescription(Msg.translate(getCtx(), "DifferenceQty"));
if (!line.save(get_TrxName()))
{
m_processMsg += "Inventory Line not created";
return false;
}
confirm.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
} // Difference
// Scrapped - Create Inventory Difference for Target Location
if (Env.ZERO.compareTo(confirm.getScrappedQty()) != 0)
{
// Get Warehouse for Target
MLocator loc = MLocator.get(getCtx(), mLine.getM_LocatorTo_ID());
if (m_inventoryTo != null
&& m_inventoryTo.getM_Warehouse_ID() != loc.getM_Warehouse_ID())
m_inventoryTo = null;
if (m_inventoryTo == null)
{
MWarehouse wh = MWarehouse.get(getCtx(), loc.getM_Warehouse_ID());
m_inventoryTo = new MInventory (wh);
m_inventoryTo.setDescription(Msg.translate(getCtx(), "M_MovementConfirm_ID") + " " + getDocumentNo());
if (!m_inventoryTo.save(get_TrxName()))
{
m_processMsg += "Inventory not created";
return false;
}
// First Inventory
if (getM_Inventory_ID() == 0)
{
setM_Inventory_ID(m_inventoryTo.getM_Inventory_ID());
m_inventoryInfo = m_inventoryTo.getDocumentNo();
}
else
m_inventoryInfo += "," + m_inventoryTo.getDocumentNo();
}
log.info("createDifferenceDoc - Scrapped=" + confirm.getScrappedQty());
MInventoryLine line = new MInventoryLine (m_inventoryTo,
mLine.getM_LocatorTo_ID(), mLine.getM_Product_ID(), mLine.getM_AttributeSetInstance_ID(),
confirm.getScrappedQty(), Env.ZERO);
line.setDescription(Msg.translate(getCtx(), "ScrappedQty"));
if (!line.save(get_TrxName()))
{
m_processMsg += "Inventory Line not created";
return false;
}
confirm.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
} // Scrapped
return true;
} // createDifferenceDoc
/**
* Void Document.
* @return false
*/
public boolean voidIt()
{
log.info("voidIt - " + toString());
return false;
} // voidIt
/**
* Close Document.
* Cancel not delivered Qunatities
* @return true if success
*/
public boolean closeIt()
{
log.info("closeIt - " + toString());
// Close Not delivered Qty
setDocAction(DOCACTION_None);
return true;
} // closeIt
/**
* Reverse Correction
* @return false
*/
public boolean reverseCorrectIt()
{
log.info("reverseCorrectIt - " + toString());
return false;
} // reverseCorrectionIt
/**
* Reverse Accrual - none
* @return false
*/
public boolean reverseAccrualIt()
{
log.info("reverseAccrualIt - " + toString());
return false;
} // reverseAccrualIt
/**
* Re-activate
* @return false
*/
public boolean reActivateIt()
{
log.info("reActivateIt - " + toString());
return false;
} // reActivateIt
/*************************************************************************
* Get Summary
* @return Summary of Document
*/
public String getSummary()
{
StringBuffer sb = new StringBuffer();
sb.append(getDocumentNo());
// : Total Lines = 123.00 (#1)
sb.append(": ")
.append(Msg.translate(getCtx(),"ApprovalAmt")).append("=").append(getApprovalAmt())
.append(" (#").append(getLines(false).length).append(")");
// - Description
if (getDescription() != null && getDescription().length() > 0)
sb.append(" - ").append(getDescription());
return sb.toString();
} // getSummary
/**
* Get Process Message
* @return clear text error message
*/
public String getProcessMsg()
{
return m_processMsg;
} // getProcessMsg
/**
* Get Document Owner (Responsible)
* @return AD_User_ID
*/
public int getDoc_User_ID()
{
return getUpdatedBy();
} // getDoc_User_ID
/**
* Get Document Currency
* @return C_Currency_ID
*/
public int getC_Currency_ID()
{
// MPriceList pl = MPriceList.get(getCtx(), getM_PriceList_ID());
// return pl.getC_Currency_ID();
return 0;
} // getC_Currency_ID
} // MMovementConfirm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -