in service/src/main/java/org/apache/fineract/cn/deposit/service/internal/service/TransactionService.java [143:185]
private TransactionEntity doDeposit(TransactionRequestData request, AccountWrapper accountWrapper,
List<Charge> charges, LocalDateTime transactionDate, String accountId) {
BigDecimal amount = request.getAmount().getAmount();
TransactionEntity txn = createTransaction(request,TransactionTypeEnum.DEPOSIT, transactionDate, CREDIT,
null, accountId, accountWrapper.instance);
String debitAccountIdentifier = accountWrapper.productDefinition.getCashAccountIdentifier();
/* if subtxn is provided and it has an account configured the do debit that account*/
if(StringUtils.isNotBlank(request.getSubTxnId())){
Optional<SubTransactionType> subTxnTypeOpt = this.subTxnTypesService.findByIdentifier(request.getSubTxnId());
if(subTxnTypeOpt.isPresent()) {
txn.setSubTxnType(subTxnTypeOpt.get().getIdentifier());
if (subTxnTypeOpt.get().getLedgerAccount() != null) {
debitAccountIdentifier = subTxnTypeOpt.get().getLedgerAccount();
}
}else{
throw ServiceException.notFound("Sub Txn Type {0} not found.", request.getSubTxnId());
}
}
final JournalEntry journalEntry = createJournalEntry(txn.getIdentifier(), TransactionTypeEnum.DEPOSIT.getCode(),
DateConverter.toIsoString(transactionDate), request.getNote(), getLoginUser());
HashSet<Debtor> debtors = new HashSet<>(1);
HashSet<Creditor> creditors = new HashSet<>(1);
addCreditor(accountWrapper.account.getIdentifier(), amount.doubleValue(), creditors);
addDebtor(debitAccountIdentifier, amount.doubleValue(), debtors);
prepareCharges(request, accountWrapper, charges, debtors, creditors, txn, accountId);
if (debtors.isEmpty()) // must be same size as creditors
throw ServiceException.badRequest("Debit and Credit doesn't match");
journalEntry.setDebtors(debtors);
journalEntry.setCreditors(creditors);
transactionRepository.save(txn);
ledgerManager.createJournalEntry(journalEntry);
return txn;
}