Search in sources :

Example 16 with VendorAddress

use of org.kuali.kfs.vnd.businessobject.VendorAddress in project cu-kfs by CU-CommunityApps.

the class CuVendorRule method processCuAddressValidation.

// CU enhancement related po transmission KFSUPGRADE-348
// can't override processAddressValidation because it has no modifier, so only class/package can access it.
boolean processCuAddressValidation(MaintenanceDocument document) {
    boolean valid = true;
    VendorDetail newVendor = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
    List<VendorAddress> addresses = newVendor.getVendorAddresses();
    String vendorTypeCode = newVendor.getVendorHeader().getVendorTypeCode();
    String vendorAddressTypeRequiredCode = newVendor.getVendorHeader().getVendorType().getVendorAddressTypeRequiredCode();
    verifyPOTransmissionTypeAllowedForVendorType(vendorTypeCode, addresses);
    for (int i = 0; i < addresses.size(); i++) {
        VendorAddress address = addresses.get(i);
        String errorPath = MAINTAINABLE_ERROR_PREFIX + VendorPropertyConstants.VENDOR_ADDRESS + "[" + i + "]";
        GlobalVariables.getMessageMap().clearErrorPath();
        GlobalVariables.getMessageMap().addToErrorPath(errorPath);
        String propertyName = VendorPropertyConstants.VENDOR_ADDRESS + "[" + i + "].";
        valid &= checkAddressMethodOfPOTransmissionAndData(vendorTypeCode, vendorAddressTypeRequiredCode, address, propertyName);
        GlobalVariables.getMessageMap().clearErrorPath();
    }
    return valid;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

Example 17 with VendorAddress

use of org.kuali.kfs.vnd.businessobject.VendorAddress in project cu-kfs by CU-CommunityApps.

the class CuVendorRule method verifyPOTransmissionTypeAllowedForVendorType.

/**
 * Method verifies that only vendors of type purchase order have method of PO transmission set for their address type.
 */
private void verifyPOTransmissionTypeAllowedForVendorType(String vendorTypeCode, List<VendorAddress> addresses) {
    // Check that there is at least one PO Address Type specified when the Vendor Type is PO
    if ((!StringUtils.isBlank(vendorTypeCode)) && StringUtils.equals(vendorTypeCode, KFSConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER)) {
        boolean poAddressExistsForPOVendor = false;
        int i = 0;
        while ((i < addresses.size()) && !poAddressExistsForPOVendor) {
            VendorAddress address = addresses.get(i);
            if ((!StringUtils.isBlank(address.getVendorAddressTypeCode())) && (StringUtils.equals(address.getVendorAddressTypeCode(), KFSConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER))) {
                poAddressExistsForPOVendor = true;
            }
            i++;
        }
        if (!poAddressExistsForPOVendor) {
            // display error message
            putFieldError(VendorPropertyConstants.VENDOR_TYPE_CODE, CUVendorKeyConstants.ERROR_PO_TRANSMISSION_REQUIRES_PO_ADDRESS);
        }
    }
    // Check that there are no PO Transmission Method values set when the Vendor Type is not PO
    if ((!StringUtils.isBlank(vendorTypeCode)) && (!StringUtils.equals(vendorTypeCode, KFSConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER))) {
        boolean poTransmissionMethodExistsForVendor = false;
        int i = 0;
        while ((i < addresses.size()) && !poTransmissionMethodExistsForVendor) {
            VendorAddress address = addresses.get(i);
            if ((!StringUtils.isBlank(((CuVendorAddressExtension) address.getExtension()).getPurchaseOrderTransmissionMethodCode())) && (!StringUtils.equals(((CuVendorAddressExtension) address.getExtension()).getPurchaseOrderTransmissionMethodCode(), KFSConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER))) {
                poTransmissionMethodExistsForVendor = true;
            }
            i++;
        }
        if (poTransmissionMethodExistsForVendor) {
            // display error message
            putFieldError(VendorPropertyConstants.VENDOR_TYPE_CODE, CUVendorKeyConstants.ERROR_PO_TRANMSISSION_NOT_ALLOWED_FOR_VENDOR_TYPE);
        }
    }
}
Also used : CuVendorAddressExtension(edu.cornell.kfs.vnd.businessobject.CuVendorAddressExtension) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

Example 18 with VendorAddress

use of org.kuali.kfs.vnd.businessobject.VendorAddress in project cu-kfs by CU-CommunityApps.

the class CuVendorMaintainableImpl method populateGeneratedAddressId.

private void populateGeneratedAddressId(VendorDetail vendorDetail) {
    if (CollectionUtils.isNotEmpty(vendorDetail.getVendorAddresses())) {
        for (VendorAddress vendorAddress : vendorDetail.getVendorAddresses()) {
            if (vendorAddress.getVendorAddressGeneratedIdentifier() == null) {
                Integer generatedHeaderId = SpringContext.getBean(SequenceAccessorService.class).getNextAvailableSequenceNumber(ADDRESS_HEADER_ID_SEQ).intValue();
                vendorAddress.setVendorAddressGeneratedIdentifier(generatedHeaderId);
                ((CuVendorAddressExtension) vendorAddress.getExtension()).setVendorAddressGeneratedIdentifier(generatedHeaderId);
            }
        }
    }
}
Also used : CuVendorAddressExtension(edu.cornell.kfs.vnd.businessobject.CuVendorAddressExtension) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

Example 19 with VendorAddress

use of org.kuali.kfs.vnd.businessobject.VendorAddress in project cu-kfs by CU-CommunityApps.

the class PaymentWorksVendorToKfsVendorDetailConversionServiceImpl method buildTaxAddressFromIsoCountryData.

private VendorAddress buildTaxAddressFromIsoCountryData(PaymentWorksVendor pmwVendor, Map<String, List<PaymentWorksIsoFipsCountryItem>> paymentWorksIsoToFipsCountryMap) {
    VendorAddress taxAddress = buildBaseAddress(CUVendorConstants.CUAddressTypes.TAX, pmwVendor.getCorpAddressStreet1(), pmwVendor.getCorpAddressStreet2(), pmwVendor.getCorpAddressCity(), pmwVendor.getCorpAddressZipCode(), paymentWorksTaxRuleDependencyService.convertIsoCountryCodeToFipsCountryCode(pmwVendor.getCorpAddressCountry(), paymentWorksIsoToFipsCountryMap));
    taxAddress = assignStateCodeOrProvinceBasedOnFipsCountryCode(taxAddress, pmwVendor.getCorpAddressState());
    return taxAddress;
}
Also used : VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

Example 20 with VendorAddress

use of org.kuali.kfs.vnd.businessobject.VendorAddress in project cu-kfs by CU-CommunityApps.

the class PaymentWorksVendorToKfsVendorDetailConversionServiceImpl method buildRemitAddressFromIsoCountryData.

private VendorAddress buildRemitAddressFromIsoCountryData(PaymentWorksVendor pmwVendor, Map<String, List<PaymentWorksIsoFipsCountryItem>> paymentWorksIsoToFipsCountryMap) {
    VendorAddress remitAddress = buildBaseAddress(VendorConstants.AddressTypes.REMIT, pmwVendor.getRemittanceAddressStreet1(), pmwVendor.getRemittanceAddressStreet2(), pmwVendor.getRemittanceAddressCity(), pmwVendor.getRemittanceAddressZipCode(), paymentWorksTaxRuleDependencyService.convertIsoCountryCodeToFipsCountryCode(pmwVendor.getRemittanceAddressCountry(), paymentWorksIsoToFipsCountryMap));
    remitAddress.setVendorDefaultAddressIndicator(true);
    remitAddress = assignStateCodeOrProvinceBasedOnFipsCountryCode(remitAddress, pmwVendor.getRemittanceAddressState());
    return (remitAddress);
}
Also used : VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

Aggregations

VendorAddress (org.kuali.kfs.vnd.businessobject.VendorAddress)35 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)13 HashMap (java.util.HashMap)6 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)6 Iterator (java.util.Iterator)5 List (java.util.List)5 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)5 VendorContract (org.kuali.kfs.vnd.businessobject.VendorContract)5 VendorService (org.kuali.kfs.vnd.document.service.VendorService)5 ArrayList (java.util.ArrayList)4 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)3 Map (java.util.Map)3 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)3 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)3 PersistenceService (org.kuali.kfs.krad.service.PersistenceService)3 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)3 VendorDefaultAddress (org.kuali.kfs.vnd.businessobject.VendorDefaultAddress)3 CuVendorAddressExtension (edu.cornell.kfs.vnd.businessobject.CuVendorAddressExtension)2 VendorBatchAddress (edu.cornell.kfs.vnd.businessobject.VendorBatchAddress)2 Date (java.util.Date)2