Search in sources :

Example 26 with VendorAddress

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

the class PaymentWorksVendorToKfsVendorDetailConversionServiceImpl method buildBaseAddress.

private VendorAddress buildBaseAddress(String addressType, String line1, String line2, String city, String zip, String fipsCountryCode) {
    VendorAddress baseAddress = new VendorAddress();
    baseAddress.setVendorAddressTypeCode(addressType);
    baseAddress.setVendorCountryCode(fipsCountryCode);
    baseAddress.setVendorLine1Address(line1);
    baseAddress.setVendorLine2Address(line2);
    baseAddress.setVendorCityName(city);
    baseAddress.setVendorZipCode(zip);
    baseAddress.setActive(true);
    return baseAddress;
}
Also used : VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

Example 27 with VendorAddress

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

the class PaymentGroup method validateVendorIdAndCustomerInstitutionIdentifier.

public void validateVendorIdAndCustomerInstitutionIdentifier() {
    BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
    Map<String, String> fieldValues = new HashMap<String, String>();
    fieldValues.put("vendorAddressGeneratedIdentifier", customerInstitutionNumber);
    String[] headerDetails = payeeId.split("-");
    fieldValues.put("vendorHeaderGeneratedIdentifier", headerDetails[0]);
    fieldValues.put("vendorDetailAssignedIdentifier", headerDetails[1]);
    List<VendorAddress> addrs = (List<VendorAddress>) bos.findMatching(VendorAddress.class, fieldValues);
    if (addrs.size() == 1) {
        VendorAddress addr = (VendorAddress) addrs.get(0);
        setVendorAddress(addr);
    } else {
        throw new RuntimeException("Invalid Address [ " + customerInstitutionNumber + " ] for payee [ " + payeeId + " ]");
    // Need to handle bad data.
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 28 with VendorAddress

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

the class IWantDocumentServiceImpl method setUpVendorSectionForReqDoc.

private void setUpVendorSectionForReqDoc(RequisitionDocument requisitionDocument, IWantDocument iWantDocument) {
    requisitionDocument.setVendorDetailAssignedIdentifier(iWantDocument.getVendorDetailAssignedIdentifier());
    requisitionDocument.setVendorHeaderGeneratedIdentifier(iWantDocument.getVendorHeaderGeneratedIdentifier());
    if (requisitionDocument.getVendorDetailAssignedIdentifier() != null && requisitionDocument.getVendorHeaderGeneratedIdentifier() != null) {
        requisitionDocument.setVendorContractGeneratedIdentifier(null);
        requisitionDocument.refreshReferenceObject("vendorContract");
        // retrieve vendor based on selection from vendor lookup
        requisitionDocument.refreshReferenceObject("vendorDetail");
        requisitionDocument.templateVendorDetail(requisitionDocument.getVendorDetail());
        // populate default address based on selected vendor
        VendorAddress defaultAddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(requisitionDocument.getVendorDetail().getVendorAddresses(), requisitionDocument.getVendorDetail().getVendorHeader().getVendorType().getAddressType().getVendorAddressTypeCode(), requisitionDocument.getDeliveryCampusCode());
        requisitionDocument.templateVendorAddress(defaultAddress);
        // vendor address holds method of po transmission that should be used
        requisitionDocument.setPurchaseOrderTransmissionMethodCode(((CuVendorAddressExtension) defaultAddress.getExtension()).getPurchaseOrderTransmissionMethodCode());
    } else {
        if (StringUtils.isNotBlank(iWantDocument.getVendorName())) {
            requisitionDocument.setVendorName(iWantDocument.getVendorName());
        }
    }
}
Also used : VendorService(org.kuali.kfs.vnd.document.service.VendorService) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

Example 29 with VendorAddress

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

the class CuB2BShoppingServiceImpl method createRequisitionsFromCxml.

@Override
public List createRequisitionsFromCxml(B2BShoppingCart message, Person user) throws WorkflowException {
    LOG.debug("createRequisitionsFromCxml() started");
    // for returning requisitions
    ArrayList requisitions = new ArrayList();
    // get items from the cart
    List items = message.getItems();
    // get vendor(s) for the items
    List vendors = getAllVendors(items);
    // create requisition(s) (one per vendor)
    for (Iterator iter = vendors.iterator(); iter.hasNext(); ) {
        VendorDetail vendor = (VendorDetail) iter.next();
        // create requisition
        RequisitionDocument req = (RequisitionDocument) documentService.getNewDocument(PurapConstants.REQUISITION_DOCUMENT_TYPE);
        String description = ((B2BShoppingCartItem) items.get(0)).getExtrinsic("CartName");
        String businessPurpose = ((CuB2BShoppingCart) message).getBusinessPurpose();
        req.getDocumentHeader().setDocumentDescription(description);
        req.getDocumentHeader().setExplanation(businessPurpose);
        req.setupAccountDistributionMethod();
        // set b2b contract for vendor
        VendorContract contract = vendorService.getVendorB2BContract(vendor, user.getCampusCode());
        if (ObjectUtils.isNotNull(contract)) {
            req.setVendorContractGeneratedIdentifier(contract.getVendorContractGeneratedIdentifier());
            if (ObjectUtils.isNotNull(contract.getPurchaseOrderCostSourceCode())) {
                // if cost source is set on contract, use it
                req.setPurchaseOrderCostSourceCode(contract.getPurchaseOrderCostSourceCode());
            } else {
                // if cost source is null on the contract, we set it by default to "Estimate"
                req.setPurchaseOrderCostSourceCode(PurapConstants.POCostSources.ESTIMATE);
            }
        } else {
            LOG.error("createRequisitionsFromCxml() Contract is missing for vendor " + vendor.getVendorName() + " (" + vendor.getVendorNumber() + ")");
            throw new B2BShoppingException(PurapConstants.B2B_VENDOR_CONTRACT_NOT_FOUND_ERROR_MESSAGE);
        }
        // get items for this vendor
        List itemsForVendor = getAllVendorItems(items, vendor);
        // KFSPTS-985
        checkToPopulateFavoriteAccount(itemsForVendor, user);
        // default data from user
        req.setDeliveryCampusCode(user.getCampusCode());
        req.setDeliveryToName(user.getName());
        req.setDeliveryToEmailAddress(user.getEmailAddressUnmasked());
        req.setDeliveryToPhoneNumber(SpringContext.getBean(PhoneNumberService.class).formatNumberIfPossible(user.getPhoneNumber()));
        DefaultPrincipalAddress defaultPrincipalAddress = new DefaultPrincipalAddress(user.getPrincipalId());
        Map addressKeys = SpringContext.getBean(PersistenceService.class).getPrimaryKeyFieldValues(defaultPrincipalAddress);
        defaultPrincipalAddress = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(DefaultPrincipalAddress.class, addressKeys);
        if (ObjectUtils.isNotNull(defaultPrincipalAddress) && ObjectUtils.isNotNull(defaultPrincipalAddress.getBuilding())) {
            if (defaultPrincipalAddress.getBuilding().isActive()) {
                req.setDeliveryCampusCode(defaultPrincipalAddress.getCampusCode());
                req.templateBuildingToDeliveryAddress(defaultPrincipalAddress.getBuilding());
                req.setDeliveryBuildingRoomNumber(defaultPrincipalAddress.getBuildingRoomNumber());
            } else {
                // since building is now inactive, delete default building record
                SpringContext.getBean(BusinessObjectService.class).delete(defaultPrincipalAddress);
            }
        }
        ChartOrgHolder purapChartOrg = SpringContext.getBean(FinancialSystemUserService.class).getPrimaryOrganization(user, PurapConstants.PURAP_NAMESPACE);
        if (ObjectUtils.isNotNull(purapChartOrg)) {
            req.setChartOfAccountsCode(purapChartOrg.getChartOfAccountsCode());
            req.setOrganizationCode(purapChartOrg.getOrganizationCode());
        }
        req.setRequestorPersonName(user.getName());
        req.setRequestorPersonEmailAddress(user.getEmailAddress());
        req.setRequestorPersonPhoneNumber(phoneNumberService.formatNumberIfPossible(user.getPhoneNumber()));
        req.setUseTaxIndicator(purchasingService.getDefaultUseTaxIndicatorValue(req));
        // set defaults that need to be set
        req.setVendorHeaderGeneratedIdentifier(vendor.getVendorHeaderGeneratedIdentifier());
        req.setVendorDetailAssignedIdentifier(vendor.getVendorDetailAssignedIdentifier());
        req.setVendorName(vendor.getVendorName());
        req.setVendorRestrictedIndicator(vendor.getVendorRestrictedIndicator());
        req.setItems(itemsForVendor);
        req.setDocumentFundingSourceCode(parameterService.getParameterValueAsString(RequisitionDocument.class, PurapParameterConstants.DEFAULT_FUNDING_SOURCE));
        req.setRequisitionSourceCode(PurapConstants.RequisitionSources.B2B);
        req.updateAndSaveAppDocStatus(RequisitionStatuses.APPDOC_IN_PROCESS);
        // KFSPTS-1446 : Needed to move the setting of method of PO transmission to after the templateVendorAddress call because that method will set the method of PO transmission to the value on the vendor address.
        // req.setPurchaseOrderTransmissionMethodCode(PurapConstants.POTransmissionMethods.ELECTRONIC);
        req.setOrganizationAutomaticPurchaseOrderLimit(purapService.getApoLimit(req));
        // retrieve from an item (sent in cxml at item level, but stored in db at REQ level)
        req.setExternalOrganizationB2bSupplierIdentifier(getSupplierIdFromFirstItem(itemsForVendor));
        // retrieve default PO address and set address
        VendorAddress vendorAddress = vendorService.getVendorDefaultAddress(vendor.getVendorHeaderGeneratedIdentifier(), vendor.getVendorDetailAssignedIdentifier(), VendorConstants.AddressTypes.PURCHASE_ORDER, user.getCampusCode());
        if (ObjectUtils.isNotNull(vendorAddress)) {
            req.templateVendorAddress(vendorAddress);
        }
        // KFSPTS-1446: Moved the setting of this attribute here from its original location to maintain the value of ELECTRONIC and not lose it to the templateVendorAddress value
        req.setPurchaseOrderTransmissionMethodCode(PurapConstants.POTransmissionMethods.ELECTRONIC);
        // retrieve billing address based on delivery campus and populate REQ with retrieved billing address
        BillingAddress billingAddress = new BillingAddress();
        billingAddress.setBillingCampusCode(req.getDeliveryCampusCode());
        Map keys = persistenceService.getPrimaryKeyFieldValues(billingAddress);
        billingAddress = businessObjectService.findByPrimaryKey(BillingAddress.class, keys);
        req.templateBillingAddress(billingAddress);
        // populate receiving address with the default one for the chart/org
        req.loadReceivingAddress();
        req.fixItemReferences();
        // save requisition to database
        purapService.saveDocumentNoValidation(req);
        // add requisition to List
        requisitions.add(req);
    }
    return requisitions;
}
Also used : DefaultPrincipalAddress(org.kuali.kfs.module.purap.businessobject.DefaultPrincipalAddress) VendorContract(org.kuali.kfs.vnd.businessobject.VendorContract) ArrayList(java.util.ArrayList) B2BShoppingException(org.kuali.kfs.module.purap.exception.B2BShoppingException) CuB2BShoppingCart(edu.cornell.kfs.module.purap.util.cxml.CuB2BShoppingCart) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) RequisitionDocument(org.kuali.kfs.module.purap.document.RequisitionDocument) PersistenceService(org.kuali.kfs.krad.service.PersistenceService) BillingAddress(org.kuali.kfs.module.purap.businessobject.BillingAddress) ChartOrgHolder(org.kuali.kfs.sys.businessobject.ChartOrgHolder) B2BShoppingCartItem(org.kuali.kfs.module.purap.businessobject.B2BShoppingCartItem) FinancialSystemUserService(org.kuali.kfs.sys.service.FinancialSystemUserService) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

Example 30 with VendorAddress

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

the class CuRequisitionDocument method toCopyFromGateway.

/**
 * toCopyFromGateway
 */
public void toCopyFromGateway() throws WorkflowException, ValidationException {
    // no validation for the KFS copy requisition rules:
    String sourceDocumentHeaderId = getDocumentNumber();
    setNewDocumentHeader();
    getDocumentHeader().setDocumentTemplateNumber(sourceDocumentHeaderId);
    // Clear out existing notes.
    if (getNotes() != null) {
        getNotes().clear();
    }
    addCopyErrorDocumentNote("copied from document " + sourceDocumentHeaderId);
    // --- LedgerPostingDocumentBase:
    setAccountingPeriod(retrieveCurrentAccountingPeriod());
    // --GeneralLedgerPostingDocumentBase:
    getGeneralLedgerPendingEntries().clear();
    // --AccountingDocumentBase:
    copyAccountingLines(false);
    updatePostingYearForAccountingLines(getSourceAccountingLines());
    updatePostingYearForAccountingLines(getTargetAccountingLines());
    // --RequisitionDocument:
    this.setObjectId(null);
    // Clear related views
    this.setAccountsPayablePurchasingDocumentLinkIdentifier(null);
    this.setRelatedViews(null);
    Person currentUser = GlobalVariables.getUserSession().getPerson();
    ChartOrgHolder purapChartOrg = SpringContext.getBean(FinancialSystemUserService.class).getPrimaryOrganization(currentUser, PurapConstants.PURAP_NAMESPACE);
    this.setPurapDocumentIdentifier(null);
    // Set req status to INPR.
    // for app doc status
    updateAndSaveAppDocStatus(RequisitionStatuses.APPDOC_IN_PROCESS);
    // Set fields from the user.
    if (ObjectUtils.isNotNull(purapChartOrg)) {
        this.setChartOfAccountsCode(purapChartOrg.getChartOfAccountsCode());
        this.setOrganizationCode(purapChartOrg.getOrganizationCode());
    }
    this.setPostingYear(SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear());
    boolean activeVendor = true;
    boolean activeContract = true;
    Date today = SpringContext.getBean(DateTimeService.class).getCurrentDate();
    VendorContract vendorContract = new VendorContract();
    vendorContract.setVendorContractGeneratedIdentifier(this.getVendorContractGeneratedIdentifier());
    Map keys = SpringContext.getBean(PersistenceService.class).getPrimaryKeyFieldValues(vendorContract);
    vendorContract = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(VendorContract.class, keys);
    if (!(vendorContract != null && today.after(vendorContract.getVendorContractBeginningDate()) && today.before(vendorContract.getVendorContractEndDate()))) {
        activeContract = false;
    }
    VendorDetail vendorDetail = SpringContext.getBean(VendorService.class).getVendorDetail(this.getVendorHeaderGeneratedIdentifier(), this.getVendorDetailAssignedIdentifier());
    if (!(vendorDetail != null && vendorDetail.isActiveIndicator())) {
        activeVendor = false;
    }
    // KFSPTS-916 : need vendor address key for business rules and only way to get it is to retrieve the default PO address for the vendor.
    if (vendorDetail != null) {
        VendorAddress vendorAddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(this.getVendorHeaderGeneratedIdentifier(), this.getVendorDetailAssignedIdentifier(), VendorConstants.AddressTypes.PURCHASE_ORDER, "");
        if (vendorAddress != null) {
            super.templateVendorAddress(vendorAddress);
        }
    }
    // B2B - only copy if contract and vendor are both active (throw separate errors to print to screen)
    if (this.getRequisitionSourceCode().equals(PurapConstants.RequisitionSources.B2B)) {
        if (!activeContract) {
        // --  throw new ValidationException(PurapKeyConstants.ERROR_REQ_COPY_EXPIRED_CONTRACT);
        }
        if (!activeVendor) {
        // -- throw new ValidationException(PurapKeyConstants.ERROR_REQ_COPY_INACTIVE_VENDOR);
        }
    }
    if (!activeVendor) {
        this.setVendorContractGeneratedIdentifier(null);
    }
    if (!activeContract) {
        this.setVendorContractGeneratedIdentifier(null);
    }
    // These fields should not be set in this method; force to be null
    this.setOrganizationAutomaticPurchaseOrderLimit(null);
    this.setPurchaseOrderAutomaticIndicator(false);
    for (Iterator iter = this.getItems().iterator(); iter.hasNext(); ) {
        RequisitionItem item = (RequisitionItem) iter.next();
        item.setPurapDocumentIdentifier(null);
        item.setItemIdentifier(null);
        for (Iterator acctIter = item.getSourceAccountingLines().iterator(); acctIter.hasNext(); ) {
            RequisitionAccount account = (RequisitionAccount) acctIter.next();
            account.setAccountIdentifier(null);
            account.setItemIdentifier(null);
        }
    }
    if (!PurapConstants.RequisitionSources.B2B.equals(this.getRequisitionSourceCode())) {
        SpringContext.getBean(PurapService.class).addBelowLineItems(this);
    }
    this.setOrganizationAutomaticPurchaseOrderLimit(getPurapService().getApoLimit(this));
    clearCapitalAssetFields();
    SpringContext.getBean(PurapService.class).clearTax(this, this.isUseTaxIndicator());
    this.refreshNonUpdateableReferences();
}
Also used : RequisitionAccount(org.kuali.kfs.module.purap.businessobject.RequisitionAccount) VendorContract(org.kuali.kfs.vnd.businessobject.VendorContract) Date(java.util.Date) PersistenceService(org.kuali.kfs.krad.service.PersistenceService) VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorService(org.kuali.kfs.vnd.document.service.VendorService) RequisitionItem(org.kuali.kfs.module.purap.businessobject.RequisitionItem) PurapService(org.kuali.kfs.module.purap.document.service.PurapService) CuPurapService(edu.cornell.kfs.module.purap.document.service.CuPurapService) ChartOrgHolder(org.kuali.kfs.sys.businessobject.ChartOrgHolder) FinancialSystemUserService(org.kuali.kfs.sys.service.FinancialSystemUserService) Iterator(java.util.Iterator) Person(org.kuali.kfs.kim.api.identity.Person) DateTimeService(org.kuali.kfs.core.api.datetime.DateTimeService) Map(java.util.Map) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress)

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