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());
}
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;
}
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;
}
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());
}
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;
}
Aggregations