Search in sources :

Example 36 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class AccountReversionTrickleDownInactivationServiceImpl method addNotesToDocument.

/**
 * Adds notes about inactivated AccountReversions, any errors while persisting inactivated account reversions or account reversions that were loccked.
 *
 * @param documentNumber
 * @param inactivatedAccountReversions
 * @param alreadyLockedAccountReversions
 * @param errorPersistingAccountReversions
 */
protected void addNotesToDocument(String documentNumber, List<AccountReversion> inactivatedAccountReversions, Map<AccountReversion, String> alreadyLockedAccountReversions, List<AccountReversion> errorPersistingAccountReversions) {
    if (inactivatedAccountReversions.isEmpty() && alreadyLockedAccountReversions.isEmpty() && errorPersistingAccountReversions.isEmpty()) {
        // if we didn't try to inactivate any AccountReversions, then don't bother
        return;
    }
    DocumentHeader noteParent = documentHeaderService.getDocumentHeaderById(documentNumber);
    Note newNote = new Note();
    addNotes(documentNumber, inactivatedAccountReversions, CUKFSKeyConstants.ACCOUNT_REVERSION_TRICKLE_DOWN_INACTIVATION, noteParent, newNote);
    addNotes(documentNumber, errorPersistingAccountReversions, CUKFSKeyConstants.ACCOUNT_REVERSION_TRICKLE_DOWN_INACTIVATION_ERROR_DURING_PERSISTENCE, noteParent, newNote);
    addMaintenanceLockedNotes(documentNumber, alreadyLockedAccountReversions, CUKFSKeyConstants.ACCOUNT_REVERSION_TRICKLE_DOWN_INACTIVATION_RECORD_ALREADY_MAINTENANCE_LOCKED, noteParent, newNote);
}
Also used : Note(org.kuali.kfs.krad.bo.Note) DocumentHeader(org.kuali.kfs.krad.bo.DocumentHeader)

Example 37 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class AdvanceDepositServiceImpl method createNotes.

private void createNotes(AchIncomeTransaction transaction, AdvanceDepositDocument document) {
    String fileName = CuFPConstants.ADVANCE_DEPOSIT_NOTE_FILE_PREFIX + document.getDocumentNumber() + "_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(dateTimeService.getCurrentDate()) + ".txt";
    StringBuilder notes = new StringBuilder();
    for (AchIncomeNote achIncomeNote : transaction.getNotes()) {
        notes.append(achIncomeNote.getNoteText());
        notes.append("\n");
    }
    byte[] notesAttachmentBytes = notes.toString().getBytes();
    String attachmentType = null;
    try {
        Attachment attachment = attachmentService.createAttachment(document.getDocumentHeader(), fileName, "text", notesAttachmentBytes.length, new ByteArrayInputStream(notesAttachmentBytes), attachmentType);
        Note note = documentService.createNoteFromDocument(document, "Attachment with transaction notes created by ach/incoming wire batch job.");
        note.setAttachment(attachment);
        attachment.setNote(note);
        noteService.save(note);
    } catch (IOException e) {
        LOG.error("Error while adding notes to advance deposit documents: " + e.getMessage(), e);
        throw new RuntimeException("Error while adding notes to the document " + document.getDocumentNumber());
    }
}
Also used : AchIncomeNote(edu.cornell.kfs.fp.businessobject.AchIncomeNote) ByteArrayInputStream(java.io.ByteArrayInputStream) Note(org.kuali.kfs.krad.bo.Note) AchIncomeFileTransactionNote(edu.cornell.kfs.fp.businessobject.AchIncomeFileTransactionNote) AchIncomeNote(edu.cornell.kfs.fp.businessobject.AchIncomeNote) Attachment(org.kuali.kfs.krad.bo.Attachment) IOException(java.io.IOException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 38 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class AccountingDocumentGeneratorBase method buildDocumentNote.

protected Note buildDocumentNote(AccountingXmlDocumentNote xmlNote) {
    Person systemUser = personService.getPersonByPrincipalName(KFSConstants.SYSTEM_USER);
    Note note = emptyNoteGenerator.get();
    note.setNoteText(xmlNote.getDescription());
    note.setAuthorUniversalIdentifier(systemUser.getPrincipalId());
    note.setNotePostedTimestampToCurrent();
    return note;
}
Also used : AccountingXmlDocumentNote(edu.cornell.kfs.fp.batch.xml.AccountingXmlDocumentNote) Note(org.kuali.kfs.krad.bo.Note) AdHocRoutePerson(org.kuali.kfs.krad.bo.AdHocRoutePerson) Person(org.kuali.rice.kim.api.identity.Person)

Example 39 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherDocumentBatchServiceImpl method populateDisbursementVoucherFields.

/**
 * Populates fields on the disbursement voucher document and performs validation
 *
 * @param disbursementVoucherDocument disbursement voucher document to populate
 * @param batchDisbursementVoucherDocument batch dv document to pull values from
 * @param batchDefault contains default values to use if value in feed is empty
 * @param MessageMap MessageMap for adding encountered errors
 */
protected void populateDisbursementVoucherFields(DisbursementVoucherDocument disbursementVoucherDocument, BatchDisbursementVoucherDocument batchDisbursementVoucherDocument, DisbursementVoucherBatchDefault batchDefault, MessageMap MessageMap) {
    disbursementVoucherDocument.getDocumentHeader().setDocumentDescription(kualiConfigurationService.getPropertyValueAsString(FPKeyConstants.MESSAGE_DV_BATCH_DOCUMENT_DESCRIPTION));
    // populate fields of document from batch instance
    disbursementVoucherDocument.getDocumentHeader().setExplanation(batchDisbursementVoucherDocument.getDocumentHeader().getExplanation());
    disbursementVoucherDocument.getDocumentHeader().setOrganizationDocumentNumber(batchDisbursementVoucherDocument.getDocumentHeader().getOrganizationDocumentNumber());
    disbursementVoucherDocument.setDisbVchrContactPersonName(batchDisbursementVoucherDocument.getDisbVchrContactPersonName());
    disbursementVoucherDocument.setDisbVchrContactPhoneNumber(batchDisbursementVoucherDocument.getDisbVchrContactPhoneNumber());
    disbursementVoucherDocument.setDisbVchrContactEmailId(batchDisbursementVoucherDocument.getDisbVchrContactEmailId());
    disbursementVoucherDocument.setDisbursementVoucherDueDate(batchDisbursementVoucherDocument.getDisbursementVoucherDueDate());
    disbursementVoucherDocument.setDisbVchrAttachmentCode(batchDisbursementVoucherDocument.isDisbVchrAttachmentCode());
    disbursementVoucherDocument.setDisbVchrSpecialHandlingCode(batchDisbursementVoucherDocument.isDisbVchrSpecialHandlingCode());
    disbursementVoucherDocument.setDisbVchrCheckTotalAmount(batchDisbursementVoucherDocument.getDisbVchrCheckTotalAmount());
    disbursementVoucherDocument.setDisbursementVoucherDocumentationLocationCode(batchDisbursementVoucherDocument.getDisbursementVoucherDocumentationLocationCode());
    disbursementVoucherDocument.setDisbVchrPaymentMethodCode(batchDisbursementVoucherDocument.getDisbVchrPaymentMethodCode());
    disbursementVoucherDocument.setCampusCode(batchDisbursementVoucherDocument.getCampusCode());
    disbursementVoucherDocument.setDisbVchrCheckStubText(batchDisbursementVoucherDocument.getDisbVchrCheckStubText());
    disbursementVoucherDocument.setDisbVchrBankCode(batchDisbursementVoucherDocument.getDisbVchrBankCode());
    disbursementVoucherDocument.getDvPayeeDetail().setDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPaymentReasonCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPaymentReasonCode());
    String payeeTypeCode = batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbursementVoucherPayeeTypeCode();
    String payeeIdNumber = batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeIdNumber();
    if (KFSConstants.PaymentPayeeTypes.VENDOR.equals(payeeTypeCode)) {
        if (StringUtils.contains(payeeIdNumber, "-")) {
            VendorDetail vendorDetail = vendorService.getVendorDetail(payeeIdNumber);
            if (vendorDetail != null) {
                VendorAddress vendorAddress = vendorService.getVendorDefaultAddress(vendorDetail.getVendorHeaderGeneratedIdentifier(), vendorDetail.getVendorDetailAssignedIdentifier(), VendorConstants.AddressTypes.PURCHASE_ORDER, disbursementVoucherDocument.getCampusCode());
                if (vendorAddress == null) {
                    vendorAddress = vendorService.getVendorDefaultAddress(vendorDetail.getVendorHeaderGeneratedIdentifier(), vendorDetail.getVendorDetailAssignedIdentifier(), VendorConstants.AddressTypes.REMIT, disbursementVoucherDocument.getCampusCode());
                }
                if (vendorAddress != null) {
                    disbursementVoucherDocument.templateVendor(vendorDetail, vendorAddress);
                }
            } else {
                batchFeedHelperService.addExistenceError(KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER, payeeIdNumber, MessageMap);
            }
        } else {
            batchFeedHelperService.addExistenceError(KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER, payeeIdNumber, MessageMap);
        }
    } else if (KFSConstants.PaymentPayeeTypes.EMPLOYEE.equals(payeeTypeCode)) {
        Person person = personService.getPersonByEmployeeId(payeeIdNumber);
        if (person != null) {
            disbursementVoucherDocument.templateEmployee(person);
        } else {
            batchFeedHelperService.addExistenceError(KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER, payeeIdNumber, MessageMap);
        }
    }
    // override payee details with values from feed if given (not blank)
    if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine1Addr())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine1Addr());
    }
    if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine2Addr())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeLine2Addr());
    }
    if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCityName())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeCityName(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCityName());
    }
    if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeStateCode())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeStateCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeStateCode());
    }
    if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeZipCode())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeZipCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeZipCode());
    }
    if (StringUtils.isNotBlank(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCountryCode())) {
        disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrPayeeCountryCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrPayeeCountryCode());
    }
    // set special handling fields
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingPersonName(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingPersonName());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingLine1Addr(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingLine1Addr());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingLine2Addr(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingLine2Addr());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingCityName(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingCityName());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingZipCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingZipCode());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingStateCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingStateCode());
    disbursementVoucherDocument.getDvPayeeDetail().setDisbVchrSpecialHandlingCountryCode(batchDisbursementVoucherDocument.getDvPayeeDetail().getDisbVchrSpecialHandlingCountryCode());
    disbursementVoucherDocument.setDvNonResidentAlienTax(batchDisbursementVoucherDocument.getDvNonResidentAlienTax());
    disbursementVoucherDocument.getDvNonResidentAlienTax().setDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
    // set defaults
    if (batchDefault != null) {
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrContactPersonName())) {
            disbursementVoucherDocument.setDisbVchrContactPersonName(batchDefault.getDisbVchrContactPersonName());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrContactPhoneNumber())) {
            disbursementVoucherDocument.setDisbVchrContactPhoneNumber(batchDefault.getDisbVchrContactPhoneNumber());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrContactEmailId())) {
            disbursementVoucherDocument.setDisbVchrContactEmailId(batchDefault.getDisbVchrContactEmailId());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getCampusCode())) {
            disbursementVoucherDocument.setCampusCode(batchDefault.getCampusCode());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrPaymentMethodCode())) {
            disbursementVoucherDocument.setDisbVchrPaymentMethodCode(batchDefault.getDisbVchrPaymentMethodCode());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbursementVoucherDocumentationLocationCode())) {
            disbursementVoucherDocument.setDisbursementVoucherDocumentationLocationCode(batchDefault.getDisbursementVoucherDocumentationLocationCode());
        }
        if (StringUtils.isBlank(disbursementVoucherDocument.getDisbVchrBankCode())) {
            disbursementVoucherDocument.setDisbVchrBankCode(batchDefault.getDisbVchrBankCode());
        }
    }
    // set accounting
    for (Iterator iterator = batchDisbursementVoucherDocument.getSourceAccountingLines().iterator(); iterator.hasNext(); ) {
        SourceAccountingLine batchAccountingLine = (SourceAccountingLine) iterator.next();
        SourceAccountingLine accountingLine = new SourceAccountingLine();
        accountingLine.setChartOfAccountsCode(batchAccountingLine.getChartOfAccountsCode());
        accountingLine.setAccountNumber(batchAccountingLine.getAccountNumber());
        if (StringUtils.isNotBlank(batchAccountingLine.getSubAccountNumber())) {
            accountingLine.setSubAccountNumber(batchAccountingLine.getSubAccountNumber());
        }
        accountingLine.setFinancialObjectCode(batchAccountingLine.getFinancialObjectCode());
        if (StringUtils.isNotBlank(batchAccountingLine.getFinancialSubObjectCode())) {
            accountingLine.setFinancialSubObjectCode(batchAccountingLine.getFinancialSubObjectCode());
        }
        if (StringUtils.isNotBlank(batchAccountingLine.getProjectCode())) {
            accountingLine.setProjectCode(batchAccountingLine.getProjectCode());
        }
        accountingLine.setOrganizationReferenceId(batchAccountingLine.getOrganizationReferenceId());
        accountingLine.setFinancialDocumentLineDescription(batchAccountingLine.getFinancialDocumentLineDescription());
        accountingLine.setAmount(batchAccountingLine.getAmount());
        // set accounting defaults
        if (batchDefault != null) {
            if (StringUtils.isBlank(accountingLine.getChartOfAccountsCode())) {
                accountingLine.setChartOfAccountsCode(batchDefault.getChartOfAccountsCode());
            }
            if (StringUtils.isBlank(accountingLine.getAccountNumber())) {
                accountingLine.setAccountNumber(batchDefault.getAccountNumber());
            }
            if (StringUtils.isBlank(accountingLine.getFinancialObjectCode())) {
                accountingLine.setFinancialObjectCode(batchDefault.getFinancialObjectCode());
            }
            if (StringUtils.isBlank(accountingLine.getFinancialDocumentLineDescription())) {
                accountingLine.setFinancialDocumentLineDescription(batchDefault.getFinancialDocumentLineDescription());
            }
        }
        accountingLine.setPostingYear(disbursementVoucherDocument.getPostingYear());
        accountingLine.setDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
        disbursementVoucherDocument.addSourceAccountingLine(accountingLine);
    }
    // set notes
    for (Iterator iterator = batchDisbursementVoucherDocument.getNotes().iterator(); iterator.hasNext(); ) {
        Note note = (Note) iterator.next();
        note.setRemoteObjectIdentifier(disbursementVoucherDocument.getObjectId());
        note.setAuthorUniversalIdentifier(batchFeedHelperService.getSystemUser().getPrincipalId());
        note.setNoteTypeCode(KFSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode());
        note.setNotePostedTimestampToCurrent();
        disbursementVoucherDocument.addNote(note);
    }
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) Note(org.kuali.kfs.krad.bo.Note) Iterator(java.util.Iterator) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) Person(org.kuali.rice.kim.api.identity.Person)

Example 40 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class BatchFeedHelperServiceImpl method loadDocumentAttachments.

/**
 * @see com.rsmart.kuali.kfs.sys.batch.service.BatchFeedHelperService#loadDocumentAttachments(org.kuali.kfs.kns.document.Document,
 *      java.util.List, java.lang.String, java.lang.String, org.kuali.kfs.kns.util.ErrorMap)
 */
public void loadDocumentAttachments(Document document, List<Attachment> attachments, String attachmentsPath, String attachmentType, MessageMap errorMap) {
    for (Attachment attachment : attachments) {
        Note note = new Note();
        note.setNoteText(kualiConfigurationService.getPropertyValueAsString(KFSKeyConstants.IMAGE_ATTACHMENT_NOTE_TEXT));
        note.setRemoteObjectIdentifier(document.getObjectId());
        note.setAuthorUniversalIdentifier(getSystemUser().getPrincipalId());
        note.setNoteTypeCode(KFSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode());
        note.setNotePostedTimestampToCurrent();
        // attempt to load file
        String fileName = attachmentsPath + "/" + attachment.getAttachmentFileName();
        File attachmentFile = new File(fileName);
        if (!attachmentFile.exists()) {
            errorMap.putError(KFSConstants.GLOBAL_ERRORS, KFSKeyConstants.ERROR_BATCH_FEED_ATTACHMENT, new String[] { attachment.getAttachmentFileName(), attachmentsPath });
            continue;
        }
        try {
            FileInputStream fileInputStream = new FileInputStream(fileName);
            Integer fileSize = Integer.parseInt(Long.toString(attachmentFile.length()));
            String mimeTypeCode = attachment.getAttachmentMimeTypeCode();
            String fileExtension = "." + StringUtils.substringAfterLast(fileName, ".");
            if (StringUtils.isNotBlank(fileExtension) && mimeTypeProperties.containsKey(fileExtension)) {
                if (StringUtils.isBlank(mimeTypeCode)) {
                    mimeTypeCode = mimeTypeProperties.getProperty(fileExtension);
                }
            } else {
                errorMap.putError(KFSConstants.GLOBAL_ERRORS, KFSKeyConstants.ERROR_BATCH_FEED_ATTACHMENT_TYPE, new String[] { fileName, fileExtension });
            }
            Attachment noteAttachment = attachmentService.createAttachment(document.getDocumentHeader(), fileName, mimeTypeCode, fileSize, fileInputStream, attachmentType);
            note.addAttachment(noteAttachment);
            document.addNote(note);
        } catch (FileNotFoundException e) {
            errorMap.putError(KFSConstants.GLOBAL_ERRORS, KFSKeyConstants.ERROR_BATCH_FEED_ATTACHMENT, new String[] { attachment.getAttachmentFileName(), attachmentsPath });
            continue;
        } catch (IOException e1) {
            throw new RuntimeException("Unable to create attachment for image: " + fileName, e1);
        }
    }
}
Also used : Note(org.kuali.kfs.krad.bo.Note) FileNotFoundException(java.io.FileNotFoundException) Attachment(org.kuali.kfs.krad.bo.Attachment) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

Note (org.kuali.kfs.krad.bo.Note)76 Attachment (org.kuali.kfs.krad.bo.Attachment)14 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)12 IOException (java.io.IOException)9 FileNotFoundException (java.io.FileNotFoundException)7 ArrayList (java.util.ArrayList)7 NoteService (org.kuali.kfs.krad.service.NoteService)7 FileInputStream (java.io.FileInputStream)6 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)6 NonTransactional (org.kuali.kfs.sys.service.NonTransactional)6 File (java.io.File)5 Iterator (java.util.Iterator)5 DocumentService (org.kuali.kfs.krad.service.DocumentService)5 Person (org.kuali.rice.kim.api.identity.Person)5 NoteExtendedAttribute (edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Document (org.kuali.kfs.krad.document.Document)4 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)4 HashMap (java.util.HashMap)3 List (java.util.List)3