Search in sources :

Example 1 with WorkflowDocument

use of org.kuali.kfs.kew.api.WorkflowDocument 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.kfs.kew.api.WorkflowDocument) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) Person(org.kuali.kfs.kim.api.identity.Person) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 2 with WorkflowDocument

use of org.kuali.kfs.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherDocumentPresentationController method addTravelEntryMode.

@Override
protected void addTravelEntryMode(Document document, Set<String> editModes) {
    final WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
    final Set<String> currentRouteLevels = workflowDocument.getCurrentNodeNames();
    if (CollectionUtils.isNotEmpty(currentRouteLevels)) {
        if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.ACCOUNT)) {
            editModes.add(KfsAuthorizationConstants.DisbursementVoucherEditMode.TRAVEL_ENTRY);
        }
    }
}
Also used : WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument)

Example 3 with WorkflowDocument

use of org.kuali.kfs.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherDocumentPresentationController method addTravelSystemGeneratedEntryMode.

/**
 * If the DV was generated from a connection with the Cornell Travel System, enforces special edit rules regarding information on the disbursement voucher.
 *
 * Added condition that DV is not in the Payment Method Reviewers' queue, as the check amount needs to be editable for that circustance.
 *
 * @param document the disbursement voucher document authorization is being sought on
 * @param editModes the edit modes so far, which can be added to
 */
protected void addTravelSystemGeneratedEntryMode(Document document, Set<String> editModes) {
    final CuDisbursementVoucherDocument dvDocument = (CuDisbursementVoucherDocument) document;
    final WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
    final Set<String> currentRouteLevels = workflowDocument.getCurrentNodeNames();
    boolean isAssociatedWithTrip = SpringContext.getBean(CULegacyTravelService.class).isCULegacyTravelIntegrationInterfaceAssociatedWithTrip(dvDocument);
    if (isAssociatedWithTrip && !currentRouteLevels.contains(KFSConstants.RouteLevelNames.PAYMENT_METHOD)) {
        LOG.info("Checking travel system generated entry permissions.");
        editModes.add(CUKFSAuthorizationConstants.DisbursementVoucherEditMode.TRAVEL_SYSTEM_GENERATED_ENTRY);
    }
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) CULegacyTravelService(edu.cornell.kfs.fp.document.service.CULegacyTravelService)

Example 4 with WorkflowDocument

use of org.kuali.kfs.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.

the class CheckReconciliationMaintainableImpl method doRouteStatusChange.

/**
 * @see org.kuali.kfs.kns.maintenance.MaintainableImpl#doRouteStatusChange(org.kuali.kfs.kns.bo.DocumentHeader)
 */
public void doRouteStatusChange(DocumentHeader documentHeader) {
    WorkflowDocument workflowDocument = documentHeader.getWorkflowDocument();
    if (workflowDocument.isProcessed() && !KFSConstants.MAINTENANCE_NEW_ACTION.equalsIgnoreCase(getMaintenanceAction())) {
        DocumentService documentService = SpringContext.getBean(DocumentService.class);
        MaintenanceDocument document;
        try {
            document = (MaintenanceDocument) documentService.getByDocumentHeaderId(documentHeader.getDocumentNumber());
            CheckReconciliation oldCr = (CheckReconciliation) document.getOldMaintainableObject().getBusinessObject();
            CheckReconciliation newCr = (CheckReconciliation) document.getNewMaintainableObject().getBusinessObject();
            if (ObjectUtils.isNotNull(oldCr) && !oldCr.getStatus().equalsIgnoreCase(newCr.getStatus())) {
                Date currentDate = SpringContext.getBean(DateTimeService.class).getCurrentSqlDate();
                newCr.setStatusChangeDate(currentDate);
                // KFSUPGRADE-377
                if (CRConstants.CANCELLED.equalsIgnoreCase(newCr.getStatus())) {
                    newCr.setCancelDocHdrId(documentHeader.getDocumentNumber());
                }
            }
        } catch (WorkflowException e) {
            throw new RuntimeCacheException(e);
        }
    }
}
Also used : RuntimeCacheException(org.apache.ojb.broker.cache.RuntimeCacheException) WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) CheckReconciliation(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation) DateTimeService(org.kuali.kfs.core.api.datetime.DateTimeService) DocumentService(org.kuali.kfs.krad.service.DocumentService) Date(java.sql.Date)

Example 5 with WorkflowDocument

use of org.kuali.kfs.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.

the class CuRequisitionAction method copy.

/**
 * Overridden to guarantee that form of copied document is set to whatever the entry mode of the document is
 * @see org.kuali.kfs.kns.web.struts.action.KualiTransactionalDocumentActionBase#copy
 * (org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm,
 * javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    ActionForward forward = null;
    String docID = "docId";
    if (request.getParameter(docID) == null) {
        forward = super.copy(mapping, form, request, response);
    } else {
        // this is copy document from Procurement Gateway:
        // use this url to call: http://localhost:8080/kfs-dev/purapRequisition.do?methodToCall=copy&docId=xxxx
        String docId = request.getParameter(docID);
        KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
        CuRequisitionDocument document = null;
        document = (CuRequisitionDocument) getDocumentService().getByDocumentHeaderId(docId);
        document.toCopyFromGateway();
        kualiDocumentFormBase.setDocument(document);
        WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
        kualiDocumentFormBase.setDocTypeName(workflowDocument.getDocumentTypeName());
        SpringContext.getBean(SessionDocumentService.class).addDocumentToUserSession(GlobalVariables.getUserSession(), workflowDocument);
        forward = mapping.findForward(KFSConstants.MAPPING_BASIC);
    }
    return forward;
}
Also used : CuRequisitionDocument(edu.cornell.kfs.module.purap.document.CuRequisitionDocument) SessionDocumentService(org.kuali.kfs.krad.service.SessionDocumentService) WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) ActionForward(org.apache.struts.action.ActionForward)

Aggregations

WorkflowDocument (org.kuali.kfs.kew.api.WorkflowDocument)36 Person (org.kuali.kfs.kim.api.identity.Person)5 ArrayList (java.util.ArrayList)4 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)3 Iterator (java.util.Iterator)3 List (java.util.List)3 ActionForward (org.apache.struts.action.ActionForward)3 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)3 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)2 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)2 HashMap (java.util.HashMap)2 ActionRequest (org.kuali.kfs.kew.actionrequest.ActionRequest)2 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)2 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)2 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)2 PurchasingAccountsPayableDocument (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)2 FinancialSystemWorkflowHelperService (org.kuali.kfs.sys.service.FinancialSystemWorkflowHelperService)2 CheckReconciliation (com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation)1 RecurringDisbursementVoucherDocument (edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument)1 CULegacyTravelService (edu.cornell.kfs.fp.document.service.CULegacyTravelService)1