Search in sources :

Example 1 with AttributedAddPurchasingItemCapitalAssetEvent

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

the class PurchasingActionBase method addItemCapitalAssetByItem.

public ActionForward addItemCapitalAssetByItem(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 = SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedAddPurchasingItemCapitalAssetEvent("", purDocument, asset));
    if (rulePassed) {
        // grab system as well and attach asset number
        CapitalAssetSystem system = assetItem.getPurchasingCapitalAssetSystem();
        asset = assetItem.getAndResetNewPurchasingItemCapitalAssetLine();
        asset.setCapitalAssetSystemIdentifier(system.getCapitalAssetSystemIdentifier());
        if (capitalAssetSystemHasAssetItem(system, asset)) {
            GlobalVariables.getMessageMap().putError(PurapConstants.CAPITAL_ASSET_TAB_ERRORS, PurapKeyConstants.ERROR_CAPITAL_ASSET_DUPLICATE_ASSET);
        } else {
            system.getItemCapitalAssets().add(asset);
        }
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) PurchasingCapitalAssetItem(org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) ItemCapitalAsset(org.kuali.kfs.integration.purap.ItemCapitalAsset) AttributedAddPurchasingItemCapitalAssetEvent(org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingItemCapitalAssetEvent) CapitalAssetSystem(org.kuali.kfs.integration.purap.CapitalAssetSystem)

Example 2 with AttributedAddPurchasingItemCapitalAssetEvent

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

the class PurchasingActionBase method addItemCapitalAssetByDocument.

public ActionForward addItemCapitalAssetByDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
    PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
    ItemCapitalAsset asset = purDocument.getPurchasingCapitalAssetItems().get(0).getNewPurchasingItemCapitalAssetLine();
    boolean rulePassed = SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedAddPurchasingItemCapitalAssetEvent("", purDocument, asset));
    if (rulePassed) {
        // get specific asset item and grab system as well and attach asset number
        CapitalAssetSystem system = purDocument.getPurchasingCapitalAssetSystems().get(getSelectedLine(request));
        asset = purDocument.getPurchasingCapitalAssetItems().get(0).getAndResetNewPurchasingItemCapitalAssetLine();
        asset.setCapitalAssetSystemIdentifier(system.getCapitalAssetSystemIdentifier());
        if (capitalAssetSystemHasAssetItem(system, asset)) {
            GlobalVariables.getMessageMap().putError(PurapConstants.CAPITAL_ASSET_TAB_ERRORS, PurapKeyConstants.ERROR_CAPITAL_ASSET_DUPLICATE_ASSET);
        } else {
            system.getItemCapitalAssets().add(asset);
        }
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) ItemCapitalAsset(org.kuali.kfs.integration.purap.ItemCapitalAsset) AttributedAddPurchasingItemCapitalAssetEvent(org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingItemCapitalAssetEvent) CapitalAssetSystem(org.kuali.kfs.integration.purap.CapitalAssetSystem)

Aggregations

CapitalAssetSystem (org.kuali.kfs.integration.purap.CapitalAssetSystem)2 ItemCapitalAsset (org.kuali.kfs.integration.purap.ItemCapitalAsset)2 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)2 PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)2 AttributedAddPurchasingItemCapitalAssetEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingItemCapitalAssetEvent)2 PurchasingCapitalAssetItem (org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem)1