use of org.kuali.kfs.module.purap.document.PurchasingDocumentBase in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method addItem.
/**
* Add a new item to the document.
*
* @param mapping An ActionMapping
* @param form An ActionForm
* @param request The HttpServletRequest
* @param response The HttpServletResponse
* @return An ActionForward
* @throws Exception
*/
@SuppressWarnings("unchecked")
public ActionForward addItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
PurApItem item = purchasingForm.getNewPurchasingItemLine();
PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
boolean rulePassed = SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedAddPurchasingAccountsPayableItemEvent("", purDocument, item));
if (rulePassed) {
item = purchasingForm.getAndResetNewPurchasingItemLine();
purDocument.addItem(item);
// KFSPTS-985
if (((PurchasingDocumentBase) purDocument).isIntegratedWithFavoriteAccount()) {
populatePrimaryFavoriteAccount(item.getSourceAccountingLines(), getAccountClassFromNewPurApAccountingLine(purchasingForm));
}
}
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
use of org.kuali.kfs.module.purap.document.PurchasingDocumentBase in project cu-kfs by CU-CommunityApps.
the class CuRequisitionAction method addItem.
@SuppressWarnings("unchecked")
@Override
public ActionForward addItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
PurApItem item = purchasingForm.getNewPurchasingItemLine();
RequisitionItem requisitionItem = (RequisitionItem) item;
PurchasingDocument purDocument = (PurchasingDocument) purchasingForm.getDocument();
if (StringUtils.isBlank(requisitionItem.getPurchasingCommodityCode())) {
boolean commCodeParam = SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(CuRequisitionDocument.class, PurapParameterConstants.ENABLE_DEFAULT_VENDOR_COMMODITY_CODE_IND);
if (commCodeParam) {
if (purchasingForm instanceof RequisitionForm) {
CuRequisitionDocument reqs = (CuRequisitionDocument) purchasingForm.getDocument();
VendorDetail dtl = reqs.getVendorDetail();
if (ObjectUtils.isNotNull(dtl)) {
List<VendorCommodityCode> vcc = dtl.getVendorCommodities();
String defaultCommodityCode = "";
Iterator<VendorCommodityCode> it = vcc.iterator();
while (it.hasNext()) {
VendorCommodityCode commodity = it.next();
if (commodity.isCommodityDefaultIndicator()) {
defaultCommodityCode = commodity.getPurchasingCommodityCode();
requisitionItem.setPurchasingCommodityCode(defaultCommodityCode);
}
}
}
}
}
}
boolean rulePassed = SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedAddPurchasingAccountsPayableItemEvent("", purDocument, item));
if (rulePassed) {
item = purchasingForm.getAndResetNewPurchasingItemLine();
purDocument.addItem(item);
// KFSPTS-985
if (((PurchasingDocumentBase) (purDocument)).isIntegratedWithFavoriteAccount()) {
populatePrimaryFavoriteAccount(item.getSourceAccountingLines(), getAccountClassFromNewPurApAccountingLine(purchasingForm));
}
}
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
use of org.kuali.kfs.module.purap.document.PurchasingDocumentBase in project cu-kfs by CU-CommunityApps.
the class CuPurchasingProcessVendorValidation method validateDataForMethodOfPOTransmissionExistsOnVendorAddress.
/**
* This routine verifies that the data necessary for the Method of PO Transmission chosen on the REQ,
* PO, or POA document exists on the document's VendorAddress record for the chosen Vendor.
* If the required checks pass, true is returned.
* If the required checks fail, false is returned.
*
* NOTE: This routine could not be used for the VendorAddress validation checks on the Vendor maintenance
* document because the Method of PO Transmission value selectable on that document pertains to the specific
* VendorAddress being maintained. The method of PO transmission being used for this routine's validation
* checks is the one that is present on the input parameter purchasing document (REQ, PO, or POA) and could
* be different from the value of the same name that is on the VendorAddress. It is ok if these two values
* are different because the user could have changed it after the default was obtained via the lookup and
* used to populate the REQ, PO, or POA value as long as the data required for the method of PO transmission
* selected in that document exists on the VendorAddress record chosen on the REQ, PO, or POA.
*
* For KFSPTS-1458: This method was changed extensively to address new business rules.
*/
public boolean validateDataForMethodOfPOTransmissionExistsOnVendorAddress(Document document) {
boolean dataExists = true;
MessageMap errorMap = GlobalVariables.getMessageMap();
errorMap.clearErrorPath();
errorMap.addToErrorPath(PurapConstants.VENDOR_ERRORS);
// for REQ, PO, and POA verify that data exists on form for method of PO transmission value selected
if ((document instanceof RequisitionDocument) || (document instanceof PurchaseOrderDocument) || (document instanceof PurchaseOrderAmendmentDocument)) {
PurchaseOrderTransmissionMethodDataRulesServiceImpl purchaseOrderTransmissionMethodDataRulesServiceImpl = SpringContext.getBean(PurchaseOrderTransmissionMethodDataRulesServiceImpl.class);
PurchasingDocumentBase purapDocument = (PurchasingDocumentBase) document;
String poTransMethodCode = purapDocument.getPurchaseOrderTransmissionMethodCode();
if (poTransMethodCode != null && !StringUtils.isBlank(poTransMethodCode)) {
if (poTransMethodCode.equals(PurapConstants.POTransmissionMethods.FAX)) {
dataExists = purchaseOrderTransmissionMethodDataRulesServiceImpl.isFaxNumberValid(purapDocument.getVendorFaxNumber());
if (!dataExists) {
errorMap.putError(VendorPropertyConstants.VENDOR_FAX_NUMBER, CUPurapKeyConstants.PURAP_MOPOT_REQUIRED_DATA_MISSING);
}
} else if (poTransMethodCode.equals(CUPurapConstants.POTransmissionMethods.EMAIL)) {
dataExists = purchaseOrderTransmissionMethodDataRulesServiceImpl.isEmailAddressValid(purapDocument.getVendorEmailAddress());
if (!dataExists) {
errorMap.putError("vendorEmailAddress", CUPurapKeyConstants.PURAP_MOPOT_REQUIRED_DATA_MISSING);
}
} else if (poTransMethodCode.equals(CUPurapConstants.POTransmissionMethods.MANUAL)) {
dataExists = purchaseOrderTransmissionMethodDataRulesServiceImpl.isPostalAddressValid(purapDocument.getVendorLine1Address(), purapDocument.getVendorCityName(), purapDocument.getVendorStateCode(), purapDocument.getVendorPostalCode(), purapDocument.getVendorCountryCode());
if (!dataExists) {
errorMap.putError(VendorPropertyConstants.VENDOR_ADDRESS_LINE_1, CUPurapKeyConstants.PURAP_MOPOT_REQUIRED_DATA_MISSING);
}
}
}
}
return dataExists;
}
use of org.kuali.kfs.module.purap.document.PurchasingDocumentBase in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method populateDeliveryBuilding.
public ActionForward populateDeliveryBuilding(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PurchasingFormBase purForm = (PurchasingFormBase) form;
PurchasingDocumentBase document = (PurchasingDocumentBase) purForm.getDocument();
updateDeliveryBuilding(request, document);
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
use of org.kuali.kfs.module.purap.document.PurchasingDocumentBase in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method selectSystemType.
/**
* This method...
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward selectSystemType(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PurchasingAccountsPayableFormBase purchasingForm = (PurchasingAccountsPayableFormBase) form;
PurchasingDocumentBase document = (PurchasingDocumentBase) purchasingForm.getDocument();
Object question = request.getParameter(PurapConstants.QUESTION_INDEX);
Object buttonClicked = request.getParameter(KFSConstants.QUESTION_CLICKED_BUTTON);
String systemTypeCode = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
systemTypeCode = StringUtils.substringBetween(systemTypeCode, "selectSystemType.", ".");
if (question == null) {
String questionText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(PurapConstants.CapitalAssetTabStrings.QUESTION_SYSTEM_SWITCHING);
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)) {
// document.setCapitalAssetSystemTypeCode(systemTypeCode);
document.refreshReferenceObject(PurapPropertyConstants.CAPITAL_ASSET_SYSTEM_TYPE);
KNSGlobalVariables.getMessageList().add(PurapKeyConstants.PUR_CAPITAL_ASSET_SYSTEM_TYPE_SWITCHED);
}
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Aggregations