use of org.kuali.rice.kew.api.WorkflowDocument 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;
}
use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method doesDocumentAllowImmediateSaveOfNewNote.
private boolean doesDocumentAllowImmediateSaveOfNewNote(Document document, Note note) {
WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
PersistableBusinessObject noteTarget = document.getNoteTarget();
// This is the same logic used by the KualiDocumentActionBase.insertBONote() method.
return !workflowDocument.isInitiated() && StringUtils.isNotBlank(noteTarget.getObjectId()) && !(document instanceof MaintenanceDocument && StringUtils.equals(NoteType.BUSINESS_OBJECT.getCode(), note.getNoteTypeCode()));
}
use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.
the class CuFinancialMaintenanceDocumentActionTest method createMockWorkflowDocument.
protected WorkflowDocument createMockWorkflowDocument(DocumentStatus documentStatus) {
WorkflowDocument workflowDocument = mock(WorkflowDocumentImpl.class);
when(workflowDocument.getStatus()).thenReturn(documentStatus);
when(workflowDocument.isInitiated()).thenReturn(DocumentStatus.INITIATED.equals(documentStatus));
when(workflowDocument.isSaved()).thenReturn(DocumentStatus.SAVED.equals(documentStatus));
when(workflowDocument.isEnroute()).thenReturn(DocumentStatus.ENROUTE.equals(documentStatus));
when(workflowDocument.isException()).thenReturn(DocumentStatus.EXCEPTION.equals(documentStatus));
when(workflowDocument.isProcessed()).thenReturn(DocumentStatus.PROCESSED.equals(documentStatus));
when(workflowDocument.isFinal()).thenReturn(DocumentStatus.FINAL.equals(documentStatus));
when(workflowDocument.isCanceled()).thenReturn(DocumentStatus.CANCELED.equals(documentStatus));
when(workflowDocument.isDisapproved()).thenReturn(DocumentStatus.DISAPPROVED.equals(documentStatus));
when(workflowDocument.isRecalled()).thenReturn(DocumentStatus.RECALLED.equals(documentStatus));
return workflowDocument;
}
use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.
the class CuPurapAccountingServiceImpl method updateAccountAmounts.
/**
* @see org.kuali.kfs.module.purap.service.PurapAccountingService#updateAccountAmounts(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)
*/
@Override
public void updateAccountAmounts(PurchasingAccountsPayableDocument document) {
PurchasingAccountsPayableDocumentBase purApDocument = (PurchasingAccountsPayableDocumentBase) document;
String accountDistributionMethod = purApDocument.getAccountDistributionMethod();
KualiRuleService kualiRuleService = SpringContext.getBean(KualiRuleService.class);
WorkflowDocument workflowDocument = purApDocument.getDocumentHeader().getWorkflowDocument();
Set<String> nodeNames = workflowDocument.getCurrentNodeNames();
// don't update if past the AP review level
if ((document instanceof PaymentRequestDocument) && purapService.isFullDocumentEntryCompleted(document)) {
if (nodeNames.contains(PaymentRequestStatuses.NODE_PAYMENT_METHOD_REVIEW)) {
// CU needs this update because the customization allows Treasury Manager to change unit/extended price and 'calculate'
for (PurApItem item : document.getItems()) {
updatePreqItemAccountAmountsOnly(item);
}
} else {
convertMoneyToPercent((PaymentRequestDocument) document);
}
return;
}
document.fixItemReferences();
// if distribution method is sequential and document is PREQ or VCM then...
if (((document instanceof PaymentRequestDocument) || (document instanceof VendorCreditMemoDocument)) && PurapConstants.AccountDistributionMethodCodes.SEQUENTIAL_CODE.equalsIgnoreCase(accountDistributionMethod)) {
if (document instanceof VendorCreditMemoDocument) {
VendorCreditMemoDocument cmDocument = (VendorCreditMemoDocument) document;
cmDocument.updateExtendedPriceOnItems();
for (PurApItem item : document.getItems()) {
for (PurApAccountingLine account : item.getSourceAccountingLines()) {
account.setAmount(KualiDecimal.ZERO);
}
}
}
// update the accounts amounts for PREQ and distribution method = sequential
for (PurApItem item : document.getItems()) {
updatePreqItemAccountAmounts(item);
}
return;
}
// if distribution method is proportional and document is PREQ or VCM then...
if (((document instanceof PaymentRequestDocument) || (document instanceof VendorCreditMemoDocument)) && PurapConstants.AccountDistributionMethodCodes.PROPORTIONAL_CODE.equalsIgnoreCase(accountDistributionMethod)) {
// update the accounts amounts for PREQ and distribution method = sequential
if (document instanceof VendorCreditMemoDocument) {
VendorCreditMemoDocument cmDocument = (VendorCreditMemoDocument) document;
cmDocument.updateExtendedPriceOnItems();
for (PurApItem item : document.getItems()) {
for (PurApAccountingLine account : item.getSourceAccountingLines()) {
account.setAmount(KualiDecimal.ZERO);
}
}
}
for (PurApItem item : document.getItems()) {
boolean rulePassed = true;
// check any business rules
rulePassed &= kualiRuleService.applyRules(new PurchasingAccountsPayableItemPreCalculateEvent(document, item));
if (rulePassed) {
updatePreqProportionalItemAccountAmounts(item);
}
}
return;
}
// No recalculate if the account distribution method code is equal to "S" sequential ON REQ or POs..
if (PurapConstants.AccountDistributionMethodCodes.SEQUENTIAL_CODE.equalsIgnoreCase(accountDistributionMethod)) {
for (PurApItem item : document.getItems()) {
boolean rulePassed = true;
// check any business rules
rulePassed &= kualiRuleService.applyRules(new PurchasingAccountsPayableItemPreCalculateEvent(document, item));
return;
}
}
// do recalculate only if the account distribution method code is not equal to "S" sequential method.
if (!PurapConstants.AccountDistributionMethodCodes.SEQUENTIAL_CODE.equalsIgnoreCase(accountDistributionMethod)) {
for (PurApItem item : document.getItems()) {
boolean rulePassed = true;
// check any business rules
rulePassed &= kualiRuleService.applyRules(new PurchasingAccountsPayableItemPreCalculateEvent(document, item));
if (rulePassed) {
updateItemAccountAmounts(item);
}
}
}
}
use of org.kuali.rice.kew.api.WorkflowDocument in project cu-kfs by CU-CommunityApps.
the class CuPaymentRequestDocumentPresentationController method getEditModes.
@Override
public Set<String> getEditModes(Document document) {
Set<String> editModes = super.getEditModes(document);
WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
PaymentRequestDocument paymentRequestDocument = (PaymentRequestDocument) document;
if (workflowDocument.isInitiated() || workflowDocument.isSaved()) {
// KFSPTS-1891
editModes.add(KfsAuthorizationConstants.TransactionalEditMode.FRN_ENTRY);
editModes.add(KfsAuthorizationConstants.TransactionalEditMode.WIRE_ENTRY);
}
// KFSPTS-1891
if (canApprove(paymentRequestDocument) && canEditAmount(paymentRequestDocument)) {
editModes.add(CUPaymentRequestEditMode.EDIT_AMOUNT);
}
if (paymentRequestDocument.isDocumentStoppedInRouteNode(PaymentRequestStatuses.NODE_PAYMENT_METHOD_REVIEW)) {
editModes.add(CUPaymentRequestEditMode.WAIVE_WIRE_FEE_EDITABLE);
// KFSPTS-1891
editModes.add(KfsAuthorizationConstants.TransactionalEditMode.FRN_ENTRY);
editModes.add(KfsAuthorizationConstants.TransactionalEditMode.WIRE_ENTRY);
// KFSPTS-2968 allows DM to edit additional charge amount
editModes.add(CUPaymentRequestEditMode.ADDITONAL_CHARGE_AMOUNT_EDITABLE);
}
if (editModes.contains(PaymentRequestEditMode.TAX_INFO_VIEWABLE)) {
editModes.remove(PaymentRequestEditMode.TAX_INFO_VIEWABLE);
}
// KFSPTS-2712 : allow payment method review to view tax info
if ((PaymentRequestStatuses.APPDOC_DEPARTMENT_APPROVED.equals(paymentRequestDocument.getApplicationDocumentStatus()) || PaymentRequestStatuses.APPDOC_PAYMENT_METHOD_REVIEW.equals(paymentRequestDocument.getApplicationDocumentStatus())) && // if and only if the preq has gone through tax review would TaxClassificationCode be non-empty
!StringUtils.isEmpty(paymentRequestDocument.getTaxClassificationCode())) {
editModes.add(PaymentRequestEditMode.TAX_INFO_VIEWABLE);
}
return editModes;
}
Aggregations