use of org.kuali.kfs.vnd.businessobject.VendorHeader in project cu-kfs by CU-CommunityApps.
the class PaymentWorksTaxRuleDependencyServiceImpl method populateTaxRuleDependentAttributes.
protected void populateTaxRuleDependentAttributes(PaymentWorksVendor pmwVendor, KfsVendorDataWrapper vendorDataWrapper, TaxRule taxRule) {
VendorDetail vendorDetail = vendorDataWrapper.getVendorDetail();
VendorHeader vendorHeader = vendorDetail.getVendorHeader();
if (taxRule.isForeign) {
poulateForeignVendorValues(pmwVendor, vendorDataWrapper, taxRule);
} else {
vendorHeader.setVendorTaxNumber(pmwVendor.getRequestingCompanyTin());
vendorHeader.setVendorTaxTypeCode(taxRule.taxTypeCode);
}
populateOwnershipCode(pmwVendor, taxRule, vendorHeader);
if (taxRule.populateW9Attributes) {
populateW9Attributes(vendorDataWrapper, pmwVendor);
}
if (taxRule.populateFirstLastLegalName) {
populateFirstLastLegalName(pmwVendor, vendorDetail);
}
if (taxRule.populateBusinessLegalName) {
populateBusinessLegalName(pmwVendor, vendorDetail);
}
}
use of org.kuali.kfs.vnd.businessobject.VendorHeader 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 = LoadFileUtils.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;
}
Aggregations