in component-test/src/main/java/org/apache/fineract/cn/accounting/JournalEntryApiDocumentation.java [242:304]
public void documentFindJournalEntry ( ) throws Exception {
final Ledger assetLedger = LedgerGenerator.createRandomLedger();
assetLedger.setIdentifier("7100");
assetLedger.setType(AccountType.ASSET.name());
this.testSubject.createLedger(assetLedger);
this.eventRecorder.wait(EventConstants.POST_LEDGER, assetLedger.getIdentifier());
final Account accountToDebit = AccountGenerator.createRandomAccount(assetLedger.getIdentifier());
accountToDebit.setIdentifier("7110");
accountToDebit.setType(AccountType.ASSET.name());
accountToDebit.setBalance(1000.0);
this.testSubject.createAccount(accountToDebit);
this.eventRecorder.wait(EventConstants.POST_ACCOUNT, accountToDebit.getIdentifier());
final Ledger liabilityLedger = LedgerGenerator.createRandomLedger();
liabilityLedger.setIdentifier("8100");
liabilityLedger.setType(AccountType.LIABILITY.name());
this.testSubject.createLedger(liabilityLedger);
this.eventRecorder.wait(EventConstants.POST_LEDGER, liabilityLedger.getIdentifier());
final Account accountToCredit = AccountGenerator.createRandomAccount(liabilityLedger.getIdentifier());
accountToCredit.setIdentifier("8110");
accountToCredit.setType(AccountType.LIABILITY.name());
this.testSubject.createAccount(accountToCredit);
this.eventRecorder.wait(EventConstants.POST_ACCOUNT, accountToCredit.getIdentifier());
final JournalEntry journalEntry = JournalEntryGenerator.createRandomJournalEntry(accountToDebit, "50.00",
accountToCredit, "50.00");
final OffsetDateTime start = OffsetDateTime.of(2017, 6, 24, 1, 0, 0, 0, ZoneOffset.UTC);
journalEntry.setTransactionDate(start.format(DateTimeFormatter.ISO_ZONED_DATE_TIME));
journalEntry.setTransactionIdentifier("FE136183");
journalEntry.setTransactionType("ACCO");
journalEntry.setClerk("Mr. " + journalEntry.getClerk().toUpperCase().charAt(0) + journalEntry.getClerk().substring(1, 5));
journalEntry.setNote("Noted");
journalEntry.setMessage("Message Noted");
this.testSubject.createJournalEntry(journalEntry);
this.eventRecorder.wait(EventConstants.POST_JOURNAL_ENTRY, journalEntry.getTransactionIdentifier());
this.eventRecorder.wait(EventConstants.RELEASE_JOURNAL_ENTRY, journalEntry.getTransactionIdentifier());
this.mockMvc.perform(get("/journal/" + journalEntry.getTransactionIdentifier())
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.ALL_VALUE))
.andExpect(status().isOk())
.andDo(document("document-find-journal-entry", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()),
responseFields(
fieldWithPath("transactionIdentifier").description("Transaction ID"),
fieldWithPath("transactionDate").description("Account identifier"),
fieldWithPath("transactionType").description("Type of transaction"),
fieldWithPath("clerk").type("String").description("Clerk who initiated transaction"),
fieldWithPath("note").type("String").description("Transaction note"),
fieldWithPath("debtors").type("Set<Debtors>").description("Set of debtors"),
fieldWithPath("creditors").type("Set<Creditors>").description("Set of creditors"),
fieldWithPath("state").type("State").description("State of journal entry " +
" + \n" +
" *enum* _State_ { + \n" +
" PENDING, + \n" +
" PROCESSED + \n" +
" } +"),
fieldWithPath("message").description("Journal Message ")
)));
}