Search in sources :

Example 31 with VendorAddress

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

the class CuEinvoiceApiResource method addVendorRemitAddressToProperties.

private void addVendorRemitAddressToProperties(Properties vendorProperties, VendorDetail vendorDetail) {
    List<VendorAddress> vendorAddresses = vendorDetail.getVendorAddresses();
    if (CollectionUtils.isNotEmpty(vendorAddresses)) {
        VendorAddress vendorAddress = getVendorAddress(vendorDetail.getVendorAddresses());
        safelyAddProperty(vendorProperties, CUPurapConstants.Einvoice.EMAIL, vendorAddress.getVendorAddressEmailAddress());
        safelyAddProperty(vendorProperties, CUPurapConstants.Einvoice.ADDRESS_LINE1, vendorAddress.getVendorLine1Address());
        safelyAddProperty(vendorProperties, CUPurapConstants.Einvoice.ADDRESS_LINE2, vendorAddress.getVendorLine2Address());
        safelyAddProperty(vendorProperties, CUPurapConstants.Einvoice.CITY, vendorAddress.getVendorCityName());
        safelyAddProperty(vendorProperties, CUPurapConstants.Einvoice.STATE, vendorAddress.getVendorStateCode());
        safelyAddProperty(vendorProperties, CUPurapConstants.Einvoice.ZIPCODE, vendorAddress.getVendorZipCode());
        safelyAddProperty(vendorProperties, CUPurapConstants.Einvoice.COUNTRY_CODE, vendorAddress.getVendorCountryCode());
        safelyAddProperty(vendorProperties, CUPurapConstants.Einvoice.COUNTRY_NAME, vendorAddress.getVendorCountry().getName());
        safelyAddProperty(vendorProperties, CUPurapConstants.Einvoice.ADDRESS_TYPE_CODE, vendorAddress.getVendorAddressTypeCode());
    }
}
Also used : VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

Example 32 with VendorAddress

use of org.kuali.kfs.vnd.businessobject.VendorAddress 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 33 with VendorAddress

use of org.kuali.kfs.vnd.businessobject.VendorAddress 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)

Example 34 with VendorAddress

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

the class CuDisbursementVoucherExtractionHelperServiceImplTest method test.

public void test() {
    CuDisbursementVoucherDocument dv = null;
    try {
        dv = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
    } catch (WorkflowException e) {
        throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
    }
    if (dv != null) {
        dv.getDocumentHeader().setDocumentDescription("Test Document Description");
        dv.getDocumentHeader().setExplanation("Stuff");
        dv.initiateDocument();
        VendorDetail vendor = SpringContext.getBean(VendorService.class).getVendorDetail("13366-0");
        VendorAddress vendoraddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(vendor.getVendorHeaderGeneratedIdentifier(), vendor.getVendorDetailAssignedIdentifier(), "RM", "");
        System.out.println(vendoraddress.getVendorCityName() + "\n");
        dv.templateVendor(vendor, vendoraddress);
        dv.setPayeeAssigned(true);
        dv.getDvPayeeDetail().setDisbVchrPaymentReasonCode("S");
        dv.setDisbVchrCheckTotalAmount(new KualiDecimal(86.00));
        dv.setDisbVchrPaymentMethodCode("P");
        dv.setDisbVchrCheckStubText("check text");
        dv.setCampusCode("IT");
        SourceAccountingLine accountingLine = new SourceAccountingLine();
        accountingLine.setChartOfAccountsCode("IT");
        accountingLine.setAccountNumber("G081040");
        accountingLine.setFinancialObjectCode("8462");
        accountingLine.setAmount((new KualiDecimal(86.00)));
        accountingLine.setPostingYear(dv.getPostingYear());
        accountingLine.setDocumentNumber(dv.getDocumentNumber());
        dv.addSourceAccountingLine(accountingLine);
        try {
            documentService.saveDocument(dv);
        } catch (WorkflowException e) {
            throw new RuntimeException("Error saving new disbursement voucher document: " + e.getMessage(), e);
        }
    }
    Date transactionTimestamp = new Date(SpringContext.getBean(DateTimeService.class).getCurrentDate().getTime());
    Date processRunDate = new java.sql.Date(transactionTimestamp.getTime());
    PaymentGroup pg = cuDisbursementVoucherExtractionHelperService.createPaymentGroup(dv, processRunDate);
    assertTrue(pg.getPaymentDetails().get(0).getCustPaymentDocNbr().equalsIgnoreCase(dv.getDocumentNumber()));
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) DocumentService(org.kuali.kfs.krad.service.DocumentService) Date(java.sql.Date) VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorService(org.kuali.kfs.vnd.document.service.VendorService) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) DateTimeService(org.kuali.kfs.core.api.datetime.DateTimeService)

Example 35 with VendorAddress

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

the class CuDisbursementVoucherDocumentIntegrationTest method setupCuDisbursementVoucherDocument.

private CuDisbursementVoucherDocument setupCuDisbursementVoucherDocument() throws WorkflowException {
    CuDisbursementVoucherDocument dv = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
    dv.getDocumentHeader().setDocumentDescription("Test Document Description");
    dv.getDocumentHeader().setExplanation("Stuff");
    dv.initiateDocument();
    VendorDetail vendor = vendorService.getVendorDetail("13366-0");
    VendorAddress vendoraddress = vendorService.getVendorDefaultAddress(vendor.getVendorHeaderGeneratedIdentifier(), vendor.getVendorDetailAssignedIdentifier(), "RM", "");
    dv.templateVendor(vendor, vendoraddress);
    dv.setPayeeAssigned(true);
    dv.getDvPayeeDetail().setDisbVchrPaymentReasonCode("S");
    dv.setDisbVchrCheckTotalAmount(new KualiDecimal(86.00));
    dv.setDisbVchrPaymentMethodCode("P");
    dv.setDisbVchrCheckStubText("check text");
    dv.setCampusCode("IT");
    SourceAccountingLine accountingLine = new SourceAccountingLine();
    accountingLine.setChartOfAccountsCode("IT");
    accountingLine.setAccountNumber("G081040");
    accountingLine.setFinancialObjectCode("8462");
    accountingLine.setAmount((new KualiDecimal(86.00)));
    accountingLine.setPostingYear(dv.getPostingYear());
    accountingLine.setDocumentNumber(dv.getDocumentNumber());
    dv.addSourceAccountingLine(accountingLine);
    documentService.saveDocument(dv);
    return dv;
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

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