use of org.kuali.kfs.vnd.businessobject.VendorHeader in project cu-kfs by CU-CommunityApps.
the class PaymentWorksVendorToKfsVendorDetailConversionServiceImpl method populateDataForTaxRuleIndividualUsEin.
private KfsVendorDataWrapper populateDataForTaxRuleIndividualUsEin(KfsVendorDataWrapper kfsVendorDataWrapper, PaymentWorksVendor pmwVendor, Map<String, List<PaymentWorksIsoFipsCountryItem>> paymentWorksIsoToFipsCountryMap) {
VendorHeader vendorHeader = new VendorHeader();
vendorHeader.setVendorForeignIndicator(new Boolean(false));
vendorHeader.setVendorTaxNumber(pmwVendor.getRequestingCompanyTin());
vendorHeader.setVendorTaxTypeCode(PaymentWorksConstants.PaymentWorksTinType.FEIN.getKfsTaxTypeCodeAsString());
vendorHeader.setVendorOwnershipCode(PaymentWorksConstants.PaymentWorksTaxClassification.INDIVIDUAL_SOLE_PROPRIETOR.getTranslationToKfsOwnershipTypeCode());
vendorHeader.setVendorCorpCitizenCode(convertIsoCountryCodeToFipsCountryCode(pmwVendor.getRequestingCompanyTaxCountry(), paymentWorksIsoToFipsCountryMap));
kfsVendorDataWrapper.getVendorDetail().setVendorHeader(vendorHeader);
kfsVendorDataWrapper = populateW9Attributes(kfsVendorDataWrapper, pmwVendor);
kfsVendorDataWrapper = populateBusinessLegalName(pmwVendor, kfsVendorDataWrapper);
return kfsVendorDataWrapper;
}
use of org.kuali.kfs.vnd.businessobject.VendorHeader 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.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 = 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.VendorHeader in project cu-kfs by CU-CommunityApps.
the class PaymentWorksVendorToKfsVendorDetailConversionServiceImpl method populateDataForTaxRuleNotIndividualUs.
private KfsVendorDataWrapper populateDataForTaxRuleNotIndividualUs(KfsVendorDataWrapper kfsVendorDataWrapper, PaymentWorksVendor pmwVendor, Map<String, List<PaymentWorksIsoFipsCountryItem>> paymentWorksIsoToFipsCountryMap) {
VendorHeader vendorHeader = new VendorHeader();
vendorHeader.setVendorForeignIndicator(new Boolean(false));
vendorHeader.setVendorTaxNumber(pmwVendor.getRequestingCompanyTin());
vendorHeader.setVendorTaxTypeCode(PaymentWorksConstants.PaymentWorksTinType.FEIN.getKfsTaxTypeCodeAsString());
vendorHeader.setVendorOwnershipCode(determineKfsOwnershipTypeCodeFromPmwTaxClassificationCode(pmwVendor));
vendorHeader.setVendorCorpCitizenCode(convertIsoCountryCodeToFipsCountryCode(pmwVendor.getRequestingCompanyTaxCountry(), paymentWorksIsoToFipsCountryMap));
kfsVendorDataWrapper.getVendorDetail().setVendorHeader(vendorHeader);
kfsVendorDataWrapper = populateW9Attributes(kfsVendorDataWrapper, pmwVendor);
kfsVendorDataWrapper = populateBusinessLegalName(pmwVendor, kfsVendorDataWrapper);
return kfsVendorDataWrapper;
}
use of org.kuali.kfs.vnd.businessobject.VendorHeader in project cu-kfs by CU-CommunityApps.
the class PaymentWorksVendorToKfsVendorDetailConversionServiceImpl method populateDataForTaxRuleIndividualUsSsn.
private KfsVendorDataWrapper populateDataForTaxRuleIndividualUsSsn(KfsVendorDataWrapper kfsVendorDataWrapper, PaymentWorksVendor pmwVendor, Map<String, List<PaymentWorksIsoFipsCountryItem>> paymentWorksIsoToFipsCountryMap) {
VendorHeader vendorHeader = new VendorHeader();
vendorHeader.setVendorForeignIndicator(new Boolean(false));
vendorHeader.setVendorTaxNumber(pmwVendor.getRequestingCompanyTin());
vendorHeader.setVendorTaxTypeCode(PaymentWorksConstants.PaymentWorksTinType.SSN.getKfsTaxTypeCodeAsString());
vendorHeader.setVendorOwnershipCode(PaymentWorksConstants.PaymentWorksTaxClassification.INDIVIDUAL_SOLE_PROPRIETOR.getTranslationToKfsOwnershipTypeCode());
vendorHeader.setVendorCorpCitizenCode(convertIsoCountryCodeToFipsCountryCode(pmwVendor.getRequestingCompanyTaxCountry(), paymentWorksIsoToFipsCountryMap));
kfsVendorDataWrapper.getVendorDetail().setVendorHeader(vendorHeader);
kfsVendorDataWrapper = populateW9Attributes(kfsVendorDataWrapper, pmwVendor);
kfsVendorDataWrapper = populateFirstLastLegalName(pmwVendor, kfsVendorDataWrapper);
return kfsVendorDataWrapper;
}
Aggregations