use of org.kuali.kfs.vnd.service.PhoneNumberService in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method refresh.
@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()));
// max lengths
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) {
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) {
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.isNotEmpty(buildingCodeParam)) {
PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
updateCapitalAssetLocation(request, purchasingForm, document, buildingCodeParam);
}
}
}
return super.refresh(mapping, form, request, response);
}
use of org.kuali.kfs.vnd.service.PhoneNumberService in project cu-kfs by CU-CommunityApps.
the class PurchaseOrderTransmissionMethodDataRulesServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
poTransMethodSataRulesService = new PurchaseOrderTransmissionMethodDataRulesServiceImpl();
PostalCodeValidationService postalCodeValidationSerivce = new testablePostalCodeValidationServiceImpl();
LocationService mockLocationService = mock(LocationService.class);
when(mockLocationService.getState(COUNTRY, STATE)).thenReturn(makeState());
((PostalCodeValidationServiceImpl) postalCodeValidationSerivce).setLocationService(mockLocationService);
((PurchaseOrderTransmissionMethodDataRulesServiceImpl) this.poTransMethodSataRulesService).setPostalCodeValidationService(postalCodeValidationSerivce);
PhoneNumberService phoneNumberService = new testablePhoneNumberServiceImpl();
((PurchaseOrderTransmissionMethodDataRulesServiceImpl) this.poTransMethodSataRulesService).setPhoneNumberService(phoneNumberService);
}
use of org.kuali.kfs.vnd.service.PhoneNumberService in project cu-kfs by CU-CommunityApps.
the class DisbursementVoucherDocument method initiateDocument.
/**
* generic, shared logic used to initiate a dv document
*/
public void initiateDocument() {
PhoneNumberService phoneNumberService = SpringContext.getBean(PhoneNumberService.class);
Person currentUser = GlobalVariables.getUserSession().getPerson();
setDisbVchrContactPersonName(currentUser.getName());
if (!phoneNumberService.isDefaultFormatPhoneNumber(currentUser.getPhoneNumber())) {
setDisbVchrContactPhoneNumber(phoneNumberService.formatNumberIfPossible(currentUser.getPhoneNumber()));
} else {
setDisbVchrContactPhoneNumber(currentUser.getPhoneNumber());
}
setDisbVchrContactEmailId(currentUser.getEmailAddress());
ChartOrgHolder chartOrg = SpringContext.getBean(org.kuali.kfs.sys.service.FinancialSystemUserService.class).getPrimaryOrganization(currentUser, KFSConstants.CoreModuleNamespaces.FINANCIAL);
// the campus code via the business object service.
if (chartOrg != null && chartOrg.getOrganization() != null) {
setCampusCode(chartOrg.getOrganization().getOrganizationPhysicalCampusCode());
} else {
// A valid campus code was not found; therefore, use the default affiliated campus code.
String affiliatedCampusCode = currentUser.getCampusCode();
setCampusCode(affiliatedCampusCode);
}
// due date
Calendar calendar = getDateTimeService().getCurrentCalendar();
calendar.add(Calendar.DAY_OF_MONTH, 1);
setDisbursementVoucherDueDate(new Date(calendar.getTimeInMillis()));
// default doc location
if (StringUtils.isBlank(getDisbursementVoucherDocumentationLocationCode())) {
setDisbursementVoucherDocumentationLocationCode(getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, FPParameterConstants.DEFAULT_DOC_LOCATION));
}
// default bank code
Bank defaultBank = SpringContext.getBean(BankService.class).getDefaultBankByDocType(this.getClass());
if (defaultBank != null) {
this.disbVchrBankCode = defaultBank.getBankCode();
this.bank = defaultBank;
}
}
use of org.kuali.kfs.vnd.service.PhoneNumberService in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherDocument method initiateDocument.
public void initiateDocument() {
PhoneNumberService phoneNumberService = SpringContext.getBean(PhoneNumberService.class);
Person currentUser = GlobalVariables.getUserSession().getPerson();
setDisbVchrContactPersonName(currentUser.getName());
setDisbVchrContactEmailId(currentUser.getEmailAddressUnmasked());
String phoneNumber = currentUser.getPhoneNumber();
if (StringUtils.isNotBlank(phoneNumber) && !StringUtils.equalsIgnoreCase("null", phoneNumber)) {
if (!phoneNumberService.isDefaultFormatPhoneNumber(currentUser.getPhoneNumber())) {
setDisbVchrContactPhoneNumber(phoneNumberService.formatNumberIfPossible(currentUser.getPhoneNumber()));
} else if (StringUtils.equalsIgnoreCase(phoneNumber, "null")) {
// do nothing... we don't want phone number set to invalid value
} else {
setDisbVchrContactPhoneNumber(phoneNumber);
}
}
if (!phoneNumberService.isDefaultFormatPhoneNumber(currentUser.getPhoneNumber())) {
setDisbVchrContactPhoneNumber(phoneNumberService.formatNumberIfPossible(currentUser.getPhoneNumber()));
}
setDisbVchrContactEmailId(currentUser.getEmailAddress());
ChartOrgHolder chartOrg = SpringContext.getBean(org.kuali.kfs.sys.service.FinancialSystemUserService.class).getPrimaryOrganization(currentUser, KFSConstants.CoreModuleNamespaces.FINANCIAL);
// the campus code via the business object service.
if (chartOrg != null && chartOrg.getOrganization() != null) {
setCampusCode(chartOrg.getOrganization().getOrganizationPhysicalCampusCode());
} else {
// A valid campus code was not found; therefore, use the default affiliated campus code.
String affiliatedCampusCode = currentUser.getCampusCode();
setCampusCode(affiliatedCampusCode);
}
setDisbursementVoucherDueDate(getCuDisbursementVoucherDefaultDueDateService().findDefaultDueDate());
// default doc location
if (StringUtils.isBlank(getDisbursementVoucherDocumentationLocationCode())) {
setDisbursementVoucherDocumentationLocationCode(getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, FPParameterConstants.DEFAULT_DOC_LOCATION));
}
// default bank code
Bank defaultBank = SpringContext.getBean(BankService.class).getDefaultBankByDocType(this.getClass());
if (defaultBank != null) {
this.disbVchrBankCode = defaultBank.getBankCode();
this.bank = defaultBank;
}
}
Aggregations