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);
}
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());
}
}
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;
}
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);
}
}
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);
}
}
}
Aggregations