diff --git a/org.adempiere.base/src/org/compiere/model/MProjectType.java b/org.adempiere.base/src/org/compiere/model/MProjectType.java index eca6082d43..b634fb1c79 100644 --- a/org.adempiere.base/src/org/compiere/model/MProjectType.java +++ b/org.adempiere.base/src/org/compiere/model/MProjectType.java @@ -152,7 +152,7 @@ public class MProjectType extends X_C_ProjectType implements ImmutablePOSupport public MProjectTypePhase[] getPhases() { ArrayList list = new ArrayList(); - String sql = "SELECT * FROM C_Phase WHERE C_ProjectType_ID=? ORDER BY SeqNo"; + String sql = "SELECT * FROM C_Phase WHERE C_ProjectType_ID=? AND IsActive='Y' ORDER BY SeqNo, C_Phase_ID"; PreparedStatement pstmt = null; ResultSet rs = null; try diff --git a/org.adempiere.base/src/org/compiere/model/MProjectTypePhase.java b/org.adempiere.base/src/org/compiere/model/MProjectTypePhase.java index c3e1768904..724556db75 100644 --- a/org.adempiere.base/src/org/compiere/model/MProjectTypePhase.java +++ b/org.adempiere.base/src/org/compiere/model/MProjectTypePhase.java @@ -73,7 +73,7 @@ public class MProjectTypePhase extends X_C_Phase public MProjectTypeTask[] getTasks() { ArrayList list = new ArrayList(); - String sql = "SELECT * FROM C_Task WHERE C_Phase_ID=? ORDER BY SeqNo"; + String sql = "SELECT * FROM C_Task WHERE C_Phase_ID=? AND IsActive='Y' ORDER BY SeqNo, C_Task_ID"; PreparedStatement pstmt = null; ResultSet rs = null; try diff --git a/org.idempiere.test/src/org/idempiere/test/model/MProjectTypeTest.java b/org.idempiere.test/src/org/idempiere/test/model/MProjectTypeTest.java new file mode 100644 index 0000000000..0eac819e3d --- /dev/null +++ b/org.idempiere.test/src/org/idempiere/test/model/MProjectTypeTest.java @@ -0,0 +1,83 @@ +/*********************************************************************** + * This file is part of iDempiere ERP Open Source * + * http://www.idempiere.org * + * * + * Copyright (C) Contributors * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * 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., 51 Franklin Street, Fifth Floor, Boston, * + * MA 02110-1301, USA. * + * * + * Contributors: * + * - hengsin * + **********************************************************************/ +package org.idempiere.test.model; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.compiere.model.MProjectType; +import org.compiere.model.MProjectTypePhase; +import org.compiere.model.MProjectTypeTask; +import org.compiere.util.Env; +import org.idempiere.test.AbstractTestCase; +import org.junit.jupiter.api.Test; + +/** + * + * @author hengsin + * + */ +public class MProjectTypeTest extends AbstractTestCase { + + private final static int IMPLEMENTATION_TYPE_ID = 100; + private final static int EVALUATION_PHASE_ID = 100; + + public MProjectTypeTest() { + } + + @Test + public void testGetTasks() { + + MProjectType type = new MProjectType(Env.getCtx(), IMPLEMENTATION_TYPE_ID, getTrxName()); + assertEquals(IMPLEMENTATION_TYPE_ID, type.get_ID()); + MProjectTypePhase[] phases = type.getPhases(); + assertEquals(2, phases.length); + MProjectTypeTask[] tasks = null; + for (MProjectTypePhase phase : phases) { + if (phase.get_ID() == EVALUATION_PHASE_ID) { + tasks = phase.getTasks(); + } + } + assertNotNull(tasks); + assertEquals(2, tasks.length); + + for (MProjectTypePhase phase : phases) { + if (phase.get_ID() != EVALUATION_PHASE_ID) { + phase.setIsActive(false); + phase.saveEx(); + } + } + tasks[0].setIsActive(false); + tasks[0].saveEx(); + + type = new MProjectType(Env.getCtx(), IMPLEMENTATION_TYPE_ID, getTrxName()); + assertEquals(IMPLEMENTATION_TYPE_ID, type.get_ID()); + phases = type.getPhases(); + assertEquals(1, phases.length); + tasks = phases[0].getTasks(); + assertNotNull(tasks); + assertEquals(1, tasks.length); + } +}