use of org.kuali.kfs.module.purap.document.PurchasingDocument in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method addCapitalAssetLocationByDocument.
public ActionForward addCapitalAssetLocationByDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
CapitalAssetLocation location = purchasingForm.getAndResetNewPurchasingCapitalAssetLocationLine();
PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
boolean rulePassed = SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedAddPurchasingCapitalAssetLocationEvent("", purDocument, location));
rulePassed = rulePassed && SpringContext.getBean(PurchasingService.class).checkCapitalAssetLocation(location);
if (rulePassed) {
// get specific asset item and grab system as well and attach asset number
CapitalAssetSystem system = purDocument.getPurchasingCapitalAssetSystems().get(getSelectedLine(request));
location.setCapitalAssetSystemIdentifier(system.getCapitalAssetSystemIdentifier());
system.getCapitalAssetLocations().add(location);
}
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 updateCamsView.
public ActionForward updateCamsView(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PurchasingAccountsPayableFormBase purchasingForm = (PurchasingAccountsPayableFormBase) form;
PurchasingDocument document = (PurchasingDocument) purchasingForm.getDocument();
SpringContext.getBean(PurchasingService.class).setupCapitalAssetItems(document);
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 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);
}
use of org.kuali.kfs.module.purap.document.PurchasingDocument in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method blanketApprove.
@Override
public ActionForward blanketApprove(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
PurchasingDocument purDoc = (PurchasingDocument) purchasingForm.getDocument();
if (isAttachmentSizeExceedSqLimit(form, "blanket approve") || isReasonToChangeRequired(form)) {
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
boolean isCreatingReasonNote = isCreatingReasonNote(form);
// call prorateDiscountTradeIn
SpringContext.getBean(PurapService.class).prorateForTradeInAndFullOrderDiscount(purDoc);
ActionForward forward = super.blanketApprove(mapping, form, request, response);
if (GlobalVariables.getMessageMap().hasNoErrors() && isCreatingReasonNote) {
createReasonNote(form);
}
return forward;
}
use of org.kuali.kfs.module.purap.document.PurchasingDocument 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);
}
Aggregations