IDEMPIERE-4038 Implement multi for Period Open Close

This commit is contained in:
Carlos Ruiz 2019-08-29 13:14:00 +02:00
parent 56b1d98e27
commit cb2387f9fe
4 changed files with 61 additions and 13 deletions

View File

@ -0,0 +1,15 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3998
-- Aug 29, 2019, 11:57:34 AM CEST
UPDATE AD_Column SET IsToolbarButton='Y',Updated=TO_DATE('2019-08-29 11:57:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5944
;
-- Aug 29, 2019, 11:58:03 AM CEST
UPDATE AD_Column SET IsToolbarButton='Y',Updated=TO_DATE('2019-08-29 11:58:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2355
;
SELECT register_migration_script('201908291158_IDEMPIERE-3998.sql') FROM dual
;

View File

@ -0,0 +1,12 @@
-- IDEMPIERE-3998
-- Aug 29, 2019, 11:57:34 AM CEST
UPDATE AD_Column SET IsToolbarButton='Y',Updated=TO_TIMESTAMP('2019-08-29 11:57:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5944
;
-- Aug 29, 2019, 11:58:03 AM CEST
UPDATE AD_Column SET IsToolbarButton='Y',Updated=TO_TIMESTAMP('2019-08-29 11:58:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2355
;
SELECT register_migration_script('201908291158_IDEMPIERE-3998.sql') FROM dual
;

View File

@ -16,6 +16,8 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.process; package org.compiere.process;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.model.MPeriodControl; import org.compiere.model.MPeriodControl;
@ -32,7 +34,7 @@ import org.compiere.util.CacheMgt;
public class PeriodControlStatus extends SvrProcess public class PeriodControlStatus extends SvrProcess
{ {
/** Period Control */ /** Period Control */
private int p_C_PeriodControl_ID = 0; private List<Integer> p_C_PeriodControl_IDs;
/** /**
* Prepare - e.g., get Parameters. * Prepare - e.g., get Parameters.
@ -45,10 +47,16 @@ public class PeriodControlStatus extends SvrProcess
String name = para[i].getParameterName(); String name = para[i].getParameterName();
if (para[i].getParameter() == null) if (para[i].getParameter() == null)
; ;
else if (name.equals("*RecordIDs*"))
;
else else
log.log(Level.SEVERE, "Unknown Parameter: " + name); log.log(Level.SEVERE, "Unknown Parameter: " + name);
} }
p_C_PeriodControl_ID = getRecord_ID(); p_C_PeriodControl_IDs = getRecord_IDs();
if (p_C_PeriodControl_IDs == null || p_C_PeriodControl_IDs.size() == 0) {
p_C_PeriodControl_IDs = new ArrayList<Integer>();
p_C_PeriodControl_IDs.add(getRecord_ID());
}
} // prepare } // prepare
/** /**
@ -58,7 +66,8 @@ public class PeriodControlStatus extends SvrProcess
*/ */
protected String doIt() throws Exception protected String doIt() throws Exception
{ {
if (log.isLoggable(Level.INFO)) log.info ("C_PeriodControl_ID=" + p_C_PeriodControl_ID); if (log.isLoggable(Level.INFO)) log.info ("C_PeriodControl_ID=" + p_C_PeriodControl_IDs);
for (int p_C_PeriodControl_ID : p_C_PeriodControl_IDs) {
MPeriodControl pc = new MPeriodControl (getCtx(), p_C_PeriodControl_ID, get_TrxName()); MPeriodControl pc = new MPeriodControl (getCtx(), p_C_PeriodControl_ID, get_TrxName());
if (pc.get_ID() == 0) if (pc.get_ID() == 0)
throw new AdempiereUserError("@NotFound@ @C_PeriodControl_ID@=" + p_C_PeriodControl_ID); throw new AdempiereUserError("@NotFound@ @C_PeriodControl_ID@=" + p_C_PeriodControl_ID);
@ -83,12 +92,13 @@ public class PeriodControlStatus extends SvrProcess
boolean ok = pc.save(); boolean ok = pc.save();
// Reset Cache // Reset Cache
CacheMgt.get().reset("C_PeriodControl", 0);
CacheMgt.get().reset("C_Period", pc.getC_Period_ID()); CacheMgt.get().reset("C_Period", pc.getC_Period_ID());
if (!ok) if (!ok)
return "@Error@"; return "@Error@";
return "@OK@"; }
CacheMgt.get().reset("C_PeriodControl", 0);
return "@OK@";
} // doIt } // doIt
} // PeriodControlStatus } // PeriodControlStatus

View File

@ -16,6 +16,8 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.process; package org.compiere.process;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.model.MPeriod; import org.compiere.model.MPeriod;
@ -32,8 +34,8 @@ import org.compiere.util.DB;
*/ */
public class PeriodStatus extends SvrProcess public class PeriodStatus extends SvrProcess
{ {
/** Period */ /** Periods */
private int p_C_Period_ID = 0; private List<Integer> p_C_Period_IDs;
/** Action */ /** Action */
private String p_PeriodAction = null; private String p_PeriodAction = null;
@ -51,10 +53,16 @@ public class PeriodStatus extends SvrProcess
; ;
else if (name.equals("PeriodAction")) else if (name.equals("PeriodAction"))
p_PeriodAction = (String)para[i].getParameter(); p_PeriodAction = (String)para[i].getParameter();
else if (name.equals("*RecordIDs*"))
;
else else
log.log(Level.SEVERE, "Unknown Parameter: " + name); log.log(Level.SEVERE, "Unknown Parameter: " + name);
} }
p_C_Period_ID = getRecord_ID(); p_C_Period_IDs = getRecord_IDs();
if (p_C_Period_IDs == null || p_C_Period_IDs.size() == 0) {
p_C_Period_IDs = new ArrayList<Integer>();
p_C_Period_IDs.add(getRecord_ID());
}
} // prepare } // prepare
/** /**
@ -64,7 +72,9 @@ public class PeriodStatus extends SvrProcess
*/ */
protected String doIt() throws Exception protected String doIt() throws Exception
{ {
if (log.isLoggable(Level.INFO)) log.info ("C_Period_ID=" + p_C_Period_ID + ", PeriodAction=" + p_PeriodAction); int no = 0;
if (log.isLoggable(Level.INFO)) log.info ("C_Period_ID=" + p_C_Period_IDs + ", PeriodAction=" + p_PeriodAction);
for (int p_C_Period_ID : p_C_Period_IDs) {
MPeriod period = new MPeriod (getCtx(), p_C_Period_ID, get_TrxName()); MPeriod period = new MPeriod (getCtx(), p_C_Period_ID, get_TrxName());
if (period.get_ID() == 0) if (period.get_ID() == 0)
throw new AdempiereUserError("@NotFound@ @C_Period_ID@=" + p_C_Period_ID); throw new AdempiereUserError("@NotFound@ @C_Period_ID@=" + p_C_Period_ID);
@ -89,12 +99,13 @@ public class PeriodStatus extends SvrProcess
.append(" AND PeriodStatus<>'P'") .append(" AND PeriodStatus<>'P'")
.append(" AND PeriodStatus<>'").append(p_PeriodAction).append("'"); .append(" AND PeriodStatus<>'").append(p_PeriodAction).append("'");
int no = DB.executeUpdate(sql.toString(), get_TrxName()); no += DB.executeUpdateEx(sql.toString(), get_TrxName());
CacheMgt.get().reset("C_PeriodControl", 0);
CacheMgt.get().reset("C_Period", p_C_Period_ID); CacheMgt.get().reset("C_Period", p_C_Period_ID);
StringBuilder msgreturn = new StringBuilder("@Updated@ #").append(no); }
return msgreturn.toString(); CacheMgt.get().reset("C_PeriodControl", 0);
StringBuilder msgreturn = new StringBuilder("@Updated@ #").append(no);
return msgreturn.toString();
} // doIt } // doIt
} // PeriodStatus } // PeriodStatus