Search in sources :

Example 6 with PurchaseOrderAmendmentDocument

use of org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method changeSystem.

public ActionForward changeSystem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingAccountsPayableFormBase purchasingForm = (PurchasingAccountsPayableFormBase) form;
    PurchasingDocument document = (PurchasingDocument) purchasingForm.getDocument();
    Object question = request.getParameter(PurapConstants.QUESTION_INDEX);
    Object buttonClicked = request.getParameter(KFSConstants.QUESTION_CLICKED_BUTTON);
    if (question == null) {
        String questionText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(PurapKeyConstants.PURCHASING_QUESTION_CONFIRM_CHANGE_SYSTEM);
        return this.performQuestionWithoutInput(mapping, form, request, response, PurapConstants.CapitalAssetTabStrings.SYSTEM_SWITCHING_QUESTION, questionText, KFSConstants.CONFIRMATION_QUESTION, KFSConstants.ROUTE_METHOD, "0");
    } else if (ConfirmationQuestion.YES.equals(buttonClicked)) {
        // Add a note if system change occurs when the document is a PO that is being amended.
        if ((document instanceof PurchaseOrderDocument) && (PurapConstants.PurchaseOrderStatuses.APPDOC_CHANGE_IN_PROCESS.equals(document.getApplicationDocumentStatus()))) {
            Integer poId = document.getPurapDocumentIdentifier();
            PurchaseOrderDocument currentPO = SpringContext.getBean(PurchaseOrderService.class).getCurrentPurchaseOrder(poId);
            String oldSystemTypeCode = "";
            if (currentPO != null) {
                oldSystemTypeCode = currentPO.getCapitalAssetSystemTypeCode();
            }
            CapitalAssetSystemType oldSystemType = new CapitalAssetSystemType();
            oldSystemType.setCapitalAssetSystemTypeCode(oldSystemTypeCode);
            Map<String, String> keys = SpringContext.getBean(PersistenceService.class).getPrimaryKeyFieldValues(oldSystemType);
            oldSystemType = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(CapitalAssetSystemType.class, keys);
            String description = ((oldSystemType == null) ? "(NONE)" : oldSystemType.getCapitalAssetSystemTypeDescription());
            if (document instanceof PurchaseOrderAmendmentDocument) {
                String noteText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(PurapKeyConstants.PURCHASE_ORDER_AMEND_MESSAGE_CHANGE_SYSTEM_TYPE);
                noteText = StringUtils.replace(noteText, "{0}", description);
                try {
                    Note systemTypeChangeNote = getDocumentService().createNoteFromDocument(document, noteText);
                    purchasingForm.setNewNote(systemTypeChangeNote);
                    insertBONote(mapping, purchasingForm, request, response);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }
        if (form instanceof RequisitionForm) {
            ((RequisitionForm) form).resetNewPurchasingCapitalAssetLocationLine();
        }
        // remove capital assets from db
        if (document instanceof PurchaseOrderAmendmentDocument) {
            for (PurchasingCapitalAssetItem assetItem : document.getPurchasingCapitalAssetItems()) {
                SpringContext.getBean(BusinessObjectService.class).delete((PersistableBusinessObject) assetItem);
            }
        }
        document.clearCapitalAssetFields();
        SpringContext.getBean(PurapService.class).saveDocumentNoValidation(document);
        KNSGlobalVariables.getMessageList().add(PurapKeyConstants.PURCHASING_MESSAGE_SYSTEM_CHANGED);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PurchaseOrderAmendmentDocument(org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument) CapitalAssetSystemType(org.kuali.kfs.module.purap.businessobject.CapitalAssetSystemType) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) ItemParserException(org.kuali.kfs.module.purap.exception.ItemParserException) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) Note(org.kuali.kfs.krad.bo.Note) PurchasingCapitalAssetItem(org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService) Map(java.util.Map) MessageMap(org.kuali.kfs.krad.util.MessageMap)

Example 7 with PurchaseOrderAmendmentDocument

use of org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument in project cu-kfs by CU-CommunityApps.

the class CuPurchaseOrderAmendmentDocumentPresentationController method getEditModes.

@Override
public Set<String> getEditModes(Document document) {
    Set<String> editModes = super.getEditModes(document);
    PurchaseOrderDocument poDocument = (PurchaseOrderDocument) document;
    if (PurapConstants.PurchaseOrderStatuses.APPDOC_CHANGE_IN_PROCESS.equals(poDocument.getApplicationDocumentStatus())) {
        WorkflowDocument workflowDocument = poDocument.getFinancialSystemDocumentHeader().getWorkflowDocument();
        // amendment doc needs to lock its field for initiator while enroute
        if (workflowDocument.isInitiated() || workflowDocument.isSaved() || workflowDocument.isCompletionRequested()) {
            editModes.add(PurchaseOrderEditMode.AMENDMENT_ENTRY);
        }
    }
    // KFSUPGRADE-339
    if (PurchaseOrderStatuses.APPDOC_AWAITING_FISCAL_REVIEW.equals(((PurchaseOrderDocument) document).getApplicationDocumentStatus())) {
        editModes.add(PurchaseOrderEditMode.AMENDMENT_ENTRY);
    }
    if (SpringContext.getBean(PurapService.class).isDocumentStoppedInRouteNode((PurchasingAccountsPayableDocument) document, "New Unordered Items")) {
        editModes.add(PurchaseOrderEditMode.UNORDERED_ITEM_ACCOUNT_ENTRY);
    }
    boolean showDisableRemoveAccounts = true;
    PurchaseOrderAmendmentDocument purchaseOrderAmendmentDocument = (PurchaseOrderAmendmentDocument) document;
    List<PurApItem> aboveTheLinePOItems = PurApItemUtils.getAboveTheLineOnly(purchaseOrderAmendmentDocument.getItems());
    PurchaseOrderDocument po = (PurchaseOrderDocument) document;
    boolean containsUnpaidPaymentRequestsOrCreditMemos = po.getContainsUnpaidPaymentRequestsOrCreditMemos();
    ItemLoop: for (PurApItem poItem : aboveTheLinePOItems) {
        boolean acctLinesEditable = allowAccountingLinesAreEditable((PurchaseOrderItem) poItem, containsUnpaidPaymentRequestsOrCreditMemos);
        for (PurApAccountingLine poAccoutingLine : poItem.getSourceAccountingLines()) {
            if (!acctLinesEditable) {
                showDisableRemoveAccounts = false;
                break ItemLoop;
            }
        }
    }
    if (!showDisableRemoveAccounts) {
        editModes.add(PurchaseOrderEditMode.DISABLE_REMOVE_ACCTS);
    }
    // KFSPTS-985
    if (document instanceof PurchaseOrderDocument && !editModes.contains(RequisitionEditMode.DISABLE_SETUP_ACCT_DISTRIBUTION) && !hasEmptyAcctline((PurchaseOrderDocument) document)) {
        editModes.add(RequisitionEditMode.DISABLE_SETUP_ACCT_DISTRIBUTION);
    }
    return editModes;
}
Also used : PurchaseOrderAmendmentDocument(org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument) PurchaseOrderItem(org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem) PurapService(org.kuali.kfs.module.purap.document.service.PurapService) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument)

Example 8 with PurchaseOrderAmendmentDocument

use of org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument in project cu-kfs by CU-CommunityApps.

the class CuPurchaseOrderForm method populateItemAccountingLines.

// end KFSUPGRADE-411
/**
 * Overridden to properly increment the local "itemCount" loop counter when processing POA documents,
 * but otherwise has the same code as in the superclass.
 *
 * @see org.kuali.kfs.module.purap.document.web.struts.PurchasingAccountsPayableFormBase#populateItemAccountingLines(java.util.Map)
 */
@SuppressWarnings("rawtypes")
@Override
protected void populateItemAccountingLines(Map parameterMap) {
    if (!(getDocument() instanceof PurchaseOrderAmendmentDocument)) {
        super.populateItemAccountingLines(parameterMap);
        return;
    }
    int itemCount = 0;
    for (PurApItem item : ((PurchasingAccountsPayableDocument) getDocument()).getItems()) {
        populateAccountingLine(item.getNewSourceLine(), KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.ITEM + "[" + itemCount + "]." + KFSPropertyConstants.NEW_SOURCE_LINE, parameterMap);
        int sourceLineCount = 0;
        for (PurApAccountingLine purApLine : item.getSourceAccountingLines()) {
            populateAccountingLine(purApLine, KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.ITEM + "[" + itemCount + "]." + KFSPropertyConstants.SOURCE_ACCOUNTING_LINE + "[" + sourceLineCount + "]", parameterMap);
            sourceLineCount += 1;
        }
        itemCount += 1;
    }
}
Also used : PurchaseOrderAmendmentDocument(org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument) PurApItem(org.kuali.kfs.module.purap.businessobject.PurApItem) PurApAccountingLine(org.kuali.kfs.module.purap.businessobject.PurApAccountingLine) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)

Aggregations

PurchaseOrderAmendmentDocument (org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument)8 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)5 MessageMap (org.kuali.kfs.krad.util.MessageMap)3 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)3 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)3 PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)3 Map (java.util.Map)2 Note (org.kuali.kfs.krad.bo.Note)2 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)2 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)2 PurchasingAccountsPayableDocument (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)2 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)2 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)2 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)2 CuPurchaseOrderAmendmentDocument (edu.cornell.kfs.module.purap.document.CuPurchaseOrderAmendmentDocument)1 PurchaseOrderTransmissionMethodDataRulesServiceImpl (edu.cornell.kfs.module.purap.document.service.impl.PurchaseOrderTransmissionMethodDataRulesServiceImpl)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)1