Search in sources :

Example 6 with VendorHeader

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;
}
Also used : VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader)

Example 7 with VendorHeader

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);
    }
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader) MaintenanceDocument(org.kuali.kfs.krad.maintenance.MaintenanceDocument) VendorMaintainableImpl(org.kuali.kfs.vnd.document.VendorMaintainableImpl) MessageMap(org.kuali.kfs.krad.util.MessageMap) ValidationException(org.kuali.kfs.krad.exception.ValidationException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ParseException(org.kuali.kfs.sys.exception.ParseException)

Example 8 with VendorHeader

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;
}
Also used : VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader) VendorInactivateConvertBatch(edu.cornell.kfs.vnd.businessobject.VendorInactivateConvertBatch) VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) UserSession(org.kuali.kfs.krad.UserSession) ArrayList(java.util.ArrayList) List(java.util.List) ParseException(org.kuali.kfs.sys.exception.ParseException)

Example 9 with VendorHeader

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;
}
Also used : VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader)

Example 10 with VendorHeader

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;
}
Also used : VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader)

Aggregations

VendorHeader (org.kuali.kfs.vnd.businessobject.VendorHeader)11 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)7 ArrayList (java.util.ArrayList)4 VendorSupplierDiversity (org.kuali.kfs.vnd.businessobject.VendorSupplierDiversity)4 Date (java.util.Date)3 CuVendorSupplierDiversityExtension (edu.cornell.kfs.vnd.businessobject.CuVendorSupplierDiversityExtension)2 List (java.util.List)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 ParseException (org.kuali.kfs.sys.exception.ParseException)2 CuVendorCreditCardMerchant (edu.cornell.kfs.vnd.businessobject.CuVendorCreditCardMerchant)1 VendorDetailExtension (edu.cornell.kfs.vnd.businessobject.VendorDetailExtension)1 VendorInactivateConvertBatch (edu.cornell.kfs.vnd.businessobject.VendorInactivateConvertBatch)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 UserSession (org.kuali.kfs.krad.UserSession)1 ValidationException (org.kuali.kfs.krad.exception.ValidationException)1 MaintenanceDocument (org.kuali.kfs.krad.maintenance.MaintenanceDocument)1 PurchasingDocument (org.kuali.kfs.module.purap.document.PurchasingDocument)1