Search in sources :

Example 1 with VendorCustomerNumber

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

the class VendorRule method processCustomAddCollectionLineBusinessRules.

/**
 * Validates business rules for VendorDetail document collection add lines. Add lines are the initial lines on a
 * collections, i.e. the ones next to the "Add" button
 */
@Override
public boolean processCustomAddCollectionLineBusinessRules(MaintenanceDocument document, String collectionName, PersistableBusinessObject bo) {
    boolean success = true;
    // this incoming bo needs to be refreshed because it doesn't have its subobjects setup
    bo.refreshNonUpdateableReferences();
    if (bo instanceof VendorAddress) {
        VendorAddress address = (VendorAddress) bo;
        success = checkAddressCountryEmptyStateZip(address);
    }
    if (bo instanceof VendorContract) {
        VendorContract contract = (VendorContract) bo;
        success &= validateVendorContractBeginEndDates(contract);
        success &= processContractB2BValidation(contract, -1);
    }
    if (bo instanceof VendorContractOrganization) {
        VendorContractOrganization contractOrg = (VendorContractOrganization) bo;
        success &= validateVendorContractOrganization(contractOrg, 0);
    }
    if (bo instanceof VendorCustomerNumber) {
        VendorCustomerNumber customerNumber = (VendorCustomerNumber) bo;
        success &= validateVendorCustomerNumber(customerNumber);
    }
    if (bo instanceof VendorDefaultAddress) {
        VendorDefaultAddress defaultAddress = (VendorDefaultAddress) bo;
        String parentName = StringUtils.substringBeforeLast(collectionName, ".");
        VendorAddress parent = (VendorAddress) ObjectUtils.getPropertyValue(this.getNewBo(), parentName);
        VendorDetail vendorDetail = (VendorDetail) document.getNewMaintainableObject().getBusinessObject();
        success &= checkDefaultAddressCampus(vendorDetail, defaultAddress, parent);
    }
    if (bo instanceof VendorCommodityCode) {
        VendorCommodityCode commodityCode = (VendorCommodityCode) bo;
        String purchasingCommodityCode = commodityCode.getPurchasingCommodityCode();
        boolean found = ObjectUtils.isNotNull(commodityCode) && StringUtils.isNotBlank(purchasingCommodityCode) && checkVendorCommodityCode(commodityCode);
        if (!found) {
            GlobalVariables.getMessageMap().putError(VendorPropertyConstants.PURCHASING_COMMODITY_CODE, KFSKeyConstants.ERROR_EXISTENCE, purchasingCommodityCode);
        }
        success &= found;
    }
    return success;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorContract(org.kuali.kfs.vnd.businessobject.VendorContract) VendorCustomerNumber(org.kuali.kfs.vnd.businessobject.VendorCustomerNumber) VendorContractOrganization(org.kuali.kfs.vnd.businessobject.VendorContractOrganization) VendorDefaultAddress(org.kuali.kfs.vnd.businessobject.VendorDefaultAddress) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) VendorCommodityCode(org.kuali.kfs.vnd.businessobject.VendorCommodityCode)

Aggregations

VendorAddress (org.kuali.kfs.vnd.businessobject.VendorAddress)1 VendorCommodityCode (org.kuali.kfs.vnd.businessobject.VendorCommodityCode)1 VendorContract (org.kuali.kfs.vnd.businessobject.VendorContract)1 VendorContractOrganization (org.kuali.kfs.vnd.businessobject.VendorContractOrganization)1 VendorCustomerNumber (org.kuali.kfs.vnd.businessobject.VendorCustomerNumber)1 VendorDefaultAddress (org.kuali.kfs.vnd.businessobject.VendorDefaultAddress)1 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)1