use of org.kuali.kfs.module.purap.document.PurchaseOrderDocument in project cu-kfs by CU-CommunityApps.
the class CuAutoClosePurchaseOrderServiceImpl method autoCloseFullyDisencumberedOrders.
@Override
public boolean autoCloseFullyDisencumberedOrders() {
LOG.debug("autoCloseFullyDisencumberedOrders() started");
List<AutoClosePurchaseOrderView> autoCloseList = this.getAllOpenPurchaseOrdersForAutoClose();
for (AutoClosePurchaseOrderView poAutoClose : autoCloseList) {
if ((poAutoClose.getTotalAmount() != null) && ((KualiDecimal.ZERO.compareTo(poAutoClose.getTotalAmount())) != 0)) {
// KFSUPGRADE-363
if (paymentRequestsStatusCanAutoClose(poAutoClose)) {
// TODO: can the following be replaced with this one line?
// autoClosePurchaseOrder(poAutoClose);
LOG.info("autoCloseFullyDisencumberedOrders() PO ID " + poAutoClose.getPurapDocumentIdentifier() + " with total " + poAutoClose.getTotalAmount().doubleValue() + " will be closed");
String newStatus = PurapConstants.PurchaseOrderStatuses.APPDOC_PENDING_CLOSE;
String annotation = "This PO was automatically closed in batch.";
String documentType = PurapConstants.PurchaseOrderDocTypes.PURCHASE_ORDER_CLOSE_DOCUMENT;
PurchaseOrderDocument document = purchaseOrderService.getPurchaseOrderByDocumentNumber(poAutoClose.getDocumentNumber());
this.createNoteForAutoCloseOrders(document, annotation);
purchaseOrderService.createAndRoutePotentialChangeDocument(poAutoClose.getDocumentNumber(), documentType, annotation, null, newStatus);
}
}
}
LOG.debug("autoCloseFullyDisencumberedOrders() ended");
return true;
}
use of org.kuali.kfs.module.purap.document.PurchaseOrderDocument in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method refresh.
/**
* @see org.kuali.kfs.sys.web.struts.KualiAccountingDocumentActionBase#refresh(org.apache.struts.action.ActionMapping,
* org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PurchasingAccountsPayableFormBase baseForm = (PurchasingAccountsPayableFormBase) form;
PurchasingDocument document = (PurchasingDocument) baseForm.getDocument();
String refreshCaller = baseForm.getRefreshCaller();
BusinessObjectService businessObjectService = SpringContext.getBean(BusinessObjectService.class);
PhoneNumberService phoneNumberService = SpringContext.getBean(PhoneNumberService.class);
// Format phone numbers
document.setInstitutionContactPhoneNumber(phoneNumberService.formatNumberIfPossible(document.getInstitutionContactPhoneNumber()));
document.setRequestorPersonPhoneNumber(phoneNumberService.formatNumberIfPossible(document.getRequestorPersonPhoneNumber()));
document.setDeliveryToPhoneNumber(phoneNumberService.formatNumberIfPossible(document.getDeliveryToPhoneNumber()));
// names in KIM are longer than what we store these names at; truncate them to match our data dictionary maxlengths
if (StringUtils.equals(refreshCaller, "kimPersonLookupable")) {
Integer deliveryToNameMaxLength = SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(document.getClass(), PurapPropertyConstants.DELIVERY_TO_NAME);
// KFSPTS-518/KFSUPGRADE-351
if (deliveryToNameMaxLength == null && document instanceof PurchaseOrderAmendmentDocument) {
deliveryToNameMaxLength = SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(PurchaseOrderDocument.class, PurapPropertyConstants.DELIVERY_TO_NAME);
}
if (StringUtils.isNotEmpty(document.getDeliveryToName()) && ObjectUtils.isNotNull(deliveryToNameMaxLength) && document.getDeliveryToName().length() > deliveryToNameMaxLength.intValue()) {
document.setDeliveryToName(document.getDeliveryToName().substring(0, deliveryToNameMaxLength));
GlobalVariables.getMessageMap().clearErrorPath();
GlobalVariables.getMessageMap().addToErrorPath(PurapConstants.DELIVERY_TAB_ERRORS);
GlobalVariables.getMessageMap().putWarning(PurapPropertyConstants.DELIVERY_TO_NAME, PurapKeyConstants.WARNING_DELIVERY_TO_NAME_TRUNCATED);
GlobalVariables.getMessageMap().removeFromErrorPath(PurapConstants.DELIVERY_TAB_ERRORS);
}
Integer requestorNameMaxLength = SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(document.getClass(), PurapPropertyConstants.REQUESTOR_PERSON_NAME);
// KFSPTS-518/KFSUPGRADE-351
if (requestorNameMaxLength == null && document instanceof PurchaseOrderAmendmentDocument) {
requestorNameMaxLength = SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(PurchaseOrderDocument.class, PurapPropertyConstants.REQUESTOR_PERSON_NAME);
}
if (StringUtils.isNotEmpty(document.getRequestorPersonName()) && ObjectUtils.isNotNull(requestorNameMaxLength) && document.getRequestorPersonName().length() > requestorNameMaxLength.intValue()) {
document.setRequestorPersonName(document.getRequestorPersonName().substring(0, requestorNameMaxLength));
GlobalVariables.getMessageMap().clearErrorPath();
GlobalVariables.getMessageMap().addToErrorPath(PurapConstants.ADDITIONAL_TAB_ERRORS);
GlobalVariables.getMessageMap().putWarning(PurapPropertyConstants.REQUESTOR_PERSON_NAME, PurapKeyConstants.WARNING_REQUESTOR_NAME_TRUNCATED);
GlobalVariables.getMessageMap().removeFromErrorPath(PurapConstants.ADDITIONAL_TAB_ERRORS);
}
}
// Refreshing the fields after returning from a vendor lookup in the vendor tab
if (StringUtils.equals(refreshCaller, VendorConstants.VENDOR_LOOKUPABLE_IMPL) && document.getVendorDetailAssignedIdentifier() != null && document.getVendorHeaderGeneratedIdentifier() != null) {
document.setVendorContractGeneratedIdentifier(null);
document.refreshReferenceObject("vendorContract");
// retrieve vendor based on selection from vendor lookup
document.refreshReferenceObject("vendorDetail");
document.templateVendorDetail(document.getVendorDetail());
// KFSPTS-1612 : populate vendor contract name
if (CollectionUtils.isNotEmpty(document.getVendorDetail().getVendorContracts())) {
for (VendorContract vendorContract : document.getVendorDetail().getVendorContracts()) {
if (vendorContract.isActive()) {
document.setVendorContractGeneratedIdentifier(vendorContract.getVendorContractGeneratedIdentifier());
document.refreshReferenceObject("vendorContract");
}
}
}
// populate default address based on selected vendor
VendorAddress defaultAddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(document.getVendorDetail().getVendorAddresses(), document.getVendorDetail().getVendorHeader().getVendorType().getAddressType().getVendorAddressTypeCode(), document.getDeliveryCampusCode());
if (defaultAddress == null) {
GlobalVariables.getMessageMap().putError(VendorPropertyConstants.VENDOR_DOC_ADDRESS, PurapKeyConstants.ERROR_INACTIVE_VENDORADDRESS);
}
document.templateVendorAddress(defaultAddress);
// CU enhancement KFSUPGRDE-348
document.setPurchaseOrderTransmissionMethodCode(((CuVendorAddressExtension) defaultAddress.getExtension()).getPurchaseOrderTransmissionMethodCode());
}
// Refreshing the fields after returning from a contract lookup in the vendor tab
if (StringUtils.equals(refreshCaller, VendorConstants.VENDOR_CONTRACT_LOOKUPABLE_IMPL)) {
if (StringUtils.isNotEmpty(request.getParameter(KFSPropertyConstants.DOCUMENT + "." + PurapPropertyConstants.VENDOR_CONTRACT_ID))) {
// retrieve Contract based on selection from contract lookup
VendorContract refreshVendorContract = new VendorContract();
refreshVendorContract.setVendorContractGeneratedIdentifier(document.getVendorContractGeneratedIdentifier());
refreshVendorContract = (VendorContract) businessObjectService.retrieve(refreshVendorContract);
// retrieve Vendor based on selected contract
document.setVendorHeaderGeneratedIdentifier(refreshVendorContract.getVendorHeaderGeneratedIdentifier());
document.setVendorDetailAssignedIdentifier(refreshVendorContract.getVendorDetailAssignedIdentifier());
document.refreshReferenceObject("vendorDetail");
document.templateVendorDetail(document.getVendorDetail());
// always template contract after vendor to keep contract defaults last
document.templateVendorContract(refreshVendorContract);
// populate default address from selected vendor
VendorAddress defaultAddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(document.getVendorDetail().getVendorAddresses(), document.getVendorDetail().getVendorHeader().getVendorType().getAddressType().getVendorAddressTypeCode(), "");
if (defaultAddress == null) {
GlobalVariables.getMessageMap().putError(VendorPropertyConstants.VENDOR_DOC_ADDRESS, PurapKeyConstants.ERROR_INACTIVE_VENDORADDRESS);
}
document.templateVendorAddress(defaultAddress);
// update internal dollar limit for PO since the contract might affect this value
if (document instanceof PurchaseOrderDocument) {
PurchaseOrderDocument poDoc = (PurchaseOrderDocument) document;
KualiDecimal limit = SpringContext.getBean(PurchaseOrderService.class).getInternalPurchasingDollarLimit(poDoc);
poDoc.setInternalPurchasingLimit(limit);
}
}
}
// Refreshing the fields after returning from an address lookup in the vendor tab
if (StringUtils.equals(refreshCaller, VendorConstants.VENDOR_ADDRESS_LOOKUPABLE_IMPL)) {
if (StringUtils.isNotEmpty(request.getParameter(KFSPropertyConstants.DOCUMENT + "." + PurapPropertyConstants.VENDOR_ADDRESS_ID))) {
// retrieve address based on selection from address lookup
VendorAddress refreshVendorAddress = new VendorAddress();
refreshVendorAddress.setVendorAddressGeneratedIdentifier(document.getVendorAddressGeneratedIdentifier());
refreshVendorAddress = (VendorAddress) businessObjectService.retrieve(refreshVendorAddress);
document.templateVendorAddress(refreshVendorAddress);
}
}
// Refreshing corresponding fields after returning from various kuali lookups
if (StringUtils.equals(refreshCaller, KFSConstants.KUALI_LOOKUPABLE_IMPL)) {
if (request.getParameter("document.deliveryCampusCode") != null) {
// returning from a building or campus lookup on the delivery tab (update billing address)
BillingAddress billingAddress = new BillingAddress();
billingAddress.setBillingCampusCode(document.getDeliveryCampusCode());
Map keys = SpringContext.getBean(PersistenceService.class).getPrimaryKeyFieldValues(billingAddress);
billingAddress = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(BillingAddress.class, keys);
document.templateBillingAddress(billingAddress);
if (request.getParameter("document.deliveryBuildingName") == null) {
// came from campus lookup not building, so clear building
clearDeliveryBuildingInfo(document, true);
} else {
// came from building lookup then turn off "OTHER" and clear room and line2address
document.setDeliveryBuildingOtherIndicator(false);
document.setDeliveryBuildingRoomNumber("");
document.setDeliveryBuildingLine2Address("");
}
} else if (request.getParameter("document.chartOfAccountsCode") != null) {
// returning from a chart/org lookup on the document detail tab (update receiving address)
document.loadReceivingAddress();
} else {
// returning from a building lookup in a capital asset tab location (update location address)
String buildingCodeParam = findBuildingCodeFromCapitalAssetBuildingLookup(request);
if (!StringUtils.isEmpty(buildingCodeParam)) {
PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
updateCapitalAssetLocation(request, purchasingForm, document, buildingCodeParam);
}
}
}
return super.refresh(mapping, form, request, response);
}
use of org.kuali.kfs.module.purap.document.PurchaseOrderDocument in project cu-kfs by CU-CommunityApps.
the class PurchaseOrderDocumentPresentationController method getEditModes.
@Override
public Set<String> getEditModes(Document document) {
Set<String> editModes = super.getEditModes(document);
PurchaseOrderDocument poDocument = (PurchaseOrderDocument) document;
WorkflowDocument workflowDocument = poDocument.getFinancialSystemDocumentHeader().getWorkflowDocument();
String statusCode = poDocument.getApplicationDocumentStatus();
editModes.add(PurchaseOrderEditMode.ASSIGN_SENSITIVE_DATA);
// if the ENABLE_COMMODITY_CODE_IND system parameter is Y then add this edit mode so that the commodity code fields would display on the document.
boolean enableCommodityCode = SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(KfsParameterConstants.PURCHASING_DOCUMENT.class, PurapParameterConstants.ENABLE_COMMODITY_CODE_IND);
if (enableCommodityCode) {
editModes.add(PurchaseOrderEditMode.ENABLE_COMMODITY_CODE);
}
if (canFirstTransmitPrintPo(poDocument)) {
editModes.add(PurchaseOrderEditMode.PRINT_PURCHASE_ORDER);
}
if (canPreviewPrintPo(poDocument)) {
editModes.add(PurchaseOrderEditMode.PREVIEW_PRINT_PURCHASE_ORDER);
}
if (canResendCxml(poDocument)) {
editModes.add(PurchaseOrderEditMode.RESEND_PURCHASE_ORDER);
}
// if vendor has been selected from DB, certain vendor fields are not allowed to be edited
if (ObjectUtils.isNotNull(poDocument.getVendorHeaderGeneratedIdentifier())) {
editModes.add(PurchaseOrderEditMode.LOCK_VENDOR_ENTRY);
}
// if B2B purchase order, certain fields are not allowed to be edited
if (RequisitionSources.B2B.equals(poDocument.getRequisitionSourceCode())) {
editModes.add(PurchaseOrderEditMode.LOCK_B2B_ENTRY);
}
// if not B2B requisition, users can edit the posting year if within a given amount of time set in a parameter
if (!RequisitionSources.B2B.equals(poDocument.getRequisitionSourceCode()) && SpringContext.getBean(PurapService.class).allowEncumberNextFiscalYear() && (PurchaseOrderStatuses.APPDOC_IN_PROCESS.equals(statusCode) || PurchaseOrderStatuses.APPDOC_WAITING_FOR_VENDOR.equals(statusCode) || PurchaseOrderStatuses.APPDOC_WAITING_FOR_DEPARTMENT.equals(statusCode) || PurchaseOrderStatuses.APPDOC_QUOTE.equals(statusCode) || PurchaseOrderStatuses.APPDOC_AWAIT_PURCHASING_REVIEW.equals(statusCode))) {
editModes.add(PurchaseOrderEditMode.ALLOW_POSTING_YEAR_ENTRY);
}
// check if purap tax is enabled
boolean salesTaxInd = SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(KfsParameterConstants.PURCHASING_DOCUMENT.class, PurapParameterConstants.ENABLE_SALES_TAX_IND);
if (salesTaxInd) {
editModes.add(PurapAuthorizationConstants.PURAP_TAX_ENABLED);
if (poDocument.isUseTaxIndicator()) {
// if use tax, don't allow editing of tax fields
editModes.add(PurchaseOrderEditMode.LOCK_TAX_AMOUNT_ENTRY);
} else {
// display the "clear all taxes" button if doc is not using use tax
editModes.add(PurchaseOrderEditMode.CLEAR_ALL_TAXES);
}
}
// set display mode for Receiving Address section according to parameter value
boolean displayReceivingAddress = SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(KfsParameterConstants.PURCHASING_DOCUMENT.class, PurapParameterConstants.ENABLE_RECEIVING_ADDRESS_IND);
if (displayReceivingAddress) {
editModes.add(PurchaseOrderEditMode.DISPLAY_RECEIVING_ADDRESS);
}
// if (workflowDocument.isInitiated() || workflowDocument.isSaved()) {
if (PurchaseOrderStatuses.APPDOC_IN_PROCESS.equals(statusCode) || PurchaseOrderStatuses.APPDOC_WAITING_FOR_VENDOR.equals(statusCode) || PurchaseOrderStatuses.APPDOC_WAITING_FOR_DEPARTMENT.equals(statusCode) || PurchaseOrderStatuses.APPDOC_QUOTE.equals(statusCode)) {
editModes.add(PurchaseOrderEditMode.PRE_ROUTE_CHANGEABLE);
}
// INTERNAL PURCHASING ROUTE LEVEL - Approvers can edit full detail on Purchase Order except they cannot change the CHART/ORG.
if (poDocument.isDocumentStoppedInRouteNode(PurapConstants.PurchaseOrderStatuses.NODE_CONTRACT_MANAGEMENT)) {
editModes.add(PurchaseOrderEditMode.LOCK_INTERNAL_PURCHASING_ENTRY);
}
// Set display mode for Split PO.
if (poDocument.isPendingSplit()) {
editModes.add(PurchaseOrderEditMode.SPLITTING_ITEM_SELECTION);
}
// KFSPTS-985, KFSUPGRADE-75
if (document instanceof PurchaseOrderDocument && !editModes.contains(RequisitionEditMode.DISABLE_SETUP_ACCT_DISTRIBUTION) && !hasEmptyAcctline((PurchaseOrderDocument) document)) {
editModes.add(RequisitionEditMode.DISABLE_SETUP_ACCT_DISTRIBUTION);
}
return editModes;
}
use of org.kuali.kfs.module.purap.document.PurchaseOrderDocument in project cu-kfs by CU-CommunityApps.
the class CuPurchaseOrderServiceImpl method createPurchaseOrderDocumentFromSourceDocument.
@Override
protected PurchaseOrderDocument createPurchaseOrderDocumentFromSourceDocument(PurchaseOrderDocument sourceDocument, String docType) throws WorkflowException {
PurchaseOrderDocument newDocument = super.createPurchaseOrderDocumentFromSourceDocument(sourceDocument, docType);
resetOverrideCodesOnItemAccountingLines(newDocument);
return newDocument;
}
use of org.kuali.kfs.module.purap.document.PurchaseOrderDocument in project cu-kfs by CU-CommunityApps.
the class CuElectronicInvoiceHelperServiceImpl method validateVendorDetails.
protected void validateVendorDetails(ElectronicInvoiceRejectDocument rejectDocument) {
boolean vendorFound = false;
if (StringUtils.isNotEmpty(rejectDocument.getVendorDunsNumber())) {
// KFSUPGRADE-479 : retrieve vendor from po vendor.
PurchaseOrderDocument po = rejectDocument.getCurrentPurchaseOrderDocument();
VendorDetail vendorDetail = null;
if (po != null) {
vendorDetail = vendorService.getVendorDetail(po.getVendorHeaderGeneratedIdentifier(), po.getVendorDetailAssignedIdentifier());
if (vendorDetail == null) {
vendorDetail = vendorService.getVendorByDunsNumber(rejectDocument.getVendorDunsNumber());
}
} else {
vendorDetail = vendorService.getVendorByDunsNumber(rejectDocument.getVendorDunsNumber());
}
if (vendorDetail != null) {
LOG.info("Vendor [" + vendorDetail.getVendorNumber() + "] match found for the DUNS - " + rejectDocument.getVendorDunsNumber());
rejectDocument.setVendorHeaderGeneratedIdentifier(vendorDetail.getVendorHeaderGeneratedIdentifier());
rejectDocument.setVendorDetailAssignedIdentifier(vendorDetail.getVendorDetailAssignedIdentifier());
rejectDocument.setVendorDetail(vendorDetail);
vendorFound = true;
}
}
if (!vendorFound) {
rejectDocument.setVendorHeaderGeneratedIdentifier(null);
rejectDocument.setVendorDetailAssignedIdentifier(null);
rejectDocument.setVendorDetail(null);
}
String newDocumentDesc = generateRejectDocumentDescription(rejectDocument);
rejectDocument.getDocumentHeader().setDocumentDescription(newDocumentDesc);
}
Aggregations