Search in sources :

Example 41 with DisbursementVoucherDocument

use of org.kuali.kfs.fp.document.DisbursementVoucherDocument 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);
    // if a cancel occurred on address lookup we need to reset the payee id and type, rest of fields will still have 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<String, String>();
            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)

Example 42 with DisbursementVoucherDocument

use of org.kuali.kfs.fp.document.DisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherAction method clearTravelPerDiem.

/**
 * Clears the travel per diem amount
 */
public ActionForward clearTravelPerDiem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
    DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) dvForm.getDocument();
    DisbursementVoucherNonEmployeeTravel dvNet = dvDocument.getDvNonEmployeeTravel();
    if (dvNet != null) {
        clearTravelPerDiem(dvNet);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : DisbursementVoucherNonEmployeeTravel(org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeTravel) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 43 with DisbursementVoucherDocument

use of org.kuali.kfs.fp.document.DisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherInitiatorPrimaryDepartmentValidation method validate.

/**
 * Validates that the initiator has a primary department id set up.
 *
 * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
 */
public boolean validate(AttributedDocumentEvent event) {
    boolean isValid = true;
    DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) accountingDocumentForValidation;
    String initiatorPrincipalId = dvDocument.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId();
    ChartOrgHolder chartOrg = SpringContext.getBean(org.kuali.kfs.sys.service.FinancialSystemUserService.class).getPrimaryOrganization(initiatorPrincipalId, KFSConstants.ParameterNamespaces.FINANCIAL);
    if (ObjectUtils.isNull(chartOrg) || ObjectUtils.isNull(chartOrg.getOrganization())) {
        GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, CUKFSKeyConstants.ERROR_DV_INITIATOR_INVALID_PRIMARY_DEPARTMENT);
        isValid = false;
    }
    return isValid;
}
Also used : ChartOrgHolder(org.kuali.kfs.sys.businessobject.ChartOrgHolder) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 44 with DisbursementVoucherDocument

use of org.kuali.kfs.fp.document.DisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class PaymentSourceExtractionServiceImpl method addPayment.

/**
 * This method creates a payment group from the disbursement voucher and batch provided and persists that group to the database.
 *
 * @param document The document used to build a payment group detail.
 * @param batch The batch file used to build a payment group and detail.
 * @param processRunDate The date the batch file is to post.
 */
protected void addPayment(PaymentSource document, Batch batch, Date processRunDate, boolean immediate) {
    LOG.info("addPayment() started for document number=" + document.getDocumentNumber());
    final java.sql.Date sqlProcessRunDate = new java.sql.Date(processRunDate.getTime());
    PaymentGroup pg = getPaymentSourceToExtractService().createPaymentGroup(document, sqlProcessRunDate);
    if (pg != null) {
        // the payment source returned null instead of a PaymentGroup?  I guess it didn't want to be paid for some reason (for instance, a 0 amount document or doc which didn't have a travel advance, etc)
        pg.setBatch(batch);
        // so, copy over for now.
        if (document instanceof DisbursementVoucherDocument) {
            if (pg.isPayableByACH()) {
                pg.setDisbursementTypeCode(PdpConstants.DisbursementTypeCodes.ACH);
            } else {
                pg.setDisbursementTypeCode(PdpConstants.DisbursementTypeCodes.CHECK);
            }
        }
        if (immediate) {
            pg.setProcessImmediate(Boolean.TRUE);
        }
        this.businessObjectService.save(pg);
        if (!testMode) {
            getPaymentSourceToExtractService().markAsExtracted(document, sqlProcessRunDate, pg.getId());
        }
    }
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) Date(java.util.Date) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Aggregations

DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)44 RecurringDisbursementVoucherDocument (edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument)10 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)8 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)7 ArrayList (java.util.ArrayList)6 List (java.util.List)4 DisbursementVoucherNonEmployeeTravel (org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeTravel)4 DisbursementVoucherPayeeDetail (org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail)4 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)4 Date (java.sql.Date)3 DisbursementVoucherNonEmployeeExpense (org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeExpense)3 DisbursementVoucherTaxService (org.kuali.kfs.fp.document.service.DisbursementVoucherTaxService)3 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)3 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)3 BatchDisbursementVoucherDocument (com.rsmart.kuali.kfs.fp.document.BatchDisbursementVoucherDocument)2 CuDisbursementVoucherPayeeDetail (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail)2 RecurringDisbursementVoucherDetail (edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail)2 HashMap (java.util.HashMap)2 DisbursementVoucherPreConferenceRegistrant (org.kuali.kfs.fp.businessobject.DisbursementVoucherPreConferenceRegistrant)2 DisbursementVoucherTravelService (org.kuali.kfs.fp.document.service.DisbursementVoucherTravelService)2