Skip to content

Commit

Permalink
KFSPTS-32805 Show DV payment info on IWNT doc (#1664)
Browse files Browse the repository at this point in the history
  • Loading branch information
cah292 committed Nov 14, 2024
1 parent cfd18ab commit cc57991
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import java.sql.Date;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.lang3.StringUtils;
import org.kuali.kfs.coa.businessobject.AccountingPeriod;
import org.kuali.kfs.coa.businessobject.Chart;
Expand All @@ -26,6 +28,8 @@
import org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument;
import org.kuali.kfs.module.purap.document.service.PurapService;
import org.kuali.kfs.module.purap.util.PurApRelatedViews;
import org.kuali.kfs.pdp.businessobject.PaymentDetail;
import org.kuali.kfs.pdp.service.PaymentDetailService;
import org.kuali.kfs.sys.KFSConstants;
import org.kuali.kfs.sys.KFSConstants.RouteLevelNames;
import org.kuali.kfs.sys.businessobject.AccountingLineParser;
Expand All @@ -43,11 +47,13 @@
import org.kuali.kfs.vnd.businessobject.VendorAddress;
import org.kuali.kfs.vnd.businessobject.VendorDetail;

import edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument;
import edu.cornell.kfs.module.purap.CUPurapConstants;
import edu.cornell.kfs.module.purap.CUPurapConstants.IWantRouteNodes;
import edu.cornell.kfs.module.purap.businessobject.IWantAccount;
import edu.cornell.kfs.module.purap.businessobject.IWantItem;
import edu.cornell.kfs.module.purap.document.service.IWantDocumentService;
import edu.cornell.kfs.pdp.service.CuPaymentDetailService;

public class IWantDocument extends FinancialSystemTransactionalDocumentBase implements Copyable, PurchasingAccountsPayableDocument, AmountTotaling {

Expand Down Expand Up @@ -1034,6 +1040,28 @@ private boolean documentIsBeingReturnedToSSC(final DocumentRouteLevelChange leve
&& !StringUtils.equals(levelChangeEvent.getOldNodeName(), RouteLevelNames.ADHOC);
}

public List<PaymentDetail> getDvPaymentDetails() {
final CuDisbursementVoucherDocument generatedDvDocument = getGeneratedDvDocument();
if (ObjectUtils.isNull(generatedDvDocument)) {
return List.of();
}
final Iterator<PaymentDetail> paymentDetails = getCuPaymentDetailService()
.getByCustomerDocumentNumberAndFinancialDocumentTypeCode(
generatedDvDocument.getDocumentNumber(), generatedDvDocument.getPaymentDetailDocumentType());
return IteratorUtils.toList(paymentDetails);
}

public CuDisbursementVoucherDocument getGeneratedDvDocument() {
if (StringUtils.isBlank(dvDocId)) {
return null;
}
return SpringContext.getBean(IWantDocumentService.class).getDisbursementVoucherGeneratedByIWantDoc(this);
}

private CuPaymentDetailService getCuPaymentDetailService() {
return ((CuPaymentDetailService) SpringContext.getBean(PaymentDetailService.class));
}

// The following link identifier getter and setter are needed for viewing the IWNT with other related PURAP docs.

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ RequisitionDocument setUpRequisitionDetailsFromIWantDoc(IWantDocument iWantDocum

void updateIWantDocumentWithDisbursementVoucherReference(IWantDocument iWantDocument, String dvDocumentNumber);

CuDisbursementVoucherDocument getDisbursementVoucherGeneratedByIWantDoc(IWantDocument iWantDocument);

/**
* Generates and sets the IWantDocument description based on the field values on the document.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,14 @@ public void setUpIWantDocDefaultValues(IWantDocument iWantDocument, Person initi

}


@Override
public CuDisbursementVoucherDocument getDisbursementVoucherGeneratedByIWantDoc(IWantDocument iWantDocument) {
if (StringUtils.isBlank(iWantDocument.getDvDocId())) {
return null;
}
return (CuDisbursementVoucherDocument) documentService.getByDocumentHeaderId(iWantDocument.getDvDocId());
}

public AttachmentService getAttachmentService() {
return attachmentService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServlet

documentForm.setDocIsInitiatedOrSaved(determineDocStatusForCollegeDepartmentButtons(iWantDoc));
documentForm.setUserMatchesInitiator(userIsInitiator(iWantDoc));

documentForm.populateGeneratedDvDocumentInfo();
}

return actionForward;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
package edu.cornell.kfs.module.purap.document.web.struts;

import edu.cornell.kfs.module.purap.CUPurapConstants;
import edu.cornell.kfs.module.purap.CUPurapKeyConstants;
import edu.cornell.kfs.module.purap.businessobject.IWantAccount;
import edu.cornell.kfs.module.purap.businessobject.IWantItem;
import edu.cornell.kfs.module.purap.document.IWantDocument;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.kuali.kfs.core.api.config.property.ConfigContext;
import org.kuali.kfs.core.api.config.property.ConfigurationService;
import org.kuali.kfs.core.api.util.KeyValue;
import org.kuali.kfs.kew.api.WorkflowDocument;
import org.kuali.kfs.kns.web.ui.ExtraButton;
import org.kuali.kfs.krad.document.Document;
import org.kuali.kfs.krad.util.KRADConstants;
import org.kuali.kfs.krad.util.ObjectUtils;
import org.kuali.kfs.pdp.businessobject.PaymentDetail;
import org.kuali.kfs.sys.KFSConstants;
import org.kuali.kfs.sys.context.SpringContext;
import org.kuali.kfs.sys.document.web.struts.FinancialSystemTransactionalDocumentFormBase;
import org.kuali.kfs.core.api.config.property.ConfigContext;
import org.kuali.kfs.core.api.config.property.ConfigurationService;
import org.kuali.kfs.core.api.util.KeyValue;
import org.kuali.kfs.kew.api.WorkflowDocument;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument;
import edu.cornell.kfs.module.purap.CUPurapConstants;
import edu.cornell.kfs.module.purap.CUPurapKeyConstants;
import edu.cornell.kfs.module.purap.businessobject.IWantAccount;
import edu.cornell.kfs.module.purap.businessobject.IWantItem;
import edu.cornell.kfs.module.purap.document.IWantDocument;

@SuppressWarnings("deprecation")
public class IWantDocumentForm extends FinancialSystemTransactionalDocumentFormBase {
Expand All @@ -45,6 +47,9 @@ public class IWantDocumentForm extends FinancialSystemTransactionalDocumentFormB
protected boolean userMatchesInitiator;
protected boolean docIsInitiatedOrSaved;

protected transient CuDisbursementVoucherDocument generatedDvDocument;
protected transient List<PaymentDetail> dvPaymentDetails;

public IWantDocumentForm() {
super();
setNewIWantItemLine(new IWantItem());
Expand Down Expand Up @@ -537,5 +542,29 @@ private boolean isDocInNode(Document document, String node) {
private boolean isInOrgHierarchyNode(Document document) {
return isDocInNode(document, KFSConstants.RouteLevelNames.ORGANIZATION_HIERARCHY);
}


public CuDisbursementVoucherDocument getGeneratedDvDocument() {
if (ObjectUtils.isNull(generatedDvDocument)) {
populateGeneratedDvDocumentInfo();
}
return generatedDvDocument;
}

public List<PaymentDetail> getDvPaymentDetails() {
if (ObjectUtils.isNull(dvPaymentDetails)) {
populateGeneratedDvDocumentInfo();
}
return dvPaymentDetails;
}

public void populateGeneratedDvDocumentInfo() {
if (StringUtils.isNotBlank(getIWantDocument().getDvDocId())) {
generatedDvDocument = getIWantDocument().getGeneratedDvDocument();
dvPaymentDetails = getIWantDocument().getDvPaymentDetails();
} else {
generatedDvDocument = null;
dvPaymentDetails = List.of();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ public interface CuPaymentDetailService extends PaymentDetailService {
Iterator<PaymentDetail> getByDisbursementNumber(Integer disbursementNumber, Integer processId,
String disbursementType, String bankCode, boolean processImmediate);

Iterator<PaymentDetail> getByCustomerDocumentNumberAndFinancialDocumentTypeCode(
final String customerDocumentNumber, final String financialDocumentTypeCode);

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package edu.cornell.kfs.pdp.service.impl;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kuali.kfs.krad.service.BusinessObjectService;
Expand Down Expand Up @@ -49,6 +52,22 @@ public Iterator<PaymentDetail> getByDisbursementNumber(final Integer disbursemen
return paymentDetailByDisbursementNumberList.iterator();
}

@Override
public Iterator<PaymentDetail> getByCustomerDocumentNumberAndFinancialDocumentTypeCode(
final String customerDocumentNumber, final String financialDocumentTypeCode) {
if (StringUtils.isAnyBlank(customerDocumentNumber, financialDocumentTypeCode)) {
return Collections.emptyIterator();
}
final Map<String, String> fieldValues = Map.ofEntries(
Map.entry(PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_CUST_PAYMENT_DOC_NBR,
customerDocumentNumber),
Map.entry(PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_FINANCIAL_DOCUMENT_TYPE_CODE,
financialDocumentTypeCode)
);
final Collection<PaymentDetail> results = businessObjectService.findMatching(PaymentDetail.class, fieldValues);
return results.iterator();
}

@Override
public void setBusinessObjectService(final BusinessObjectService businessObjectService) {
super.setBusinessObjectService(businessObjectService);
Expand Down
74 changes: 74 additions & 0 deletions src/main/webapp/WEB-INF/tags/module/purap/iWantDvPayments.tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<%@ include file="/jsp/sys/kfsTldHeader.jsp" %>

<c:set var="dvAttributes" value="${DataDictionary.DisbursementVoucherDocument.attributes}"/>
<c:set var="paymentDetailAttributes" value="${DataDictionary.PurchasingPaymentDetail.attributes}"/>

<c:set var="dvStatus" value="${KualiForm.generatedDvDocument.documentHeader.workflowDocument.status}"/>
<c:set var="dvPaymentDetails" value="${KualiForm.dvPaymentDetails}"/>
<c:set var="dvHasExactlyOnePayment" value="${fn:length(dvPaymentDetails) eq 1}"/>

<kul:tab tabTitle="Disbursement Voucher Payments" defaultOpen="true">
<div class="tab-container">
<h3>DV Payment Information</h3>
<c:choose>
<c:when test="${dvStatus eq 'PROCESSED' || dvStatus eq 'FINAL'}">
<table class="datatable standard side-margins" summary="DV PDP Status">
<tr>
<th class="right" width="50%">
<kul:htmlAttributeLabel attributeEntry="${dvAttributes.disbursementVoucherPdpStatus}"/>
</th>
<td class="datacell" width="50%">
<kul:htmlControlAttribute
attributeEntry="${dvAttributes.disbursementVoucherPdpStatus}"
property="generatedDvDocument.disbursementVoucherPdpStatus"
readOnly="true"/>
</td>
</tr>
</table>
<table class="datatable standard side-margins" summary="Payments">
<tr class="header">
<kul:htmlAttributeHeaderCell literalLabel="&nbsp;" scope="col" align="left"/>
<kul:htmlAttributeHeaderCell
attributeEntry="${paymentDetailAttributes['paymentGroup.disbursementType.name']}"
hideRequiredAsterisk="true" useShortLabel="false" scope="col" align="left"/>
<kul:htmlAttributeHeaderCell
attributeEntry="${paymentDetailAttributes['paymentGroup.disbursementDate']}"
hideRequiredAsterisk="true" useShortLabel="false" scope="col" align="left"/>
</tr>
<c:forEach var="payment" items="${dvPaymentDetails}" varStatus="status">
<c:set var="lineNumber" value="${dvHasExactlyOnePayment ? '&nbsp;' : (status.index + 1)}"/>
<tr class="${status.index % 2 == 0 ? 'highlight' : ''}">
<td>${lineNumber}</td>
<td>
<kul:htmlControlAttribute
attributeEntry="${paymentDetailAttributes['paymentGroup.disbursementType.name']}"
property="dvPaymentDetails[${status.index}].paymentGroup.disbursementType.name"
readOnly="true"/>
</td>
<td>
<kul:htmlControlAttribute
attributeEntry="${paymentDetailAttributes['paymentGroup.disbursementDate']}"
property="dvPaymentDetails[${status.index}].paymentGroup.disbursementDate"
readOnly="true"/>
</td>
</tr>
</c:forEach>
<c:if test="${empty dvPaymentDetails}">
<tr>
<td>&nbsp;</td>
<td colspan="2">No Payment Information Available</td>
</tr>
</c:if>
</table>
</c:when>
<c:otherwise>
<table class="datatable standard side-margins" summary="DV PDP Status">
<tr>
<th>No Payment Information Available</th>
</tr>
</table>
</c:otherwise>
</c:choose>

</div>
</kul:tab>
1 change: 1 addition & 0 deletions src/main/webapp/jsp/module/purap/IWant.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
</c:if>

<c:if test="${!empty(KualiForm.document.dvDocId)}">
<purap:iWantDvPayments />
<purap:iWantRelatedDocuments />
</c:if>

Expand Down

0 comments on commit cc57991

Please sign in to comment.