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