Search in sources :

Example 6 with Principal

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

the class PaymentSourceExtractionServiceImpl method extractSingleImmediatePayment.

/**
 * Extracts a single DisbursementVoucherDocument
 *
 * @see org.kuali.kfs.fp.batch.service.DisbursementVoucherExtractService#extractImmediatePayment(org.kuali.kfs.fp.document.DisbursementVoucherDocument)
 */
@Override
public void extractSingleImmediatePayment(PaymentSource paymentSource) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("extractImmediatePayment(DisbursementVoucherDocument) started");
    }
    if (getPaymentSourceToExtractService().shouldExtractPayment(paymentSource)) {
        final Date processRunDate = dateTimeService.getCurrentDate();
        final Principal principal = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(KFSConstants.SYSTEM_USER);
        if (principal == null) {
            LOG.debug("extractPayments() Unable to find user " + KFSConstants.SYSTEM_USER);
            throw new IllegalArgumentException("Unable to find user " + KFSConstants.SYSTEM_USER);
        }
        Batch batch = createBatch(paymentSource.getCampusCode(), principal.getPrincipalId(), processRunDate);
        KualiDecimal totalAmount = KualiDecimal.ZERO;
        addPayment(paymentSource, batch, processRunDate, true);
        totalAmount = totalAmount.add(getPaymentSourceToExtractService().getPaymentAmount(paymentSource));
        batch.setPaymentCount(new KualiInteger(1));
        batch.setPaymentTotalAmount(totalAmount);
        businessObjectService.save(batch);
        paymentFileEmailService.sendPaymentSourceImmediateExtractEmail(paymentSource, getPaymentSourceToExtractService().getImmediateExtractEMailFromAddress(), getPaymentSourceToExtractService().getImmediateExtractEmailToAddresses());
    }
}
Also used : Batch(org.kuali.kfs.pdp.businessobject.Batch) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) Date(java.util.Date) Principal(org.kuali.rice.kim.api.identity.principal.Principal)

Example 7 with Principal

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

the class PaymentSourceExtractionServiceImpl method extractPayments.

/**
 * This method extracts all payments from a disbursement voucher with a status code of "A" and uploads them as a batch for
 * processing.
 *
 * @return Always returns true if the method completes.
 * @see org.kuali.kfs.fp.batch.service.DisbursementVoucherExtractService#extractPayments()
 */
@Override
public boolean extractPayments() {
    if (LOG.isDebugEnabled()) {
        LOG.debug("extractPayments() started");
    }
    final Date processRunDate = dateTimeService.getCurrentDate();
    final Principal uuser = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(KFSConstants.SYSTEM_USER);
    if (uuser == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("extractPayments() Unable to find user " + KFSConstants.SYSTEM_USER);
        }
        throw new IllegalArgumentException("Unable to find user " + KFSConstants.SYSTEM_USER);
    }
    // Get a list of campuses that have documents with an 'A' (approved) status.
    Map<String, List<PaymentSource>> campusListMap = paymentSourceToExtractService.retrievePaymentSourcesByCampus(false);
    if (campusListMap != null && !campusListMap.isEmpty()) {
        // Process each campus one at a time
        for (String campusCode : campusListMap.keySet()) {
            extractPaymentsForCampus(campusCode, uuser.getPrincipalId(), processRunDate, campusListMap.get(campusCode));
        }
    }
    return true;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Date(java.util.Date) Principal(org.kuali.rice.kim.api.identity.principal.Principal)

Example 8 with Principal

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

the class IWantDocumentServiceImpl method setUpIWantDocDefaultValues.

/**
 * @see edu.cornell.kfs.module.purap.document.service.IWantDocumentService#setUpIWantDocDefaultValues(IWantDocument, Person)
 */
@Override
public void setUpIWantDocDefaultValues(IWantDocument iWantDocument, Person initiatorUser) {
    String principalId = iWantDocument.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId();
    Principal initiator = KimApiServiceLocator.getIdentityService().getPrincipal(principalId);
    String initiatorPrincipalID = initiator.getPrincipalId();
    String initiatorNetID = initiator.getPrincipalName();
    iWantDocument.setInitiatorNetID(initiatorNetID);
    String initiatorName = initiatorUser.getName();
    String initiatorPhoneNumber = initiatorUser.getPhoneNumber();
    String initiatorEmailAddress = initiatorUser.getEmailAddress();
    String address = getPersonCampusAddress(initiatorNetID);
    iWantDocument.setInitiatorName(initiatorName);
    iWantDocument.setInitiatorPhoneNumber(initiatorPhoneNumber);
    iWantDocument.setInitiatorEmailAddress(initiatorEmailAddress);
    iWantDocument.setInitiatorAddress(address);
    // check default user options
    Map<String, String> primaryKeysCollegeOption = new HashMap<String, String>();
    primaryKeysCollegeOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysCollegeOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_COLLEGE);
    IWantDocUserOptions userOptionsCollege = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysCollegeOption);
    Map<String, String> primaryKeysDepartmentOption = new HashMap<String, String>();
    primaryKeysDepartmentOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysDepartmentOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DEPARTMENT);
    IWantDocUserOptions userOptionsDepartment = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDepartmentOption);
    // check default deliver to address info
    Map<String, String> primaryKeysdeliverToNetIDOption = new HashMap<String, String>();
    primaryKeysdeliverToNetIDOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysdeliverToNetIDOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_NET_ID);
    IWantDocUserOptions userOptionsDeliverToNetID = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysdeliverToNetIDOption);
    Map<String, String> primaryKeysDeliverToNameOption = new HashMap<String, String>();
    primaryKeysDeliverToNameOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysDeliverToNameOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_NAME);
    IWantDocUserOptions userOptionsDeliverToName = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDeliverToNameOption);
    Map<String, String> primaryKeysDeliverToEmailOption = new HashMap<String, String>();
    primaryKeysDeliverToEmailOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysDeliverToEmailOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_EMAIL_ADDRESS);
    IWantDocUserOptions userOptionsDeliverToEmail = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDeliverToEmailOption);
    Map<String, String> primaryKeysDeliverToPhnNbrOption = new HashMap<String, String>();
    primaryKeysDeliverToPhnNbrOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysDeliverToPhnNbrOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_PHONE_NUMBER);
    IWantDocUserOptions userOptionsDeliverToPhnNbr = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDeliverToPhnNbrOption);
    Map<String, String> primaryKeysDeliverToAddressOption = new HashMap<String, String>();
    primaryKeysDeliverToAddressOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
    primaryKeysDeliverToAddressOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_ADDRESS);
    IWantDocUserOptions userOptionsDeliverToAddress = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDeliverToAddressOption);
    if (ObjectUtils.isNotNull(userOptionsCollege)) {
        iWantDocument.setCollegeLevelOrganization(userOptionsCollege.getOptionValue());
    }
    if (ObjectUtils.isNotNull(userOptionsDepartment)) {
        iWantDocument.setDepartmentLevelOrganization(userOptionsDepartment.getOptionValue());
    }
    // if no default user options check primary department
    if (ObjectUtils.isNull(userOptionsCollege) && ObjectUtils.isNull(userOptionsDepartment)) {
        String primaryDeptOrg = null;
        if (ObjectUtils.isNotNull(iWantDocument)) {
            Entity entityInfo = KimApiServiceLocator.getIdentityService().getEntityByPrincipalId(initiatorUser.getPrincipalId());
            if (ObjectUtils.isNotNull(entityInfo)) {
                if (ObjectUtils.isNotNull(entityInfo.getEmploymentInformation()) && entityInfo.getEmploymentInformation().size() > 0) {
                    EntityEmployment employmentInformation = entityInfo.getEmploymentInformation().get(0);
                    String primaryDepartment = employmentInformation.getPrimaryDepartmentCode();
                    primaryDeptOrg = primaryDepartment.substring(primaryDepartment.lastIndexOf('-') + 1, primaryDepartment.length());
                    String cLevelOrg = getCLevelOrganizationForDLevelOrg(primaryDepartment);
                    iWantDocument.setCollegeLevelOrganization(cLevelOrg);
                }
            }
        }
        if (ObjectUtils.isNotNull(iWantDocument) && StringUtils.isNotEmpty(iWantDocument.getCollegeLevelOrganization())) {
            if (ObjectUtils.isNotNull(primaryDeptOrg)) {
                iWantDocument.setDepartmentLevelOrganization(primaryDeptOrg);
            }
        }
    }
    if (ObjectUtils.isNotNull(userOptionsDeliverToNetID)) {
        iWantDocument.setDeliverToNetID(userOptionsDeliverToNetID.getOptionValue());
    }
    if (ObjectUtils.isNotNull(userOptionsDeliverToName)) {
        iWantDocument.setDeliverToName(userOptionsDeliverToName.getOptionValue());
    }
    if (ObjectUtils.isNotNull(userOptionsDeliverToEmail)) {
        iWantDocument.setDeliverToEmailAddress(userOptionsDeliverToEmail.getOptionValue());
    }
    if (ObjectUtils.isNotNull(userOptionsDeliverToPhnNbr)) {
        iWantDocument.setDeliverToPhoneNumber(userOptionsDeliverToPhnNbr.getOptionValue());
    }
    if (ObjectUtils.isNotNull(userOptionsDeliverToAddress)) {
        iWantDocument.setDeliverToAddress(userOptionsDeliverToAddress.getOptionValue());
    }
    setIWantDocumentDescription(iWantDocument);
}
Also used : Entity(org.kuali.rice.kim.api.identity.entity.Entity) HashMap(java.util.HashMap) EntityEmployment(org.kuali.rice.kim.api.identity.employment.EntityEmployment) IWantDocUserOptions(edu.cornell.kfs.module.purap.businessobject.IWantDocUserOptions) Principal(org.kuali.rice.kim.api.identity.principal.Principal)

Example 9 with Principal

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

the class IWantDocumentAction method docHandler.

/**
 * @see org.kuali.kfs.kns.web.struts.action.KualiDocumentActionBase#docHandler(org.apache.struts.action.ActionMapping,
 * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
 * javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward docHandler(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    ActionForward actionForward = super.docHandler(mapping, form, request, response);
    IWantDocumentForm iWantForm = (IWantDocumentForm) form;
    IWantDocument iWantDocument = iWantForm.getIWantDocument();
    String command = iWantForm.getCommand();
    String step = request.getParameter(CUPurapConstants.IWNT_STEP_PARAMETER);
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    if (step != null) {
        iWantForm.setStep(step);
    }
    if (iWantDocument != null) {
        if (iWantDocument.getDocumentHeader().getWorkflowDocument().isSaved()) {
            step = CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP;
        }
        iWantDocument.setStep(step);
        if (KewApiConstants.INITIATE_COMMAND.equalsIgnoreCase(command)) {
            iWantForm.setDocument(iWantDocument);
            if (iWantDocument != null) {
                String principalId = iWantDocument.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId();
                Principal initiator = KimApiServiceLocator.getIdentityService().getPrincipal(principalId);
                String initiatorPrincipalID = initiator.getPrincipalId();
                String initiatorNetID = initiator.getPrincipalName();
                iWantDocument.setInitiatorNetID(initiatorNetID);
                Person currentUser = GlobalVariables.getUserSession().getPerson();
                String initiatorName = currentUser.getNameUnmasked();
                String initiatorPhoneNumber = currentUser.getPhoneNumberUnmasked();
                String initiatorEmailAddress = currentUser.getEmailAddressUnmasked();
                String address = iWantDocumentService.getPersonCampusAddress(initiatorNetID);
                iWantDocument.setInitiatorName(initiatorName);
                iWantDocument.setInitiatorPhoneNumber(initiatorPhoneNumber);
                iWantDocument.setInitiatorEmailAddress(initiatorEmailAddress);
                iWantDocument.setInitiatorAddress(address);
                // check default user options
                Map<String, String> primaryKeysCollegeOption = new HashMap<String, String>();
                primaryKeysCollegeOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
                primaryKeysCollegeOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_COLLEGE);
                IWantDocUserOptions userOptionsCollege = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysCollegeOption);
                Map<String, String> primaryKeysDepartmentOption = new HashMap<String, String>();
                primaryKeysDepartmentOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
                primaryKeysDepartmentOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DEPARTMENT);
                IWantDocUserOptions userOptionsDepartment = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDepartmentOption);
                // check default deliver to address info
                Map<String, String> primaryKeysdeliverToNetIDOption = new HashMap<String, String>();
                primaryKeysdeliverToNetIDOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
                primaryKeysdeliverToNetIDOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_NET_ID);
                IWantDocUserOptions userOptionsDeliverToNetID = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysdeliverToNetIDOption);
                Map<String, String> primaryKeysDeliverToNameOption = new HashMap<String, String>();
                primaryKeysDeliverToNameOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
                primaryKeysDeliverToNameOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_NAME);
                IWantDocUserOptions userOptionsDeliverToName = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDeliverToNameOption);
                Map<String, String> primaryKeysDeliverToEmailOption = new HashMap<String, String>();
                primaryKeysDeliverToEmailOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
                primaryKeysDeliverToEmailOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_EMAIL_ADDRESS);
                IWantDocUserOptions userOptionsDeliverToEmail = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDeliverToEmailOption);
                Map<String, String> primaryKeysDeliverToPhnNbrOption = new HashMap<String, String>();
                primaryKeysDeliverToPhnNbrOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
                primaryKeysDeliverToPhnNbrOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_PHONE_NUMBER);
                IWantDocUserOptions userOptionsDeliverToPhnNbr = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDeliverToPhnNbrOption);
                Map<String, String> primaryKeysDeliverToAddressOption = new HashMap<String, String>();
                primaryKeysDeliverToAddressOption.put(CUPurapConstants.USER_OPTIONS_PRINCIPAL_ID, initiatorPrincipalID);
                primaryKeysDeliverToAddressOption.put(CUPurapConstants.USER_OPTIONS_OPTION_ID, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_ADDRESS);
                IWantDocUserOptions userOptionsDeliverToAddress = (IWantDocUserOptions) getBusinessObjectService().findByPrimaryKey(IWantDocUserOptions.class, primaryKeysDeliverToAddressOption);
                if (ObjectUtils.isNotNull(userOptionsCollege)) {
                    iWantDocument.setCollegeLevelOrganization(userOptionsCollege.getOptionValue());
                }
                if (ObjectUtils.isNotNull(userOptionsDepartment)) {
                    iWantDocument.setDepartmentLevelOrganization(userOptionsDepartment.getOptionValue());
                }
                // if no default user options check primary department
                if (ObjectUtils.isNull(userOptionsCollege) && ObjectUtils.isNull(userOptionsDepartment)) {
                    // / set college and department based on primary id
                    setCollegeAndDepartmentBasedOnPrimaryDepartment(iWantForm);
                }
                if (ObjectUtils.isNotNull(userOptionsDeliverToNetID)) {
                    iWantDocument.setDeliverToNetID(userOptionsDeliverToNetID.getOptionValue());
                }
                if (ObjectUtils.isNotNull(userOptionsDeliverToName)) {
                    iWantDocument.setDeliverToName(userOptionsDeliverToName.getOptionValue());
                }
                if (ObjectUtils.isNotNull(userOptionsDeliverToEmail)) {
                    iWantDocument.setDeliverToEmailAddress(userOptionsDeliverToEmail.getOptionValue());
                }
                if (ObjectUtils.isNotNull(userOptionsDeliverToPhnNbr)) {
                    iWantDocument.setDeliverToPhoneNumber(userOptionsDeliverToPhnNbr.getOptionValue());
                }
                if (ObjectUtils.isNotNull(userOptionsDeliverToAddress)) {
                    iWantDocument.setDeliverToAddress(userOptionsDeliverToAddress.getOptionValue());
                }
            }
            iWantDocumentService.setIWantDocumentDescription(iWantDocument);
        }
    }
    return actionForward;
}
Also used : HashMap(java.util.HashMap) IWantDocUserOptions(edu.cornell.kfs.module.purap.businessobject.IWantDocUserOptions) Person(org.kuali.rice.kim.api.identity.Person) ActionForward(org.apache.struts.action.ActionForward) Principal(org.kuali.rice.kim.api.identity.principal.Principal) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument) IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService)

Aggregations

Principal (org.kuali.rice.kim.api.identity.principal.Principal)9 Date (java.util.Date)3 IWantDocUserOptions (edu.cornell.kfs.module.purap.businessobject.IWantDocUserOptions)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)1 IWantDocumentService (edu.cornell.kfs.module.purap.document.service.IWantDocumentService)1 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)1 ActionForward (org.apache.struts.action.ActionForward)1 Batch (org.kuali.kfs.pdp.businessobject.Batch)1 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)1 KualiInteger (org.kuali.rice.core.api.util.type.KualiInteger)1 Person (org.kuali.rice.kim.api.identity.Person)1 EntityEmployment (org.kuali.rice.kim.api.identity.employment.EntityEmployment)1 Entity (org.kuali.rice.kim.api.identity.entity.Entity)1