Search in sources :

Example 1 with DisbursementVoucherBatchSummaryLine

use of com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchSummaryLine in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherDocumentBatchServiceImpl method populateBatchSummaryLine.

/**
 * Creates and populates a batch summary line for the disbursement voucher document
 *
 * @param disbursementVoucherDocument batch disbursement voucher document
 * @param MessageMap MessageMap containing errors encountered while populating document
 * @return PurchaseOrderBatchSummaryLine
 */
protected DisbursementVoucherBatchSummaryLine populateBatchSummaryLine(DisbursementVoucherDocument disbursementVoucherDocument, MessageMap MessageMap) {
    DisbursementVoucherBatchSummaryLine batchSummaryLine = new DisbursementVoucherBatchSummaryLine();
    DisbursementVoucherPayeeDetail dvPayeeDetail = disbursementVoucherDocument.getDvPayeeDetail();
    // dvPayeeDetail.refresh();
    Date currentDate = dateTimeService.getCurrentDate();
    batchSummaryLine.setDisbVchrCreateDate(dateTimeService.toDateString(currentDate));
    batchSummaryLine.setDisbVchrPayeeId(dvPayeeDetail.getDisbVchrPayeeIdNumber() + " (" + dvPayeeDetail.getDisbVchrPayeePersonName() + " )");
    if (disbursementVoucherDocument.getDisbVchrCheckTotalAmount() != null) {
        String totalDollarAmount = (String) (new CurrencyFormatter()).formatForPresentation(disbursementVoucherDocument.getDisbVchrCheckTotalAmount());
        batchSummaryLine.setDisbVchrAmount(totalDollarAmount);
    }
    if (disbursementVoucherDocument.getDisbursementVoucherDueDate() != null) {
        batchSummaryLine.setDisbursementVoucherDueDate(disbursementVoucherDocument.getDisbursementVoucherDueDate().toString());
    }
    if (ObjectUtils.isNotNull(dvPayeeDetail.getDisbVchrPaymentReason())) {
        String paymentReasonDescription = dvPayeeDetail.getDisbVchrPaymentReason().getDescription();
        if (paymentReasonDescription.length() >= 50) {
            paymentReasonDescription = paymentReasonDescription.substring(0, 49);
        }
        batchSummaryLine.setDisbVchrPaymentReason(dvPayeeDetail.getDisbVchrPaymentReasonCode() + "-" + paymentReasonDescription);
    }
    batchSummaryLine.setAuditMessage(batchFeedHelperService.getAuditMessage(FPKeyConstants.MESSAGE_AUDIT_DV_SUCCESSFULLY_GENERATED, disbursementVoucherDocument.getDocumentNumber(), MessageMap));
    return batchSummaryLine;
}
Also used : DisbursementVoucherPayeeDetail(org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail) CurrencyFormatter(org.kuali.rice.core.web.format.CurrencyFormatter) DisbursementVoucherBatchSummaryLine(com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchSummaryLine) Date(java.util.Date)

Example 2 with DisbursementVoucherBatchSummaryLine

use of com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchSummaryLine in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherDocumentBatchServiceImpl method loadDisbursementVouchers.

/**
 * @see com.rsmart.kuali.kfs.fp.batch.service.DisbursementVoucherDocumentBatchService#loadDisbursementVouchers(com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchFeed,
 *      com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchStatus, java.lang.String,
 *      org.kuali.kfs.kns.util.MessageMap)
 */
public void loadDisbursementVouchers(DisbursementVoucherBatchFeed batchFeed, DisbursementVoucherBatchStatus batchStatus, String incomingFileName, MessageMap MessageMap) {
    // get new batch record for the load
    DisbursementVoucherBatch disbursementVoucherBatch = getNewDisbursementVoucherBatch();
    businessObjectService.save(disbursementVoucherBatch);
    batchStatus.setUnitCode(batchFeed.getUnitCode());
    boolean batchHasErrors = false;
    for (BatchDisbursementVoucherDocument batchDisbursementVoucherDocument : batchFeed.getBatchDisbursementVoucherDocuments()) {
        batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_DV_RECORDS_READ, 1);
        batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_ACCOUNTING_RECORDS_READ, batchDisbursementVoucherDocument.getSourceAccountingLines().size());
        // get defaults for DV chart/org
        DisbursementVoucherBatchDefault batchDefault = null;
        if (StringUtils.isNotBlank(batchFeed.getUnitCode())) {
            batchDefault = getDisbursementVoucherBatchDefault(batchFeed.getUnitCode());
        }
        MessageMap documentMessageMap = new MessageMap();
        batchFeedHelperService.performForceUppercase(DisbursementVoucherDocument.class.getName(), batchDisbursementVoucherDocument);
        // create and route doc as system user
        // create and route doc as system user
        UserSession actualUserSession = GlobalVariables.getUserSession();
        GlobalVariables.setUserSession(new UserSession(KFSConstants.SYSTEM_USER));
        MessageMap globalMessageMap = GlobalVariables.getMessageMap();
        GlobalVariables.setMessageMap(documentMessageMap);
        DisbursementVoucherDocument disbursementVoucherDocument = null;
        try {
            disbursementVoucherDocument = populateDisbursementVoucherDocument(disbursementVoucherBatch, batchDisbursementVoucherDocument, batchDefault, documentMessageMap);
            // if the document is valid create GLPEs, Save and Approve
            if (documentMessageMap.hasNoErrors()) {
                businessObjectService.save(disbursementVoucherDocument.getExtension());
                documentService.routeDocument(disbursementVoucherDocument, "", null);
                if (documentMessageMap.hasNoErrors()) {
                    batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_DV_RECORDS_WRITTEN, 1);
                    batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_ACCOUNTING_RECORDS_WRITTEN, disbursementVoucherDocument.getSourceAccountingLines().size());
                    batchStatus.updateStatistics(FPConstants.BatchReportStatisticKeys.NUM_GLPE_RECORDS_WRITTEN, disbursementVoucherDocument.getGeneralLedgerPendingEntries().size());
                    batchStatus.getBatchDisbursementVoucherDocuments().add(disbursementVoucherDocument);
                }
            }
        } catch (WorkflowException e) {
            LOG.error("Unable to route DV: " + e.getMessage());
            throw new RuntimeException("Unable to route DV: " + e.getMessage(), e);
        } catch (ValidationException e1) {
        // will be reported in audit report
        } finally {
            GlobalVariables.setUserSession(actualUserSession);
            GlobalVariables.setMessageMap(globalMessageMap);
        }
        if (documentMessageMap.hasErrors()) {
            batchHasErrors = true;
        }
        // populate summary line and add to report
        DisbursementVoucherBatchSummaryLine batchSummaryLine = populateBatchSummaryLine(disbursementVoucherDocument, documentMessageMap);
        batchStatus.getBatchSummaryLines().add(batchSummaryLine);
    }
    // indicate in global map there were errors (for batch upload screen)
    if (batchHasErrors) {
        MessageMap.putError(KFSConstants.GLOBAL_ERRORS, FPKeyConstants.ERROR_BATCH_DISBURSEMENT_VOUCHER_ERRORS_NOTIFICATION);
    }
    batchFeedHelperService.removeDoneFile(incomingFileName);
}
Also used : ValidationException(org.kuali.kfs.krad.exception.ValidationException) BatchDisbursementVoucherDocument(com.rsmart.kuali.kfs.fp.document.BatchDisbursementVoucherDocument) DisbursementVoucherBatchDefault(com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchDefault) UserSession(org.kuali.kfs.krad.UserSession) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) DisbursementVoucherBatch(com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatch) DisbursementVoucherBatchSummaryLine(com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchSummaryLine) MessageMap(org.kuali.kfs.krad.util.MessageMap) BatchDisbursementVoucherDocument(com.rsmart.kuali.kfs.fp.document.BatchDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Aggregations

DisbursementVoucherBatchSummaryLine (com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchSummaryLine)2 DisbursementVoucherBatch (com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatch)1 DisbursementVoucherBatchDefault (com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchDefault)1 BatchDisbursementVoucherDocument (com.rsmart.kuali.kfs.fp.document.BatchDisbursementVoucherDocument)1 Date (java.util.Date)1 DisbursementVoucherPayeeDetail (org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail)1 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)1 UserSession (org.kuali.kfs.krad.UserSession)1 ValidationException (org.kuali.kfs.krad.exception.ValidationException)1 MessageMap (org.kuali.kfs.krad.util.MessageMap)1 CurrencyFormatter (org.kuali.rice.core.web.format.CurrencyFormatter)1 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)1