Search in sources :

Example 11 with PaymentDetail

use of org.kuali.kfs.pdp.businessobject.PaymentDetail in project cu-kfs by CU-CommunityApps.

the class CuPaymentMaintenanceServiceImpl method cancelDisbursement.

@Override
public boolean cancelDisbursement(Integer paymentGroupId, Integer paymentDetailId, String note, Person user) {
    LOG.debug("cancelDisbursement() started");
    if (!pdpAuthorizationService.hasCancelPaymentPermission(user.getPrincipalId())) {
        LOG.warn("cancelDisbursement() User " + user.getPrincipalId() + " does not have rights to cancel payments. This should not happen unless user is URL spoofing.");
        throw new RuntimeException("cancelDisbursement() User " + user.getPrincipalId() + " does not have rights to cancel payments. This should not happen unless user is URL spoofing.");
    }
    PaymentGroup paymentGroup = this.paymentGroupService.get(paymentGroupId);
    if (paymentGroup == null) {
        LOG.debug("cancelDisbursement() Disbursement not found; throw exception.");
        GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.PaymentDetail.ErrorMessages.ERROR_DISBURSEMENT_NOT_FOUND);
        return false;
    }
    // get the target PaymentGroup info
    PaymentDetail targetPd = getPaymentDetail(paymentDetailId);
    KualiInteger targetGroupId = targetPd.getPaymentGroupId();
    PaymentGroup targetPg = getPaymentGroup(targetGroupId);
    String targetDvTypeCode = targetPg.getDisbursementTypeCode();
    String targetDvBankCode = targetPg.getBankCode();
    String paymentStatus = paymentGroup.getPaymentStatus().getCode();
    if (!(PdpConstants.PaymentStatusCodes.CANCEL_DISBURSEMENT.equals(paymentStatus))) {
        if (((PdpConstants.PaymentStatusCodes.EXTRACTED.equals(paymentStatus)) && (ObjectUtils.isNotNull(paymentGroup.getDisbursementDate()))) || (PdpConstants.PaymentStatusCodes.PENDING_ACH.equals(paymentStatus))) {
            LOG.debug("cancelDisbursement() Payment status is " + paymentStatus + "; continue with cancel.");
            List<PaymentGroup> allDisbursementPaymentGroups = this.paymentGroupService.getByDisbursementNumber(paymentGroup.getDisbursementNbr().intValue());
            for (PaymentGroup element : allDisbursementPaymentGroups) {
                // should be the same DV type and the same bank
                if (!(element.getDisbursementTypeCode().equalsIgnoreCase(targetDvTypeCode) && element.getBankCode().equalsIgnoreCase(targetDvBankCode))) {
                    continue;
                }
                PaymentGroupHistory pgh = new PaymentGroupHistory();
                if (!element.getPaymentDetails().get(0).isDisbursementActionAllowed()) {
                    LOG.warn("cancelDisbursement() Payment does not allow disbursement action. This should not happen unless user is URL spoofing.");
                    throw new RuntimeException("cancelDisbursement() Payment does not allow disbursement action. This should not happen unless user is URL spoofing.");
                }
                if ((ObjectUtils.isNotNull(element.getDisbursementType())) && (element.getDisbursementType().getCode().equals(PdpConstants.DisbursementTypeCodes.CHECK))) {
                    pgh.setPmtCancelExtractStat(Boolean.FALSE);
                }
                changeStatus(element, PdpConstants.PaymentStatusCodes.CANCEL_DISBURSEMENT, PdpConstants.PaymentChangeCodes.CANCEL_DISBURSEMENT, note, user, pgh);
                glPendingTransactionService.generateCancellationGeneralLedgerPendingEntry(element);
                // set primary cancel indicator for EPIC to use
                // these payment details will be canceled when running processPdpCancelAndPaidJOb
                Map<String, KualiInteger> primaryKeys = new HashMap<>();
                primaryKeys.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_PAYMENT_GROUP_ID, element.getId());
                // cancel all  payment details for payment group
                List<PaymentDetail> pds = (List<PaymentDetail>) this.businessObjectService.findMatching(PaymentDetail.class, primaryKeys);
                if (pds != null && !pds.isEmpty()) {
                    for (PaymentDetail pd : pds) {
                        pd.setPrimaryCancelledPayment(Boolean.TRUE);
                        this.businessObjectService.save(pd);
                    }
                }
            }
            LOG.debug("cancelDisbursement() Disbursement cancelled; exit method.");
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("cancelDisbursement() Payment status is " + paymentStatus + " and disbursement date is " + paymentGroup.getDisbursementDate() + "; cannot cancel payment in this status");
            }
            GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.PaymentDetail.ErrorMessages.ERROR_DISBURSEMENT_INVALID_TO_CANCEL);
            return false;
        }
    } else {
        LOG.debug("cancelDisbursement() Disbursement has already been cancelled; exit method.");
    }
    return true;
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) PaymentGroupHistory(org.kuali.kfs.pdp.businessobject.PaymentGroupHistory) HashMap(java.util.HashMap) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) List(java.util.List)

Example 12 with PaymentDetail

use of org.kuali.kfs.pdp.businessobject.PaymentDetail in project cu-kfs by CU-CommunityApps.

the class AchBundlerHelperServiceImpl method getPendingAchPaymentDetailsByDisbursementNumberAndBank.

/**
 * Returns all PaymentDetail records for pending ACH payments for a given bank code
 * @param bankCode the bank code of the payment group of payment details to find
 * @return an iterator of PaymentDetail records matching the given criteria
 */
public Iterator<PaymentDetail> getPendingAchPaymentDetailsByDisbursementNumberAndBank(Integer disbursementNumber, String bankCode) {
    Map fieldValues = new HashMap();
    fieldValues.put(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP + "." + PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.ACH);
    fieldValues.put(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP + "." + PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PAYMENT_STATUS_CODE, PdpConstants.PaymentStatusCodes.PENDING_ACH);
    fieldValues.put(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP + "." + PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_NBR, disbursementNumber);
    fieldValues.put(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP + "." + PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE, bankCode);
    List<PaymentDetail> paymentDetailByDisbursementNumberList = (List<PaymentDetail>) this.businessObjectService.findMatching(PaymentDetail.class, fieldValues);
    DynamicCollectionComparator.sort(paymentDetailByDisbursementNumberList, PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_FINANCIAL_DOCUMENT_TYPE_CODE, PdpPropertyConstants.PaymentDetail.PAYMENT_DISBURSEMENT_CUST_PAYMENT_DOC_NBR);
    return paymentDetailByDisbursementNumberList.iterator();
}
Also used : HashMap(java.util.HashMap) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with PaymentDetail

use of org.kuali.kfs.pdp.businessobject.PaymentDetail in project cu-kfs by CU-CommunityApps.

the class AchBundlerHelperServiceImpl method getPendingAchPaymentDetailsByBank.

/**
 * Returns all PaymentDetail records for pending ACH payments for a given bank code
 * @param bankCode the bank code of the payment group of payment details to find
 * @return an iterator of PaymentDetail records matching the given criteria
 */
public Iterator<PaymentDetail> getPendingAchPaymentDetailsByBank(String bankCode) {
    Map fieldValues = new HashMap();
    fieldValues.put(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP + "." + PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.ACH);
    fieldValues.put(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP + "." + PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PAYMENT_STATUS_CODE, PdpConstants.PaymentStatusCodes.PENDING_ACH);
    fieldValues.put(PdpPropertyConstants.PaymentDetail.PAYMENT_GROUP + "." + PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE, bankCode);
    List<PaymentDetail> paymentDetailList = (List<PaymentDetail>) this.businessObjectService.findMatching(PaymentDetail.class, fieldValues);
    return paymentDetailList.iterator();
}
Also used : HashMap(java.util.HashMap) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 14 with PaymentDetail

use of org.kuali.kfs.pdp.businessobject.PaymentDetail in project cu-kfs by CU-CommunityApps.

the class GlTransactionStep method execute.

/**
 * Execute
 *
 * @param jobName Job Name
 * @param jobRunDate Job Date
 * @see org.kuali.kfs.kns.bo.Step#execute(java.lang.String, java.util.Date)
 */
public boolean execute(String jobName, Date jobRunDate) throws InterruptedException {
    LOG.info("Started GlTransactionStep @ " + (new Date()).toString());
    LOG.info("Get Bank List");
    Collection<Bank> banks = businessObjectService.findAll(Bank.class);
    List<String> bankCodes = null;
    Collection<PaymentGroup> paymentGroups = null;
    Map<String, Object> fieldValues = null;
    Collection<CheckReconciliation> records = null;
    // Stop payments
    fieldValues = new HashMap<String, Object>();
    fieldValues.put("glTransIndicator", "N");
    fieldValues.put("status", CRConstants.STOP);
    fieldValues.put("sourceCode", CRConstants.PDP_SRC);
    records = businessObjectService.findMatching(CheckReconciliation.class, fieldValues);
    for (CheckReconciliation cr : records) {
        bankCodes = new ArrayList<String>();
        // Generate list of valid bank codes
        setBankCodes(banks, cr, bankCodes);
        if (bankCodes.size() > 0) {
            paymentGroups = glTransactionService.getAllPaymentGroupForSearchCriteria(cr.getCheckNumber(), bankCodes);
            if (paymentGroups.isEmpty()) {
                LOG.warn("No payment group found id : " + cr.getId());
            } else {
                for (PaymentGroup paymentGroup : paymentGroups) {
                    // KFSUPGRADE-636
                    // Create cancellation offsets for STOPed checks. KFSPTS-1741
                    glPendingTransactionService.generateStopGeneralLedgerPendingEntry(paymentGroup);
                    // glTransactionService.generateGlPendingTransactionStop(paymentGroup);
                    KualiCode code = businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, cr.getStatus());
                    if (paymentGroup.getPaymentStatus() != ((PaymentStatus) code)) {
                        paymentGroup.setPaymentStatus((PaymentStatus) code);
                    }
                    Date lastUpdate = cr.getStatusChangeDate();
                    if (ObjectUtils.isNull(lastUpdate)) {
                        lastUpdate = new Date();
                    }
                    paymentGroup.setLastUpdatedTimestamp(new Timestamp(lastUpdate.getTime()));
                    businessObjectService.save(paymentGroup);
                    // Update status
                    cr.setGlTransIndicator(Boolean.TRUE);
                    businessObjectService.save(cr);
                    LOG.info("Generated Stop GL Pending Transacation");
                }
            }
        }
    }
    // Canceled payments
    fieldValues = new HashMap<String, Object>();
    fieldValues.put("glTransIndicator", "N");
    fieldValues.put("status", CRConstants.CANCELLED);
    fieldValues.put("sourceCode", CRConstants.PDP_SRC);
    records = businessObjectService.findMatching(CheckReconciliation.class, fieldValues);
    for (CheckReconciliation cr : records) {
        bankCodes = new ArrayList<String>();
        // Generate list of valid bank codes
        setBankCodes(banks, cr, bankCodes);
        if (bankCodes.size() > 0) {
            paymentGroups = glTransactionService.getAllPaymentGroupForSearchCriteria(cr.getCheckNumber(), bankCodes);
            if (paymentGroups.isEmpty()) {
                LOG.warn("No payment group found id : " + cr.getId());
            } else {
                for (PaymentGroup paymentGroup : paymentGroups) {
                    // KFSPTS-2260
                    glPendingTransactionService.generateCRCancellationGeneralLedgerPendingEntry(paymentGroup);
                    // glTransactionService.generateGlPendingTransactionCancel(paymentGroup);
                    KualiCode code = businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, cr.getStatus());
                    if (paymentGroup.getPaymentStatus() != ((PaymentStatus) code)) {
                        paymentGroup.setPaymentStatus((PaymentStatus) code);
                    }
                    Date lastUpdate = cr.getStatusChangeDate();
                    if (ObjectUtils.isNull(lastUpdate)) {
                        lastUpdate = new Date();
                    }
                    paymentGroup.setLastUpdatedTimestamp(new Timestamp(lastUpdate.getTime()));
                    businessObjectService.save(paymentGroup);
                    // update cancel flag on payment details
                    for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
                        // paymentDetail.refreshReferenceObject("extension");
                        PaymentDetailExtendedAttribute extendedAttribute = (PaymentDetailExtendedAttribute) paymentDetail.getExtension();
                        extendedAttribute.setCrCancelledPayment(Boolean.TRUE);
                        businessObjectService.save(paymentDetail);
                    }
                    // Update status
                    cr.setGlTransIndicator(Boolean.TRUE);
                    businessObjectService.save(cr);
                    LOG.info("Generated Cancelled GL Pending Transacation");
                }
            }
        }
    }
    // VOID payments
    fieldValues = new HashMap<String, Object>();
    fieldValues.put("glTransIndicator", "N");
    fieldValues.put("status", CRConstants.VOIDED);
    fieldValues.put("sourceCode", CRConstants.PDP_SRC);
    records = businessObjectService.findMatching(CheckReconciliation.class, fieldValues);
    for (CheckReconciliation cr : records) {
        bankCodes = new ArrayList<String>();
        // Generate list of valid bank codes
        setBankCodes(banks, cr, bankCodes);
        if (bankCodes.size() > 0) {
            paymentGroups = glTransactionService.getAllPaymentGroupForSearchCriteria(cr.getCheckNumber(), bankCodes);
            if (paymentGroups.isEmpty()) {
                LOG.warn("No payment group found id : " + cr.getId());
            } else {
                for (PaymentGroup paymentGroup : paymentGroups) {
                    // Do not generate GL tarsactions for VIODED trasactions
                    // glTransactionService.generateGlPendingTransactionStop(paymentGroup);
                    KualiCode code = businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, cr.getStatus());
                    if (paymentGroup.getPaymentStatus() != ((PaymentStatus) code)) {
                        paymentGroup.setPaymentStatus((PaymentStatus) code);
                    }
                    Date lastUpdate = cr.getStatusChangeDate();
                    if (ObjectUtils.isNull(lastUpdate)) {
                        lastUpdate = new Date();
                    }
                    paymentGroup.setLastUpdatedTimestamp(new Timestamp(lastUpdate.getTime()));
                    businessObjectService.save(paymentGroup);
                    // Update status
                    cr.setGlTransIndicator(Boolean.TRUE);
                    businessObjectService.save(cr);
                    LOG.info("Generated VOID GL Pending Transacation");
                }
            }
        }
    }
    // Stale payments
    fieldValues = new HashMap<String, Object>();
    fieldValues.put("glTransIndicator", "N");
    fieldValues.put("status", CRConstants.STALE);
    fieldValues.put("sourceCode", CRConstants.PDP_SRC);
    records = businessObjectService.findMatching(CheckReconciliation.class, fieldValues);
    for (CheckReconciliation cr : records) {
        bankCodes = new ArrayList<String>();
        // Generate list of valid bank codes
        setBankCodes(banks, cr, bankCodes);
        if (bankCodes.size() > 0) {
            paymentGroups = glTransactionService.getAllPaymentGroupForSearchCriteria(cr.getCheckNumber(), bankCodes);
            if (paymentGroups.isEmpty()) {
                LOG.warn("No payment group found id : " + cr.getId());
            } else {
                for (PaymentGroup paymentGroup : paymentGroups) {
                    // KFSPTS-2246
                    glPendingTransactionService.generateStaleGeneralLedgerPendingEntry(paymentGroup);
                    // glPendingTransactionService.g .generateStaleGeneralLedgerPendingEntry(paymentGroup);
                    KualiCode code = businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, cr.getStatus());
                    if (paymentGroup.getPaymentStatus() != ((PaymentStatus) code)) {
                        paymentGroup.setPaymentStatus((PaymentStatus) code);
                    }
                    Date lastUpdate = cr.getStatusChangeDate();
                    if (ObjectUtils.isNull(lastUpdate)) {
                        lastUpdate = new Date();
                    }
                    paymentGroup.setLastUpdatedTimestamp(new Timestamp(lastUpdate.getTime()));
                    businessObjectService.save(paymentGroup);
                    // Update status
                    cr.setGlTransIndicator(Boolean.TRUE);
                    businessObjectService.save(cr);
                    LOG.info("Generated Stale GL Pending Transacation");
                }
            }
        }
    }
    LOG.info("Completed GlTransactionStep @ " + (new Date()).toString());
    return true;
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) Bank(org.kuali.kfs.sys.businessobject.Bank) KualiCode(org.kuali.kfs.krad.bo.KualiCode) PaymentDetailExtendedAttribute(edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute) Timestamp(java.sql.Timestamp) Date(java.util.Date) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) CheckReconciliation(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation) PaymentStatus(org.kuali.kfs.pdp.businessobject.PaymentStatus)

Example 15 with PaymentDetail

use of org.kuali.kfs.pdp.businessobject.PaymentDetail in project cu-kfs by CU-CommunityApps.

the class GlTransactionServiceImpl method generateGlPendingTransaction.

/**
 * Generate GlPendingTransaction
 *
 * @param paymentGroup
 * @param financialDocumentTypeCode
 * @param stale
 */
private void generateGlPendingTransaction(PaymentGroup paymentGroup, String financialDocumentTypeCode, boolean stale) {
    List<PaymentAccountDetail> accountListings = new ArrayList<PaymentAccountDetail>();
    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()));
        glPendingTransaction.setFdocRefTypCd(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode());
        glPendingTransaction.setFsRefOriginCd(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode());
        glPendingTransaction.setFinancialBalanceTypeCode(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.setSubAccountNumber(paymentAccountDetail.getSubAccountNbr());
        glPendingTransaction.setChartOfAccountsCode(paymentAccountDetail.getFinChartCode());
        glPendingTransaction.setFdocNbr(paymentGroup.getDisbursementNbr().toString());
        // Set doc type and origin code
        glPendingTransaction.setFinancialDocumentTypeCode(financialDocumentTypeCode);
        glPendingTransaction.setFsOriginCd(CRConstants.CR_FDOC_ORIGIN_CODE);
        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
        String accountNbr = stale ? clAcct : paymentAccountDetail.getAccountNbr();
        String finObjectCode = stale ? obCode : paymentAccountDetail.getFinObjectCode();
        String finCoaCd = stale ? coaCode : paymentAccountDetail.getFinChartCode();
        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.setAccountNumber(accountNbr);
            glPendingTransaction.setChartOfAccountsCode(finCoaCd);
            glPendingTransaction.setFinancialObjectCode(offsetDefinition != null ? offsetDefinition.getFinancialObjectCode() : finObjectCode);
            glPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        } else {
            glPendingTransaction.setAccountNumber(accountNbr);
            glPendingTransaction.setChartOfAccountsCode(finCoaCd);
            glPendingTransaction.setFinancialObjectCode(finObjectCode);
            glPendingTransaction.setFinancialSubObjectCode(paymentAccountDetail.getFinSubObjectCode());
        }
        glPendingTransaction.setProjectCd(paymentAccountDetail.getProjectCode());
        if (paymentAccountDetail.getAccountNetAmount().bigDecimalValue().signum() >= 0) {
            glPendingTransaction.setDebitCrdtCd(KFSConstants.GL_CREDIT_CODE);
        } else {
            glPendingTransaction.setDebitCrdtCd(KFSConstants.GL_DEBIT_CODE);
        }
        glPendingTransaction.setAmount(paymentAccountDetail.getAccountNetAmount().abs());
        String trnDesc;
        String payeeName = paymentGroup.getPayeeName();
        trnDesc = payeeName.length() > 40 ? payeeName.substring(0, 40) : StringUtils.rightPad(payeeName, 40);
        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();
    }
}
Also used : GlPendingTransaction(org.kuali.kfs.pdp.businessobject.GlPendingTransaction) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) AccountingPeriod(org.kuali.kfs.coa.businessobject.AccountingPeriod) ArrayList(java.util.ArrayList) GeneralLedgerPendingEntrySequenceHelper(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper) Date(java.sql.Date) Date(java.sql.Date) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) FlexibleOffsetAccountService(org.kuali.kfs.sys.service.FlexibleOffsetAccountService) OffsetDefinition(org.kuali.kfs.coa.businessobject.OffsetDefinition) OffsetDefinitionService(org.kuali.kfs.coa.service.OffsetDefinitionService) PaymentAccountDetail(org.kuali.kfs.pdp.businessobject.PaymentAccountDetail)

Aggregations

PaymentDetail (org.kuali.kfs.pdp.businessobject.PaymentDetail)25 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)11 KualiInteger (org.kuali.rice.core.api.util.type.KualiInteger)11 HashMap (java.util.HashMap)7 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)7 Date (java.sql.Date)6 ArrayList (java.util.ArrayList)6 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)6 BufferedWriter (java.io.BufferedWriter)5 IOException (java.io.IOException)5 GeneralLedgerPendingEntrySequenceHelper (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)5 FileWriter (java.io.FileWriter)4 Date (java.util.Date)4 List (java.util.List)4 PaymentAccountDetail (org.kuali.kfs.pdp.businessobject.PaymentAccountDetail)4 PaymentNoteText (org.kuali.kfs.pdp.businessobject.PaymentNoteText)4 SimpleDateFormat (java.text.SimpleDateFormat)3 Map (java.util.Map)3 AccountingPeriod (org.kuali.kfs.coa.businessobject.AccountingPeriod)3 OffsetDefinition (org.kuali.kfs.coa.businessobject.OffsetDefinition)3