Search in sources :

Example 1 with CuVendorCreditCardMerchant

use of edu.cornell.kfs.vnd.businessobject.CuVendorCreditCardMerchant in project cu-kfs by CU-CommunityApps.

the class CuVendorRule method validateCreditCardMerchantAddition.

protected boolean validateCreditCardMerchantAddition(VendorDetail vendorDetail, CuVendorCreditCardMerchant vendorCreditCardMerchant) {
    boolean success = true;
    List<CuVendorCreditCardMerchant> vendorCreditCardMerchants = ((VendorDetailExtension) vendorDetail.getExtension()).getVendorCreditCardMerchants();
    for (CuVendorCreditCardMerchant existingMerchant : vendorCreditCardMerchants) {
        if (existingMerchant.getCreditMerchantName().equals(vendorCreditCardMerchant.getCreditMerchantName())) {
            putFieldError("add.vendorCreditCardMerchants.creditMerchantName", CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_CREDIT_MERCHANT_NAME_DUPLICATE);
            // can't have duplicate merchant names, part of the primary key for the table in the db
            success = false;
        }
    }
    return success;
}
Also used : CuVendorCreditCardMerchant(edu.cornell.kfs.vnd.businessobject.CuVendorCreditCardMerchant) VendorDetailExtension(edu.cornell.kfs.vnd.businessobject.VendorDetailExtension)

Example 2 with CuVendorCreditCardMerchant

use of edu.cornell.kfs.vnd.businessobject.CuVendorCreditCardMerchant in project cu-kfs by CU-CommunityApps.

the class CuVendorRule method processCustomAddCollectionLineBusinessRules.

public boolean processCustomAddCollectionLineBusinessRules(MaintenanceDocument document, String collectionName, PersistableBusinessObject bo) {
    boolean success = super.processCustomAddCollectionLineBusinessRules(document, collectionName, bo);
    if (bo instanceof VendorAddress) {
        VendorAddress address = (VendorAddress) bo;
        VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
        VendorHeader vendorHeader = vendorDetail.getVendorHeader();
        // String propertyConstant = KFSConstants.ADD_PREFIX + "." + VendorPropertyConstants.VENDOR_ADDRESS + ".";
        String propertyConstant = "add.vendorAddresses.";
        if (StringUtils.isBlank(vendorHeader.getVendorTypeCode())) {
            success = false;
            putFieldError(VendorPropertyConstants.VENDOR_TYPE_CODE, CUVendorKeyConstants.ERROR_DOCUMENT_VENDOR_TYPE_IS_REQUIRED_FOR_ADD_VENDORADRESS);
        } else {
            vendorHeader.refreshReferenceObject(KFSPropertyConstants.VENDOR_TYPE_CODE);
            success &= this.checkAddressMethodOfPOTransmissionAndData(vendorHeader.getVendorTypeCode(), vendorHeader.getVendorType().getVendorAddressTypeRequiredCode(), address, propertyConstant);
        }
    }
    if (bo instanceof CuVendorCreditCardMerchant) {
        CuVendorCreditCardMerchant vendorMerchant = (CuVendorCreditCardMerchant) bo;
        VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
        success &= validateCreditCardMerchantAddition(vendorDetail, vendorMerchant);
    }
    if (bo instanceof VendorSupplierDiversity) {
        VendorSupplierDiversity vendorSupplierDiversity = (VendorSupplierDiversity) bo;
        success &= validateSupplierDiversityAddition(vendorSupplierDiversity);
    }
    return success;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader) CuVendorCreditCardMerchant(edu.cornell.kfs.vnd.businessobject.CuVendorCreditCardMerchant) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) VendorSupplierDiversity(org.kuali.kfs.vnd.businessobject.VendorSupplierDiversity)

Example 3 with CuVendorCreditCardMerchant

use of edu.cornell.kfs.vnd.businessobject.CuVendorCreditCardMerchant in project cu-kfs by CU-CommunityApps.

the class CuVendorRule method checkMerchantNameUniqueness.

protected boolean checkMerchantNameUniqueness(MaintenanceDocument document) {
    boolean success = true;
    VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
    List<CuVendorCreditCardMerchant> vendorCreditCardMerchants = ((VendorDetailExtension) vendorDetail.getExtension()).getVendorCreditCardMerchants();
    ArrayList<String> merchantNames = new ArrayList<String>();
    int i = 0;
    for (CuVendorCreditCardMerchant vendorCreditCardMerchant : vendorCreditCardMerchants) {
        if (merchantNames.contains(vendorCreditCardMerchant.getCreditMerchantName())) {
            putFieldError("vendorCreditCardMerchants[" + i + "].creditMerchantName", CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_CREDIT_MERCHANT_NAME_DUPLICATE);
            // can't have duplicate merchant names, part of the primary key for the table in the db
            success = false;
        }
        if (vendorCreditCardMerchant.getCreditMerchantName() == null || vendorCreditCardMerchant.getCreditMerchantName().equals("")) {
            // can't have a null or blank name, it's part of the primary key for this table in the db
            putFieldError("vendorCreditCardMerchants[" + i + "].creditMerchantName", CUVendorKeyConstants.ERROR_DOCUMENT_VNDMAINT_CREDIT_MERCHANT_NAME_BLANK);
            success = false;
        }
        merchantNames.add(vendorCreditCardMerchant.getCreditMerchantName());
        i++;
    }
    return success;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) CuVendorCreditCardMerchant(edu.cornell.kfs.vnd.businessobject.CuVendorCreditCardMerchant) ArrayList(java.util.ArrayList) VendorDetailExtension(edu.cornell.kfs.vnd.businessobject.VendorDetailExtension)

Aggregations

CuVendorCreditCardMerchant (edu.cornell.kfs.vnd.businessobject.CuVendorCreditCardMerchant)3 VendorDetailExtension (edu.cornell.kfs.vnd.businessobject.VendorDetailExtension)2 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)2 ArrayList (java.util.ArrayList)1 VendorAddress (org.kuali.kfs.vnd.businessobject.VendorAddress)1 VendorHeader (org.kuali.kfs.vnd.businessobject.VendorHeader)1 VendorSupplierDiversity (org.kuali.kfs.vnd.businessobject.VendorSupplierDiversity)1