Search in sources :

Example 1 with AchIncomeFileTransactionNote

use of edu.cornell.kfs.fp.businessobject.AchIncomeFileTransactionNote in project cu-kfs by CU-CommunityApps.

the class AdvanceDepositServiceImpl method addRMRAndNTELinesToNotes.

private List<String> addRMRAndNTELinesToNotes(AchIncomeFileTransaction achIncomeFileTransaction, StringBuilder notes) {
    List<String> achNotes = new ArrayList<>();
    boolean header = true;
    Integer lineCount = 1;
    for (AchIncomeFileTransactionOpenItemReference openItemReference : achIncomeFileTransaction.getOpenItemReferences()) {
        int leftNoteSize = MAX_NOTE_SIZE - notes.length();
        if ((notes.length() >= MAX_NOTE_SIZE) || (leftNoteSize <= MIN_NOTE_SIZE)) {
            achNotes.add(notes.toString());
            notes = new StringBuilder();
            header = true;
        }
        String type = openItemReference.getType();
        if (CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_REFERENCE_TYPE_CR.equals(type) || CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_REFERENCE_TYPE_IV.equals(type) || CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_REFERENCE_TYPE_OI.equals(type)) {
            if (header) {
                notes.append(StringUtils.rightPad("LINE", CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_LINE_COLUMN_WIDTH));
                notes.append(StringUtils.rightPad("INVOICE NUMBER", CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_INVOICE_NUMBER_COLUMN_WIDTH));
                notes.append(StringUtils.rightPad("NETAMOUNT PAID", CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_NET_AMOUNT_COLUMN_WIDTH));
                notes.append(StringUtils.rightPad("INVOICE AMOUNT", CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_INVOICE_AMOUNT_COLUMN_WIDTH));
                notes.append("\n");
                header = false;
            }
            notes.append(StringUtils.rightPad(getFormattedAmount("00000", lineCount), CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_LINE_COLUMN_WIDTH));
            notes.append(StringUtils.rightPad(openItemReference.getInvoiceNumber(), CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_INVOICE_NUMBER_COLUMN_WIDTH));
            if (openItemReference.getNetAmount() != null) {
                notes.append(StringUtils.leftPad(getFormattedAmount("##,##,###.00", openItemReference.getNetAmount()), CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_NET_AMOUNT_COLUMN_WIDTH));
            }
            if (openItemReference.getInvoiceAmount() != null) {
                notes.append(StringUtils.leftPad(getFormattedAmount("##,##,###.00", openItemReference.getInvoiceAmount()), CuFPConstants.AchIncomeFileTransactionOpenItemReference.RMR_NOTE_INVOICE_AMOUNT_COLUMN_WIDTH));
            }
            notes.append("\n");
            lineCount++;
        }
    }
    List<AchIncomeFileTransactionNote> fileTransactionNotes = achIncomeFileTransaction.getNotes();
    for (AchIncomeFileTransactionNote fileTransactionNote : fileTransactionNotes) {
        if (fileTransactionNote.getType() != null) {
            String nteTxt = fileTransactionNote.getType().toUpperCase() + ": " + fileTransactionNote.getValue();
            int notesPlusNoteTxtLength = nteTxt.length() + notes.length();
            if (notesPlusNoteTxtLength >= MAX_NOTE_SIZE) {
                achNotes.add(notes.toString());
                notes = new StringBuilder();
            }
            notes.append(nteTxt.trim());
            notes.append("\n");
        }
    }
    achNotes.add(notes.toString());
    return achNotes;
}
Also used : AchIncomeFileTransactionOpenItemReference(edu.cornell.kfs.fp.businessobject.AchIncomeFileTransactionOpenItemReference) AchIncomeFileTransactionNote(edu.cornell.kfs.fp.businessobject.AchIncomeFileTransactionNote) ArrayList(java.util.ArrayList)

Example 2 with AchIncomeFileTransactionNote

use of edu.cornell.kfs.fp.businessobject.AchIncomeFileTransactionNote in project cu-kfs by CU-CommunityApps.

the class AchIncomeDelimitedFlatFileSpecificationTest method testParseLineIntoObjectAchIncomeFileTransactionNote.

@Test
public void testParseLineIntoObjectAchIncomeFileTransactionNote() throws Exception {
    AbstractFlatFileObjectSpecification flatFileObjectSpecification = new FlatFilePrefixObjectSpecification();
    List<FlatFilePropertySpecification> parseProperties = new ArrayList<>();
    setFlatFileProperty(parseProperties, 1, "type");
    setFlatFileProperty(parseProperties, 2, "value");
    flatFileObjectSpecification.setParseProperties(parseProperties);
    AchIncomeFileTransactionNote achIncomeFileTransactionNote = new AchIncomeFileTransactionNote();
    achIncomeDelimitedFlatFileSpecification.parseLineIntoObject(flatFileObjectSpecification, NTE_LINE, achIncomeFileTransactionNote, 1);
    assertEquals("001", achIncomeFileTransactionNote.getType());
    assertEquals("TRANSACTION NOTE", achIncomeFileTransactionNote.getValue());
}
Also used : FlatFilePrefixObjectSpecification(org.kuali.kfs.sys.batch.FlatFilePrefixObjectSpecification) AchIncomeFileTransactionNote(edu.cornell.kfs.fp.businessobject.AchIncomeFileTransactionNote) ArrayList(java.util.ArrayList) FlatFilePropertySpecification(org.kuali.kfs.sys.batch.FlatFilePropertySpecification) DelimitedFlatFilePropertySpecification(org.kuali.kfs.sys.batch.DelimitedFlatFilePropertySpecification) AbstractFlatFileObjectSpecification(org.kuali.kfs.sys.batch.AbstractFlatFileObjectSpecification) Test(org.junit.Test)

Aggregations

AchIncomeFileTransactionNote (edu.cornell.kfs.fp.businessobject.AchIncomeFileTransactionNote)2 ArrayList (java.util.ArrayList)2 AchIncomeFileTransactionOpenItemReference (edu.cornell.kfs.fp.businessobject.AchIncomeFileTransactionOpenItemReference)1 Test (org.junit.Test)1 AbstractFlatFileObjectSpecification (org.kuali.kfs.sys.batch.AbstractFlatFileObjectSpecification)1 DelimitedFlatFilePropertySpecification (org.kuali.kfs.sys.batch.DelimitedFlatFilePropertySpecification)1 FlatFilePrefixObjectSpecification (org.kuali.kfs.sys.batch.FlatFilePrefixObjectSpecification)1 FlatFilePropertySpecification (org.kuali.kfs.sys.batch.FlatFilePropertySpecification)1