Search in sources :

Example 1 with AchIncomeNote

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);
}
Also used : AchIncomeNote(edu.cornell.kfs.fp.businessobject.AchIncomeNote) IncomingWireAchMapping(edu.cornell.kfs.fp.businessobject.IncomingWireAchMapping)

Example 2 with AchIncomeNote

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;
}
Also used : AchIncomeNote(edu.cornell.kfs.fp.businessobject.AchIncomeNote) ArrayList(java.util.ArrayList)

Example 3 with AchIncomeNote

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());
}
Also used : AchIncomeTransaction(edu.cornell.kfs.fp.businessobject.AchIncomeTransaction) AchIncomeNote(edu.cornell.kfs.fp.businessobject.AchIncomeNote) Test(org.junit.Test)

Example 4 with AchIncomeNote

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;
}
Also used : AchIncomeNote(edu.cornell.kfs.fp.businessobject.AchIncomeNote) ArrayList(java.util.ArrayList)

Example 5 with AchIncomeNote

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

Aggregations

AchIncomeNote (edu.cornell.kfs.fp.businessobject.AchIncomeNote)6 AchIncomeTransaction (edu.cornell.kfs.fp.businessobject.AchIncomeTransaction)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 AchIncomeFileTransactionNote (edu.cornell.kfs.fp.businessobject.AchIncomeFileTransactionNote)1 IncomingWireAchMapping (edu.cornell.kfs.fp.businessobject.IncomingWireAchMapping)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Attachment (org.kuali.kfs.krad.bo.Attachment)1 Note (org.kuali.kfs.krad.bo.Note)1