Search in sources :

Example 16 with VendorHeader

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

Example 17 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 = 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;
}
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)

Aggregations

VendorHeader (org.kuali.kfs.vnd.businessobject.VendorHeader)17 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)8 ArrayList (java.util.ArrayList)4 VendorSupplierDiversity (org.kuali.kfs.vnd.businessobject.VendorSupplierDiversity)4 Date (java.util.Date)3 PaymentWorksVendor (edu.cornell.kfs.pmw.batch.businessobject.PaymentWorksVendor)2 CuVendorSupplierDiversityExtension (edu.cornell.kfs.vnd.businessobject.CuVendorSupplierDiversityExtension)2 List (java.util.List)2 Test (org.junit.jupiter.api.Test)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 ParseException (org.kuali.kfs.sys.exception.ParseException)2 TaxRule (edu.cornell.kfs.pmw.batch.TaxRule)1 KfsVendorDataWrapper (edu.cornell.kfs.pmw.batch.businessobject.KfsVendorDataWrapper)1 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 Date (java.sql.Date)1 HashMap (java.util.HashMap)1