Search in sources :

Example 1 with FinancialSystemDocumentHeader

use of org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader in project cu-kfs by CU-CommunityApps.

the class AccountingDocumentGeneratorBase method populateDocumentHeader.

protected void populateDocumentHeader(T document, AccountingXmlDocumentEntry documentEntry) {
    FinancialSystemDocumentHeader documentHeader = (FinancialSystemDocumentHeader) document.getDocumentHeader();
    documentHeader.setDocumentDescription(documentEntry.getDescription());
    documentHeader.setExplanation(documentEntry.getExplanation());
    documentHeader.setOrganizationDocumentNumber(documentEntry.getOrganizationDocumentNumber());
}
Also used : FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader)

Example 2 with FinancialSystemDocumentHeader

use of org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader in project cu-kfs by CU-CommunityApps.

the class AccountingLineAccessibleValidation method validate.

/**
 * Validates that the given accounting line is accessible for editing by the current user.
 * <strong>This method expects a document as the first parameter and an accounting line as the second</strong>
 *
 * @see org.kuali.kfs.sys.document.validation.Validation#validate(java.lang.Object[])
 */
@Override
public boolean validate(AttributedDocumentEvent event) {
    final Person currentUser = GlobalVariables.getUserSession().getPerson();
    if (accountingDocumentForValidation instanceof Correctable) {
        final String errorDocumentNumber = ((FinancialSystemDocumentHeader) accountingDocumentForValidation.getDocumentHeader()).getFinancialDocumentInErrorNumber();
        if (StringUtils.isNotBlank(errorDocumentNumber)) {
            return true;
        }
    }
    final AccountingLineAuthorizer accountingLineAuthorizer = lookupAccountingLineAuthorizer();
    final Set<String> currentNodes = accountingDocumentForValidation.getDocumentHeader().getWorkflowDocument().getCurrentNodeNames();
    final boolean lineIsAccessible = accountingLineAuthorizer.hasEditPermissionOnAccountingLine(accountingDocumentForValidation, accountingLineForValidation, getAccountingLineCollectionProperty(), currentUser, true, currentNodes);
    final boolean isAccessible = accountingLineAuthorizer.hasEditPermissionOnField(accountingDocumentForValidation, accountingLineForValidation, getAccountingLineCollectionProperty(), KFSPropertyConstants.ACCOUNT_NUMBER, lineIsAccessible, true, currentUser, currentNodes);
    boolean valid = true;
    boolean isExceptionNode = isExceptionNode(event.getDocument());
    if (!isAccessible) {
        // if only object code changed and the user has edit permissions on object code, that's ok
        if (event instanceof UpdateAccountingLineEvent) {
            final boolean isObjectCodeAccessible = accountingLineAuthorizer.hasEditPermissionOnField(accountingDocumentForValidation, accountingLineForValidation, getAccountingLineCollectionProperty(), KFSPropertyConstants.FINANCIAL_OBJECT_CODE, lineIsAccessible, true, currentUser, currentNodes);
            final boolean onlyObjectCodeChanged = onlyObjectCodeChanged(((UpdateAccountingLineEvent) event).getAccountingLine(), ((UpdateAccountingLineEvent) event).getUpdatedAccountingLine());
            if (isObjectCodeAccessible && onlyObjectCodeChanged) {
                return true;
            }
        }
        if (isPreqDiscountRecreate(event)) {
            return true;
        }
        // KFSPTS-2253
        if (!isExceptionNode) {
            final String principalName = currentUser.getPrincipalName();
            final String[] chartErrorParams = new String[] { getDataDictionaryService().getAttributeLabel(accountingLineForValidation.getClass(), KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE), accountingLineForValidation.getChartOfAccountsCode(), principalName };
            // KFSPTS-1273 : fixing an exisiting issue.  Limit to REQ and POA.  Broader solution need more work.
            if (event instanceof UpdateAccountingLineEvent) {
                // if (CollectionUtils.isEmpty(GlobalVariables.getMessageMap().getErrorPath()) && event instanceof UpdateAccountingLineEvent) {
                GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(event.getErrorPathPrefix() + "." + KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, convertEventToMessage(event), chartErrorParams);
            } else {
                GlobalVariables.getMessageMap().putError(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, convertEventToMessage(event), chartErrorParams);
            }
            final String[] accountErrorParams = new String[] { getDataDictionaryService().getAttributeLabel(accountingLineForValidation.getClass(), KFSPropertyConstants.ACCOUNT_NUMBER), accountingLineForValidation.getAccountNumber(), principalName };
            // KFSPTS-1273 : fixing an exisiting issue.  Limit to REQ and POA.  Broader solution need more work.
            if (event instanceof UpdateAccountingLineEvent) {
                GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(event.getErrorPathPrefix() + "." + KFSPropertyConstants.ACCOUNT_NUMBER, convertEventToMessage(event), accountErrorParams);
            } else {
                GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, convertEventToMessage(event), accountErrorParams);
            }
        }
    // end KFSPTS-2253
    } else if (event instanceof AddAccountingLineEvent && isAccountNode(event.getDocument()) && !isAccountingLineFo(event.getDocument()) && !isDiscountTradeInAccount()) {
        final String principalName = currentUser.getPrincipalName();
        final String[] chartErrorParams = new String[] { getDataDictionaryService().getAttributeLabel(accountingLineForValidation.getClass(), KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE), accountingLineForValidation.getChartOfAccountsCode(), principalName };
        GlobalVariables.getMessageMap().putError(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, convertEventToMessage(event), chartErrorParams);
        final String[] accountErrorParams = new String[] { getDataDictionaryService().getAttributeLabel(accountingLineForValidation.getClass(), KFSPropertyConstants.ACCOUNT_NUMBER), accountingLineForValidation.getAccountNumber(), principalName };
        GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, convertEventToMessage(event), accountErrorParams);
        valid = false;
    }
    return (isAccessible || isExceptionNode) && valid;
}
Also used : AddAccountingLineEvent(org.kuali.kfs.sys.document.validation.event.AddAccountingLineEvent) Correctable(org.kuali.kfs.sys.document.Correctable) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) UpdateAccountingLineEvent(org.kuali.kfs.sys.document.validation.event.UpdateAccountingLineEvent) AccountingLineAuthorizer(org.kuali.kfs.sys.document.authorization.AccountingLineAuthorizer) Person(org.kuali.rice.kim.api.identity.Person)

Example 3 with FinancialSystemDocumentHeader

use of org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader in project cu-kfs by CU-CommunityApps.

the class CuPreEncumbranceAccountingLineAuthorizer method determineEditPermissionOnField.

@Override
public boolean determineEditPermissionOnField(AccountingDocument accountingDocument, AccountingLine accountingLine, String accountingLineCollectionProperty, String fieldName, boolean editablePage) {
    final FinancialSystemDocumentHeader documentHeader = (FinancialSystemDocumentHeader) accountingDocument.getDocumentHeader();
    final WorkflowDocument workflowDocument = documentHeader.getWorkflowDocument();
    if (workflowDocument.isInitiated()) {
        return true;
    } else {
        // no edits by default on non editable pages
        if (!editablePage) {
            return false;
        }
        // if a document is cancelled or in error, all of its fields cannot be editable
        if (workflowDocument.isCanceled()) {
            return false;
        }
    }
    return true;
}
Also used : WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader)

Example 4 with FinancialSystemDocumentHeader

use of org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader in project cu-kfs by CU-CommunityApps.

the class GlLineServiceImpl method isDocumentAnErrorCorrection.

/**
 * determines if the document is an error correction document...
 *
 * @param entry
 * @return true if the document is an error correction else false
 */
protected boolean isDocumentAnErrorCorrection(GeneralLedgerEntry entry) {
    DocumentHeader docHeader = documentHeaderService.getDocumentHeaderById(entry.getDocumentNumber());
    FinancialSystemDocumentHeader fsDocumentHeader = (FinancialSystemDocumentHeader) docHeader;
    return fsDocumentHeader != null && StringUtils.isNotBlank(fsDocumentHeader.getFinancialDocumentInErrorNumber());
}
Also used : FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) DocumentHeader(org.kuali.kfs.krad.bo.DocumentHeader) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader)

Example 5 with FinancialSystemDocumentHeader

use of org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader in project cu-kfs by CU-CommunityApps.

the class CuAutoDisapproveDocumentsServiceImpl method getDocumentsWithActualWorkflowStatus.

/**
 * CU Customization:
 *
 * There is a known Rice issue where the KFS document headers are not auto-saved when a KFS
 * document gets recalled to the action list. This is due to Rice explicitly avoiding any
 * auto-saves on documents moving to SAVED status, to prevent Optimistic Locking problems
 * for end-users as per the Rice PostProcessorServiceImpl code comments.
 *
 * Therefore, to prevent problems with auto-disapprovals accidentally targeting recalled
 * documents (due to them being retrieved based on KFS document header status), this method
 * filters out any documents whose KEW doc statuses do not match the expected one.
 *
 * @param documentList The document headers to filter; cannot be null.
 * @param workflowStatus The workflow status that the documents are expected to have; cannot be null.
 * @return A new collection containing only the KFS doc headers whose matching route headers actually have the given workflow status.
 */
protected Collection<FinancialSystemDocumentHeader> getDocumentsWithActualWorkflowStatus(Collection<FinancialSystemDocumentHeader> documentList, DocumentStatus status) {
    final int SCALED_SET_SIZE = (int) (documentList.size() * 1.4);
    Set<String> documentIds = new HashSet<String>(SCALED_SET_SIZE);
    Collection<DocumentRouteHeaderValue> routeHeaders;
    Collection<FinancialSystemDocumentHeader> finalList = new ArrayList<FinancialSystemDocumentHeader>(documentList.size());
    // Assemble document IDs, then search for workflow headers.
    for (FinancialSystemDocumentHeader docHeader : documentList) {
        documentIds.add(docHeader.getDocumentNumber());
    }
    routeHeaders = routeHeaderService.getRouteHeaders(documentIds);
    // Track which headers have the expected document status.
    documentIds = new HashSet<String>(SCALED_SET_SIZE);
    if (routeHeaders != null) {
        for (DocumentRouteHeaderValue routeHeader : routeHeaders) {
            if (status.equals(routeHeader.getStatus())) {
                documentIds.add(routeHeader.getDocumentId());
            }
        }
    }
    // Update final-headers collection with any doc headers that actually have the given workflow status in KEW.
    for (FinancialSystemDocumentHeader docHeader : documentList) {
        if (documentIds.contains(docHeader.getDocumentNumber())) {
            finalList.add(docHeader);
        }
    }
    return finalList;
}
Also used : FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) ArrayList(java.util.ArrayList) DocumentRouteHeaderValue(org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue) HashSet(java.util.HashSet)

Aggregations

FinancialSystemDocumentHeader (org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader)10 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)3 ArrayList (java.util.ArrayList)2 Person (org.kuali.rice.kim.api.identity.Person)2 ParseException (java.text.ParseException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 InternalBillingDocument (org.kuali.kfs.fp.document.InternalBillingDocument)1 DocumentHeader (org.kuali.kfs.krad.bo.DocumentHeader)1 Document (org.kuali.kfs.krad.document.Document)1 PurchasingAccountsPayableDocument (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)1 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)1 Correctable (org.kuali.kfs.sys.document.Correctable)1 AccountingLineAuthorizer (org.kuali.kfs.sys.document.authorization.AccountingLineAuthorizer)1 AddAccountingLineEvent (org.kuali.kfs.sys.document.validation.event.AddAccountingLineEvent)1 UpdateAccountingLineEvent (org.kuali.kfs.sys.document.validation.event.UpdateAccountingLineEvent)1 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)1 DocumentRouteHeaderValue (org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue)1 UnknownDocumentTypeException (org.kuali.rice.krad.datadictionary.exception.UnknownDocumentTypeException)1