Search in sources :

Example 11 with PurchasingCapitalAssetItem

use of org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method deleteItemCapitalAssetByDocument.

public ActionForward deleteItemCapitalAssetByDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
    // get specific asset item
    PurchasingCapitalAssetItem assetItem = purDocument.getPurchasingCapitalAssetItems().get(getSelectedLine(request));
    ItemCapitalAsset asset = assetItem.getNewPurchasingItemCapitalAssetLine();
    boolean rulePassed = true;
    if (rulePassed) {
        String fullParameter = (String) request.getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE);
        String systemIndex = StringUtils.substringBetween(fullParameter, KFSConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL);
        String assetIndex = StringUtils.substringBetween(fullParameter, KFSConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL);
        PurchasingCapitalAssetSystemBase system = (PurchasingCapitalAssetSystemBase) purDocument.getPurchasingCapitalAssetSystems().get(Integer.parseInt(systemIndex));
        system.getItemCapitalAssets().remove(Integer.parseInt(assetIndex));
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PurchasingCapitalAssetItem(org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) PurchasingCapitalAssetSystemBase(org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetSystemBase) ItemCapitalAsset(org.kuali.kfs.integration.purap.ItemCapitalAsset)

Example 12 with PurchasingCapitalAssetItem

use of org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method updateCapitalAssetLocation.

protected void updateCapitalAssetLocation(HttpServletRequest request, PurchasingFormBase purchasingForm, PurchasingDocument document, String buildingCodeParam) {
    String buildingCode = request.getParameterValues(buildingCodeParam)[0];
    String campusCodeParam = buildingCodeParam.replace("buildingCode", "campusCode");
    String campusCode = request.getParameterValues(campusCodeParam)[0];
    Building locationBuilding = findBuilding(buildingCode, campusCode);
    CapitalAssetLocation location = null;
    boolean isNewLine = StringUtils.containsIgnoreCase(buildingCodeParam, "newPurchasingCapitalAssetLocationLine");
    if (isNewLine) {
        if (document.getCapitalAssetSystemType().getCapitalAssetSystemTypeCode().equals(PurapConstants.CapitalAssetSystemTypes.INDIVIDUAL)) {
            String locationCapitalAssetItemNumber = getCaptialAssetItemNumberFromParameter(buildingCodeParam);
            PurchasingCapitalAssetItem capitalAssetItem = document.getPurchasingCapitalAssetItems().get(Integer.parseInt(locationCapitalAssetItemNumber));
            location = capitalAssetItem.getPurchasingCapitalAssetSystem().getNewPurchasingCapitalAssetLocationLine();
        } else {
            location = purchasingForm.getNewPurchasingCapitalAssetLocationLine();
        }
    } else if (StringUtils.containsIgnoreCase(buildingCodeParam, "purchasingCapitalAssetLocationLine")) {
        String locationCapitalAssetLocationNumber = getCaptialAssetLocationNumberFromParameter(buildingCodeParam);
        if (document.getCapitalAssetSystemType().getCapitalAssetSystemTypeCode().equals(PurapConstants.CapitalAssetSystemTypes.INDIVIDUAL)) {
            String locationCapitalAssetItemNumber = getCaptialAssetItemNumberFromParameter(buildingCodeParam);
            PurchasingCapitalAssetItem capitalAssetItem = document.getPurchasingCapitalAssetItems().get(Integer.parseInt(locationCapitalAssetItemNumber));
            location = capitalAssetItem.getPurchasingCapitalAssetSystem().getCapitalAssetLocations().get(Integer.parseInt(locationCapitalAssetLocationNumber));
        }
    } else if (StringUtils.containsIgnoreCase(buildingCodeParam, "purchasingCapitalAssetSystem")) {
        String locationCapitalAssetLocationNumber = getCaptialAssetLocationNumberFromParameter(buildingCodeParam);
        if (document.getCapitalAssetSystemType().getCapitalAssetSystemTypeCode().equals(PurapConstants.CapitalAssetSystemTypes.INDIVIDUAL)) {
            String locationCapitalAssetItemNumber = getCaptialAssetItemNumberFromParameter(buildingCodeParam);
            PurchasingCapitalAssetItem capitalAssetItem = document.getPurchasingCapitalAssetItems().get(Integer.parseInt(locationCapitalAssetItemNumber));
            location = capitalAssetItem.getPurchasingCapitalAssetSystem().getCapitalAssetLocations().get(Integer.parseInt(locationCapitalAssetLocationNumber));
        } else {
            CapitalAssetSystem capitalAssetSystem = document.getPurchasingCapitalAssetSystems().get(0);
            location = capitalAssetSystem.getCapitalAssetLocations().get(Integer.parseInt(locationCapitalAssetLocationNumber));
        }
    }
    if (location != null) {
        location.templateBuilding(locationBuilding);
    }
    if (locationBuilding == null && !(isNewLine && buildingCode.isEmpty())) {
        // ignore scenario where isNewLine and it's empty as this is the default case; only validate new lines if
        // data exists
        GlobalVariables.getMessageMap().putError(buildingCodeParam, PurapKeyConstants.ERROR_CAPITAL_ASSET_LOCATION_BUILDING_CODE_INVALID);
    }
}
Also used : Building(org.kuali.kfs.sys.businessobject.Building) CapitalAssetLocation(org.kuali.kfs.integration.purap.CapitalAssetLocation) PurchasingCapitalAssetItem(org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem) CapitalAssetSystem(org.kuali.kfs.integration.purap.CapitalAssetSystem)

Example 13 with PurchasingCapitalAssetItem

use of org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem 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 14 with PurchasingCapitalAssetItem

use of org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method setManufacturerFromVendorByItem.

public ActionForward setManufacturerFromVendorByItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingAccountsPayableFormBase purchasingForm = (PurchasingAccountsPayableFormBase) form;
    PurchasingDocument document = (PurchasingDocument) purchasingForm.getDocument();
    String vendorName = document.getVendorName();
    if (StringUtils.isEmpty(vendorName)) {
        GlobalVariables.getMessageMap().putError(PurapConstants.CAPITAL_ASSET_TAB_ERRORS, PurapKeyConstants.ERROR_CAPITAL_ASSET_NO_VENDOR, (String[]) null);
    } else {
        PurchasingCapitalAssetItem assetItem = document.getPurchasingCapitalAssetItems().get(getSelectedLine(request));
        CapitalAssetSystem system = assetItem.getPurchasingCapitalAssetSystem();
        if (system != null) {
            system.setCapitalAssetManufacturerName(vendorName);
        }
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PurchasingCapitalAssetItem(org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) CapitalAssetSystem(org.kuali.kfs.integration.purap.CapitalAssetSystem)

Aggregations

PurchasingCapitalAssetItem (org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem)14 PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)10 CapitalAssetSystem (org.kuali.kfs.integration.purap.CapitalAssetSystem)9 ItemCapitalAsset (org.kuali.kfs.integration.purap.ItemCapitalAsset)4 CapitalAssetLocation (org.kuali.kfs.integration.purap.CapitalAssetLocation)2 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)2 PurchasingCapitalAssetSystemBase (org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetSystemBase)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Note (org.kuali.kfs.krad.bo.Note)1 PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)1 ApproveDocumentEvent (org.kuali.kfs.krad.rules.rule.event.ApproveDocumentEvent)1 RouteDocumentEvent (org.kuali.kfs.krad.rules.rule.event.RouteDocumentEvent)1 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)1 MessageMap (org.kuali.kfs.krad.util.MessageMap)1 CapitalAssetSystemType (org.kuali.kfs.module.purap.businessobject.CapitalAssetSystemType)1 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)1 PurchaseOrderAmendmentDocument (org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument)1 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)1