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