FR [ 1984700 ] Introduce PeriodClosedException
This commit is contained in:
parent
f3a58107b3
commit
8a71746ee0
|
@ -0,0 +1,36 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 2008 SC ARHIPAC SERVICE SRL. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.exceptions;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
|
||||
/**
|
||||
* Period Closed Exception.
|
||||
* This exception is throwed by
|
||||
* {@link org.compiere.model.MPeriod#testPeriodOpen(java.util.Properties, Timestamp, int)} and
|
||||
* {@link org.compiere.model.MPeriod#testPeriodOpen(java.util.Properties, Timestamp, String)} methods.
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||
*
|
||||
*/
|
||||
public class PeriodClosedException extends AdempiereException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public PeriodClosedException(Timestamp dateAcct, String docBaseType) {
|
||||
super("@PeriodClosed@ @Date@="+dateAcct+", @DocBaseType@="+docBaseType);
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@ import java.util.Iterator;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.PeriodClosedException;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
@ -510,4 +511,34 @@ public class MPeriod extends X_C_Period
|
|||
return sb.toString ();
|
||||
} // toString
|
||||
|
||||
/**
|
||||
* Conventient method for testing if a period is open
|
||||
* @param ctx
|
||||
* @param dateAcct
|
||||
* @param docBaseType
|
||||
* @throws PeriodClosedException if period is closed
|
||||
* @see #isOpen(Properties, Timestamp, String)
|
||||
*/
|
||||
public static void testPeriodOpen(Properties ctx, Timestamp dateAcct, String docBaseType)
|
||||
throws PeriodClosedException
|
||||
{
|
||||
if (!MPeriod.isOpen(ctx, dateAcct, docBaseType)) {
|
||||
throw new PeriodClosedException(dateAcct, docBaseType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Conventient method for testing if a period is open
|
||||
* @param ctx
|
||||
* @param dateAcct
|
||||
* @param C_DocType_ID
|
||||
* @throws PeriodClosedException
|
||||
* @see {@link #isOpen(Properties, Timestamp, String)}
|
||||
*/
|
||||
public static void testPeriodOpen(Properties ctx, Timestamp dateAcct, int C_DocType_ID)
|
||||
throws PeriodClosedException
|
||||
{
|
||||
MDocType dt = MDocType.get(ctx, C_DocType_ID);
|
||||
testPeriodOpen(ctx, dateAcct, dt.getDocBaseType());
|
||||
}
|
||||
} // MPeriod
|
||||
|
|
Loading…
Reference in New Issue