use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class VendorInactivateConvertBatchServiceImpl method inactivateConvert.
/**
*/
public boolean inactivateConvert(String fileName, BatchInputFileType batchInputFileType) {
boolean result = true;
// load up the file into a byte array
byte[] fileByteContent = safelyLoadFileBytes(fileName);
LOG.info("Attempting to parse the file");
Object parsedObject = null;
try {
parsedObject = batchInputFileService.parse(batchInputFileType, fileByteContent);
} catch (ParseException e) {
String errorMessage = "Error parsing batch file: " + e.getMessage();
LOG.error(errorMessage, e);
throw new RuntimeException(errorMessage);
}
// make sure we got the type we expected, then cast it
if (!(parsedObject instanceof List)) {
String errorMessage = "Parsed file was not of the expected type. Expected [" + List.class + "] but got [" + parsedObject.getClass() + "].";
criticalError(errorMessage);
}
List<VendorInactivateConvertBatch> vendors = ((List<VendorInactivateConvertBatch>) parsedObject);
for (VendorInactivateConvertBatch vendor : vendors) {
String[] vendorId = vendor.getVendorId().split("-");
Collection<VendorDetail> vendorDets = businessObjectService.findMatching(VendorDetail.class, Collections.singletonMap("vendorHeaderGeneratedIdentifier", vendorId[0]));
GlobalVariables.setUserSession(new UserSession("kfs"));
VendorDetail vnd = cuVendorService.getByVendorNumber(vendor.getVendorId());
if (ObjectUtils.isNull(vnd)) {
LOG.info("Vendor with id: " + vendor.getVendorId() + " does not exist in the database.");
}
if ((ObjectUtils.isNotNull(vnd))) {
VendorHeader vHead = businessObjectService.findBySinglePrimaryKey(VendorHeader.class, vnd.getVendorHeaderGeneratedIdentifier());
if (vendor.getAction().equalsIgnoreCase("inactivate") && ((vendorDets.size() == 1) || !(vendorId[1].equalsIgnoreCase("0")))) {
inactivateVendor(vnd, vendor.getNote(), vendor.getReason());
} else if (vendor.getAction().equalsIgnoreCase("activate") && ((vendorDets.size() == 1) || !(vendorId[1].equalsIgnoreCase("0")))) {
activateVendor(vnd, vendor.getNote(), vendor.getReason());
} else if (vendor.getAction().equalsIgnoreCase("convert") && ((vendorDets.size() == 1) || !(vendorId[1].equalsIgnoreCase("0")))) {
convertVendor(vHead, vnd, vendor.getNote(), vendor.getConvertType());
} else if (vendorDets.size() > 1) {
LOG.info("failed to process for " + vnd.getVendorNumber() + ", This vendor has child records. These must be processed through the application");
} else {
String errorMessage = "Failed to parse vendor action expected inactivate or convert but recevied " + vendor.getAction();
criticalError(errorMessage);
}
}
}
return result;
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class CuVendorRule method checkAutoLiabilityAmountAndExpiration.
protected boolean checkAutoLiabilityAmountAndExpiration(MaintenanceDocument document) {
boolean success = true;
VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
VendorDetailExtension vendorDetailExt = ((VendorDetailExtension) vendorDetail.getExtension());
if (vendorDetailExt.getAutomobileLiabilityCoverageAmount() != null && vendorDetailExt.getAutomobileLiabilityExpiration() == null) {
success = false;
putFieldError(CUVendorPropertyConstants.AUTOMOBILE_LIABILITY_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_AUTO_EXPR_NEEDED);
}
if (vendorDetailExt.getAutomobileLiabilityCoverageAmount() == null && vendorDetailExt.getAutomobileLiabilityExpiration() != null) {
success = false;
putFieldError(CUVendorPropertyConstants.AUTOMOBILE_LIABILITY_AMOUNT, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_AUTO_COVERAGE_NEEDED);
}
if (vendorDetailExt.getAutomobileLiabilityExpiration() != null && vendorDetailExt.getAutomobileLiabilityExpiration().before(new Date())) {
// Only check expiration date on new vendors
if (document.isNew()) {
success = false;
putFieldError(CUVendorPropertyConstants.AUTOMOBILE_LIABILITY_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 checkInsuranceRequired.
protected boolean checkInsuranceRequired(MaintenanceDocument document) {
boolean success = true;
boolean dataEntered = false;
VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
VendorDetailExtension vendorDetailExt = ((VendorDetailExtension) vendorDetail.getExtension());
if (vendorDetailExt.isInsuranceRequiredIndicator()) {
dataEntered |= (vendorDetailExt.getAutomobileLiabilityCoverageAmount() == null ? false : true);
dataEntered |= (vendorDetailExt.getAutomobileLiabilityExpiration() == null ? false : true);
dataEntered |= (vendorDetailExt.getCornellAdditionalInsuredIndicator() == null ? false : true);
dataEntered |= (vendorDetailExt.getExcessLiabilityUmbExpiration() == null ? false : true);
dataEntered |= (vendorDetailExt.getExcessLiabilityUmbrellaAmount() == null ? false : true);
dataEntered |= (vendorDetailExt.getGeneralLiabilityCoverageAmount() == null ? false : true);
dataEntered |= (vendorDetailExt.getGeneralLiabilityExpiration() == null ? false : true);
dataEntered |= (vendorDetailExt.getWorkmansCompCoverageAmount() == null ? false : true);
dataEntered |= (vendorDetailExt.getWorkmansCompExpiration() == null ? false : true);
dataEntered |= (vendorDetailExt.getHealthOffSiteCateringLicenseReq() == null ? false : true);
dataEntered |= (vendorDetailExt.getHealthOffSiteLicenseExpirationDate() == null ? false : true);
dataEntered |= (vendorDetailExt.getInsuranceNotes() == null ? false : true);
if (!dataEntered) {
putFieldError(CUVendorPropertyConstants.INSURANCE_REQUIRED, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_INSURANCE_REQUIRED_USED_WO_DATA);
return false;
}
}
return success;
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class CuVendorRule method checkMerchantNameUniqueness.
protected boolean checkMerchantNameUniqueness(MaintenanceDocument document) {
boolean success = true;
VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
List<CuVendorCreditCardMerchant> vendorCreditCardMerchants = ((VendorDetailExtension) vendorDetail.getExtension()).getVendorCreditCardMerchants();
ArrayList<String> merchantNames = new ArrayList<String>();
int i = 0;
for (CuVendorCreditCardMerchant vendorCreditCardMerchant : vendorCreditCardMerchants) {
if (merchantNames.contains(vendorCreditCardMerchant.getCreditMerchantName())) {
putFieldError("vendorCreditCardMerchants[" + i + "].creditMerchantName", CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_CREDIT_MERCHANT_NAME_DUPLICATE);
// can't have duplicate merchant names, part of the primary key for the table in the db
success = false;
}
if (vendorCreditCardMerchant.getCreditMerchantName() == null || vendorCreditCardMerchant.getCreditMerchantName().equals("")) {
// can't have a null or blank name, it's part of the primary key for this table in the db
putFieldError("vendorCreditCardMerchants[" + i + "].creditMerchantName", CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_CREDIT_MERCHANT_NAME_BLANK);
success = false;
}
merchantNames.add(vendorCreditCardMerchant.getCreditMerchantName());
i++;
}
return success;
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class CuVendorRule method checkGeneralLiabilityAmountAndExpiration.
protected boolean checkGeneralLiabilityAmountAndExpiration(MaintenanceDocument document) {
boolean success = true;
VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
VendorDetailExtension vendorDetailExt = ((VendorDetailExtension) vendorDetail.getExtension());
if (vendorDetailExt.getGeneralLiabilityCoverageAmount() != null && vendorDetailExt.getGeneralLiabilityExpiration() == null) {
success = false;
putFieldError(CUVendorPropertyConstants.GENERAL_LIABILITY_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_GENERAL_LIABILITY_EXPR_DATE_NEEDED);
}
if (vendorDetailExt.getGeneralLiabilityCoverageAmount() == null && vendorDetailExt.getGeneralLiabilityExpiration() != null) {
success = false;
putFieldError(CUVendorPropertyConstants.GENERAL_LIABILITY_AMOUNT, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_GENERAL_LIABILITY_COVERAGE_NEEDED);
}
if (vendorDetailExt.getGeneralLiabilityExpiration() != null && vendorDetailExt.getGeneralLiabilityExpiration().before(new Date())) {
// Only check expiration date on new vendors
if (document.isNew()) {
success = false;
putFieldError(CUVendorPropertyConstants.GENERAL_LIABILITY_EXPIRATION, CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_DATE_IN_PAST);
}
}
return success;
}
Aggregations