[ 2616330 ] Use MPeriod.testPeriodOpen instead of isOpen

https://sourceforge.net/tracker/index.php?func=detail&aid=2616330&group_id=176962&atid=879335

Implemented for MInvoice and MAllocationHdr
This commit is contained in:
teo_sarca 2009-02-19 14:00:12 +00:00
parent 672d637e71
commit ec11810ad2
2 changed files with 7 additions and 26 deletions

View File

@ -305,11 +305,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
log.warning ("No transaction"); log.warning ("No transaction");
if (isPosted()) if (isPosted())
{ {
if (!MPeriod.isOpen(getCtx(), getDateTrx(), MDocType.DOCBASETYPE_PaymentAllocation, getAD_Org_ID())) MPeriod.testPeriodOpen(getCtx(), getDateTrx(), MDocType.DOCBASETYPE_PaymentAllocation, getAD_Org_ID());
{
log.warning ("Period Closed");
return false;
}
setPosted(false); setPosted(false);
MFactAcct.deleteEx (Table_ID, get_ID(), trxName); MFactAcct.deleteEx (Table_ID, get_ID(), trxName);
} }
@ -394,11 +390,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
// Std Period open? // Std Period open?
if (!MPeriod.isOpen(getCtx(), getDateAcct(), MDocType.DOCBASETYPE_PaymentAllocation, getAD_Org_ID())) MPeriod.testPeriodOpen(getCtx(), getDateAcct(), MDocType.DOCBASETYPE_PaymentAllocation, getAD_Org_ID());
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
}
getLines(false); getLines(false);
if (m_lines.length == 0) if (m_lines.length == 0)
{ {
@ -713,8 +705,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
throw new IllegalStateException("Allocation already reversed (not active)"); throw new IllegalStateException("Allocation already reversed (not active)");
// Can we delete posting // Can we delete posting
if (!MPeriod.isOpen(getCtx(), getDateTrx(), MPeriodControl.DOCBASETYPE_PaymentAllocation, getAD_Org_ID())) MPeriod.testPeriodOpen(getCtx(), getDateTrx(), MPeriodControl.DOCBASETYPE_PaymentAllocation, getAD_Org_ID());
throw new IllegalStateException("@PeriodClosed@");
// Set Inactive // Set Inactive
setIsActive (false); setIsActive (false);

View File

@ -1371,14 +1371,9 @@ public class MInvoice extends X_C_Invoice implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE); m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE);
if (m_processMsg != null) if (m_processMsg != null)
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
MDocType dt = MDocType.get(getCtx(), getC_DocTypeTarget_ID());
// Std Period open? MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocTypeTarget_ID(), getAD_Org_ID());
if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
}
// Lines // Lines
MInvoiceLine[] lines = getLines(true); MInvoiceLine[] lines = getLines(true);
if (lines.length == 0) if (lines.length == 0)
@ -2036,7 +2031,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
return null; return null;
MBPartner counterBP = new MBPartner (getCtx(), counterC_BPartner_ID, null); MBPartner counterBP = new MBPartner (getCtx(), counterC_BPartner_ID, null);
MOrgInfo counterOrgInfo = MOrgInfo.get(getCtx(), counterAD_Org_ID); // MOrgInfo counterOrgInfo = MOrgInfo.get(getCtx(), counterAD_Org_ID);
log.info("Counter BP=" + counterBP.getName()); log.info("Counter BP=" + counterBP.getName());
// Document Type // Document Type
@ -2202,12 +2197,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
if (m_processMsg != null) if (m_processMsg != null)
return false; return false;
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID());
if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return false;
}
// //
MAllocationHdr[] allocations = MAllocationHdr.getOfInvoice(getCtx(), MAllocationHdr[] allocations = MAllocationHdr.getOfInvoice(getCtx(),
getC_Invoice_ID(), get_TrxName()); getC_Invoice_ID(), get_TrxName());