Skip to content

Commit

Permalink
Multiple interface improvments FEXPND-54 #resolve (#201)
Browse files Browse the repository at this point in the history
* Multiple interface improvments FEXPND-54 #resolve

* Budget is submitted by requested unit.
  • Loading branch information
Luis-Cruz authored May 16, 2020
1 parent 95219ab commit 8243a25
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class InternalRequest {
}

class InternalRequestItem {
int itemOrder;
int quantity;
String description;
Money price;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
import pt.ist.expenditureTrackingSystem.domain.organization.Unit;

import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.stream.Collectors;

public class InternalRequest extends InternalRequest_Base {

public InternalRequest(Person requestingPerson, Unit requestingUnit, Unit requestedUnit, InternalRequestProcess process) {
// BUSINESS LOGIC CHECKING
if ((!isUnitInternal(requestingUnit)) || (!doesPersonBelongToUnit(requestingPerson, requestingUnit))) {
if ((!isUnitInternal(requestingUnit))) {
throw new UnacceptableUnitException(requestingUnit);
}
if (!isUnitInternal(requestedUnit)) {
Expand Down Expand Up @@ -98,4 +100,11 @@ public void delete() {
this.setInternalRequestSystem(null);
super.deleteDomainObject();
}

public SortedSet<InternalRequestItem> getSortedItemsSet() {
final SortedSet<InternalRequestItem> result = new TreeSet<>();
result.addAll(getItemsSet());
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import pt.ist.fenixframework.Atomic;
import pt.ist.fenixframework.Atomic.TxMode;

public class InternalRequestItem extends InternalRequestItem_Base {
public class InternalRequestItem extends InternalRequestItem_Base implements Comparable<InternalRequestItem> {

public InternalRequestItem(int quantity, String description, InternalRequest request) {
this.setQuantity(quantity);
this.setDescription(description);
this.setInternalRequest(request);
setItemOrder(request.getItemsSet().stream().mapToInt(i -> i.getItemOrder()).max().orElse(0) + 1);
setQuantity(quantity);
setDescription(description);
setInternalRequest(request);
}

@Atomic(mode = TxMode.WRITE)
Expand All @@ -29,5 +30,11 @@ public void delete() {
this.setInternalRequest(null);
super.deleteDomainObject();
}


@Override
public int compareTo(final InternalRequestItem item) {
final int i = Integer.compare(getItemOrder(), item.getItemOrder());
return i == 0 ? getExternalId().compareTo(item.getExternalId()) : i;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public boolean canSubmitBudget(Person person) {
final pt.ist.expenditureTrackingSystem.domain.organization.Person expenditurePerson =
person.getUser().getExpenditurePerson();
if (expenditurePerson == null) { return false; }
return getInternalRequest().getRequestingUnit().isProjectAccountingEmployee(expenditurePerson);
return getInternalRequest().getRequestedUnit().isProjectAccountingEmployee(expenditurePerson);
}
public void submitBudget(Person budgetedBy) {
this.setHasBudget(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class AddItemActivityInformation extends ActivityInformation<InternalRequestProcess> implements Serializable {

private int quantity;
private int quantity = 1;
private String description;

public AddItemActivityInformation(final InternalRequestProcess internalRequestProcess,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<th class="col-sm-2"></th>
</tr>

<logic:iterate id="item" indexId="counter" name="process" property="internalRequest.itemsSet">
<logic:iterate id="item" indexId="counter" name="process" property="internalRequest.sortedItemsSet">
<bean:define id="itemOID" name="item" property="externalId" type="java.lang.String"/>
<tr>
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<b><bean:message bundle="INTERNAL_REQUEST_RESOURCES" key="title.internalRequest.process"/>:</b>
</span>
</td>
<td width="80%">
<td width="80%" colspan="2">
<bean:write name="process" property="processIdentification"/>
</td>
</tr>
Expand All @@ -23,15 +23,23 @@
<b><bean:message bundle="INTERNAL_REQUEST_RESOURCES" key="label.internalRequest.requestingUnit"/>:</b>
</td>
<td width="80%">
<logic:present name="process" property="internalRequest.requestingUnit"><fr:view name="process" property="internalRequest.requestingUnit.name"/></logic:present>
<logic:present name="process" property="internalRequest.requestingUnit">
<fr:view name="process" property="internalRequest.requestingUnit.unit.acronym"/>
-
<fr:view name="process" property="internalRequest.requestingUnit.name"/>
</logic:present>
</td>
</tr>
<tr>
<td width="20%">
<b><bean:message bundle="INTERNAL_REQUEST_RESOURCES" key="label.internalRequest.requestedUnit"/>:</b>
</td>
<td width="80%">
<logic:present name="process" property="internalRequest.requestedUnit"><fr:view name="process" property="internalRequest.requestedUnit.name"/></logic:present>
<logic:present name="process" property="internalRequest.requestedUnit">
<fr:view name="process" property="internalRequest.requestedUnit.unit.acronym"/>
-
<fr:view name="process" property="internalRequest.requestedUnit.name"/>
</logic:present>
</td>
</tr>
</table>
Expand Down

0 comments on commit 8243a25

Please sign in to comment.