Search in sources :

Example 21 with KualiInteger

use of org.kuali.kfs.core.api.util.type.KualiInteger 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(getDateTimeService().getCurrentDate().getTime());
        glPendingTransaction.setTransactionDt(transactionTimestamp);
        AccountingPeriod fiscalPeriod = getAccountingPeriodService().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(CUPdpConstants.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());
            glPendingTransaction.setSubAccountNumber(getCheckYear(paymentGroup));
        } 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 (getResearchParticipantPaymentValidationService().isResearchParticipantPayment(customerProfile)) {
            BusinessObjectEntry businessObjectEntry = getBusinessObjectDictionaryService().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.getBusinessObjectService().save(glPendingTransaction);
        sequenceHelper.increment();
        if (getBankService().isBankSpecificationEnabled()) {
            this.populateBankOffsetEntry(paymentGroup, glPendingTransaction, sequenceHelper);
        }
    }
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) GlPendingTransaction(org.kuali.kfs.pdp.businessobject.GlPendingTransaction) KualiInteger(org.kuali.kfs.core.api.util.type.KualiInteger) AccountingPeriod(org.kuali.kfs.coa.businessobject.AccountingPeriod) ArrayList(java.util.ArrayList) AttributeDefinition(org.kuali.kfs.krad.datadictionary.AttributeDefinition) CustomerProfile(org.kuali.kfs.pdp.businessobject.CustomerProfile) GeneralLedgerPendingEntrySequenceHelper(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper) Date(java.sql.Date) Date(java.sql.Date) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) BusinessObjectEntry(org.kuali.kfs.kns.datadictionary.BusinessObjectEntry) FlexibleOffsetAccountService(org.kuali.kfs.sys.service.FlexibleOffsetAccountService) OffsetDefinition(org.kuali.kfs.coa.businessobject.OffsetDefinition) OffsetDefinitionService(org.kuali.kfs.coa.service.OffsetDefinitionService) AttributeSecurity(org.kuali.kfs.krad.datadictionary.AttributeSecurity) PaymentAccountDetail(org.kuali.kfs.pdp.businessobject.PaymentAccountDetail) MaskFormatterLiteral(org.kuali.kfs.krad.datadictionary.mask.MaskFormatterLiteral)

Example 22 with KualiInteger

use of org.kuali.kfs.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.

the class PaymentWorksVendorToKfsPayeeAchAccountConversionServiceImpl method populatePayeeAchAccount.

private KfsAchDataWrapper populatePayeeAchAccount(PaymentWorksVendor pmwVendor) {
    KfsAchDataWrapper kfsAchDataWrapper = new KfsAchDataWrapper();
    kfsAchDataWrapper.getPayeeAchAccount().setAchAccountGeneratedIdentifier(new KualiInteger(getSequenceAccessorService().getNextAvailableSequenceNumber(PdpConstants.ACH_ACCOUNT_IDENTIFIER_SEQUENCE_NAME)));
    kfsAchDataWrapper.getPayeeAchAccount().setPayeeIdentifierTypeCode(PdpConstants.PayeeIdTypeCodes.VENDOR_ID);
    kfsAchDataWrapper.getPayeeAchAccount().setPayeeIdNumber(formatPayeeNumberForVendor(pmwVendor));
    kfsAchDataWrapper.getPayeeAchAccount().setBankRoutingNumber(pmwVendor.getBankAcctRoutingNumber());
    kfsAchDataWrapper.getPayeeAchAccount().setBankAccountNumber(pmwVendor.getBankAcctBankAccountNumber());
    kfsAchDataWrapper.getPayeeAchAccount().setBankAccountTypeCode(convertBankAccountTypeFromPmwToKfs(pmwVendor.getBankAcctType()));
    kfsAchDataWrapper.getPayeeAchAccount().setPayeeName(pmwVendor.getRequestingCompanyLegalName());
    kfsAchDataWrapper.getPayeeAchAccount().setPayeeEmailAddress(pmwVendor.getBankAcctAchEmail());
    kfsAchDataWrapper.getPayeeAchAccount().setAchTransactionType(PaymentWorksConstants.KFSPayeeAchMaintenanceDocumentConstants.ACH_DIRECT_DEPOSIT_TRANSACTION_TYPE);
    kfsAchDataWrapper.getPayeeAchAccount().setActive(true);
    return kfsAchDataWrapper;
}
Also used : KualiInteger(org.kuali.kfs.core.api.util.type.KualiInteger) KfsAchDataWrapper(edu.cornell.kfs.pmw.batch.businessobject.KfsAchDataWrapper)

Example 23 with KualiInteger

use of org.kuali.kfs.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.

the class CuPaymentSourceHelperServiceImpl method buildNotesForCheckStubText.

@Override
public List<PaymentNoteText> buildNotesForCheckStubText(String text, int previousLineCount) {
    PaymentNoteText pnt = null;
    List<PaymentNoteText> pnts = new ArrayList<PaymentNoteText>();
    final String maxNoteLinesParam = parameterService.getParameterValueAsString(KfsParameterConstants.PRE_DISBURSEMENT_ALL.class, PdpParameterConstants.MAX_NOTE_LINES);
    int maxNoteLines;
    try {
        maxNoteLines = Integer.parseInt(maxNoteLinesParam);
    } catch (NumberFormatException nfe) {
        throw new IllegalArgumentException("Invalid Max Notes Lines parameter, value: " + maxNoteLinesParam + " cannot be converted to an integer");
    }
    // The WordUtils should be sufficient for the majority of cases.  This method will
    // word wrap the whole string based on the MAX_NOTE_LINE_SIZE, separating each wrapped
    // word by a newline character.  The 'wrap' method adds line feeds to the end causing
    // the character length to exceed the max length by 1, hence the need for the replace
    // method before splitting.
    String wrappedText = WordUtils.wrap(text, CuDisbursementVoucherConstants.DV_EXTRACT_MAX_NOTE_LINE_SIZE);
    String[] noteLines = wrappedText.replaceAll("[\r]", "").split("\\n");
    // Loop through all the note lines.
    for (String noteLine : noteLines) {
        if (previousLineCount < (maxNoteLines - 3) && !StringUtils.isEmpty(noteLine)) {
            // The only concern I have for this occurring is with URLs/email addresses.
            if (noteLine.length() > CuDisbursementVoucherConstants.DV_EXTRACT_MAX_NOTE_LINE_SIZE) {
                for (String choppedWord : chopWord(noteLine, CuDisbursementVoucherConstants.DV_EXTRACT_MAX_NOTE_LINE_SIZE)) {
                    // Make sure we're still under the maximum number of note lines.
                    if (previousLineCount < (maxNoteLines - 3) && !StringUtils.isEmpty(choppedWord)) {
                        pnt = new PaymentNoteText();
                        pnt.setCustomerNoteLineNbr(new KualiInteger(previousLineCount++));
                        pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_TYPED_NOTE_PREFIX_IDENTIFIER + choppedWord.replaceAll("\\n", "").trim());
                    } else {
                        // just break out of the loop early - there's nothing left to do.
                        break;
                    }
                }
            } else {
                // This should be the most common case.  Simply create a new PaymentNoteText, add the line at the
                // correct line location.
                pnt = new PaymentNoteText();
                pnt.setCustomerNoteLineNbr(new KualiInteger(previousLineCount++));
                pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_TYPED_NOTE_PREFIX_IDENTIFIER + noteLine.replaceAll("\\n", "").trim());
            }
            if (pnt != null) {
                // This should never be null at this point, but...
                pnts.add(pnt);
            }
        }
    }
    return pnts;
}
Also used : PaymentNoteText(org.kuali.kfs.pdp.businessobject.PaymentNoteText) KualiInteger(org.kuali.kfs.core.api.util.type.KualiInteger) ArrayList(java.util.ArrayList) KfsParameterConstants(org.kuali.kfs.sys.service.impl.KfsParameterConstants)

Example 24 with KualiInteger

use of org.kuali.kfs.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.

the class PendingTransactionServiceImpl method populateBankOffsetEntry.

/**
 * Generates the bank offset for an entry (when enabled in the system)
 *
 * @param paymentGroup         PaymentGroup for which entries are being generated, contains the Bank
 * @param glPendingTransaction PDP entry created for payment detail
 * @param sequenceHelper       holds current entry sequence value
 */
public void populateBankOffsetEntry(PaymentGroup paymentGroup, GlPendingTransaction glPendingTransaction, GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
    GlPendingTransaction bankPendingTransaction = new GlPendingTransaction();
    bankPendingTransaction.setSequenceNbr(new KualiInteger(sequenceHelper.getSequenceCounter()));
    bankPendingTransaction.setFdocRefTypCd(null);
    bankPendingTransaction.setFsRefOriginCd(null);
    bankPendingTransaction.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
    bankPendingTransaction.setTransactionDt(glPendingTransaction.getTransactionDt());
    bankPendingTransaction.setUniversityFiscalYear(glPendingTransaction.getUniversityFiscalYear());
    bankPendingTransaction.setUnivFiscalPrdCd(glPendingTransaction.getUnivFiscalPrdCd());
    bankPendingTransaction.setFinancialDocumentTypeCode(glPendingTransaction.getFinancialDocumentTypeCode());
    bankPendingTransaction.setFsOriginCd(glPendingTransaction.getFsOriginCd());
    bankPendingTransaction.setFdocNbr(glPendingTransaction.getFdocNbr());
    Bank bank = paymentGroup.getBank();
    bankPendingTransaction.setChartOfAccountsCode(bank.getCashOffsetFinancialChartOfAccountCode());
    bankPendingTransaction.setAccountNumber(bank.getCashOffsetAccountNumber());
    if (StringUtils.isBlank(bank.getCashOffsetSubAccountNumber())) {
        bankPendingTransaction.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
    } else {
        bankPendingTransaction.setSubAccountNumber(bank.getCashOffsetSubAccountNumber());
    }
    bankPendingTransaction.setFinancialObjectCode(bank.getCashOffsetObjectCode());
    if (StringUtils.isBlank(bank.getCashOffsetSubObjectCode())) {
        bankPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
    } else {
        bankPendingTransaction.setFinancialSubObjectCode(bank.getCashOffsetSubObjectCode());
    }
    bankPendingTransaction.setProjectCd(KFSConstants.getDashProjectCode());
    if (KFSConstants.GL_CREDIT_CODE.equals(glPendingTransaction.getDebitCrdtCd())) {
        bankPendingTransaction.setDebitCrdtCd(KFSConstants.GL_DEBIT_CODE);
    } else {
        bankPendingTransaction.setDebitCrdtCd(KFSConstants.GL_CREDIT_CODE);
    }
    bankPendingTransaction.setAmount(glPendingTransaction.getAmount());
    String description = kualiConfigurationService.getPropertyValueAsString(FPKeyConstants.DESCRIPTION_GLPE_BANK_OFFSET);
    bankPendingTransaction.setDescription(description);
    bankPendingTransaction.setOrgDocNbr(glPendingTransaction.getOrgDocNbr());
    bankPendingTransaction.setOrgReferenceId(null);
    bankPendingTransaction.setFdocRefNbr(null);
    this.businessObjectService.save(bankPendingTransaction);
    sequenceHelper.increment();
}
Also used : Bank(org.kuali.kfs.sys.businessobject.Bank) GlPendingTransaction(org.kuali.kfs.pdp.businessobject.GlPendingTransaction) KualiInteger(org.kuali.kfs.core.api.util.type.KualiInteger)

Example 25 with KualiInteger

use of org.kuali.kfs.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.

the class PaymentDetail method addPaymentText.

/**
 * Constructs a new {@link PaymentNoteText} for the given payment text and adds to the detail {@link List}.
 *
 * @param paymentText note text
 */
public void addPaymentText(String paymentText) {
    PaymentNoteText paymentNoteText = new PaymentNoteText();
    paymentNoteText.setCustomerNoteText(paymentText);
    paymentNoteText.setCustomerNoteLineNbr(new KualiInteger(this.notes.size() + 1));
    addNote(paymentNoteText);
}
Also used : KualiInteger(org.kuali.kfs.core.api.util.type.KualiInteger)

Aggregations

KualiInteger (org.kuali.kfs.core.api.util.type.KualiInteger)26 ArrayList (java.util.ArrayList)8 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)7 PaymentDetail (org.kuali.kfs.pdp.businessobject.PaymentDetail)7 Date (java.sql.Date)5 HashMap (java.util.HashMap)5 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)5 PaymentNoteText (org.kuali.kfs.pdp.businessobject.PaymentNoteText)5 Date (java.util.Date)4 GlPendingTransaction (org.kuali.kfs.pdp.businessobject.GlPendingTransaction)4 PaymentAccountDetail (org.kuali.kfs.pdp.businessobject.PaymentAccountDetail)4 CheckReconciliation (com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation)3 AccountingPeriod (org.kuali.kfs.coa.businessobject.AccountingPeriod)3 OffsetDefinition (org.kuali.kfs.coa.businessobject.OffsetDefinition)3 Batch (org.kuali.kfs.pdp.businessobject.Batch)3 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)3 GeneralLedgerPendingEntrySequenceHelper (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)3 Timestamp (java.sql.Timestamp)2 Calendar (java.util.Calendar)2 List (java.util.List)2