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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations