IDEMPIERE-5114 MProjectTypePhase: getTasks() should return only active task records (#1069)

This commit is contained in:
hengsin 2021-12-20 18:11:48 +08:00 committed by GitHub
parent 85cb32f2d8
commit 774ba1d427
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 85 additions and 2 deletions

View File

@ -152,7 +152,7 @@ public class MProjectType extends X_C_ProjectType implements ImmutablePOSupport
public MProjectTypePhase[] getPhases()
{
ArrayList<MProjectTypePhase> list = new ArrayList<MProjectTypePhase>();
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

View File

@ -73,7 +73,7 @@ public class MProjectTypePhase extends X_C_Phase
public MProjectTypeTask[] getTasks()
{
ArrayList<MProjectTypeTask> list = new ArrayList<MProjectTypeTask>();
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

View File

@ -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);
}
}