use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class DisbursementVoucherAction method setupPayeeAsVendor.
/**
* setup the payee as a vendor with the given id number and address id
*/
protected void setupPayeeAsVendor(DisbursementVoucherForm dvForm, String payeeIdNumber, String payeeAddressIdentifier) {
VendorDetail vendorDetail = new VendorDetail();
vendorDetail.setVendorNumber(payeeIdNumber);
vendorDetail = (VendorDetail) SpringContext.getBean(BusinessObjectService.class).retrieve(vendorDetail);
VendorAddress vendorAddress = new VendorAddress();
if (StringUtils.isNotBlank(payeeAddressIdentifier)) {
try {
vendorAddress.setVendorAddressGeneratedIdentifier(new Integer(payeeAddressIdentifier));
vendorAddress = (VendorAddress) SpringContext.getBean(BusinessObjectService.class).retrieve(vendorAddress);
dvForm.setTempPayeeIdNumber(payeeIdNumber);
dvForm.setOldPayeeType(KFSConstants.PaymentPayeeTypes.VENDOR);
} catch (Exception e) {
LOG.error("Exception while attempting to retrieve vendor address for vendor address id " + payeeAddressIdentifier + ": " + e);
}
}
((DisbursementVoucherDocument) dvForm.getDocument()).templateVendor(vendorDetail, vendorAddress);
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class CuVendorRule method processAddCollectionLineBusinessRules.
public boolean processAddCollectionLineBusinessRules(MaintenanceDocument document, String collectionName, PersistableBusinessObject bo) {
boolean success = super.processAddCollectionLineBusinessRules(document, collectionName, bo);
if (collectionName.equals(VendorConstants.VENDOR_HEADER_ATTR + "." + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES)) {
VendorDetail vendorDetail = (VendorDetail) document.getDocumentBusinessObject();
VendorHeader vendorHeader = vendorDetail.getVendorHeader();
List<VendorSupplierDiversity> vendorSupplierDiversities = vendorHeader.getVendorSupplierDiversities();
if (vendorSupplierDiversities.size() > 0) {
int i = 0;
for (VendorSupplierDiversity vendor : vendorSupplierDiversities) {
if (((CuVendorSupplierDiversityExtension) vendor.getExtension()).getVendorSupplierDiversityExpirationDate() == null) {
success = false;
putFieldError(VendorConstants.VENDOR_HEADER_ATTR + "." + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES + "[" + i + "]." + CUVendorPropertyConstants.SUPPLIER_DIVERSITY_EXPRIATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_SUPPLIER_DIVERSITY_DATE_BLANK);
} else if (((CuVendorSupplierDiversityExtension) vendor.getExtension()).getVendorSupplierDiversityExpirationDate().before(new Date())) {
// Only check expiration date on new vendors
if (document.isNew()) {
success = false;
putFieldError(VendorConstants.VENDOR_HEADER_ATTR + "." + VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES + "[" + i + "]." + CUVendorPropertyConstants.SUPPLIER_DIVERSITY_EXPRIATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_SUPPLIER_DIVERSITY_DATE_IN_PAST);
}
}
i++;
}
}
if (!success) {
return success;
}
}
if (collectionName.equals("vendorCommodities")) {
VendorCommodityCode codeToBeValidated = (VendorCommodityCode) bo;
CommodityCode persistedCommodity = commodityCodeService.getByPrimaryId(codeToBeValidated.getPurchasingCommodityCode());
if (persistedCommodity == null) {
// a commodity code entered by a user does not exist
putFieldError("add.vendorCommodities.purchasingCommodityCode", CUVendorKeyConstants.ERROR_VENDOR_COMMODITY_CODE_DOES_NOT_EXIST, codeToBeValidated.getPurchasingCommodityCode());
success = false;
}
if (codeToBeValidated.isCommodityDefaultIndicator()) {
VendorDetail vendorDetail = (VendorDetail) document.getDocumentBusinessObject();
List<VendorCommodityCode> vendorCommodities = vendorDetail.getVendorCommodities();
Iterator<VendorCommodityCode> commodities = vendorCommodities.iterator();
int indice = 0;
while (commodities.hasNext()) {
VendorCommodityCode commodity = (VendorCommodityCode) commodities.next();
if (commodity.isCommodityDefaultIndicator()) {
// more than one "default" commodity code has been specified
putFieldError("add.vendorCommodities.commodityDefaultIndicator", CUVendorKeyConstants.ERROR_DEFAULT_VENDOR_COMMODITY_CODE_ALREADY_EXISTS, Integer.toString(indice));
success = false;
}
indice++;
}
}
VendorDetail vendorDetail = (VendorDetail) document.getDocumentBusinessObject();
boolean commodityAlreadyAssignedToThisVendor = false;
Iterator<VendorCommodityCode> codes = vendorDetail.getVendorCommodities().iterator();
while (codes.hasNext()) {
VendorCommodityCode vcc = codes.next();
if (vcc.getPurchasingCommodityCode().equals(codeToBeValidated.getPurchasingCommodityCode())) {
commodityAlreadyAssignedToThisVendor = true;
break;
}
}
if (commodityAlreadyAssignedToThisVendor) {
putFieldError("add.vendorCommodities.purchasingCommodityCode", CUVendorKeyConstants.ERROR_VENDOR_COMMODITY_CODE_ALREADY_ASSIGNED_TO_VENDOR);
success = false;
}
return success;
}
return success;
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class CuVendorRule method checkWorkmansCompAmountAndExpiration.
protected boolean checkWorkmansCompAmountAndExpiration(MaintenanceDocument document) {
boolean success = true;
VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
VendorDetailExtension vendorDetailExt = ((VendorDetailExtension) vendorDetail.getExtension());
if (vendorDetailExt.getWorkmansCompCoverageAmount() != null && vendorDetailExt.getWorkmansCompExpiration() == null) {
success = false;
putFieldError(CUVendorPropertyConstants.WORKMANS_COMP_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_WC_EXPR_NEEDED);
}
if (vendorDetailExt.getWorkmansCompCoverageAmount() == null && vendorDetailExt.getWorkmansCompExpiration() != null) {
success = false;
putFieldError(CUVendorPropertyConstants.WORKMANS_COMP_AMOUNT, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_WC_COVERAGE_NEEDED);
}
if (vendorDetailExt.getWorkmansCompExpiration() != null && vendorDetailExt.getWorkmansCompExpiration().before(new Date())) {
// Only check expiration date on new vendors
if (document.isNew()) {
success = false;
putFieldError(CUVendorPropertyConstants.WORKMANS_COMP_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_DATE_IN_PAST);
}
}
return success;
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class CuVendorRule method processCustomAddCollectionLineBusinessRules.
public boolean processCustomAddCollectionLineBusinessRules(MaintenanceDocument document, String collectionName, PersistableBusinessObject bo) {
boolean success = super.processCustomAddCollectionLineBusinessRules(document, collectionName, bo);
if (bo instanceof VendorAddress) {
VendorAddress address = (VendorAddress) bo;
VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
VendorHeader vendorHeader = vendorDetail.getVendorHeader();
// String propertyConstant = KFSConstants.ADD_PREFIX + "." + VendorPropertyConstants.VENDOR_ADDRESS + ".";
String propertyConstant = "add.vendorAddresses.";
if (StringUtils.isBlank(vendorHeader.getVendorTypeCode())) {
success = false;
putFieldError(VendorPropertyConstants.VENDOR_TYPE_CODE, CUVendorKeyConstants.ERROR_DOCUMENT_VENDOR_TYPE_IS_REQUIRED_FOR_ADD_VENDORADRESS);
} else {
vendorHeader.refreshReferenceObject(KFSPropertyConstants.VENDOR_TYPE_CODE);
success &= this.checkAddressMethodOfPOTransmissionAndData(vendorHeader.getVendorTypeCode(), vendorHeader.getVendorType().getVendorAddressTypeRequiredCode(), address, propertyConstant);
}
}
if (bo instanceof CuVendorCreditCardMerchant) {
CuVendorCreditCardMerchant vendorMerchant = (CuVendorCreditCardMerchant) bo;
VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
success &= validateCreditCardMerchantAddition(vendorDetail, vendorMerchant);
}
if (bo instanceof VendorSupplierDiversity) {
VendorSupplierDiversity vendorSupplierDiversity = (VendorSupplierDiversity) bo;
success &= validateSupplierDiversityAddition(vendorSupplierDiversity);
}
return success;
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class CuVendorRule method checkHealthLicenseAndExpiration.
protected boolean checkHealthLicenseAndExpiration(MaintenanceDocument document) {
boolean success = true;
VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
Boolean offSiteCateringLicenseRequired = ((VendorDetailExtension) vendorDetail.getExtension()).getHealthOffSiteCateringLicenseReq();
if (offSiteCateringLicenseRequired == null) {
offSiteCateringLicenseRequired = false;
}
if (offSiteCateringLicenseRequired && ((VendorDetailExtension) vendorDetail.getExtension()).getHealthOffSiteLicenseExpirationDate() == null) {
success = false;
putFieldError(CUVendorPropertyConstants.HEALTH_OFFSITE_LICENSE_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_HEALTH_LICENSE_EXPR_NEEDED);
}
if (!offSiteCateringLicenseRequired && ((VendorDetailExtension) vendorDetail.getExtension()).getHealthOffSiteLicenseExpirationDate() != null) {
success = false;
putFieldError(CUVendorPropertyConstants.HEALTH_OFFSITE_LICENSE_REQUIRED, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_HEALTH_LICENSE_NEEDED);
}
if (((VendorDetailExtension) vendorDetail.getExtension()).getHealthOffSiteLicenseExpirationDate() != null && ((VendorDetailExtension) vendorDetail.getExtension()).getHealthOffSiteLicenseExpirationDate().before(new Date())) {
// Only check expiration date on new vendors
if (document.isNew()) {
success = false;
putFieldError(CUVendorPropertyConstants.HEALTH_OFFSITE_LICENSE_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_DATE_IN_PAST);
}
}
return success;
}
Aggregations