Search in sources :

Example 21 with PurchasingDocument

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

the class PurchasingNewIndividualItemValidation method validate.

public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;
    valid &= super.validate(event);
    PurchasingDocument purDoc = (PurchasingDocument) event.getDocument();
    String recurringPaymentTypeCode = purDoc.getRecurringPaymentTypeCode();
    // Capital asset validations are only done on line items (not additional charge items).
    if (!getItemForValidation().getItemType().isAdditionalChargeIndicator()) {
        valid &= capitalAssetManagementModuleService.validateItemCapitalAssetWithErrors(recurringPaymentTypeCode, getItemForValidation(), false);
    }
    unitOfMeasureValidation.setItemForValidation(getItemForValidation());
    valid &= unitOfMeasureValidation.validate(event);
    if (getItemForValidation().getItemType().isLineItemIndicator()) {
        itemUnitPriceValidation.setItemForValidation(getItemForValidation());
        valid &= itemUnitPriceValidation.validate(event);
        itemDescriptionValidation.setItemForValidation(getItemForValidation());
        valid &= itemDescriptionValidation.validate(event);
        itemQuantityValidation.setItemForValidation(getItemForValidation());
        valid &= itemQuantityValidation.validate(event);
        commodityCodeValidation.setItemForValidation(getItemForValidation());
        valid &= commodityCodeValidation.validate(event);
    } else {
        // No accounts can be entered on below-the-line items that have no unit cost.
        belowTheLineItemNoUnitCostValidation.setItemForValidation(getItemForValidation());
        valid &= belowTheLineItemNoUnitCostValidation.validate(event);
    }
    return valid;
}
Also used : PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument)

Example 22 with PurchasingDocument

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

the class PurchasingActionBase method setManufacturerFromVendorByDocument.

public ActionForward setManufacturerFromVendorByDocument(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 {
        CapitalAssetSystem system = document.getPurchasingCapitalAssetSystems().get(getSelectedLine(request));
        if (system != null) {
            system.setCapitalAssetManufacturerName(vendorName);
        }
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) CapitalAssetSystem(org.kuali.kfs.integration.purap.CapitalAssetSystem)

Example 23 with PurchasingDocument

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

the class PurchasingActionBase method deleteItemCapitalAssetByItem.

public ActionForward deleteItemCapitalAssetByItem(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 assetIndex = StringUtils.substringBetween(fullParameter, KFSConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL);
        PurchasingCapitalAssetSystemBase system = (PurchasingCapitalAssetSystemBase) assetItem.getPurchasingCapitalAssetSystem();
        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 24 with PurchasingDocument

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

the class PurchasingActionBase method deleteItem.

/**
 * Delete an item from the document.
 *
 * @param mapping An ActionMapping
 * @param form An ActionForm
 * @param request The HttpServletRequest
 * @param response The HttpServletResponse
 * @return An ActionForward
 * @throws Exception
 */
public ActionForward deleteItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PurchasingAccountsPayableFormBase purchasingForm = (PurchasingAccountsPayableFormBase) form;
    PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
    if (!purDocument.getPurchasingCapitalAssetItems().isEmpty()) {
        purDocument.setPurchasingCapitalAssetItems(new PurApArrayList(purDocument.getPurchasingCapitalAssetItemClass()));
        SpringContext.getBean(PurapService.class).saveDocumentNoValidation(purDocument);
    }
    purDocument.deleteItem(getSelectedLine(request));
    if (StringUtils.isNotBlank(purDocument.getCapitalAssetSystemTypeCode())) {
        boolean rulePassed = SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedUpdateCamsViewPurapEvent(purDocument));
        if (rulePassed) {
            SpringContext.getBean(PurchasingService.class).setupCapitalAssetItems(purDocument);
        }
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : KualiRuleService(org.kuali.kfs.krad.service.KualiRuleService) PurapService(org.kuali.kfs.module.purap.document.service.PurapService) PurApArrayList(org.kuali.kfs.module.purap.util.PurApArrayList) PurchasingDocument(org.kuali.kfs.module.purap.document.PurchasingDocument) AttributedUpdateCamsViewPurapEvent(org.kuali.kfs.module.purap.document.validation.event.AttributedUpdateCamsViewPurapEvent) PurchasingService(org.kuali.kfs.module.purap.document.service.PurchasingService)

Example 25 with PurchasingDocument

use of org.kuali.kfs.module.purap.document.PurchasingDocument 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

PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)42 CapitalAssetSystem (org.kuali.kfs.integration.purap.CapitalAssetSystem)14 PurchasingCapitalAssetItem (org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetItem)10 KualiRuleService (org.kuali.kfs.krad.service.KualiRuleService)7 PurapService (org.kuali.kfs.module.purap.document.service.PurapService)6 PurchasingService (org.kuali.kfs.module.purap.document.service.PurchasingService)5 ItemCapitalAsset (org.kuali.kfs.integration.purap.ItemCapitalAsset)4 MessageMap (org.kuali.kfs.krad.util.MessageMap)4 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)4 ActionForward (org.apache.struts.action.ActionForward)3 Map (java.util.Map)2 CapitalAssetLocation (org.kuali.kfs.integration.purap.CapitalAssetLocation)2 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)2 PurchasingCapitalAssetSystemBase (org.kuali.kfs.module.purap.businessobject.PurchasingCapitalAssetSystemBase)2 PurchaseOrderAmendmentDocument (org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument)2 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)2 PurchasingDocumentBase (org.kuali.kfs.module.purap.document.PurchasingDocumentBase)2 AttributedAddPurchasingAccountsPayableItemEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingAccountsPayableItemEvent)2 AttributedAddPurchasingCapitalAssetLocationEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingCapitalAssetLocationEvent)2 AttributedAddPurchasingItemCapitalAssetEvent (org.kuali.kfs.module.purap.document.validation.event.AttributedAddPurchasingItemCapitalAssetEvent)2