Search in sources :

Example 1 with RecurringDisbursementVoucherDocument

use of edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherAccountingLineTotalsValidation method validate.

@Override
public boolean validate(AttributedDocumentEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("validate start");
    }
    DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) event.getDocument();
    Person financialSystemUser = GlobalVariables.getUserSession().getPerson();
    final Set<String> currentEditModes = getEditModesFromDocument(dvDocument, financialSystemUser);
    // amounts can only decrease
    List<String> candidateEditModes = this.getCandidateEditModes();
    if (this.hasRequiredEditMode(currentEditModes, candidateEditModes)) {
        // users in foreign or wire workgroup can increase or decrease amounts because of currency conversion
        List<String> foreignDraftAndWireTransferEditModes = this.getForeignDraftAndWireTransferEditModes(dvDocument);
        if (!this.hasRequiredEditMode(currentEditModes, foreignDraftAndWireTransferEditModes)) {
            DisbursementVoucherDocument persistedDocument = (DisbursementVoucherDocument) retrievePersistedDocument(dvDocument);
            if (persistedDocument == null) {
                handleNonExistentDocumentWhenApproving(dvDocument);
                return true;
            }
            // KFSMI- 5183
            if (persistedDocument.getDocumentHeader().getWorkflowDocument().isSaved() && persistedDocument.getDisbVchrCheckTotalAmount().isZero()) {
                return true;
            }
            // check total cannot decrease
            if (!persistedDocument.getDocumentHeader().getWorkflowDocument().isCompletionRequested() && (!persistedDocument.getDisbVchrCheckTotalAmount().equals(dvDocument.getDisbVchrCheckTotalAmount()))) {
                GlobalVariables.getMessageMap().putError(KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.DISB_VCHR_CHECK_TOTAL_AMOUNT, CUKFSKeyConstants.ERROR_DV_CHECK_TOTAL_NO_CHANGE);
                return false;
            }
        }
        return true;
    }
    // KFSUPGRADE-848 : skip total check here for FO
    final WorkflowDocument workflowDocument = dvDocument.getDocumentHeader().getWorkflowDocument();
    final Set<String> currentRouteLevels = workflowDocument.getCurrentNodeNames();
    if (CollectionUtils.isNotEmpty(currentRouteLevels)) {
        if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.ACCOUNT)) {
            return true;
        }
    }
    if (dvDocument instanceof RecurringDisbursementVoucherDocument) {
        RecurringDisbursementVoucherDocument recurringDV = (RecurringDisbursementVoucherDocument) dvDocument;
        if (!doesAccountingLineTotalEqualDVTotalDollarAmount(recurringDV)) {
            String propertyName = KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.DISB_VCHR_CHECK_TOTAL_AMOUNT;
            GlobalVariables.getMessageMap().putError(propertyName, CUKFSKeyConstants.ERROR_DV_CHECK_TOTAL_MUST_EQUAL_ACCOUNTING_LINE_TOTAL);
            return false;
        }
        if (StringUtils.isEmpty(recurringDV.getDisbVchrCheckStubText()) && !recurringDV.getSourceAccountingLines().isEmpty()) {
            String propertyName = KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.DISB_VCHR_CHECK_STUB_TEXT;
            GlobalVariables.getMessageMap().putError(propertyName, CUKFSKeyConstants.ERROR_DV_CHECK_STUB_REQUIRED);
            return false;
        }
        if (!isAccountingLineEndDateValid(recurringDV)) {
            return false;
        }
    }
    return super.validate(event);
}
Also used : WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) Person(org.kuali.rice.kim.api.identity.Person) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 2 with RecurringDisbursementVoucherDocument

use of edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method getCuDisbursementVoucherDocument.

private CuDisbursementVoucherDocument getCuDisbursementVoucherDocument(List<DisbursementVoucherDocument> generatedDVs, RecurringDisbursementVoucherDocument recurringDV, Date dvCheckDate) throws WorkflowException {
    for (DisbursementVoucherDocument dv : generatedDVs) {
        if (dv.getDisbursementVoucherDueDate().equals(dvCheckDate)) {
            return (CuDisbursementVoucherDocument) dv;
        }
    }
    CuDisbursementVoucherDocument dv = buildCuDisbursementVoucherDocument(recurringDV);
    dv.setDisbursementVoucherDueDate(dvCheckDate);
    dv.setDisbursementVoucherCheckDate(new Timestamp(dvCheckDate.getTime()));
    generatedDVs.add(dv);
    return dv;
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) Timestamp(java.sql.Timestamp) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)

Example 3 with RecurringDisbursementVoucherDocument

use of edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherAction method confirmAndCancel.

public ActionForward confirmAndCancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    RecurringDisbursementVoucherForm recurringForm = (RecurringDisbursementVoucherForm) form;
    RecurringDisbursementVoucherDocument recurringDV = (RecurringDisbursementVoucherDocument) recurringForm.getDocument();
    if (StringUtils.isBlank(recurringDV.getPaymentCancelReason())) {
        String paymentCancelFieldName = AccountingDocumentRuleBaseConstants.ERROR_PATH.DOCUMENT_ERROR_PREFIX + CUKFSPropertyConstants.RECURRING_DV_PAYMENT_CANCEL_REASON_FIELD_NAME;
        GlobalVariables.getMessageMap().putError(paymentCancelFieldName, CUKFSKeyConstants.ERROR_RCDV_PAYMENT_CANCEL_REASON_REQUIRED);
    } else {
        Set<String> canceledPaymentGroups = getRecurringDisbursementVoucherDocumentService().cancelOpenPDPPayments(recurringDV, recurringDV.getPaymentCancelReason());
        Set<String> canceledDVs = getRecurringDisbursementVoucherDocumentService().cancelSavedDisbursementVouchers(recurringDV, recurringDV.getPaymentCancelReason());
        Set<String> canceledDVsApprovedNotExtracted = getRecurringDisbursementVoucherDocumentService().cancelDisbursementVouchersFinalizedNotExtracted(recurringDV, recurringDV.getPaymentCancelReason());
        canceledDVs.addAll(canceledDVsApprovedNotExtracted);
        reportCanceledItemsToBrowser(canceledPaymentGroups, canceledDVs);
        forceRefreshOfPDPStatuses(recurringForm);
    }
    return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
Also used : RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument)

Example 4 with RecurringDisbursementVoucherDocument

use of edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method generateDisbursementDocumentsFromRecurringDV.

@Override
public List<DisbursementVoucherDocument> generateDisbursementDocumentsFromRecurringDV(RecurringDisbursementVoucherDocument recurringDV) throws WorkflowException {
    List<DisbursementVoucherDocument> generatedDVs = new ArrayList<DisbursementVoucherDocument>();
    int rowId = 0;
    for (Object accountingLine : recurringDV.getSourceAccountingLines()) {
        ScheduledSourceAccountingLine scheduledAccountingLine = (ScheduledSourceAccountingLine) accountingLine;
        TreeMap<Date, KualiDecimal> datesAndAmounts = getScheduledAccountingLineService().generateDatesAndAmounts(scheduledAccountingLine, rowId);
        for (Date date : datesAndAmounts.keySet()) {
            KualiDecimal amount = datesAndAmounts.get(date);
            CuDisbursementVoucherDocument disbursementVoucherDocument = getCuDisbursementVoucherDocument(generatedDVs, recurringDV, date);
            disbursementVoucherDocument.setDisbVchrCheckTotalAmount(calculateDVCheckAmount(amount, disbursementVoucherDocument));
            RecurringDisbursementVoucherDetail dvDetail = getDetailtem(recurringDV.getRecurringDisbursementVoucherDetails(), date);
            dvDetail.setDvDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
            disbursementVoucherDocument.setDisbVchrCheckStubText(dvDetail.getDvCheckStub());
            SourceAccountingLine line = buildSourceAccountingLine(scheduledAccountingLine);
            line.setAmount(amount);
            disbursementVoucherDocument.addSourceAccountingLine(line);
        }
        rowId++;
    }
    saveDisbursementVouchers(generatedDVs, recurringDV);
    return generatedDVs;
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) ArrayList(java.util.ArrayList) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) RecurringDisbursementVoucherDetail(edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail) ScheduledSourceAccountingLine(edu.cornell.kfs.fp.businessobject.ScheduledSourceAccountingLine) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) ScheduledSourceAccountingLine(edu.cornell.kfs.fp.businessobject.ScheduledSourceAccountingLine) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) Date(java.sql.Date)

Example 5 with RecurringDisbursementVoucherDocument

use of edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method findPdpStatuses.

@Override
public List<RecurringDisbursementVoucherPDPStatus> findPdpStatuses(RecurringDisbursementVoucherDocument recurringDV) {
    List<RecurringDisbursementVoucherPDPStatus> pdpStatuses = new ArrayList<RecurringDisbursementVoucherPDPStatus>();
    for (RecurringDisbursementVoucherDetail detail : recurringDV.getRecurringDisbursementVoucherDetails()) {
        if (StringUtils.isNotEmpty(detail.getDvDocumentNumber())) {
            DisbursementVoucherDocument disbursementVoucherDocument;
            try {
                disbursementVoucherDocument = (DisbursementVoucherDocument) getDocumentService().getByDocumentHeaderId(detail.getDvDocumentNumber());
            } catch (WorkflowException e) {
                LOG.error("findPdpStatuses: There was a problem getting DV from the recurring DV detail: " + e);
                throw new RuntimeException(e);
            }
            pdpStatuses.add(buildRecurringDisbursementVoucherPDPStatus(disbursementVoucherDocument));
        }
    }
    Collections.sort(pdpStatuses);
    return pdpStatuses;
}
Also used : RecurringDisbursementVoucherPDPStatus(edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherPDPStatus) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList) RecurringDisbursementVoucherDetail(edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)

Aggregations

RecurringDisbursementVoucherDocument (edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument)8 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)6 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)4 RecurringDisbursementVoucherDetail (edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail)2 ArrayList (java.util.ArrayList)2 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)2 RecurringDisbursementVoucherPDPStatus (edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherPDPStatus)1 ScheduledSourceAccountingLine (edu.cornell.kfs.fp.businessobject.ScheduledSourceAccountingLine)1 Date (java.sql.Date)1 Timestamp (java.sql.Timestamp)1 DisbursementVoucherPayeeDetail (org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail)1 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)1 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)1 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)1 Person (org.kuali.rice.kim.api.identity.Person)1