Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Reskin payment improvements #61

Merged
merged 5 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class PaymentHistory extends BaseProcessor implements PactsConstants {
public static final String XLS_FORMAT = "xls";
public static final String FULL_LIST = "full_list";
public static final String PAYMENTS = "payments";
public static final String OWED_PAYMENTS = "owedPayments";
public static final String TOTAL_OWED_PAYMENTS = "totalOwedPayments";

/**
* <p>A <code>String</code> providing the name for request attribute holding the ID of a payment method preferred by
Expand Down Expand Up @@ -150,9 +152,17 @@ protected void businessProcessing() throws TCWebException {

List<BasePayment> removeNonPending = new ArrayList<BasePayment>();

List<Long> owedPayments = new ArrayList<Long>();
double totalOwedPayments = 0.0;
Date currentDate = new Date();

for (BasePayment payment : payments) {
if (payment.getPaymentType() == 3 || payment.getPaymentType() == 5) {
removePayments.add(payment);
} else if ((payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.OWED_PAYMENT_STATUS))) &&
!(payment.getDueDate().after(currentDate))) {
owedPayments.add(payment.getId());
totalOwedPayments += payment.getNetAmount();
} else {
if (!(payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.OWED_PAYMENT_STATUS))) &&
!(payment.getCurrentStatus().equals(PaymentStatusFactory.createStatus(PaymentStatus.ENTERED_INTO_PAYMENT_SYSTEM_PAYMENT_STATUS))) &&
Expand Down Expand Up @@ -184,6 +194,8 @@ protected void businessProcessing() throws TCWebException {
getRequest().setAttribute("NUM_TOTAL", payments.size());
getRequest().setAttribute("NUM_PER_PAGE", numRecords);
getRequest().setAttribute("NUM_PENDING", pendingPayments);
getRequest().setAttribute("OWED_PAYMENTS", owedPayments);
getRequest().setAttribute("TOTAL_OWED_PAYMENTS", totalOwedPayments);

if (exportToExcel) {
produceXLS(payments);
Expand Down
91 changes: 88 additions & 3 deletions src/main/com/topcoder/web/tc/view/pacts/client/PaymentHistory.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
<c:set value="<%=request.getAttribute("NUM_TOTAL")%>" var="numTotal" />
<c:set value="<%=request.getAttribute("NUM_PER_PAGE")%>" var="numPerPage" />
<c:set value="<%=request.getAttribute("NUM_PENDING")%>" var="numPending" />
<c:set value="<%=request.getAttribute("OWED_PAYMENTS")%>" var="owedPayments" />
<c:set value="<%=request.getAttribute("TOTAL_OWED_PAYMENTS")%>" var="totalOwedPayments" />
<c:set value="<%=DataAccessConstants.SORT_COLUMN%>" var="sortColumn"/>
<c:set value="<%=DataAccessConstants.SORT_DIRECTION%>" var="sortDirection"/>

Expand All @@ -81,6 +83,9 @@
MINIMUM_PAYMENT_ACCRUAL_AMOUNT = ${MINIMUM_PAYMENT_ACCRUAL_AMOUNT};
PAY_ME_CONFIRMATION_TEMPLATE = '${paymentConfirmationTemplate}';
var owedPayments = ${owedPayments};
var totalOwedPayments = ${totalOwedPayments};
function next() {
var myForm = document.f;
myForm.<%=DataAccessConstants.START_RANK%>.value = ${requestScope[defaults][startRank]} + parseInt(myForm.<%=DataAccessConstants.NUMBER_RECORDS%>.value);
Expand Down Expand Up @@ -139,6 +144,23 @@
$('.payable[value="' + paymentId + '"]').click();
});
$('.checkAll').click(function () {
if (this.checked) {
$('.checkAll').attr('checked', true);
$('.payable').each(function () {
var paymentId = this.value;
$('[data-name="${PAYMENT_ID}"][data-value="'+paymentId+'"]').removeClass('checked');
$('[data-name="${PAYMENT_ID}"][data-value="'+paymentId+'"]').addClass('checked');
});
} else {
$('.checkAll').attr('checked', false);
$('.payable').each(function () {
var paymentId = this.value;
$('[data-name="${PAYMENT_ID}"][data-value="'+paymentId+'"]').removeClass('checked');
});
}
});
$('.payable').click(function() {
var hasSelected = false;
$('.payable:checked').each(function () {
Expand All @@ -151,6 +173,11 @@
error = $('<span />').attr('class', 'bigRed').html('The total net amount for selected payments is less than $25');
$("#PaymentHistoryForm").prev().append('<br>').append(error)
}
if ($('.checkable:checked').length == $('.checkable').length) {
$('.checkAll').attr('checked', true);
} else if ($('.checkable').not(':checked').length == $('.checkable').length) {
$('.checkAll').attr('checked', false);
}
});
});
}
Expand Down Expand Up @@ -224,6 +251,12 @@
</c:if>

<c:if test="${isReskin}">
<div class="above-tabs">
<div align="right" class="pay-me-btn">
<input type="button" value="Pay Me" id="quickPayMe"/>
</div>
</div>

<%-- desktop tabs --%>
<nav class="tabs paymentHistoryTabs">
<c:if test="${fullList}" >
Expand Down Expand Up @@ -285,6 +318,15 @@
}
</script>
</div>
<%-- Mobile select all checkbox --%>
<c:if test="${not empty payments}">
<div class="mobile-select-all-checkbox">
<span class="checkbox">
<input type="checkbox" class="checkAll">
<span class="checkbox-label"></span>
</span>
</div>
</c:if>
<%-- Mobile sort-button --%>
<c:if test="${not empty payments}">
<a
Expand Down Expand Up @@ -377,7 +419,13 @@
<a class="getable" href="<%=sessionInfo.getServletPath()%>?<tc-webtag:sort column="7" includeParams="true" />" >Date Paid</a>
<%--</c:if>--%>
</td>
<td class="header">&nbsp;</td>
<td class="headerC">
<span class="checkbox">
<input type="checkbox" class="checkAll">
<span class="checkbox-label"></span>
</span>
</td>
<%-- <td class="header">&nbsp;</td> --%>
</tr>

<c:forEach items="${payments}" var="payment">
Expand Down Expand Up @@ -424,7 +472,22 @@
<td class="value type">${payment.paymentTypeDesc}</td>
<td class="valueC create-date"><fmt:formatDate value="${payment.createDate}" pattern="dd/MM/yyyy"/></td>
<td class="valueR net-payment"><fmt:formatNumber value="${payment.netAmount}" type="currency" currencySymbol="$"/></td>
<td class="value status"><span class="status ${payment.currentStatus.desc}"><span class="status-label">${payment.currentStatus.desc}</span></span>
<td class="value status">
<span class="status ${payment.currentStatus.desc}">
<span class="status-label">
<c:choose>
<c:when test="${payment.currentStatus.id eq OWED}">
Available
</c:when>
<c:when test="${payment.currentStatus.id eq ACCRUING}">
Pending
</c:when>
<c:otherwise>
${payment.currentStatus.desc}
</c:otherwise>
</c:choose>
</span>
</span>
<c:forEach items="${payment.currentStatus.reasons}" var="reason">
<br>- ${reason.desc}
</c:forEach>
Expand All @@ -448,6 +511,10 @@
<c:when test="${payment.currentStatus.id eq OWED or payment.currentStatus.id eq ACCRUING}">
<%-- Owed, Accruing --%>
<c:choose>
<c:when test="${payment.currentStatus.id eq ACCRUING}">
<%-- Payment is pending yet: un-checked, disabled --%>
<input type="checkbox" disabled="disabled" name="${PAYMENT_ID}" value="${payment.id}"/>
</c:when>
<c:when test="${payment.dueDate eq null or (payment.dueDate > now)}">
<%-- Payment release date is not reached yet: un-checked, disabled --%>
<input type="checkbox" disabled="disabled" name="${PAYMENT_ID}" value="${payment.id}"/>
Expand Down Expand Up @@ -550,7 +617,21 @@
<div class="row status">
<div class="col col-label">Status</div>
<div class="col col-value">
<span class="status ${paymentItem.currentStatus.desc}"><span class="status-label">${paymentItem.currentStatus.desc}</span></span>
<span class="status ${paymentItem.currentStatus.desc}">
<span class="status-label">
<c:choose>
<c:when test="${paymentItem.currentStatus.id eq OWED}">
Available
</c:when>
<c:when test="${paymentItem.currentStatus.id eq ACCRUING}">
Pending
</c:when>
<c:otherwise>
${paymentItem.currentStatus.desc}
</c:otherwise>
</c:choose>
</span>
</span>
<c:forEach items="${paymentItem.currentStatus.reasons}" var="reason">
<br>- ${reason.desc}
</c:forEach>
Expand Down Expand Up @@ -583,6 +664,10 @@
<c:when test="${paymentItem.currentStatus.id eq OWED or paymentItem.currentStatus.id eq ACCRUING}">
<%-- Owed, Accruing --%>
<c:choose>
<c:when test="${paymentItem.currentStatus.id eq ACCRUING}">
<%-- Payment is pending yet: un-checked, disabled --%>
<span role="checkbox" class="checkbox disabled" data-name="${PAYMENT_ID}" data-value="${paymentItem.id}"></span>
</c:when>
<c:when test="${paymentItem.dueDate eq null or (paymentItem.dueDate > now)}">
<%-- Payment release date is not reached yet: un-checked, disabled --%>
<span role="checkbox" class="checkbox disabled" data-name="${PAYMENT_ID}" data-value="${paymentItem.id}"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,13 @@
<rsc:iterator list="<%=rsc%>" id="resultRow">
<tr class="<%=even?"dark":"light"%>">
<TD class="value payment-status">
<% if ("Owed".equals(resultRow.getStringItem("payment_status"))) { %>
Available
<% } else if ("Accruing".equals(resultRow.getStringItem("payment_status"))) { %>
Pending
<% } else { %>
<rsc:item name="payment_status" row="<%=resultRow%>"/>
<% } %>
</TD>
<TD class="valueR net-amount">
<% if (resultRow.getDoubleItem("net_amount") > 0) {
Expand Down