use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherExtractionHelperServiceImpl method createPaymentGroup.
@Override
public PaymentGroup createPaymentGroup(DisbursementVoucherDocument document, Date processRunDate) {
if (LOG.isDebugEnabled()) {
LOG.debug("createPaymentGroupForDisbursementVoucher() started");
}
PaymentGroup pg = new PaymentGroup();
pg.setCombineGroups(Boolean.TRUE);
pg.setCampusAddress(Boolean.FALSE);
CuDisbursementVoucherPayeeDetail pd = businessObjectService.findBySinglePrimaryKey(CuDisbursementVoucherPayeeDetail.class, document.getDocumentNumber());
String rc = pd.getDisbVchrPaymentReasonCode();
if (KFSConstants.PaymentPayeeTypes.CUSTOMER.equals(document.getDvPayeeDetail().getDisbursementVoucherPayeeTypeCode())) {
pg.setPayeeIdTypeCd(PdpConstants.PayeeIdTypeCodes.CUSTOMER);
pg.setTaxablePayment(Boolean.FALSE);
} else // If the payee is an employee, set these flags accordingly
if ((pd.isVendor() && SpringContext.getBean(VendorService.class).isVendorInstitutionEmployee(pd.getDisbVchrVendorHeaderIdNumberAsInteger())) || document.getDvPayeeDetail().isEmployee()) {
pg.setEmployeeIndicator(Boolean.TRUE);
pg.setPayeeIdTypeCd(PdpConstants.PayeeIdTypeCodes.EMPLOYEE);
pg.setTaxablePayment(!/*REFACTORME*/
getParameterEvaluatorService().getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_PAYMENT_REASONS_PARM_NM, rc).evaluationSucceeds() && !getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, DisbursementVoucherConstants.PAYMENT_REASON_CODE_RENTAL_PAYMENT_PARM_NM).equals(rc) && !getParameterService().getParameterValueAsString(DisbursementVoucherDocument.class, DisbursementVoucherConstants.PAYMENT_REASON_CODE_ROYALTIES_PARM_NM).equals(rc));
} else // If the payee is an alumni or student, set these flags accordingly
if (pd.isStudent() || pd.isAlumni()) {
pg.setPayeeIdTypeCd(PdpConstants.PayeeIdTypeCodes.ENTITY);
// All payments are taxable except research participant, rental & royalties
pg.setTaxablePayment(!SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(CuDisbursementVoucherDocument.class, DisbursementVoucherConstants.RESEARCH_PAYMENT_REASONS_PARM_NM, rc).evaluationSucceeds() && !CuDisbursementVoucherConstants.PaymentReasonCodes.RENTAL_PAYMENT.equals(rc) && !CuDisbursementVoucherConstants.PaymentReasonCodes.ROYALTIES.equals(rc));
} else {
// These are taxable
VendorDetail vendDetail = getVendorService().getVendorDetail(pd.getDisbVchrVendorHeaderIdNumberAsInteger(), pd.getDisbVchrVendorDetailAssignedIdNumberAsInteger());
String vendorOwnerCode = vendDetail.getVendorHeader().getVendorOwnershipCode();
String vendorOwnerCategoryCode = vendDetail.getVendorHeader().getVendorOwnershipCategoryCode();
String payReasonCode = pd.getDisbVchrPaymentReasonCode();
pg.setPayeeIdTypeCd(PdpConstants.PayeeIdTypeCodes.VENDOR_ID);
// Assume it is not taxable until proven otherwise
pg.setTaxablePayment(Boolean.FALSE);
pg.setPayeeOwnerCd(vendorOwnerCode);
ParameterEvaluator parameterEvaluator1 = /*REFACTORME*/
getParameterEvaluatorService().getParameterEvaluator(DvToPdpExtractStep.class, PdpParameterConstants.TAXABLE_PAYMENT_REASON_CODES_BY_OWNERSHIP_CODES_PARAMETER_NAME, PdpParameterConstants.NON_TAXABLE_PAYMENT_REASON_CODES_BY_OWNERSHIP_CODES_PARAMETER_NAME, vendorOwnerCode, payReasonCode);
ParameterEvaluator parameterEvaluator2 = /*REFACTORME*/
getParameterEvaluatorService().getParameterEvaluator(DvToPdpExtractStep.class, PdpParameterConstants.TAXABLE_PAYMENT_REASON_CODES_BY_CORPORATION_OWNERSHIP_TYPE_CATEGORY_PARAMETER_NAME, PdpParameterConstants.NON_TAXABLE_PAYMENT_REASON_CODES_BY_CORPORATION_OWNERSHIP_TYPE_CATEGORY_PARAMETER_NAME, vendorOwnerCategoryCode, payReasonCode);
if (parameterEvaluator1.evaluationSucceeds()) {
pg.setTaxablePayment(Boolean.TRUE);
} else if (getParameterService().getParameterValueAsString(DvToPdpExtractStep.class, PdpParameterConstants.CORPORATION_OWNERSHIP_TYPE_PARAMETER_NAME).equals("CP") && StringUtils.isEmpty(vendorOwnerCategoryCode) && /*REFACTORME*/
getParameterEvaluatorService().getParameterEvaluator(DvToPdpExtractStep.class, PdpParameterConstants.TAXABLE_PAYMENT_REASON_CODES_FOR_BLANK_CORPORATION_OWNERSHIP_TYPE_CATEGORIES_PARAMETER_NAME, payReasonCode).evaluationSucceeds()) {
pg.setTaxablePayment(Boolean.TRUE);
} else if (getParameterService().getParameterValueAsString(DvToPdpExtractStep.class, PdpParameterConstants.CORPORATION_OWNERSHIP_TYPE_PARAMETER_NAME).equals("CP") && !StringUtils.isEmpty(vendorOwnerCategoryCode) && parameterEvaluator2.evaluationSucceeds()) {
pg.setTaxablePayment(Boolean.TRUE);
}
}
pg.setCity(pd.getDisbVchrPayeeCityName());
pg.setCountry(pd.getDisbVchrPayeeCountryCode());
pg.setLine1Address(pd.getDisbVchrPayeeLine1Addr());
pg.setLine2Address(pd.getDisbVchrPayeeLine2Addr());
pg.setPayeeName(pd.getDisbVchrPayeePersonName());
pg.setPayeeId(pd.getDisbVchrPayeeIdNumber());
pg.setState(pd.getDisbVchrPayeeStateCode());
pg.setZipCd(pd.getDisbVchrPayeeZipCode());
pg.setPaymentDate(document.getDisbursementVoucherDueDate());
pg.setProcessImmediate(document.isImmediatePaymentIndicator());
pg.setPymtAttachment(document.isDisbVchrAttachmentCode());
pg.setPymtSpecialHandling(document.isDisbVchrSpecialHandlingCode());
pg.setNraPayment(pd.isDisbVchrAlienPaymentCode());
pg.setBankCode(document.getDisbVchrBankCode());
pg.setPaymentStatusCode(PdpConstants.PaymentStatusCodes.OPEN);
// now add the payment detail
final PaymentDetail paymentDetail = buildPaymentDetail(document, processRunDate);
pg.addPaymentDetails(paymentDetail);
paymentDetail.setPaymentGroup(pg);
return pg;
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherPayeeInitiatorValidation method validate.
public boolean validate(AttributedDocumentEvent event) {
LOG.debug("validate start");
boolean isValid = true;
CuDisbursementVoucherDocument document = (CuDisbursementVoucherDocument) accountingDocumentForValidation;
CuDisbursementVoucherPayeeDetail payeeDetail = document.getDvPayeeDetail();
MessageMap errors = GlobalVariables.getMessageMap();
errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
String uuid = null;
// If payee is a vendor, then look up SSN and look for SSN in the employee table
if (payeeDetail.isVendor() && StringUtils.isNotBlank(payeeDetail.getDisbVchrVendorHeaderIdNumber())) {
VendorDetail dvVendor = retrieveVendorDetail(payeeDetail.getDisbVchrVendorHeaderIdNumberAsInteger(), payeeDetail.getDisbVchrVendorDetailAssignedIdNumberAsInteger());
// if the vendor tax type is SSN, then check the tax number
if (dvVendor != null && TAX_TYPE_SSN.equals(dvVendor.getVendorHeader().getVendorTaxTypeCode())) {
// check ssn against employee table
Person user = retrieveEmployeeBySSN(dvVendor.getVendorHeader().getVendorTaxNumber());
if (user != null) {
uuid = user.getPrincipalId();
}
}
} else if (payeeDetail.isEmployee()) {
Person employee = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeDetail.getDisbVchrEmployeeIdNumber());
uuid = employee.getPrincipalId();
} else if (payeeDetail.isStudent() || payeeDetail.isAlumni()) {
uuid = payeeDetail.getDisbVchrPayeeIdNumber();
}
// If a uuid was found for payee, check it against the initiator uuid
if (StringUtils.isNotBlank(uuid)) {
Person initUser = getInitiator(document);
if (uuid.equals(initUser.getPrincipalId())) {
errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_PAYEE_INITIATOR);
isValid = false;
}
}
errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
return isValid;
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class DisbursementVoucherAction method refreshAfterPayeeSelection.
// do refresh after a payee is selected
protected ActionForward refreshAfterPayeeSelection(ActionMapping mapping, DisbursementVoucherForm dvForm, HttpServletRequest request) {
String refreshCaller = dvForm.getRefreshCaller();
DisbursementVoucherDocument document = (DisbursementVoucherDocument) dvForm.getDocument();
boolean isPayeeLookupable = KFSConstants.KUALI_DISBURSEMENT_PAYEE_LOOKUPABLE_IMPL.equals(refreshCaller);
boolean isAddressLookupable = KFSConstants.KUALI_VENDOR_ADDRESS_LOOKUPABLE_IMPL.equals(refreshCaller);
boolean isKualiLookupable = KFSConstants.KUALI_LOOKUPABLE_IMPL.equals(refreshCaller);
// if a cancel occurred on address lookup we need to reset the payee id and type, rest of fields will still have correct information
if (refreshCaller == null && hasFullEdit(document)) {
dvForm.setPayeeIdNumber(dvForm.getTempPayeeIdNumber());
dvForm.setHasMultipleAddresses(false);
document.getDvPayeeDetail().setDisbVchrPayeeIdNumber(dvForm.getTempPayeeIdNumber());
document.getDvPayeeDetail().setDisbursementVoucherPayeeTypeCode(dvForm.getOldPayeeType());
return null;
}
// do not execute the further refreshing logic if the refresh caller is not a lookupable
if (!isPayeeLookupable && !isAddressLookupable && !isKualiLookupable) {
return null;
}
// do not execute the further refreshing logic if a payee is not selected
String payeeIdNumber = document.getDvPayeeDetail().getDisbVchrPayeeIdNumber();
if (payeeIdNumber == null) {
return null;
}
dvForm.setPayeeIdNumber(payeeIdNumber);
dvForm.setHasMultipleAddresses(false);
// determine whether the selected vendor has multiple addresses. If so, redirect to the address selection screen
if (isPayeeLookupable && dvForm.isVendor()) {
VendorDetail refreshVendorDetail = new VendorDetail();
refreshVendorDetail.setVendorNumber(payeeIdNumber);
refreshVendorDetail = (VendorDetail) SpringContext.getBean(BusinessObjectService.class).retrieve(refreshVendorDetail);
VendorAddress defaultVendorAddress = null;
if (refreshVendorDetail != null) {
List<VendorAddress> vendorAddresses = refreshVendorDetail.getVendorAddresses();
boolean hasMultipleAddresses = vendorAddresses != null && vendorAddresses.size() > 1;
dvForm.setHasMultipleAddresses(hasMultipleAddresses);
if (vendorAddresses != null) {
defaultVendorAddress = vendorAddresses.get(0);
}
}
if (dvForm.hasMultipleAddresses()) {
return renderVendorAddressSelection(mapping, request, dvForm);
} else if (defaultVendorAddress != null) {
setupPayeeAsVendor(dvForm, payeeIdNumber, defaultVendorAddress.getVendorAddressGeneratedIdentifier().toString());
}
return null;
}
String payeeAddressIdentifier = request.getParameter(KFSPropertyConstants.VENDOR_ADDRESS_GENERATED_ID);
if (isAddressLookupable && StringUtils.isNotBlank(payeeAddressIdentifier)) {
setupPayeeAsVendor(dvForm, payeeIdNumber, payeeAddressIdentifier);
}
if (isPayeeLookupable && dvForm.isEmployee()) {
this.setupPayeeAsEmployee(dvForm, payeeIdNumber);
}
// check for multiple custom addresses
if (isPayeeLookupable && dvForm.isCustomer()) {
AccountsReceivableCustomer customer = SpringContext.getBean(AccountsReceivableModuleService.class).findCustomer(payeeIdNumber);
AccountsReceivableCustomerAddress defaultCustomerAddress = null;
if (customer != null) {
defaultCustomerAddress = customer.getPrimaryAddress();
Map<String, String> addressSearch = new HashMap<String, String>();
addressSearch.put(KFSPropertyConstants.CUSTOMER_NUMBER, payeeIdNumber);
List<AccountsReceivableCustomerAddress> customerAddresses = (List<AccountsReceivableCustomerAddress>) SpringContext.getBean(AccountsReceivableModuleService.class).searchForCustomerAddresses(addressSearch);
if (customerAddresses != null && !customerAddresses.isEmpty()) {
if (customerAddresses.size() > 1) {
dvForm.setHasMultipleAddresses(true);
} else if (defaultCustomerAddress == null) {
defaultCustomerAddress = customerAddresses.get(0);
}
}
}
if (dvForm.hasMultipleAddresses()) {
return renderCustomerAddressSelection(mapping, request, dvForm);
} else if (defaultCustomerAddress != null) {
setupPayeeAsCustomer(dvForm, payeeIdNumber, defaultCustomerAddress.getCustomerAddressIdentifier().toString());
}
}
String customerAddressIdentifier = request.getParameter(KFSPropertyConstants.CUSTOMER_ADDRESS_IDENTIFIER);
if (isKualiLookupable && StringUtils.isNotBlank(customerAddressIdentifier)) {
setupPayeeAsCustomer(dvForm, payeeIdNumber, customerAddressIdentifier);
}
String paymentReasonCode = document.getDvPayeeDetail().getDisbVchrPaymentReasonCode();
addPaymentCodeWarningMessage(dvForm, paymentReasonCode);
return null;
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class VendorBatchServiceImpl method addVendor.
/*
* create vendor document and route
*/
private String addVendor(VendorBatchDetail vendorBatch) {
GlobalVariables.setMessageMap(new MessageMap());
// create and route doc as system user
// GlobalVariables.setUserSession(new UserSession("kfs"));
LOG.info("addVendor " + vendorBatch.getLogData());
try {
MaintenanceDocument vendorDoc = (MaintenanceDocument) documentService.getNewDocument(VENDOR_DOCUMENT_TYPE_NAME);
vendorDoc.getDocumentHeader().setDocumentDescription(getDocumentDescription(vendorBatch, true));
VendorMaintainableImpl vImpl = (VendorMaintainableImpl) vendorDoc.getNewMaintainableObject();
vImpl.setMaintenanceAction(KFSConstants.MAINTENANCE_NEW_ACTION);
VendorDetail vDetail = (VendorDetail) vImpl.getBusinessObject();
setupVendorDetailFields(vDetail, vendorBatch);
setupInsuranceTracking((VendorDetailExtension) vDetail.getExtension(), vendorBatch);
vDetail.setVendorAddresses(getVendorAddresses(vendorBatch.getVendorAddresses(), vDetail));
vDetail.setVendorContacts(getVendorContacts(vendorBatch.getVendorContacts()));
VendorHeader vHeader = vDetail.getVendorHeader();
setupVendorHeaderFields(vHeader, vendorBatch);
vHeader.setVendorSupplierDiversities(getVendorSupplierDiversities(vendorBatch.getVendorSupplierDiversities()));
vDetail.setVendorHeader(vHeader);
vImpl.setBusinessObject(vDetail);
vendorDoc.setNewMaintainableObject(vImpl);
addNotes(vendorDoc, vendorBatch);
if (StringUtils.isNotBlank(vendorBatch.getAttachmentFiles())) {
loadDocumentAttachments(vendorDoc, Arrays.asList(vendorBatch.getAttachmentFiles().split(COLLECTION_FIELD_DELIMITER)));
}
documentService.routeDocument(vendorDoc, KFSConstants.EMPTY_STRING, null);
return vendorDoc.getDocumentNumber();
} catch (Exception e) {
LOG.info("addVendor STE " + e.getStackTrace() + e.toString());
return getFailRequestMessage(e);
}
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class VendorBatchServiceImpl method updateVendor.
/*
* update vendor record. vendor number must be valid.
*/
private String updateVendor(VendorBatchDetail vendorBatch) {
GlobalVariables.setMessageMap(new MessageMap());
try {
MaintenanceDocument vendorDoc = (MaintenanceDocument) documentService.getNewDocument(VENDOR_DOCUMENT_TYPE_NAME);
vendorDoc.getDocumentHeader().setDocumentDescription(getDocumentDescription(vendorBatch, false));
LOG.info("updateVendor " + vendorBatch.getLogData());
VendorDetail vendor = cuVendorService.getByVendorNumber(vendorBatch.getVendorNumber());
if (vendor != null) {
// Vendor does not eist
VendorMaintainableImpl oldVendorImpl = (VendorMaintainableImpl) vendorDoc.getOldMaintainableObject();
oldVendorImpl.setBusinessObject(vendor);
} else {
// Vendor does not eist
return "Failed request : Vendor " + vendorBatch.getVendorNumber() + " Not Found.";
}
VendorMaintainableImpl vImpl = (VendorMaintainableImpl) vendorDoc.getNewMaintainableObject();
vImpl.setMaintenanceAction(KFSConstants.MAINTENANCE_EDIT_ACTION);
vendorDoc.getNewMaintainableObject().setDocumentNumber(vendorDoc.getDocumentNumber());
vImpl.setBusinessObject((VendorDetail) ObjectUtils.deepCopy(vendor));
VendorDetail vDetail = (VendorDetail) vImpl.getBusinessObject();
setupVendorDetailFields(vDetail, vendorBatch);
setupInsuranceTracking((VendorDetailExtension) vDetail.getExtension(), vendorBatch);
updateVendorAddresses(vendorBatch.getVendorAddresses(), vendor, vDetail);
updateVendorContacts(vendorBatch.getVendorContacts(), vendor, vDetail);
updateVendorSupplierDiversitys(vendorBatch.getVendorSupplierDiversities(), vendor, vDetail);
setupVendorHeaderFields(vDetail.getVendorHeader(), vendorBatch);
vImpl.setBusinessObject(vDetail);
vendorDoc.setNewMaintainableObject(vImpl);
addNotes(vendorDoc, vendorBatch);
// attachment
if (StringUtils.isNotBlank(vendorBatch.getAttachmentFiles())) {
loadDocumentAttachments(vendorDoc, Arrays.asList(vendorBatch.getAttachmentFiles().split(COLLECTION_FIELD_DELIMITER)));
}
// end attachment
documentService.routeDocument(vendorDoc, KFSConstants.EMPTY_STRING, null);
return vendorDoc.getDocumentNumber();
} catch (Exception e) {
LOG.info("updateVendor STE " + e.getStackTrace() + e.toString());
return getFailRequestMessage(e);
}
}
Aggregations