in component-test/src/main/java/org/apache/fineract/cn/accounting/TrialBalanceApiDocumentation.java [69:211]
public void documentGenerateTrialBalance ( ) throws Exception {
final Ledger assetLedger = LedgerGenerator.createRandomLedger();
this.testSubject.createLedger(assetLedger);
this.eventRecorder.wait(EventConstants.POST_LEDGER, assetLedger.getIdentifier());
final Ledger assetSubLedgerOne = LedgerGenerator.createRandomLedger();
this.testSubject.addSubLedger(assetLedger.getIdentifier(), assetSubLedgerOne);
this.eventRecorder.wait(EventConstants.POST_LEDGER, assetSubLedgerOne.getIdentifier());
final Ledger assetSubLedgerTwo = LedgerGenerator.createRandomLedger();
this.testSubject.addSubLedger(assetLedger.getIdentifier(), assetSubLedgerTwo);
this.eventRecorder.wait(EventConstants.POST_LEDGER, assetSubLedgerTwo.getIdentifier());
final Ledger liabilityLedger = LedgerGenerator.createRandomLedger();
liabilityLedger.setType(AccountType.LIABILITY.name());
this.testSubject.createLedger(liabilityLedger);
this.eventRecorder.wait(EventConstants.POST_LEDGER, liabilityLedger.getIdentifier());
final Ledger liabilitySubLedger = LedgerGenerator.createRandomLedger();
liabilitySubLedger.setType(AccountType.LIABILITY.name());
this.testSubject.addSubLedger(liabilityLedger.getIdentifier(), liabilitySubLedger);
this.eventRecorder.wait(EventConstants.POST_LEDGER, liabilitySubLedger.getIdentifier());
final Account account4ledgerOne = AccountGenerator.createRandomAccount(assetSubLedgerOne.getIdentifier());
this.testSubject.createAccount(account4ledgerOne);
this.eventRecorder.wait(EventConstants.POST_ACCOUNT, account4ledgerOne.getIdentifier());
final Account secondAccount4ledgerOne = AccountGenerator.createRandomAccount(assetSubLedgerOne.getIdentifier());
this.testSubject.createAccount(secondAccount4ledgerOne);
this.eventRecorder.wait(EventConstants.POST_ACCOUNT, secondAccount4ledgerOne.getIdentifier());
final Account account4subLedgerOne = AccountGenerator.createRandomAccount(assetSubLedgerTwo.getIdentifier());
this.testSubject.createAccount(account4subLedgerOne);
this.eventRecorder.wait(EventConstants.POST_ACCOUNT, account4subLedgerOne.getIdentifier());
final Account account4ledgerTwo = AccountGenerator.createRandomAccount(liabilitySubLedger.getIdentifier());
account4ledgerTwo.setType(AccountType.LIABILITY.name());
this.testSubject.createAccount(account4ledgerTwo);
this.eventRecorder.wait(EventConstants.POST_ACCOUNT, account4ledgerTwo.getIdentifier());
final JournalEntry firstBooking =
JournalEntryGenerator.createRandomJournalEntry(secondAccount4ledgerOne, "50.00", account4ledgerTwo, "50.00");
this.testSubject.createJournalEntry(firstBooking);
this.eventRecorder.wait(EventConstants.RELEASE_JOURNAL_ENTRY, firstBooking.getTransactionIdentifier());
final JournalEntry secondBooking =
JournalEntryGenerator.createRandomJournalEntry(secondAccount4ledgerOne, "50.00", account4ledgerOne, "50.00");
this.testSubject.createJournalEntry(secondBooking);
this.eventRecorder.wait(EventConstants.RELEASE_JOURNAL_ENTRY, secondBooking.getTransactionIdentifier());
final JournalEntry thirdBooking =
JournalEntryGenerator.createRandomJournalEntry(account4subLedgerOne, "50.00", account4ledgerTwo, "50.00");
this.testSubject.createJournalEntry(thirdBooking);
this.eventRecorder.wait(EventConstants.RELEASE_JOURNAL_ENTRY, thirdBooking.getTransactionIdentifier());
this.mockMvc.perform(get("/trialbalance")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.ALL_VALUE))
.andExpect(status().isOk())
.andDo(document("document-show-chart-of-accounts", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()),
responseFields(
fieldWithPath("trialBalanceEntries[].ledger.identifier").description("String").description("First Trial Balance Entry Identifier"),
fieldWithPath("trialBalanceEntries[].ledger.type").description("Type").description("Type of trial balance " +
" + \n" +
" + \n" +
" *enum* _Type_ { + \n" +
" DEBIT, + \n" +
" CREDIT, + \n" +
"}"),
fieldWithPath("trialBalanceEntries[].ledger.name").description("String").description("Ledger Name"),
fieldWithPath("trialBalanceEntries[].ledger.description").description("String").description("Description of Ledger"),
fieldWithPath("trialBalanceEntries[].ledger.parentLedgerIdentifier").description("String").description("Parent Ledger"),
fieldWithPath("trialBalanceEntries[].ledger.subLedgers").description("String").description("Name of Subledger"),
fieldWithPath("trialBalanceEntries[].ledger.totalValue").description("BigDecimal").description("Total Value"),
fieldWithPath("trialBalanceEntries[].ledger.createdOn").description("String").description("Creation Date"),
fieldWithPath("trialBalanceEntries[].ledger.createdBy").description("String").description("Employee Who Created"),
fieldWithPath("trialBalanceEntries[].ledger.lastModifiedOn").description("String").description("Last Modified Date"),
fieldWithPath("trialBalanceEntries[].ledger.lastModifiedBy").description("String").description("Empoyee Who Last Modified"),
fieldWithPath("trialBalanceEntries[].ledger.showAccountsInChart").description("String").description("Should We Show Chart of Accounts"),
fieldWithPath("trialBalanceEntries[].type").description("Type").description("Type of trial balance entry " +
" + \n" +
" + \n" +
" *enum* _Type_ { + \n" +
" DEBIT, + \n" +
" CREDIT, + \n" +
"}"),
fieldWithPath("trialBalanceEntries[].amount").description("BigDecimal").description("Amount"),
fieldWithPath("trialBalanceEntries[1].ledger.identifier").description("String").description("Second Trial Balance Entry Identifier"),
fieldWithPath("trialBalanceEntries[1].ledger.type").description("Type").description("Type of trial balance " +
" + \n" +
" + \n" +
" *enum* _Type_ { + \n" +
" DEBIT, + \n" +
" CREDIT, + \n" +
"}"),
fieldWithPath("trialBalanceEntries[1].ledger.name").description("String").description("Ledger Name"),
fieldWithPath("trialBalanceEntries[1].ledger.description").description("String").description("Description of Ledger"),
fieldWithPath("trialBalanceEntries[1].ledger.parentLedgerIdentifier").description("String").description("Parent Ledger"),
fieldWithPath("trialBalanceEntries[1].ledger.subLedgers").description("String").description("Name of Subledger"),
fieldWithPath("trialBalanceEntries[1].ledger.totalValue").description("BigDecimal").description("Total Value"),
fieldWithPath("trialBalanceEntries[1].ledger.createdOn").description("String").description("Creation Date"),
fieldWithPath("trialBalanceEntries[1].ledger.createdBy").description("String").description("Employee Who Created"),
fieldWithPath("trialBalanceEntries[1].ledger.lastModifiedOn").description("String").description("Last Modified Date"),
fieldWithPath("trialBalanceEntries[1].ledger.lastModifiedBy").description("String").description("Empoyee Who Last Modified"),
fieldWithPath("trialBalanceEntries[1].ledger.showAccountsInChart").description("String").description("Should We Show Chart of Accounts"),
fieldWithPath("trialBalanceEntries[1].type").description("Type").description("Type of trial balance entry " +
" + \n" +
" + \n" +
" *enum* _Type_ { + \n" +
" DEBIT, + \n" +
" CREDIT, + \n" +
"}"),
fieldWithPath("trialBalanceEntries[1].amount").description("BigDecimal").description("Amount"),
fieldWithPath("trialBalanceEntries[1].ledger.identifier").description("String").description("Third Trial Balance Entry Identifier"),
fieldWithPath("trialBalanceEntries[2].ledger.type").description("Type").description("Type of trial balance " +
" + \n" +
" + \n" +
" *enum* _Type_ { + \n" +
" DEBIT, + \n" +
" CREDIT, + \n" +
"}"),
fieldWithPath("trialBalanceEntries[2].ledger.name").description("String").description("Ledger Name"),
fieldWithPath("trialBalanceEntries[2].ledger.description").description("String").description("Description of Ledger"),
fieldWithPath("trialBalanceEntries[2].ledger.parentLedgerIdentifier").description("String").description("Parent Ledger"),
fieldWithPath("trialBalanceEntries[2].ledger.subLedgers").description("String").description("Name of Subledger"),
fieldWithPath("trialBalanceEntries[2].ledger.totalValue").description("BigDecimal").description("Total Value"),
fieldWithPath("trialBalanceEntries[2].ledger.createdOn").description("String").description("Creation Date"),
fieldWithPath("trialBalanceEntries[2].ledger.createdBy").description("String").description("Employee Who Created"),
fieldWithPath("trialBalanceEntries[2].ledger.lastModifiedOn").description("String").description("Last Modified Date"),
fieldWithPath("trialBalanceEntries[2].ledger.lastModifiedBy").description("String").description("Empoyee Who Last Modified"),
fieldWithPath("trialBalanceEntries[2].ledger.showAccountsInChart").description("String").description("Should We Show Chart of Accounts"),
fieldWithPath("trialBalanceEntries[2].type").description("Type").description("Type of trial balance entry " +
" + \n" +
" + \n" +
" *enum* _Type_ { + \n" +
" DEBIT, + \n" +
" CREDIT, + \n" +
"}"),
fieldWithPath("trialBalanceEntries[2].amount").description("BigDecimal").description("Amount"),
fieldWithPath("debitTotal").type("BigDecimal").description("Total Debit"),
fieldWithPath("creditTotal").type("BigDecimal").description("Total Credit")
)));
}