Search in sources :

Example 1 with MaintenanceDocument

use of org.kuali.kfs.krad.maintenance.MaintenanceDocument in project cu-kfs by CU-CommunityApps.

the class CuSubAccountMaintainableImpl method hasIcrSectionChanged.

// KFSUPGRADE-765 :  Route edits to indirect cost to CG Resp ID
private boolean hasIcrSectionChanged() {
    String maintAction = super.getMaintenanceAction();
    boolean retval = false;
    if ((maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_NEW_ACTION)) || (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_COPY_ACTION))) {
        // need "new" bo for data comparisons
        SubAccount subAccount = (SubAccount) super.getBusinessObject();
        if (subAccount.getA21SubAccount().getSubAccountTypeCode().equals(KFSConstants.SubAccountType.EXPENSE)) {
            // We need to route only when the ICR data the user is submitting does NOT match the ICR data on the account
            // "new" subAccount for data comparisons
            A21SubAccount newSubAccount = subAccount.getA21SubAccount();
            // "existing" data that would have pre-populated
            Account account = this.getAccountService().getByPrimaryIdWithCaching(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber());
            if (ObjectUtils.isNotNull(account) && ObjectUtils.isNotNull(newSubAccount)) {
                List<IndirectCostRecoveryAccount> acctIcr = account.getIndirectCostRecoveryAccounts();
                List<A21IndirectCostRecoveryAccount> subAcctIcr = newSubAccount.getA21ActiveIndirectCostRecoveryAccounts();
                if (CollectionUtils.isEmpty(subAcctIcr)) {
                    if (CollectionUtils.isEmpty(acctIcr)) {
                        retval = false;
                    } else {
                        retval = true;
                    }
                } else {
                    if (CollectionUtils.isEmpty(acctIcr)) {
                        retval = true;
                    } else {
                        /*
                        	 * the ICR accounts on the sub account needs to match the active ICR accounts on the parent account.
                        	 */
                        int activeAcctIcrCount = 0;
                        for (IndirectCostRecoveryAccount acct : acctIcr) {
                            if (acct.isActive()) {
                                activeAcctIcrCount++;
                            }
                        }
                        if (subAcctIcr.size() == activeAcctIcrCount) {
                            retval = isIcrSectionDataChanged(subAcctIcr, acctIcr);
                        } else {
                            retval = true;
                        }
                    }
                }
            }
        }
    } else if (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_EDIT_ACTION)) {
        // need "new" bo for data comparisons
        SubAccount subAccount = (SubAccount) super.getBusinessObject();
        // "new" subAccount for data comparisons
        A21SubAccount newSubAccount = subAccount.getA21SubAccount();
        if (ObjectUtils.isNotNull(newSubAccount)) {
            try {
                MaintenanceDocument oldMaintDoc = (MaintenanceDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(getDocumentNumber());
                A21SubAccount oldSubAccount = (A21SubAccount) ((SubAccount) oldMaintDoc.getOldMaintainableObject().getDataObject()).getA21SubAccount();
                retval = isIcrSectionChanged(newSubAccount, oldSubAccount);
            } catch (Exception e) {
                LOG.error("caught exception while getting subaccount old maintainable -> documentService.getByDocumentHeaderId(" + getDocumentNumber() + "). ", e);
            }
        }
    }
    return retval;
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) Account(org.kuali.kfs.coa.businessobject.Account) MaintenanceDocument(org.kuali.kfs.krad.maintenance.MaintenanceDocument) DocumentService(org.kuali.kfs.krad.service.DocumentService) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 2 with MaintenanceDocument

use of org.kuali.kfs.krad.maintenance.MaintenanceDocument 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 3 with MaintenanceDocument

use of org.kuali.kfs.krad.maintenance.MaintenanceDocument in project cu-kfs by CU-CommunityApps.

the class VendorBatchServiceImpl method addVendor.

/*
	 * create vendor document and route
	 */
private String addVendor(VendorBatchDetail vendorBatch) {
    GlobalVariables.setMessageMap(new MessageMap());
    // create and route doc as system user
    // GlobalVariables.setUserSession(new UserSession("kfs"));
    LOG.info("addVendor " + vendorBatch.getLogData());
    try {
        MaintenanceDocument vendorDoc = (MaintenanceDocument) documentService.getNewDocument(VENDOR_DOCUMENT_TYPE_NAME);
        vendorDoc.getDocumentHeader().setDocumentDescription(getDocumentDescription(vendorBatch, true));
        VendorMaintainableImpl vImpl = (VendorMaintainableImpl) vendorDoc.getNewMaintainableObject();
        vImpl.setMaintenanceAction(KFSConstants.MAINTENANCE_NEW_ACTION);
        VendorDetail vDetail = (VendorDetail) vImpl.getBusinessObject();
        setupVendorDetailFields(vDetail, vendorBatch);
        setupInsuranceTracking((VendorDetailExtension) vDetail.getExtension(), vendorBatch);
        vDetail.setVendorAddresses(getVendorAddresses(vendorBatch.getVendorAddresses(), vDetail));
        vDetail.setVendorContacts(getVendorContacts(vendorBatch.getVendorContacts()));
        VendorHeader vHeader = vDetail.getVendorHeader();
        setupVendorHeaderFields(vHeader, vendorBatch);
        vHeader.setVendorSupplierDiversities(getVendorSupplierDiversities(vendorBatch.getVendorSupplierDiversities()));
        vDetail.setVendorHeader(vHeader);
        vImpl.setBusinessObject(vDetail);
        vendorDoc.setNewMaintainableObject(vImpl);
        addNotes(vendorDoc, vendorBatch);
        if (StringUtils.isNotBlank(vendorBatch.getAttachmentFiles())) {
            loadDocumentAttachments(vendorDoc, Arrays.asList(vendorBatch.getAttachmentFiles().split(COLLECTION_FIELD_DELIMITER)));
        }
        documentService.routeDocument(vendorDoc, KFSConstants.EMPTY_STRING, null);
        return vendorDoc.getDocumentNumber();
    } catch (Exception e) {
        LOG.info("addVendor STE " + e.getStackTrace() + e.toString());
        return getFailRequestMessage(e);
    }
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader) MaintenanceDocument(org.kuali.kfs.krad.maintenance.MaintenanceDocument) VendorMaintainableImpl(org.kuali.kfs.vnd.document.VendorMaintainableImpl) MessageMap(org.kuali.kfs.krad.util.MessageMap) ValidationException(org.kuali.kfs.krad.exception.ValidationException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ParseException(org.kuali.kfs.sys.exception.ParseException)

Example 4 with MaintenanceDocument

use of org.kuali.kfs.krad.maintenance.MaintenanceDocument in project cu-kfs by CU-CommunityApps.

the class VendorBatchServiceImpl method updateVendor.

/*
	 * update vendor record.  vendor number must be valid.
	 */
private String updateVendor(VendorBatchDetail vendorBatch) {
    GlobalVariables.setMessageMap(new MessageMap());
    try {
        MaintenanceDocument vendorDoc = (MaintenanceDocument) documentService.getNewDocument(VENDOR_DOCUMENT_TYPE_NAME);
        vendorDoc.getDocumentHeader().setDocumentDescription(getDocumentDescription(vendorBatch, false));
        LOG.info("updateVendor " + vendorBatch.getLogData());
        VendorDetail vendor = cuVendorService.getByVendorNumber(vendorBatch.getVendorNumber());
        if (vendor != null) {
            // Vendor does not eist
            VendorMaintainableImpl oldVendorImpl = (VendorMaintainableImpl) vendorDoc.getOldMaintainableObject();
            oldVendorImpl.setBusinessObject(vendor);
        } else {
            // Vendor does not eist
            return "Failed request : Vendor " + vendorBatch.getVendorNumber() + " Not Found.";
        }
        VendorMaintainableImpl vImpl = (VendorMaintainableImpl) vendorDoc.getNewMaintainableObject();
        vImpl.setMaintenanceAction(KFSConstants.MAINTENANCE_EDIT_ACTION);
        vendorDoc.getNewMaintainableObject().setDocumentNumber(vendorDoc.getDocumentNumber());
        vImpl.setBusinessObject((VendorDetail) ObjectUtils.deepCopy(vendor));
        VendorDetail vDetail = (VendorDetail) vImpl.getBusinessObject();
        setupVendorDetailFields(vDetail, vendorBatch);
        setupInsuranceTracking((VendorDetailExtension) vDetail.getExtension(), vendorBatch);
        updateVendorAddresses(vendorBatch.getVendorAddresses(), vendor, vDetail);
        updateVendorContacts(vendorBatch.getVendorContacts(), vendor, vDetail);
        updateVendorSupplierDiversitys(vendorBatch.getVendorSupplierDiversities(), vendor, vDetail);
        setupVendorHeaderFields(vDetail.getVendorHeader(), vendorBatch);
        vImpl.setBusinessObject(vDetail);
        vendorDoc.setNewMaintainableObject(vImpl);
        addNotes(vendorDoc, vendorBatch);
        // attachment
        if (StringUtils.isNotBlank(vendorBatch.getAttachmentFiles())) {
            loadDocumentAttachments(vendorDoc, Arrays.asList(vendorBatch.getAttachmentFiles().split(COLLECTION_FIELD_DELIMITER)));
        }
        // end attachment
        documentService.routeDocument(vendorDoc, KFSConstants.EMPTY_STRING, null);
        return vendorDoc.getDocumentNumber();
    } catch (Exception e) {
        LOG.info("updateVendor STE " + e.getStackTrace() + e.toString());
        return getFailRequestMessage(e);
    }
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) MaintenanceDocument(org.kuali.kfs.krad.maintenance.MaintenanceDocument) VendorMaintainableImpl(org.kuali.kfs.vnd.document.VendorMaintainableImpl) MessageMap(org.kuali.kfs.krad.util.MessageMap) ValidationException(org.kuali.kfs.krad.exception.ValidationException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ParseException(org.kuali.kfs.sys.exception.ParseException)

Aggregations

MaintenanceDocument (org.kuali.kfs.krad.maintenance.MaintenanceDocument)4 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 ValidationException (org.kuali.kfs.krad.exception.ValidationException)3 ParseException (org.kuali.kfs.sys.exception.ParseException)3 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)2 VendorMaintainableImpl (org.kuali.kfs.vnd.document.VendorMaintainableImpl)2 PayeeACHAccountExtractStep (edu.cornell.kfs.pdp.batch.PayeeACHAccountExtractStep)1 MessagingException (javax.mail.MessagingException)1 A21IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount)1 A21SubAccount (org.kuali.kfs.coa.businessobject.A21SubAccount)1 Account (org.kuali.kfs.coa.businessobject.Account)1 IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)1 SubAccount (org.kuali.kfs.coa.businessobject.SubAccount)1 InvalidAddressException (org.kuali.kfs.krad.exception.InvalidAddressException)1 DocumentService (org.kuali.kfs.krad.service.DocumentService)1 PayeeACHAccount (org.kuali.kfs.pdp.businessobject.PayeeACHAccount)1 PayeeACHAccountMaintainableImpl (org.kuali.kfs.pdp.document.PayeeACHAccountMaintainableImpl)1 VendorHeader (org.kuali.kfs.vnd.businessobject.VendorHeader)1