Search in sources :

Example 1 with AccountsReceivableCustomerAddress

use of org.kuali.kfs.integration.ar.AccountsReceivableCustomerAddress in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherAction method setupPayeeAsCustomer.

/**
 * setup the payee as a customer with the given id number and address id
 */
protected void setupPayeeAsCustomer(DisbursementVoucherForm dvForm, String payeeIdNumber, String payeeAddressIdentifier) {
    AccountsReceivableCustomer customer = SpringContext.getBean(AccountsReceivableModuleService.class).findCustomer(payeeIdNumber);
    AccountsReceivableCustomerAddress customerAddress = null;
    if (StringUtils.isNotBlank(payeeAddressIdentifier)) {
        customerAddress = SpringContext.getBean(AccountsReceivableModuleService.class).findCustomerAddress(payeeIdNumber, payeeAddressIdentifier);
    }
    dvForm.setTempPayeeIdNumber(payeeIdNumber);
    dvForm.setOldPayeeType(KFSConstants.PaymentPayeeTypes.CUSTOMER);
    ((DisbursementVoucherDocument) dvForm.getDocument()).templateCustomer(customer, customerAddress);
}
Also used : AccountsReceivableCustomerAddress(org.kuali.kfs.integration.ar.AccountsReceivableCustomerAddress) AccountsReceivableModuleService(org.kuali.kfs.integration.ar.AccountsReceivableModuleService) AccountsReceivableCustomer(org.kuali.kfs.integration.ar.AccountsReceivableCustomer) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 2 with AccountsReceivableCustomerAddress

use of org.kuali.kfs.integration.ar.AccountsReceivableCustomerAddress in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherAction method refreshAfterPayeeSelection.

protected ActionForward refreshAfterPayeeSelection(ActionMapping mapping, CuDisbursementVoucherForm dvForm, HttpServletRequest request) {
    String refreshCaller = dvForm.getRefreshCaller();
    CuDisbursementVoucherDocument document = (CuDisbursementVoucherDocument) dvForm.getDocument();
    boolean isPayeeLookupable = KFSConstants.KUALI_DISBURSEMENT_PAYEE_LOOKUPABLE_IMPL.equals(refreshCaller);
    boolean isAddressLookupable = KFSConstants.KUALI_VENDOR_ADDRESS_LOOKUPABLE_IMPL.equals(refreshCaller);
    boolean isKualiLookupable = KFSConstants.KUALI_LOOKUPABLE_IMPL.equals(refreshCaller);
    // correct information
    if (refreshCaller == null && hasFullEdit(document)) {
        dvForm.setPayeeIdNumber(dvForm.getTempPayeeIdNumber());
        dvForm.setHasMultipleAddresses(false);
        document.getDvPayeeDetail().setDisbVchrPayeeIdNumber(dvForm.getTempPayeeIdNumber());
        document.getDvPayeeDetail().setDisbursementVoucherPayeeTypeCode(dvForm.getOldPayeeType());
        return null;
    }
    // do not execute the further refreshing logic if the refresh caller is not a lookupable
    if (!isPayeeLookupable && !isAddressLookupable && !isKualiLookupable) {
        return null;
    }
    // do not execute the further refreshing logic if a payee is not selected
    String payeeIdNumber = document.getDvPayeeDetail().getDisbVchrPayeeIdNumber();
    if (payeeIdNumber == null) {
        return null;
    }
    dvForm.setPayeeIdNumber(payeeIdNumber);
    dvForm.setHasMultipleAddresses(false);
    // determine whether the selected vendor has multiple addresses. If so, redirect to the address selection screen
    if (isPayeeLookupable) {
        if (dvForm.isVendor()) {
            VendorDetail refreshVendorDetail = new VendorDetail();
            refreshVendorDetail.setVendorNumber(payeeIdNumber);
            refreshVendorDetail = (VendorDetail) SpringContext.getBean(BusinessObjectService.class).retrieve(refreshVendorDetail);
            VendorAddress defaultVendorAddress = null;
            if (refreshVendorDetail != null) {
                List<VendorAddress> vendorAddresses = refreshVendorDetail.getVendorAddresses();
                boolean hasMultipleAddresses = vendorAddresses != null && vendorAddresses.size() > 1;
                dvForm.setHasMultipleAddresses(hasMultipleAddresses);
                if (vendorAddresses != null && !vendorAddresses.isEmpty()) {
                    defaultVendorAddress = vendorAddresses.get(0);
                }
            }
            if (dvForm.hasMultipleAddresses()) {
                return renderVendorAddressSelection(mapping, request, dvForm);
            } else if (defaultVendorAddress != null) {
                setupPayeeAsVendor(dvForm, payeeIdNumber, defaultVendorAddress.getVendorAddressGeneratedIdentifier().toString());
            }
            return null;
        } else if (dvForm.isEmployee()) {
            this.setupPayeeAsEmployee(dvForm, payeeIdNumber);
        } else if (dvForm.isStudent()) {
            this.setupPayeeAsStudent(dvForm, payeeIdNumber);
        } else if (dvForm.isAlumni()) {
            this.setupPayeeAsAlumni(dvForm, payeeIdNumber);
        }
    }
    String payeeAddressIdentifier = request.getParameter(KFSPropertyConstants.VENDOR_ADDRESS_GENERATED_ID);
    if (isAddressLookupable && StringUtils.isNotBlank(payeeAddressIdentifier)) {
        setupPayeeAsVendor(dvForm, payeeIdNumber, payeeAddressIdentifier);
    }
    // check for multiple custom addresses
    if (isPayeeLookupable && dvForm.isCustomer()) {
        AccountsReceivableCustomer customer = SpringContext.getBean(AccountsReceivableModuleService.class).findCustomer(payeeIdNumber);
        AccountsReceivableCustomerAddress defaultCustomerAddress = null;
        if (customer != null) {
            defaultCustomerAddress = customer.getPrimaryAddress();
            Map<String, String> addressSearch = new HashMap<>();
            addressSearch.put(KFSPropertyConstants.CUSTOMER_NUMBER, payeeIdNumber);
            List<AccountsReceivableCustomerAddress> customerAddresses = (List<AccountsReceivableCustomerAddress>) SpringContext.getBean(AccountsReceivableModuleService.class).searchForCustomerAddresses(addressSearch);
            if (customerAddresses != null && !customerAddresses.isEmpty()) {
                if (customerAddresses.size() > 1) {
                    dvForm.setHasMultipleAddresses(true);
                } else if (defaultCustomerAddress == null) {
                    defaultCustomerAddress = customerAddresses.get(0);
                }
            }
        }
        if (dvForm.hasMultipleAddresses()) {
            return renderCustomerAddressSelection(mapping, request, dvForm);
        } else if (defaultCustomerAddress != null) {
            setupPayeeAsCustomer(dvForm, payeeIdNumber, defaultCustomerAddress.getCustomerAddressIdentifier().toString());
        }
    }
    String customerAddressIdentifier = request.getParameter(KFSPropertyConstants.CUSTOMER_ADDRESS_IDENTIFIER);
    if (isKualiLookupable && StringUtils.isNotBlank(customerAddressIdentifier)) {
        setupPayeeAsCustomer(dvForm, payeeIdNumber, customerAddressIdentifier);
    }
    String paymentReasonCode = document.getDvPayeeDetail().getDisbVchrPaymentReasonCode();
    addPaymentCodeWarningMessage(dvForm, paymentReasonCode);
    return null;
}
Also used : HashMap(java.util.HashMap) AccountsReceivableModuleService(org.kuali.kfs.integration.ar.AccountsReceivableModuleService) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) AccountsReceivableCustomerAddress(org.kuali.kfs.integration.ar.AccountsReceivableCustomerAddress) AccountsReceivableCustomer(org.kuali.kfs.integration.ar.AccountsReceivableCustomer) List(java.util.List) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

Example 3 with AccountsReceivableCustomerAddress

use of org.kuali.kfs.integration.ar.AccountsReceivableCustomerAddress in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherAction method refreshAfterPayeeSelection.

// do refresh after a payee is selected
protected ActionForward refreshAfterPayeeSelection(ActionMapping mapping, DisbursementVoucherForm dvForm, HttpServletRequest request) {
    String refreshCaller = dvForm.getRefreshCaller();
    DisbursementVoucherDocument document = (DisbursementVoucherDocument) dvForm.getDocument();
    boolean isPayeeLookupable = KFSConstants.KUALI_DISBURSEMENT_PAYEE_LOOKUPABLE_IMPL.equals(refreshCaller);
    boolean isAddressLookupable = KFSConstants.KUALI_VENDOR_ADDRESS_LOOKUPABLE_IMPL.equals(refreshCaller);
    boolean isKualiLookupable = KFSConstants.KUALI_LOOKUPABLE_IMPL.equals(refreshCaller);
    // correct information
    if (refreshCaller == null && hasFullEdit(document)) {
        dvForm.setPayeeIdNumber(dvForm.getTempPayeeIdNumber());
        dvForm.setHasMultipleAddresses(false);
        document.getDvPayeeDetail().setDisbVchrPayeeIdNumber(dvForm.getTempPayeeIdNumber());
        document.getDvPayeeDetail().setDisbursementVoucherPayeeTypeCode(dvForm.getOldPayeeType());
        return null;
    }
    // do not execute the further refreshing logic if the refresh caller is not a lookupable
    if (!isPayeeLookupable && !isAddressLookupable && !isKualiLookupable) {
        return null;
    }
    // do not execute the further refreshing logic if a payee is not selected
    String payeeIdNumber = document.getDvPayeeDetail().getDisbVchrPayeeIdNumber();
    if (payeeIdNumber == null) {
        return null;
    }
    dvForm.setPayeeIdNumber(payeeIdNumber);
    dvForm.setHasMultipleAddresses(false);
    // determine whether the selected vendor has multiple addresses. If so, redirect to the address selection screen
    if (isPayeeLookupable && dvForm.isVendor()) {
        VendorDetail refreshVendorDetail = new VendorDetail();
        refreshVendorDetail.setVendorNumber(payeeIdNumber);
        refreshVendorDetail = (VendorDetail) SpringContext.getBean(BusinessObjectService.class).retrieve(refreshVendorDetail);
        VendorAddress defaultVendorAddress = null;
        if (refreshVendorDetail != null) {
            List<VendorAddress> vendorAddresses = refreshVendorDetail.getVendorAddresses();
            boolean hasMultipleAddresses = vendorAddresses != null && vendorAddresses.size() > 1;
            dvForm.setHasMultipleAddresses(hasMultipleAddresses);
            if (vendorAddresses != null) {
                defaultVendorAddress = vendorAddresses.get(0);
            }
        }
        if (dvForm.hasMultipleAddresses()) {
            return renderVendorAddressSelection(mapping, request, dvForm);
        } else if (defaultVendorAddress != null) {
            setupPayeeAsVendor(dvForm, payeeIdNumber, defaultVendorAddress.getVendorAddressGeneratedIdentifier().toString());
        }
        return null;
    }
    String payeeAddressIdentifier = request.getParameter(KFSPropertyConstants.VENDOR_ADDRESS_GENERATED_ID);
    if (isAddressLookupable && StringUtils.isNotBlank(payeeAddressIdentifier)) {
        setupPayeeAsVendor(dvForm, payeeIdNumber, payeeAddressIdentifier);
    }
    if (isPayeeLookupable && dvForm.isEmployee()) {
        this.setupPayeeAsEmployee(dvForm, payeeIdNumber);
    }
    // check for multiple custom addresses
    if (isPayeeLookupable && dvForm.isCustomer()) {
        AccountsReceivableCustomer customer = SpringContext.getBean(AccountsReceivableModuleService.class).findCustomer(payeeIdNumber);
        AccountsReceivableCustomerAddress defaultCustomerAddress = null;
        if (customer != null) {
            defaultCustomerAddress = customer.getPrimaryAddress();
            Map<String, String> addressSearch = new HashMap<>();
            addressSearch.put(KFSPropertyConstants.CUSTOMER_NUMBER, payeeIdNumber);
            List<AccountsReceivableCustomerAddress> customerAddresses = (List<AccountsReceivableCustomerAddress>) SpringContext.getBean(AccountsReceivableModuleService.class).searchForCustomerAddresses(addressSearch);
            if (customerAddresses != null && !customerAddresses.isEmpty()) {
                if (customerAddresses.size() > 1) {
                    dvForm.setHasMultipleAddresses(true);
                } else if (defaultCustomerAddress == null) {
                    defaultCustomerAddress = customerAddresses.get(0);
                }
            }
        }
        if (dvForm.hasMultipleAddresses()) {
            return renderCustomerAddressSelection(mapping, request, dvForm);
        } else if (defaultCustomerAddress != null) {
            setupPayeeAsCustomer(dvForm, payeeIdNumber, defaultCustomerAddress.getCustomerAddressIdentifier().toString());
        }
    }
    String customerAddressIdentifier = request.getParameter(KFSPropertyConstants.CUSTOMER_ADDRESS_IDENTIFIER);
    if (isKualiLookupable && StringUtils.isNotBlank(customerAddressIdentifier)) {
        setupPayeeAsCustomer(dvForm, payeeIdNumber, customerAddressIdentifier);
    }
    String paymentReasonCode = document.getDvPayeeDetail().getDisbVchrPaymentReasonCode();
    addPaymentCodeWarningMessage(dvForm, paymentReasonCode);
    return null;
}
Also used : HashMap(java.util.HashMap) AccountsReceivableModuleService(org.kuali.kfs.integration.ar.AccountsReceivableModuleService) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) AccountsReceivableCustomerAddress(org.kuali.kfs.integration.ar.AccountsReceivableCustomerAddress) AccountsReceivableCustomer(org.kuali.kfs.integration.ar.AccountsReceivableCustomer) List(java.util.List) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Aggregations

AccountsReceivableCustomer (org.kuali.kfs.integration.ar.AccountsReceivableCustomer)3 AccountsReceivableCustomerAddress (org.kuali.kfs.integration.ar.AccountsReceivableCustomerAddress)3 AccountsReceivableModuleService (org.kuali.kfs.integration.ar.AccountsReceivableModuleService)3 HashMap (java.util.HashMap)2 List (java.util.List)2 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)2 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)2 VendorAddress (org.kuali.kfs.vnd.businessobject.VendorAddress)2 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)2 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)1