Search in sources :

Example 26 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class SubmitTripWebServiceImpl method canViewKfsDocument.

/**
 * @param viewerNetId
 * @param docID
 * @return
 * @throws Exception
 */
public boolean canViewKfsDocument(String viewerNetId, String docID) throws Exception {
    Person viewer = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(viewerNetId);
    Document document = SpringContext.getBean(DocumentService.class).getByDocumentHeaderIdSessionless(docID);
    DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(document);
    return documentAuthorizer.canOpen(document, viewer);
}
Also used : PersonService(org.kuali.rice.kim.api.identity.PersonService) DocumentAuthorizer(org.kuali.kfs.krad.document.DocumentAuthorizer) Document(org.kuali.kfs.krad.document.Document) DistributionOfIncomeAndExpenseDocument(org.kuali.kfs.fp.document.DistributionOfIncomeAndExpenseDocument) CuDistributionOfIncomeAndExpenseDocument(edu.cornell.kfs.fp.document.CuDistributionOfIncomeAndExpenseDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) Person(org.kuali.rice.kim.api.identity.Person) DocumentService(org.kuali.kfs.krad.service.DocumentService) DocumentHelperService(org.kuali.kfs.kns.service.DocumentHelperService)

Example 27 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class SubmitTripWebServiceImpl method buildDisbursementVoucher.

/**
 * @param dvDescription
 * @param dvExplanation
 * @param tripNumber
 * @param travelerNetId
 * @param initiatorNetId
 * @param totalAmount
 * @param checkStubText
 * @return
 * @throws Exception
 */
private String buildDisbursementVoucher(String dvDescription, String dvExplanation, String tripNumber, String travelerNetId, String initiatorNetId, double totalAmount, String checkStubText) throws Exception {
    try {
        if (!isValidDocumentInitiator(initiatorNetId, DISBURSEMENT_VOUCHER)) {
            throw new RuntimeException("Initiator identified does not have permission to create a DV.");
        }
    } catch (Exception ex) {
        throw new RuntimeException("Initiator identified does not have permission to create a DV.", ex);
    }
    // create and route doc as system user
    GlobalVariables.setUserSession(new UserSession(initiatorNetId));
    MessageMap documentErrorMap = new MessageMap();
    GlobalVariables.setMessageMap(documentErrorMap);
    // Create document with description provided
    CuDisbursementVoucherDocument dvDoc = null;
    try {
        dvDoc = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
    } catch (WorkflowException e) {
        throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
    }
    if (dvDoc != null) {
        dvDoc.getDocumentHeader().setDocumentDescription(dvDescription);
        dvDoc.getDocumentHeader().setExplanation(dvExplanation);
        dvDoc.getDocumentHeader().setOrganizationDocumentNumber(tripNumber);
        dvDoc.initiateDocument();
        // Set vendor to traveler using netID provided
        Person traveler = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(travelerNetId);
        for (EntityAffiliationContract entityAffiliation : ((PersonImpl) traveler).getAffiliations()) {
            if (entityAffiliation.isDefaultValue()) {
                if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STUDENT)) {
                    dvDoc.templateStudent(traveler);
                } else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.ALUMNI)) {
                    dvDoc.templateAlumni(traveler);
                } else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.FACULTY) || StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STAFF)) {
                    dvDoc.templateEmployee(traveler);
                }
            }
        }
        dvDoc.setPayeeAssigned(true);
        dvDoc.getDvPayeeDetail().setDisbVchrPaymentReasonCode("J");
        dvDoc.setDisbVchrCheckTotalAmount(new KualiDecimal(totalAmount));
        dvDoc.setDisbVchrPaymentMethodCode("P");
        dvDoc.setDisbVchrCheckStubText(checkStubText);
        dvDoc.setTripId(tripNumber);
        dvDoc.setTripAssociationStatusCode(CULegacyTravelServiceImpl.TRIP_ASSOCIATIONS.IS_TRIP_DOC);
        // Persist document
        SpringContext.getBean(DocumentService.class).saveDocument(dvDoc);
        return dvDoc.getDocumentNumber();
    } else {
        return "";
    }
}
Also used : EntityAffiliationContract(org.kuali.rice.kim.api.identity.affiliation.EntityAffiliationContract) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) PersonImpl(org.kuali.rice.kim.impl.identity.PersonImpl) UserSession(org.kuali.kfs.krad.UserSession) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) PersonService(org.kuali.rice.kim.api.identity.PersonService) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) Person(org.kuali.rice.kim.api.identity.Person) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) MessageMap(org.kuali.kfs.krad.util.MessageMap) DocumentService(org.kuali.kfs.krad.service.DocumentService)

Example 28 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method cancelOpenPDPPayments.

@Override
public Set<String> cancelOpenPDPPayments(RecurringDisbursementVoucherDocument recurringDisbursementVoucherDocument, String cancelMessage) {
    Collection<PaymentDetail> paymentDetails = findPaymentDetailsFromRecurringDisbursementVoucher(recurringDisbursementVoucherDocument);
    Set<String> canceledPaymentGroups = new HashSet<String>();
    Person loggedINPerson = GlobalVariables.getUserSession().getPerson();
    for (PaymentDetail detail : paymentDetails) {
        String paymentDetailStatus = detail.getPaymentGroup().getPaymentStatusCode();
        if (isPaymentCancelableByLoggedInUser(paymentDetailStatus)) {
            LOG.debug("cancelPDPPayments: About to Cancel " + detail.getId() + " for a reason of " + cancelMessage);
            int paymentGroupId = detail.getPaymentGroupId().intValue();
            int paymentDetailId = detail.getId().intValue();
            boolean canceledSuccessfully = getRecurringDisbursementVoucherPaymentMaintenanceService().cancelPendingPayment(paymentGroupId, paymentDetailId, cancelMessage, loggedINPerson);
            if (canceledSuccessfully) {
                canceledPaymentGroups.add(detail.getPaymentGroupId().toString());
            } else {
                throw new RuntimeException("cancelPDPPayments: unable to cancel payment Payment Detail " + detail.getId());
            }
        } else {
            LOG.debug("cancelPDPPayments: Not going to cancel Payment Detail " + detail.getId());
        }
    }
    noteChangeOnRecurringDV(recurringDisbursementVoucherDocument, "The following payments were canceled: ", canceledPaymentGroups);
    return canceledPaymentGroups;
}
Also used : PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) Person(org.kuali.rice.kim.api.identity.Person) HashSet(java.util.HashSet)

Example 29 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class CuPaymentFileValidationServiceImpl method processGroupValidation.

@Override
protected void processGroupValidation(PaymentFileLoad paymentFile, MessageMap errorMap) {
    int groupCount = 0;
    for (PaymentGroup paymentGroup : paymentFile.getPaymentGroups()) {
        groupCount++;
        int noteLineCount = 0;
        int detailCount = 0;
        // We've encountered Payment Files that have address lines exceeding the column size in DB table;
        // so adding extra validation on payment group BO, especially the max length, based on DD definitions.
        // Check that PaymentGroup String properties don't exceed maximum allowed length
        checkPaymentGroupPropertyMaxLength(paymentGroup, errorMap);
        // verify payee id and owner code if customer requires them to be filled in
        if (paymentFile.getCustomer().getPayeeIdRequired() && StringUtils.isBlank(paymentGroup.getPayeeId())) {
            LOG.debug("processGroupValidation, No payee");
            errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_PAYEE_ID_REQUIRED, Integer.toString(groupCount));
        }
        if (paymentFile.getCustomer().getOwnershipCodeRequired() && StringUtils.isBlank(paymentGroup.getPayeeOwnerCd())) {
            LOG.debug("processGroupValidation, no ownership code");
            errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_PAYEE_OWNER_CODE, Integer.toString(groupCount));
        }
        // validate payee id type
        if (StringUtils.isNotBlank(paymentGroup.getPayeeIdTypeCd())) {
            PayeeType payeeType = businessObjectService.findBySinglePrimaryKey(PayeeType.class, paymentGroup.getPayeeIdTypeCd());
            if (payeeType == null) {
                LOG.debug("processGroupValidation, no payee type");
                errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_INVALID_PAYEE_ID_TYPE, Integer.toString(groupCount), paymentGroup.getPayeeIdTypeCd());
            }
        }
        // validate vendor id and customer institution number
        if (paymentGroup.getPayeeId().split("-").length > 1) {
            try {
                paymentGroup.validateVendorIdAndCustomerInstitutionIdentifier();
            } catch (RuntimeException e1) {
                LOG.error("processGroupValidation, there was an error validating customer institution information", e1);
                errorMap.putError(KFSConstants.GLOBAL_ERRORS, CUKFSKeyConstants.ERROR_BATCH_UPLOAD_PARSING_XML, new String[] { e1.getMessage() });
            }
        } else {
            LOG.debug("processGroupValidation, found a non vendor number payee ID: " + paymentGroup.getPayeeId());
            if (cuPdpEmployeeService.shouldPayeeBeProcessedAsEmployeeForThisCustomer(paymentFile)) {
                Person employee = findPerson(paymentGroup.getPayeeId());
                if (ObjectUtils.isNull(employee)) {
                    LOG.error("processGroupValidation, unable to get a person from the employee id");
                    errorMap.putError(KFSConstants.GLOBAL_ERRORS, CUPdpKeyConstants.ERROR_PDP_PAYMENTLOAD_INVALID_EMPLOYEE_ID, paymentGroup.getPayeeId());
                }
            }
        }
        // validate bank
        String bankCode = paymentGroup.getBankCode();
        if (StringUtils.isNotBlank(bankCode)) {
            Bank bank = bankService.getByPrimaryId(bankCode);
            if (bank == null) {
                LOG.debug("processGroupValidation, no bank");
                errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_INVALID_BANK_CODE, Integer.toString(groupCount), bankCode);
            } else if (!bank.isActive()) {
                LOG.debug("processGroupValidation, bank isn't active");
                errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_INACTIVE_BANK_CODE, Integer.toString(groupCount), bankCode);
            }
        }
        KualiDecimal groupTotal = KualiDecimal.ZERO;
        for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
            detailCount++;
            // Add a line to print the invoice number
            noteLineCount++;
            noteLineCount = noteLineCount + paymentDetail.getNotes().size();
            if ((paymentDetail.getNetPaymentAmount() == null) && (!paymentDetail.isDetailAmountProvided())) {
                paymentDetail.setNetPaymentAmount(paymentDetail.getAccountTotal());
            } else if ((paymentDetail.getNetPaymentAmount() == null) && (paymentDetail.isDetailAmountProvided())) {
                paymentDetail.setNetPaymentAmount(paymentDetail.getCalculatedPaymentAmount());
            }
            // compare net to accounting segments
            if (paymentDetail.getAccountTotal().compareTo(paymentDetail.getNetPaymentAmount()) != 0) {
                LOG.debug("processGroupValidation, account total (" + paymentDetail.getAccountTotal() + ") not equal to net amount total (" + paymentDetail.getNetPaymentAmount() + ")");
                errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_DETAIL_TOTAL_MISMATCH, Integer.toString(groupCount), Integer.toString(detailCount), paymentDetail.getAccountTotal().toString(), paymentDetail.getNetPaymentAmount().toString());
            }
            // validate origin code if given
            if (StringUtils.isNotBlank(paymentDetail.getFinancialSystemOriginCode())) {
                OriginationCode originationCode = originationCodeService.getByPrimaryKey(paymentDetail.getFinancialSystemOriginCode());
                if (originationCode == null) {
                    LOG.debug("processGroupValidation, origination code is null");
                    errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_INVALID_ORIGIN_CODE, Integer.toString(groupCount), Integer.toString(detailCount), paymentDetail.getFinancialSystemOriginCode());
                }
            }
            // validate doc type if given
            if (StringUtils.isNotBlank(paymentDetail.getFinancialDocumentTypeCode())) {
                if (!documentTypeService.isActiveByName(paymentDetail.getFinancialDocumentTypeCode())) {
                    LOG.debug("processGroupValidation, " + paymentDetail.getFinancialDocumentTypeCode() + " is not active.");
                    errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_INVALID_DOC_TYPE, Integer.toString(groupCount), Integer.toString(detailCount), paymentDetail.getFinancialDocumentTypeCode());
                }
            }
            groupTotal = groupTotal.add(paymentDetail.getNetPaymentAmount());
        }
        // verify total for group is not negative
        if (groupTotal.doubleValue() < 0) {
            LOG.debug("processGroupValidation, group total less than zero");
            errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_NEGATIVE_GROUP_TOTAL, Integer.toString(groupCount));
        }
        // check that the number of detail items and note lines will fit on a check stub
        if (noteLineCount > getMaxNoteLines()) {
            LOG.debug("processGroupValidation, too many notes");
            errorMap.putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.ERROR_PAYMENT_LOAD_MAX_NOTE_LINES, Integer.toString(groupCount), Integer.toString(noteLineCount), Integer.toString(getMaxNoteLines()));
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("After processGroupValidation: " + printErrorMap(errorMap));
        }
    }
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) Bank(org.kuali.kfs.sys.businessobject.Bank) PayeeType(org.kuali.kfs.pdp.businessobject.PayeeType) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) OriginationCode(org.kuali.kfs.sys.businessobject.OriginationCode) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) Person(org.kuali.rice.kim.api.identity.Person)

Example 30 with Person

use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class CuFormatAction method prepare.

@Override
public ActionForward prepare(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    CuFormatForm formatForm = (CuFormatForm) form;
    DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
    if (formatForm.getCampus() == null) {
        return mapping.findForward(PdpConstants.MAPPING_SELECTION);
    }
    // Figure out which ones they have selected
    List selectedCustomers = new ArrayList();
    for (CustomerProfile customer : formatForm.getCustomers()) {
        if (customer.isSelectedForFormat()) {
            selectedCustomers.add(customer);
        }
    }
    Date paymentDate = dateTimeService.convertToSqlDate(formatForm.getPaymentDate());
    Person kualiUser = GlobalVariables.getUserSession().getPerson();
    FormatProcessSummary formatProcessSummary = ((CuFormatService) formatService).startFormatProcess(kualiUser, formatForm.getCampus(), selectedCustomers, paymentDate, formatForm.getPaymentTypes(), formatForm.getPaymentDistribution());
    if (formatProcessSummary.getProcessSummaryList().size() == 0) {
        KNSGlobalVariables.getMessageList().add(PdpKeyConstants.Format.ERROR_PDP_NO_MATCHING_PAYMENT_FOR_FORMAT);
        return mapping.findForward(PdpConstants.MAPPING_SELECTION);
    }
    formatForm.setFormatProcessSummary(formatProcessSummary);
    return mapping.findForward(PdpConstants.MAPPING_CONTINUE);
}
Also used : FormatProcessSummary(org.kuali.kfs.pdp.businessobject.FormatProcessSummary) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CustomerProfile(org.kuali.kfs.pdp.businessobject.CustomerProfile) DateTimeService(org.kuali.rice.core.api.datetime.DateTimeService) Person(org.kuali.rice.kim.api.identity.Person) Date(java.util.Date) CuFormatService(edu.cornell.kfs.pdp.service.CuFormatService)

Aggregations

Person (org.kuali.rice.kim.api.identity.Person)64 ArrayList (java.util.ArrayList)12 PersonService (org.kuali.rice.kim.api.identity.PersonService)12 HashMap (java.util.HashMap)10 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)8 List (java.util.List)6 AdHocRoutePerson (org.kuali.kfs.krad.bo.AdHocRoutePerson)6 Map (java.util.Map)5 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)5 Note (org.kuali.kfs.krad.bo.Note)5 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)5 DateTimeService (org.kuali.rice.core.api.datetime.DateTimeService)5 MessageMap (org.kuali.kfs.krad.util.MessageMap)4 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)4 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)4 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)4 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)3 Date (java.util.Date)3 ChartOrgHolder (org.kuali.kfs.sys.businessobject.ChartOrgHolder)3 AccountingXmlDocumentNote (edu.cornell.kfs.fp.batch.xml.AccountingXmlDocumentNote)2