Search in sources :

Example 1 with KualiInteger

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

the class PaymentFileServiceImpl method createNewBatch.

/**
 * Create a new <code>Batch</code> record for the payment file.
 *
 * @param paymentFile parsed payment file object
 * @param fileName payment file name (without path)
 * @return <code>Batch<code> object
 */
protected Batch createNewBatch(PaymentFileLoad paymentFile, String fileName) {
    Timestamp now = dateTimeService.getCurrentTimestamp();
    Calendar nowPlus30 = Calendar.getInstance();
    nowPlus30.setTime(now);
    nowPlus30.add(Calendar.DATE, 30);
    Calendar nowMinus30 = Calendar.getInstance();
    nowMinus30.setTime(now);
    nowMinus30.add(Calendar.DATE, -30);
    Batch batch = new Batch();
    CustomerProfile customer = customerProfileService.get(paymentFile.getChart(), paymentFile.getUnit(), paymentFile.getSubUnit());
    batch.setCustomerProfile(customer);
    batch.setCustomerFileCreateTimestamp(new Timestamp(paymentFile.getCreationDate().getTime()));
    batch.setFileProcessTimestamp(now);
    batch.setPaymentCount(new KualiInteger(paymentFile.getPaymentCount()));
    if (fileName.length() > 30) {
        batch.setPaymentFileName(fileName.substring(0, 30));
    } else {
        batch.setPaymentFileName(fileName);
    }
    batch.setPaymentTotalAmount(paymentFile.getPaymentTotalAmount());
    batch.setSubmiterUserId(GlobalVariables.getUserSession().getPerson().getPrincipalId());
    return batch;
}
Also used : Batch(org.kuali.kfs.pdp.businessobject.Batch) Calendar(java.util.Calendar) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) CustomerProfile(org.kuali.kfs.pdp.businessobject.CustomerProfile) Timestamp(java.sql.Timestamp)

Example 2 with KualiInteger

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

the class PendingTransactionServiceImpl 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>();
    for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
        accountListings.addAll(paymentDetail.getAccountDetail());
    }
    BusinessObjectEntry businessObjectEntry = dataDictionaryService.getDataDictionary().getBusinessObjectEntry(PaymentDetail.class.getName());
    AttributeDefinition attributeDefinition = businessObjectEntry.getAttributeDefinition("paymentGroup.payeeName");
    AttributeSecurity originalPayeeNameAttributeSecurity = attributeDefinition.getAttributeSecurity();
    String maskLiteral = ((MaskFormatterLiteral) originalPayeeNameAttributeSecurity.getMaskFormatter()).getLiteral();
    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(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());
        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();
        if (researchParticipantPaymentValidationService.isResearchParticipantPayment(customerProfile)) {
            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);
        }
    }
}
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) 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.krad.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 3 with KualiInteger

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

the class FormatAction method cancel.

/**
 * This method cancels the format process
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    FormatForm formatForm = (FormatForm) form;
    KualiInteger processId = formatForm.getFormatProcessSummary().getProcessId();
    if (processId != null) {
        formatService.clearUnfinishedFormat(processId.intValue());
    }
    return mapping.findForward(KRADConstants.MAPPING_PORTAL);
}
Also used : KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger)

Example 4 with KualiInteger

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

the class FormatAction method continueFormat.

/**
 * This method performs the format process.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward continueFormat(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    FormatForm formatForm = (FormatForm) form;
    KualiInteger processId = formatForm.getFormatProcessSummary().getProcessId();
    try {
        formatService.performFormat(processId.intValue());
        // remove this
        LOG.info("Formatting done..");
    } catch (FormatException e) {
        // errors added to global message map
        return mapping.findForward(PdpConstants.MAPPING_CONTINUE);
    }
    String lookupUrl = buildUrl(String.valueOf(processId.intValue()));
    // remove this
    LOG.info("Forwarding to lookup");
    return new ActionForward(lookupUrl, true);
}
Also used : KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) FormatException(org.kuali.kfs.pdp.service.impl.exception.FormatException) ActionForward(org.apache.struts.action.ActionForward)

Example 5 with KualiInteger

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

the class PaymentSourceExtractionServiceImpl method extractImmediatePaymentsForCampus.

/**
 * Builds payment batch for Disbursement Vouchers marked as immediate
 *
 * @param campusCode the campus code the disbursement vouchers should be associated with
 * @param user the user responsible building the payment batch (typically the System User, kfs)
 * @param processRunDate the time that the job to build immediate payments is run
 */
protected void extractImmediatePaymentsForCampus(String campusCode, String principalId, Date processRunDate, List<? extends PaymentSource> documents) {
    LOG.debug("extractImmediatesPaymentsForCampus() started for campus: " + campusCode);
    if (!documents.isEmpty()) {
        final PaymentSource firstPaymentSource = documents.get(0);
        Batch batch = createBatch(campusCode, principalId, processRunDate);
        Integer count = 0;
        KualiDecimal totalAmount = KualiDecimal.ZERO;
        for (PaymentSource document : documents) {
            if (getPaymentSourceToExtractService().shouldExtractPayment(document)) {
                addPayment(document, batch, processRunDate, false);
                count++;
                totalAmount = totalAmount.add(getPaymentSourceToExtractService().getPaymentAmount(document));
            }
        }
        batch.setPaymentCount(new KualiInteger(count));
        batch.setPaymentTotalAmount(totalAmount);
        businessObjectService.save(batch);
        paymentFileEmailService.sendLoadEmail(batch);
    }
}
Also used : KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) Batch(org.kuali.kfs.pdp.businessobject.Batch) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) PaymentSource(org.kuali.kfs.sys.document.PaymentSource) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Aggregations

KualiInteger (org.kuali.rice.core.api.util.type.KualiInteger)24 ArrayList (java.util.ArrayList)7 PaymentDetail (org.kuali.kfs.pdp.businessobject.PaymentDetail)7 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)7 Date (java.sql.Date)5 HashMap (java.util.HashMap)5 PaymentNoteText (org.kuali.kfs.pdp.businessobject.PaymentNoteText)5 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 Date (java.util.Date)3 AccountingPeriod (org.kuali.kfs.coa.businessobject.AccountingPeriod)3 OffsetDefinition (org.kuali.kfs.coa.businessobject.OffsetDefinition)3 OffsetDefinitionService (org.kuali.kfs.coa.service.OffsetDefinitionService)3 Batch (org.kuali.kfs.pdp.businessobject.Batch)3 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)3 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)3 IOException (java.io.IOException)2 Timestamp (java.sql.Timestamp)2 Iterator (java.util.Iterator)2