Search in sources :

Example 6 with FinancialSystemDocumentHeader

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

the class MockDocumentUtils method performInitializationFromSkippedConstructor.

private static void performInitializationFromSkippedConstructor(Document document) {
    document.setDocumentHeader(new FinancialSystemDocumentHeader());
    document.setAdHocRoutePersons(new ArrayList<>());
    document.setAdHocRouteWorkgroups(new ArrayList<>());
    document.setNotes(new ArrayList<>());
    if (document instanceof AccountingDocument) {
        AccountingDocument accountingDocument = (AccountingDocument) document;
        accountingDocument.setSourceAccountingLines(new ArrayList<>());
        accountingDocument.setTargetAccountingLines(new ArrayList<>());
        accountingDocument.setNextSourceLineNumber(Integer.valueOf(1));
        accountingDocument.setNextTargetLineNumber(Integer.valueOf(1));
    }
    if (document instanceof InternalBillingDocument) {
        InternalBillingDocument internalBillingDocument = (InternalBillingDocument) document;
        internalBillingDocument.setItems(new ArrayList<>());
        internalBillingDocument.setNextItemLineNumber(Integer.valueOf(1));
    }
}
Also used : FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) InternalBillingDocument(org.kuali.kfs.fp.document.InternalBillingDocument)

Example 7 with FinancialSystemDocumentHeader

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

the class CuAdvanceDepositDocumentPresentationController method canEdit.

/**
 * @see org.kuali.kfs.kns.document.authorization.DocumentPresentationControllerBase#canEdit(org.kuali.kfs.kns.document.Document)
 */
@Override
public boolean canEdit(Document document) {
    WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
    FinancialSystemDocumentHeader documentheader = (FinancialSystemDocumentHeader) (document.getDocumentHeader());
    if (workflowDocument.isCanceled() || documentheader.getFinancialDocumentInErrorNumber() != null) {
        return false;
    }
    boolean canEdit = false;
    if (workflowDocument.isInitiated() || workflowDocument.isSaved() || workflowDocument.isEnroute() || workflowDocument.isException()) {
        canEdit = true;
    }
    return canEdit;
}
Also used : WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader)

Example 8 with FinancialSystemDocumentHeader

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

the class PurchasingCommodityCodeValidation method shouldCheckCommodityCodeIsActive.

/**
 * This method analyzes the document status and determines if the commodity codes associated with this item should be verified as active.
 * The current implementation only checks that a commodity code is active if the document associated is in either INITIATED or SAVED status.
 * For all other statuses the document may be in, the commodity code will not be checked for active status and the method will simply return
 * true unconditionally.
 *
 * @param item
 * @return
 */
private boolean shouldCheckCommodityCodeIsActive(PurApItem item) {
    if (ObjectUtils.isNotNull(item.getPurapDocument())) {
        String docNum = item.getPurapDocument().getDocumentNumber();
        PurchasingAccountsPayableDocument purapDoc = item.getPurapDocument();
        // Ran into issues with workflow doc not being populated in doc header for some PURAP docs, so needed to add check and retrieval.
        FinancialSystemDocumentHeader docHdr = (FinancialSystemDocumentHeader) purapDoc.getDocumentHeader();
        WorkflowDocument kwd = null;
        kwd = WorkflowDocumentFactory.loadDocument(GlobalVariables.getUserSession().getPrincipalId(), docNum);
        docHdr.setWorkflowDocument(kwd);
        // Only check for active commodity codes if the doc is in initiated or saved status.
        if (ObjectUtils.isNull(kwd)) {
            kwd = docHdr.getWorkflowDocument();
        }
        if (!(kwd.isInitiated() || kwd.isSaved())) {
            return false;
        }
    }
    return true;
}
Also used : WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)

Example 9 with FinancialSystemDocumentHeader

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

the class AccountingLineAccessibleValidation method isAccountingLineFo.

// CU customization
/*
     * KFSPTS-1273
     */
private boolean isAccountingLineFo(Document document) {
    Person currentUser = GlobalVariables.getUserSession().getPerson();
    List<String> roleIds = new ArrayList<String>();
    roleIds.add(KimApiServiceLocator.getRoleService().getRoleIdByNamespaceCodeAndName(KFSConstants.ParameterNamespaces.KFS, KFSConstants.SysKimApiConstants.FISCAL_OFFICER_KIM_ROLE_NAME));
    roleIds.add(KimApiServiceLocator.getRoleService().getRoleIdByNamespaceCodeAndName(KFSConstants.ParameterNamespaces.KFS, KFSConstants.SysKimApiConstants.FISCAL_OFFICER_PRIMARY_DELEGATE_KIM_ROLE_NAME));
    roleIds.add(KimApiServiceLocator.getRoleService().getRoleIdByNamespaceCodeAndName(KFSConstants.ParameterNamespaces.KFS, KFSConstants.SysKimApiConstants.FISCAL_OFFICER_SECONDARY_DELEGATE_KIM_ROLE_NAME));
    Map<String, String> roleQualifier = new HashMap<String, String>();
    roleQualifier.put(KimConstants.AttributeConstants.DOCUMENT_NUMBER, document.getDocumentNumber());
    roleQualifier.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
    roleQualifier.put(KfsKimAttributes.FINANCIAL_DOCUMENT_TOTAL_AMOUNT, ((FinancialSystemDocumentHeader) document.getDocumentHeader()).getFinancialDocumentTotalAmount().toString());
    roleQualifier.put(KfsKimAttributes.CHART_OF_ACCOUNTS_CODE, accountingLineForValidation.getChartOfAccountsCode());
    roleQualifier.put(KfsKimAttributes.ACCOUNT_NUMBER, accountingLineForValidation.getAccountNumber());
    return KimApiServiceLocator.getRoleService().principalHasRole(currentUser.getPrincipalId(), roleIds, roleQualifier);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) Person(org.kuali.rice.kim.api.identity.Person)

Example 10 with FinancialSystemDocumentHeader

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

the class CuAutoDisapproveDocumentsServiceImpl method processAutoDisapproveDocuments.

@Override
protected boolean processAutoDisapproveDocuments(String principalId, String annotation) {
    boolean success = true;
    Collection<FinancialSystemDocumentHeader> documentList = getDocumentsToDisapprove();
    LOG.info("Total documents to process " + documentList.size());
    String documentHeaderId = null;
    // CU Customization: Filter out documents whose workflow statuses are not actually ENROUTE (see referenced method for details).
    documentList = getDocumentsWithActualWorkflowStatus(documentList, DocumentStatus.ENROUTE);
    for (FinancialSystemDocumentHeader result : documentList) {
        documentHeaderId = result.getDocumentNumber();
        Document document = findDocumentForAutoDisapproval(documentHeaderId);
        if (document != null) {
            if (checkIfDocumentEligibleForAutoDispproval(document.getDocumentHeader())) {
                try {
                    String successMessage = buildSuccessMessage(document);
                    autoDisapprovalYearEndDocument(document, annotation);
                    sendAcknowledgement(document.getDocumentHeader(), annotation);
                    LOG.info("The document with header id: " + documentHeaderId + " is automatically disapproved by this job.");
                    getAutoDisapproveErrorReportWriterService().writeFormattedMessageLine(successMessage);
                } catch (Exception e) {
                    LOG.error("Exception encountered trying to auto disapprove the document " + e.getMessage());
                    String message = ("Exception encountered trying to auto disapprove the document: ").concat(documentHeaderId);
                    getAutoDisapproveErrorReportWriterService().writeFormattedMessageLine(message);
                }
            }
        } else {
            LOG.error("Document is NULL.  It should never have been null");
            String message = ("Error: Document with id: ").concat(documentHeaderId).concat(" - Document is NULL.  It should never have been null");
            getAutoDisapproveErrorReportWriterService().writeFormattedMessageLine(message);
        }
    }
    return success;
}
Also used : FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) Document(org.kuali.kfs.krad.document.Document) ParseException(java.text.ParseException) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) UnknownDocumentTypeException(org.kuali.rice.krad.datadictionary.exception.UnknownDocumentTypeException)

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