use of edu.cornell.kfs.fp.businessobject.AchIncomeNote in project cu-kfs by CU-CommunityApps.
the class AdvanceDepositServiceImpl method createSourceAccountingLine.
protected void createSourceAccountingLine(AchIncomeTransaction transaction, AdvanceDepositDocument advanceDepositDocument) {
String chart = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.CHART);
String objectCode = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.OBJECT_CODE);
String account = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.ACCOUNT);
IncomingWireAchMapping matchingIncomingWireAchMapping = null;
Collection<IncomingWireAchMapping> incomingWireAchMappings = businessObjectService.findAll(IncomingWireAchMapping.class);
for (IncomingWireAchMapping mapping : incomingWireAchMappings) {
List<AchIncomeNote> notes = transaction.getNotes();
if (doNotesMatch(mapping, notes)) {
matchingIncomingWireAchMapping = mapping;
break;
}
}
if (ObjectUtils.isNotNull(matchingIncomingWireAchMapping)) {
chart = matchingIncomingWireAchMapping.getChartOfAccountsCode();
objectCode = matchingIncomingWireAchMapping.getFinancialObjectCode();
account = matchingIncomingWireAchMapping.getAccountNumber();
}
setupSourceAccountingLine(transaction, advanceDepositDocument, chart, objectCode, account);
}
use of edu.cornell.kfs.fp.businessobject.AchIncomeNote in project cu-kfs by CU-CommunityApps.
the class AdvanceDepositServiceImpl method createNotes.
private List<AchIncomeNote> createNotes(AchIncomeFileTransaction achIncomeFileTransaction) {
StringBuilder notes = addPaymentInformationToNotes(achIncomeFileTransaction);
List<String> achNotes = addRMRAndNTELinesToNotes(achIncomeFileTransaction, notes);
List<AchIncomeNote> achIncomeNotes = new ArrayList<>();
int noteLineNumber = 1;
for (String noteText : achNotes) {
AchIncomeNote achIncomeNote = new AchIncomeNote();
achIncomeNote.setNoteLineNumber(noteLineNumber);
achIncomeNote.setNoteText(noteText);
achIncomeNotes.add(achIncomeNote);
noteLineNumber++;
}
return achIncomeNotes;
}
use of edu.cornell.kfs.fp.businessobject.AchIncomeNote in project cu-kfs by CU-CommunityApps.
the class AdvanceDepositServiceImplTest method testCreateSourceAccountingLineMatchingNote.
@Test
public void testCreateSourceAccountingLineMatchingNote() {
AchIncomeTransaction transaction = new AchIncomeTransaction();
List<AchIncomeNote> notes = setupNotes("an ARMY of one");
transaction.setNotes(notes);
advanceDepositService.createSourceAccountingLine(transaction, advanceDepositDocument);
assertNotNull(advanceDepositDocument.getSourceAccountingLines());
assertEquals(1, advanceDepositDocument.getSourceAccountingLines().size());
assertEquals("CU", advanceDepositDocument.getSourceAccountingLine(0).getChartOfAccountsCode());
assertEquals("5000", advanceDepositDocument.getSourceAccountingLine(0).getFinancialObjectCode());
assertEquals("1234567", advanceDepositDocument.getSourceAccountingLine(0).getAccountNumber());
}
use of edu.cornell.kfs.fp.businessobject.AchIncomeNote in project cu-kfs by CU-CommunityApps.
the class AdvanceDepositServiceImplTest method setupNotes.
protected List<AchIncomeNote> setupNotes(String noteText) {
List<AchIncomeNote> notes = new ArrayList<>();
AchIncomeNote note = new AchIncomeNote();
note.setNoteText(noteText);
notes.add(note);
return notes;
}
use of edu.cornell.kfs.fp.businessobject.AchIncomeNote 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());
}
}
Aggregations