use of org.kuali.kfs.pdp.businessobject.PaymentDetail in project cu-kfs by CU-CommunityApps.
the class CuProcessPdpCancelPaidServiceImpl method processPdpCancels.
/**
* Overridden to process each payment detail in its own transaction.
* This implementation forces the current service to call a proxied version of itself,
* in order for Spring to handle the transactions properly on the per-payment handler method.
*
* @see org.kuali.kfs.pdp.batch.service.impl.ProcessPdpCancelPaidServiceImpl#processPdpCancels()
*/
@Override
public void processPdpCancels() {
LOG.debug("processPdpCancels() started");
CuProcessPdpCancelPaidService proxiedProcessPdpCancelPaidService = getProxiedProcessPdpCancelPaidService();
Date processDate = dateTimeService.getCurrentSqlDate();
List<ExtractionUnit> extractionUnits = getExtractionUnits();
Iterator<PaymentDetail> details = paymentDetailService.getUnprocessedCancelledDetails(extractionUnits);
while (details.hasNext()) {
PaymentDetail paymentDetail = details.next();
proxiedProcessPdpCancelPaidService.processPdpCancel(paymentDetail, processDate);
}
}
use of org.kuali.kfs.pdp.businessobject.PaymentDetail in project cu-kfs by CU-CommunityApps.
the class CuPendingTransactionServiceImpl method populatePaymentGeneralLedgerPendingEntry.
/**
* Populates and stores a new GLPE for each account detail in the payment group.
*
* @param paymentGroup payment group to generate entries for
* @param achFdocTypeCode doc type for ach disbursements
* @param checkFdocTypeCod doc type for check disbursements
* @param reversal boolean indicating if this is a reversal
*/
protected void populatePaymentGeneralLedgerPendingEntry(PaymentGroup paymentGroup, String achFdocTypeCode, String checkFdocTypeCod, boolean reversal) {
List<PaymentAccountDetail> accountListings = new ArrayList<PaymentAccountDetail>();
GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
accountListings.addAll(paymentDetail.getAccountDetail());
}
// GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
for (PaymentAccountDetail paymentAccountDetail : accountListings) {
GlPendingTransaction glPendingTransaction = new GlPendingTransaction();
glPendingTransaction.setSequenceNbr(new KualiInteger(sequenceHelper.getSequenceCounter()));
if (StringUtils.isNotBlank(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode()) && StringUtils.isNotBlank(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode())) {
glPendingTransaction.setFdocRefTypCd(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode());
glPendingTransaction.setFsRefOriginCd(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode());
} else {
glPendingTransaction.setFdocRefTypCd(PdpConstants.PDP_FDOC_TYPE_CODE);
glPendingTransaction.setFsRefOriginCd(PdpConstants.PDP_FDOC_ORIGIN_CODE);
}
glPendingTransaction.setFinancialBalanceTypeCode(org.kuali.kfs.sys.KFSConstants.BALANCE_TYPE_ACTUAL);
Date transactionTimestamp = new Date(dateTimeService.getCurrentDate().getTime());
glPendingTransaction.setTransactionDt(transactionTimestamp);
AccountingPeriod fiscalPeriod = accountingPeriodService.getByDate(new java.sql.Date(transactionTimestamp.getTime()));
glPendingTransaction.setUniversityFiscalYear(fiscalPeriod.getUniversityFiscalYear());
glPendingTransaction.setUnivFiscalPrdCd(fiscalPeriod.getUniversityFiscalPeriodCode());
glPendingTransaction.setAccountNumber(paymentAccountDetail.getAccountNbr());
glPendingTransaction.setSubAccountNumber(paymentAccountDetail.getSubAccountNbr());
glPendingTransaction.setChartOfAccountsCode(paymentAccountDetail.getFinChartCode());
if (paymentGroup.getDisbursementType().getCode().equals(PdpConstants.DisbursementTypeCodes.ACH)) {
glPendingTransaction.setFinancialDocumentTypeCode(achFdocTypeCode);
} else if (paymentGroup.getDisbursementType().getCode().equals(PdpConstants.DisbursementTypeCodes.CHECK)) {
glPendingTransaction.setFinancialDocumentTypeCode(checkFdocTypeCod);
}
glPendingTransaction.setFsOriginCd(PdpConstants.PDP_FDOC_ORIGIN_CODE);
glPendingTransaction.setFdocNbr(paymentGroup.getDisbursementNbr().toString());
// if stale
if (StringUtils.equals(FDOC_TYP_CD_STALE_CHECK, checkFdocTypeCod)) {
ParameterService parameterService = SpringContext.getBean(ParameterService.class);
String clAcct = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_ACCOUNT);
String obCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_OBJECT_CODE);
String coaCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_COA);
// Use clearing parameters if stale
glPendingTransaction.setAccountNumber(clAcct);
glPendingTransaction.setFinancialObjectCode(obCode);
glPendingTransaction.setChartOfAccountsCode(coaCode);
glPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
// KFSUPGRADE-943
glPendingTransaction.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
} else {
Boolean relieveLiabilities = paymentGroup.getBatch().getCustomerProfile().getRelieveLiabilities();
if ((relieveLiabilities != null) && (relieveLiabilities.booleanValue()) && paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode() != null) {
OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class).getByPrimaryId(glPendingTransaction.getUniversityFiscalYear(), glPendingTransaction.getChartOfAccountsCode(), paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode(), glPendingTransaction.getFinancialBalanceTypeCode());
glPendingTransaction.setFinancialObjectCode(offsetDefinition != null ? offsetDefinition.getFinancialObjectCode() : paymentAccountDetail.getFinObjectCode());
glPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
} else {
glPendingTransaction.setFinancialObjectCode(paymentAccountDetail.getFinObjectCode());
glPendingTransaction.setFinancialSubObjectCode(paymentAccountDetail.getFinSubObjectCode());
}
}
glPendingTransaction.setProjectCd(paymentAccountDetail.getProjectCode());
glPendingTransaction.setDebitCrdtCd(pdpUtilService.isDebit(paymentAccountDetail, reversal) ? KFSConstants.GL_DEBIT_CODE : KFSConstants.GL_CREDIT_CODE);
glPendingTransaction.setAmount(paymentAccountDetail.getAccountNetAmount().abs());
// Changes for Research Participant Upload
String trnDesc = StringUtils.EMPTY;
CustomerProfile customerProfile = paymentGroup.getBatch().getCustomerProfile();
// KFSUPGRADE-973
if (researchParticipantPaymentValidationService.isResearchParticipantPayment(customerProfile)) {
BusinessObjectEntry businessObjectEntry = dataDictionaryService.getDataDictionary().getBusinessObjectEntry(PaymentDetail.class.getName());
AttributeDefinition attributeDefinition = businessObjectEntry.getAttributeDefinition("paymentGroup.payeeName");
AttributeSecurity originalPayeeNameAttributeSecurity = attributeDefinition.getAttributeSecurity();
// This is a temporary work around for an issue introduced with KFSCNTRB-705.
if (ObjectUtils.isNotNull(originalPayeeNameAttributeSecurity)) {
String maskLiteral = ((MaskFormatterLiteral) originalPayeeNameAttributeSecurity.getMaskFormatter()).getLiteral();
trnDesc = maskLiteral;
}
} else {
String payeeName = paymentGroup.getPayeeName();
if (StringUtils.isNotBlank(payeeName)) {
trnDesc = payeeName.length() > 40 ? payeeName.substring(0, 40) : StringUtils.rightPad(payeeName, 40);
}
if (reversal) {
String poNbr = paymentAccountDetail.getPaymentDetail().getPurchaseOrderNbr();
if (StringUtils.isNotBlank(poNbr)) {
trnDesc += " " + (poNbr.length() > 9 ? poNbr.substring(0, 9) : StringUtils.rightPad(poNbr, 9));
}
String invoiceNbr = paymentAccountDetail.getPaymentDetail().getInvoiceNbr();
if (StringUtils.isNotBlank(invoiceNbr)) {
trnDesc += " " + (invoiceNbr.length() > 14 ? invoiceNbr.substring(0, 14) : StringUtils.rightPad(invoiceNbr, 14));
}
if (trnDesc.length() > 40) {
trnDesc = trnDesc.substring(0, 40);
}
}
}
glPendingTransaction.setDescription(trnDesc);
glPendingTransaction.setOrgDocNbr(paymentAccountDetail.getPaymentDetail().getOrganizationDocNbr());
glPendingTransaction.setOrgReferenceId(paymentAccountDetail.getOrgReferenceId());
glPendingTransaction.setFdocRefNbr(paymentAccountDetail.getPaymentDetail().getCustPaymentDocNbr());
// update the offset account if necessary
SpringContext.getBean(FlexibleOffsetAccountService.class).updateOffset(glPendingTransaction);
this.businessObjectService.save(glPendingTransaction);
sequenceHelper.increment();
if (bankService.isBankSpecificationEnabled()) {
this.populateBankOffsetEntry(paymentGroup, glPendingTransaction, sequenceHelper);
}
}
}
use of org.kuali.kfs.pdp.businessobject.PaymentDetail in project cu-kfs by CU-CommunityApps.
the class CuPendingTransactionServiceImpl method generateStopGeneralLedgerPendingEntry.
/**
* @see org.kuali.kfs.pdp.service.PendingTransactionService#generateCancellationGeneralLedgerPendingEntry(org.kuali.kfs.pdp.businessobject.PaymentGroup)
*/
public void generateStopGeneralLedgerPendingEntry(PaymentGroup paymentGroup) {
GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
// Need to reverse the payment document's GL entries if the check is stopped or cancelled
reverseSourceDocumentsEntries(paymentDetail, sequenceHelper);
}
this.populatePaymentGeneralLedgerPendingEntry(paymentGroup, FDOC_TYP_CD_CANCEL_ACH, FDOC_TYP_CD_STOP_CHECK, true);
}
use of org.kuali.kfs.pdp.businessobject.PaymentDetail in project cu-kfs by CU-CommunityApps.
the class CuPendingTransactionServiceImpl method generateCRCancellationGeneralLedgerPendingEntry.
/**
* @see org.kuali.kfs.pdp.service.PendingTransactionService#generateCRCancellationGeneralLedgerPendingEntry(org.kuali.kfs.pdp.businessobject.PaymentGroup)
*/
public void generateCRCancellationGeneralLedgerPendingEntry(PaymentGroup paymentGroup) {
GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
// Need to reverse the payment document's GL entries if the check is stopped or cancelled
reverseSourceDocumentsEntries(paymentDetail, sequenceHelper);
}
this.populatePaymentGeneralLedgerPendingEntry(paymentGroup, FDOC_TYP_CD_CANCEL_ACH, FDOC_TYP_CD_CANCEL_CHECK, true);
}
use of org.kuali.kfs.pdp.businessobject.PaymentDetail in project cu-kfs by CU-CommunityApps.
the class CuPdpEmailServiceImpl method sendAchAdviceEmail.
/**
* Send advice notification email to the payee receiving an ACH payment for both bundled and unbundled ACH payments.
*
* KFSPTS-1460:
* New method signature due to need for refactoring to deal with both the unbundled and bundled cases.
* The major change is that the paymentDetail input parameter is now a list of payment details instead of being a singleton.
* The caller will pass the entire list of payment detail records and sendAchAdviceEmail will loop through them taking into
* account cases for multiples and singletons when creating and sending the advice emails.
*
* @param paymentGroup Payment group corresponding to the payment detail records
* @param paymentDetails List of all payment details to process for the single advice email being sent
* @param customer Pdp customer profile for payment
*/
public void sendAchAdviceEmail(PaymentGroup paymentGroup, List<PaymentDetail> paymentDetails, CustomerProfile customer) {
LOG.debug("sendAchAdviceEmail() with payment details list starting");
Integer numPayments = 0;
String productionEnvironmentCode = kualiConfigurationService.getPropertyValueAsString(KFSConstants.PROD_ENVIRONMENT_CODE_KEY);
String environmentCode = kualiConfigurationService.getPropertyValueAsString(KFSConstants.ENVIRONMENT_KEY);
boolean shouldBundleAchPayments = this.getAchBundlerHelperService().shouldBundleAchPayments();
if (shouldBundleAchPayments) {
// Send out one email to the payee listing all the payment details for the specified payment group
BodyMailMessage bundledMessage = createAdviceMessageAndPopulateHeader(paymentGroup, customer, productionEnvironmentCode, environmentCode);
// create the formatted body
// this seems wasteful, but since the total net amount is needed in the message body before the payment details...it's needed
KualiDecimal totalNetAmount = new KualiDecimal(0);
Iterator<PaymentDetail> pdToNetAmountIter = paymentDetails.iterator();
while (pdToNetAmountIter.hasNext()) {
numPayments = numPayments + 1;
PaymentDetail pd = pdToNetAmountIter.next();
totalNetAmount = totalNetAmount.add(pd.getNetPaymentAmount());
}
// max # of payment detail records to include in email body as well as in the attachment, only used for non-DV advices
int maxNumDetailsForBody = 10;
StringBuffer bundledBody = createAdviceMessageBody(paymentGroup, customer, totalNetAmount, numPayments);
// format payment details based on the whether it is a DV or a PREQ
// formatting of payment details for DV is different than for PREQ
boolean adviceIsForDV = false;
// first time through loop
boolean firstPass = true;
StringBuffer bundledAtachmentData = new StringBuffer();
for (Iterator<PaymentDetail> payDetailsIter = paymentDetails.iterator(); payDetailsIter.hasNext(); ) {
PaymentDetail paymentDetail = payDetailsIter.next();
// initialize data the first time through the loop
if (firstPass) {
adviceIsForDV = (paymentDetail.getFinancialDocumentTypeCode().equalsIgnoreCase(DisbursementVoucherConstants.DOCUMENT_TYPE_CHECKACH)) ? true : false;
if (adviceIsForDV) {
// we will NOT be sending an attachment, all payment detail will be in the body of the message
bundledBody.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_PAYMENT_HEADER_LINE_ONE));
bundledBody.append(customer.getAdviceHeaderText());
bundledBody.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_PAYMENT_SEPARATOR));
} else {
// we will be sending an attachment
bundledAtachmentData = new StringBuffer();
// creating the payment detail table header
bundledAtachmentData.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_ATTACHMENT_HEADING_SUMMARY_LINE_ONE));
bundledAtachmentData.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_ATTACHMENT_HEADING_SUMMARY_LINE_TWO));
bundledAtachmentData.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_ATTACHMENT_HEADING_SUMMARY_LINE_THREE));
// verbiage describing the payment details and attachment
bundledBody.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_DETAIL_INFO_MSG, numPayments));
if (numPayments <= maxNumDetailsForBody) {
// email body will have details and an attachment will be sent
bundledBody.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_DETAIL_UNDER_LIMIT_MSG));
// individual customer message for the payment
bundledBody.append(customer.getAdviceHeaderText());
bundledBody.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_PAYMENT_SEPARATOR));
}
// implied else that numPayments is over the max so only send an attachment
}
// ensure headers only included once
firstPass = false;
}
if (adviceIsForDV) {
// format payment detail information and include it in the message body, do not send an attachment
bundledBody.append(createAdviceMessagePaymentDetail(paymentGroup, paymentDetail, adviceIsForDV, shouldBundleAchPayments));
} else {
// put payment detail information in the attachment
bundledAtachmentData.append(createAdviceMessagePaymentDetail(paymentGroup, paymentDetail, adviceIsForDV, shouldBundleAchPayments));
// also put payment detail in the body when the number of payments is fewer than the max
if (numPayments <= maxNumDetailsForBody) {
// explicitly using false instead of shouldBundleAchPayments so that we get the correct format for the email body
bundledBody.append(createAdviceMessagePaymentDetail(paymentGroup, paymentDetail, adviceIsForDV, false));
}
}
}
// for-loop
bundledMessage.setMessage(bundledBody.toString());
if (!adviceIsForDV) {
// only create the attachment file when the payments are NOT for DV's
Formatter integerFormatter = new IntegerFormatter();
String attachmentFileName = new String("paymentDetailsForDisbursement_" + (String) integerFormatter.formatForPresentation(paymentGroup.getDisbursementNbr()) + ".csv");
bundledMessage.setAttachmentFileName(attachmentFileName);
bundledMessage.setAttachmentContent(bundledAtachmentData.toString().getBytes());
bundledMessage.setAttachmentContentType(new String("text/csv"));
}
sendFormattedAchAdviceEmail(bundledMessage, customer, paymentGroup, productionEnvironmentCode, environmentCode);
} else {
// so that the appropriate mail "send" is invoked based on the message type that we created and passed.
for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
numPayments = paymentGroup.getPaymentDetails().size();
BodyMailMessage nonBundledMessage = createAdviceMessageAndPopulateHeader(paymentGroup, customer, productionEnvironmentCode, environmentCode);
StringBuffer nonBundledBody = createAdviceMessageBody(paymentGroup, customer, paymentDetail.getNetPaymentAmount(), numPayments);
nonBundledBody.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_PAYMENT_HEADER_LINE_ONE));
nonBundledBody.append(customer.getAdviceHeaderText());
nonBundledBody.append(getMessage(CUPdpKeyConstants.MESSAGE_PDP_ACH_ADVICE_EMAIL_BODY_PAYMENT_SEPARATOR));
boolean adviceIsForDV = (paymentDetail.getFinancialDocumentTypeCode().equalsIgnoreCase(DisbursementVoucherConstants.DOCUMENT_TYPE_CHECKACH)) ? true : false;
nonBundledBody.append(createAdviceMessagePaymentDetail(paymentGroup, paymentDetail, adviceIsForDV, shouldBundleAchPayments));
nonBundledMessage.setMessage(nonBundledBody.toString());
sendFormattedAchAdviceEmail(nonBundledMessage, customer, paymentGroup, productionEnvironmentCode, environmentCode);
}
}
}
Aggregations