Search in sources :

Example 1 with PayeeACHAccount

use of org.kuali.kfs.pdp.businessobject.PayeeACHAccount in project cu-kfs by CU-CommunityApps.

the class PayeeACHAccountExtractServiceImpl method addACHAccount.

/**
 * Creates and routes a PAAT document to create a new ACH Account of the given payee type.
 */
protected String addACHAccount(Person payee, PayeeACHAccountExtractDetail achDetail, String payeeType) {
    // Create and route a new PAAT (Payee ACH Account Maintenance) document.
    String processingError = null;
    try {
        // Create document and set description.
        MaintenanceDocument paatDocument = (MaintenanceDocument) documentService.getNewDocument(CUPdpConstants.PAYEE_ACH_ACCOUNT_EXTRACT_MAINT_DOC_TYPE);
        paatDocument.getDocumentHeader().setDocumentDescription(getDocumentDescription(payee, PayeeIdTypeCodes.ENTITY.equals(payeeType), true));
        // Configure as "New" maintenance and get maintained object.
        PayeeACHAccountMaintainableImpl maintainable = (PayeeACHAccountMaintainableImpl) paatDocument.getNewMaintainableObject();
        maintainable.setMaintenanceAction(KFSConstants.MAINTENANCE_NEW_ACTION);
        PayeeACHAccount achAccount = (PayeeACHAccount) maintainable.getDataObject();
        // Setup payee ID and type.
        if (PayeeIdTypeCodes.ENTITY.equals(payeeType)) {
            achAccount.setPayeeIdNumber(payee.getEntityId());
        } else if (PayeeIdTypeCodes.EMPLOYEE.equals(payeeType)) {
            achAccount.setPayeeIdNumber(payee.getEmployeeId());
        } else {
            processingError = new String("addACHAccount: " + achDetail.getLogData() + ": Unexpected payee ID type '" + payeeType + "' for automated Payee during ACH Account creation attempt.");
            LOG.error(processingError);
            return processingError;
        }
        achAccount.setPayeeIdentifierTypeCode(payeeType);
        // Setup other fields.
        achAccount.setAchAccountGeneratedIdentifier(new KualiInteger(sequenceAccessorService.getNextAvailableSequenceNumber(PdpConstants.ACH_ACCOUNT_IDENTIFIER_SEQUENCE_NAME)));
        achAccount.setAchTransactionType(getDirectDepositTransactionType());
        achAccount.setBankRoutingNumber(achDetail.getBankRoutingNumber());
        achAccount.setBankAccountNumber(achDetail.getBankAccountNumber());
        achAccount.setBankAccountTypeCode(getACHTransactionCode(achDetail.getBankAccountType()));
        if (StringUtils.isNotBlank(payee.getNameUnmasked())) {
            achAccount.setPayeeName(payee.getNameUnmasked());
        }
        if (StringUtils.isNotBlank(payee.getEmailAddressUnmasked())) {
            achAccount.setPayeeEmailAddress(payee.getEmailAddressUnmasked());
        }
        achAccount.setActive(true);
        // Add a note indicating that this document was generated by a batch process.
        addNote(paatDocument, parameterService.getParameterValueAsString(PayeeACHAccountExtractStep.class, CUPdpParameterConstants.GENERATED_PAYEE_ACH_ACCOUNT_DOC_NOTE_TEXT));
        // Route the document and send notifications.
        paatDocument = (MaintenanceDocument) documentService.routeDocument(paatDocument, KFSConstants.EMPTY_STRING, null);
        sendPayeeACHAccountAddOrUpdateEmail((PayeeACHAccount) paatDocument.getNewMaintainableObject().getDataObject(), payee, getPayeeACHAccountAddOrUpdateEmailSubject(true), getUnresolvedPayeeACHAccountAddOrUpdateEmailBody(true));
    } catch (Exception e) {
        LOG.error("addACHAccount STE " + e.getStackTrace() + e.toString());
        LOG.error(getFailRequestMessage(e));
        processingError = new String("addACHAccount: " + achDetail.getLogData() + " STE was generated. " + getFailRequestMessage(e));
    }
    return processingError;
}
Also used : PayeeACHAccountMaintainableImpl(org.kuali.kfs.pdp.document.PayeeACHAccountMaintainableImpl) MaintenanceDocument(org.kuali.kfs.krad.maintenance.MaintenanceDocument) PayeeACHAccount(org.kuali.kfs.pdp.businessobject.PayeeACHAccount) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) PayeeACHAccountExtractStep(edu.cornell.kfs.pdp.batch.PayeeACHAccountExtractStep) ValidationException(org.kuali.kfs.krad.exception.ValidationException) MessagingException(javax.mail.MessagingException) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) FileNotFoundException(java.io.FileNotFoundException) InvalidAddressException(org.kuali.kfs.krad.exception.InvalidAddressException) IOException(java.io.IOException) ParseException(org.kuali.kfs.sys.exception.ParseException)

Example 2 with PayeeACHAccount

use of org.kuali.kfs.pdp.businessobject.PayeeACHAccount in project cu-kfs by CU-CommunityApps.

the class CuFormatServiceImpl method populateDisbursementType.

/**
 * This method sets the appropriate disbursement type on the Payment Group to either ACH or CHCK.
 *
 * @param paymentGroup
 */
protected void populateDisbursementType(PaymentGroup paymentGroup) {
    DisbursementType disbursementType = null;
    if (paymentGroup.isPayableByCheck()) {
        disbursementType = (DisbursementType) businessObjectService.findBySinglePrimaryKey(DisbursementType.class, PdpConstants.DisbursementTypeCodes.CHECK);
        paymentGroup.setDisbursementType(disbursementType);
        paymentGroup.setDisbursementTypeCode(PdpConstants.DisbursementTypeCodes.CHECK);
    } else {
        disbursementType = (DisbursementType) businessObjectService.findBySinglePrimaryKey(DisbursementType.class, PdpConstants.DisbursementTypeCodes.ACH);
        paymentGroup.setDisbursementType(disbursementType);
        paymentGroup.setDisbursementTypeCode(PdpConstants.DisbursementTypeCodes.ACH);
        CustomerProfile customer = paymentGroup.getBatch().getCustomerProfile();
        PayeeACHAccount payeeAchAccount = SpringContext.getBean(AchService.class).getAchInformation(paymentGroup.getPayeeIdTypeCd(), paymentGroup.getPayeeId(), customer.getAchTransactionType());
        paymentGroup.setAchBankRoutingNbr(payeeAchAccount.getBankRoutingNumber());
        paymentGroup.setAdviceEmailAddress(payeeAchAccount.getPayeeEmailAddress());
        paymentGroup.setAchAccountType(payeeAchAccount.getBankAccountTypeCode());
        AchAccountNumber achAccountNumber = new AchAccountNumber();
        achAccountNumber.setAchBankAccountNbr(payeeAchAccount.getBankAccountNumber());
        achAccountNumber.setId(paymentGroup.getId());
        paymentGroup.setAchAccountNumber(achAccountNumber);
    }
}
Also used : AchAccountNumber(org.kuali.kfs.pdp.businessobject.AchAccountNumber) PayeeACHAccount(org.kuali.kfs.pdp.businessobject.PayeeACHAccount) DisbursementType(org.kuali.kfs.pdp.businessobject.DisbursementType) CustomerProfile(org.kuali.kfs.pdp.businessobject.CustomerProfile) AchService(org.kuali.kfs.pdp.service.AchService)

Example 3 with PayeeACHAccount

use of org.kuali.kfs.pdp.businessobject.PayeeACHAccount in project cu-kfs by CU-CommunityApps.

the class CuPayeeACHAccountMaintainableImpl method refresh.

@Override
public void refresh(String refreshCaller, Map fieldValues, MaintenanceDocument document) {
    super.refresh(refreshCaller, fieldValues, document);
    if (StringUtils.isNotEmpty(refreshCaller) && refreshCaller.equalsIgnoreCase("achPayeeLookupable")) {
        PayeeACHAccount payeeAchAccount = (PayeeACHAccount) document.getNewMaintainableObject().getBusinessObject();
        String payeeIdNumber = payeeAchAccount.getPayeeIdNumber();
        String payeeIdentifierTypeCode = payeeAchAccount.getPayeeIdentifierTypeCode();
        if (StringUtils.isNotEmpty(payeeAchAccount.getPayeeIdNumber())) {
            // for Employee, retrieve from Person table by employee ID
            if (StringUtils.equalsIgnoreCase(payeeIdentifierTypeCode, PayeeIdTypeCodes.EMPLOYEE)) {
                Person person = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeIdNumber);
                if (ObjectUtils.isNotNull(person)) {
                    payeeAchAccount.setPayeeEmailAddress(person.getEmailAddress());
                }
            } else // for Entity, retrieve from Entity table by entity ID then from Person table
            if (StringUtils.equalsIgnoreCase(payeeIdentifierTypeCode, PayeeIdTypeCodes.ENTITY)) {
                if (ObjectUtils.isNotNull(payeeIdNumber)) {
                    EntityDefault entity = KimApiServiceLocator.getIdentityService().getEntityDefault(payeeIdNumber);
                    if (ObjectUtils.isNotNull(entity)) {
                        List<Principal> principals = entity.getPrincipals();
                        if (principals.size() > 0 && ObjectUtils.isNotNull(principals.get(0))) {
                            String principalId = principals.get(0).getPrincipalId();
                            Person person = SpringContext.getBean(PersonService.class).getPerson(principalId);
                            if (ObjectUtils.isNotNull(person)) {
                                payeeAchAccount.setPayeeEmailAddress(person.getEmailAddress());
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : PayeeACHAccount(org.kuali.kfs.pdp.businessobject.PayeeACHAccount) PersonService(org.kuali.rice.kim.api.identity.PersonService) List(java.util.List) Person(org.kuali.rice.kim.api.identity.Person) EntityDefault(org.kuali.rice.kim.api.identity.entity.EntityDefault)

Example 4 with PayeeACHAccount

use of org.kuali.kfs.pdp.businessobject.PayeeACHAccount in project cu-kfs by CU-CommunityApps.

the class CuPayeeACHAccountMaintenanceDocumentPresentationController method getConditionallyReadOnlyPropertyNames.

/**
 * Adds the payeeEmailAddress field as readOnly if payee type is Employee or Entity.
 * @see org.kuali.kfs.kns.document.authorization.MaintenanceDocumentPresentationControllerBase#getConditionallyReadOnlyPropertyNames(org.kuali.kfs.kns.document.MaintenanceDocument)
 */
@Override
public Set<String> getConditionallyReadOnlyPropertyNames(MaintenanceDocument document) {
    Set<String> readOnlyPropertyNames = super.getConditionallyReadOnlyPropertyNames(document);
    PayeeACHAccount payeeAccount = (PayeeACHAccount) document.getNewMaintainableObject().getBusinessObject();
    String payeeIdTypeCode = payeeAccount.getPayeeIdentifierTypeCode();
    // make name and email address readOnly if payee type is Employee or Entity
    if (StringUtils.equalsIgnoreCase(payeeIdTypeCode, PayeeIdTypeCodes.EMPLOYEE) || StringUtils.equalsIgnoreCase(payeeIdTypeCode, PayeeIdTypeCodes.ENTITY)) {
        if (readOnlyPropertyNames.contains(PdpPropertyConstants.PAYEE_EMAIL_ADDRESS)) {
            readOnlyPropertyNames.remove(PdpPropertyConstants.PAYEE_EMAIL_ADDRESS);
        }
    }
    return readOnlyPropertyNames;
}
Also used : PayeeACHAccount(org.kuali.kfs.pdp.businessobject.PayeeACHAccount)

Example 5 with PayeeACHAccount

use of org.kuali.kfs.pdp.businessobject.PayeeACHAccount in project cu-kfs by CU-CommunityApps.

the class PayeeACHAccountExtractServiceImplTest method createNewMaintainableForPAAT.

private FinancialSystemMaintainable createNewMaintainableForPAAT() {
    FinancialSystemMaintainable maintainable = new PayeeACHAccountMaintainableImpl();
    maintainable.setBoClass(PayeeACHAccount.class);
    maintainable.setDataObject(new PayeeACHAccount());
    return maintainable;
}
Also used : PayeeACHAccountMaintainableImpl(org.kuali.kfs.pdp.document.PayeeACHAccountMaintainableImpl) FinancialSystemMaintainable(org.kuali.kfs.sys.document.FinancialSystemMaintainable) PayeeACHAccount(org.kuali.kfs.pdp.businessobject.PayeeACHAccount)

Aggregations

PayeeACHAccount (org.kuali.kfs.pdp.businessobject.PayeeACHAccount)10 Person (org.kuali.rice.kim.api.identity.Person)3 PayeeACHAccountMaintainableImpl (org.kuali.kfs.pdp.document.PayeeACHAccountMaintainableImpl)2 PayeeACHAccountExtractStep (edu.cornell.kfs.pdp.batch.PayeeACHAccountExtractStep)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 GeneralSecurityException (java.security.GeneralSecurityException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 MessagingException (javax.mail.MessagingException)1 Test (org.junit.Test)1 AttributeDefinition (org.kuali.kfs.krad.datadictionary.AttributeDefinition)1 AttributeSecurity (org.kuali.kfs.krad.datadictionary.AttributeSecurity)1 InvalidAddressException (org.kuali.kfs.krad.exception.InvalidAddressException)1 ValidationException (org.kuali.kfs.krad.exception.ValidationException)1 KeyValuesFinder (org.kuali.kfs.krad.keyvalues.KeyValuesFinder)1