fixes the functions which are used to check out if the cost category and

the hour cost are active in the specified work report line.

FEA: ItEr76S04BugFixing
This commit is contained in:
Susana Montes Pedreira 2012-06-06 11:25:45 +01:00
parent 193a4315b7
commit e06ebb6c4c
3 changed files with 24 additions and 4 deletions

View file

@ -102,8 +102,7 @@ public class CostCategoryDAO extends IntegrationEntityDAO<CostCategory>
for (ResourcesCostCategoryAssignment each : resource
.getResourcesCostCategoryAssignments()) {
if ((date.isAfter(each.getInitDate()))
&& (!date.isBefore(each.getInitDate()))) {
if (each.isActiveAtDate(date)) {
for (HourCost hourCost : each.getCostCategory().getHourCosts()) {
if (hourCost.isActiveAtDate(date)
&& hourCost.getType().getCode().equals(type)) {

View file

@ -136,13 +136,20 @@ public class HourCost extends IntegrationEntity {
}
public boolean isActiveAtDate(LocalDate date) {
if ((date.isAfter(this.getInitDate()))
&& (!date.isBefore(this.getInitDate()))) {
if (isEqualOrAfter(date) && isEqualOrBefore(date)) {
return true;
}
return false;
}
private boolean isEqualOrAfter(LocalDate date) {
return (!date.isBefore(this.getInitDate()));
}
private boolean isEqualOrBefore(LocalDate date) {
return (this.getEndDate() == null || !date.isAfter(this.getEndDate()));
}
@AssertTrue(message="The end date cannot be before the init date")
public boolean checkPositiveTimeInterval() {
if (initDate == null) {

View file

@ -168,4 +168,18 @@ public class ResourcesCostCategoryAssignment extends IntegrationEntity {
return Registry.getResourcesCostCategoryAssignmentDAO();
}
public boolean isActiveAtDate(LocalDate date) {
if (isEqualOrAfter(date) && isEqualOrBefore(date)) {
return true;
}
return false;
}
private boolean isEqualOrAfter(LocalDate date) {
return (!date.isBefore(this.getInitDate()));
}
private boolean isEqualOrBefore(LocalDate date) {
return (this.getEndDate() == null || !date.isAfter(this.getEndDate()));
}
}