public String createJournalEntry()

in service/src/main/java/org/apache/fineract/cn/accounting/service/internal/command/handler/JournalEntryCommandHandler.java [64:103]


  public String createJournalEntry(final CreateJournalEntryCommand createJournalEntryCommand) {
    final JournalEntry journalEntry = createJournalEntryCommand.journalEntry();
    final Set<Debtor> debtors = journalEntry.getDebtors();
    final Set<DebtorType> debtorTypes = debtors
        .stream()
        .map(debtor -> {
          final DebtorType debtorType = new DebtorType();
          debtorType.setAccountNumber(debtor.getAccountNumber());
          debtorType.setAmount(Double.valueOf(debtor.getAmount()));
          return debtorType;
        })
        .collect(Collectors.toSet());
    final Set<Creditor> creditors = journalEntry.getCreditors();
    final Set<CreditorType> creditorTypes = creditors
        .stream()
        .map(creditor -> {
          final CreditorType creditorType = new CreditorType();
          creditorType.setAccountNumber(creditor.getAccountNumber());
          creditorType.setAmount(Double.valueOf(creditor.getAmount()));
          return creditorType;
        })
        .collect(Collectors.toSet());
    final JournalEntryEntity journalEntryEntity = new JournalEntryEntity();
    journalEntryEntity.setTransactionIdentifier(journalEntry.getTransactionIdentifier());
    final LocalDateTime transactionDate = DateConverter.fromIsoString(journalEntry.getTransactionDate());
    journalEntryEntity.setDateBucket(DateConverter.toIsoString(DateConverter.toLocalDate(transactionDate)));
    journalEntryEntity.setTransactionDate(transactionDate);
    journalEntryEntity.setTransactionType(journalEntry.getTransactionType());
    journalEntryEntity.setClerk(journalEntry.getClerk() != null ? journalEntry.getClerk() : UserContextHolder.checkedGetUser());
    journalEntryEntity.setNote(journalEntry.getNote());
    journalEntryEntity.setDebtors(debtorTypes);
    journalEntryEntity.setCreditors(creditorTypes);
    journalEntryEntity.setMessage(journalEntry.getMessage());
    journalEntryEntity.setState(JournalEntry.State.PENDING.name());
    journalEntryEntity.setCreatedBy(UserContextHolder.checkedGetUser());
    journalEntryEntity.setCreatedOn(LocalDateTime.now(Clock.systemUTC()));
    journalEntryRepository.saveJournalEntry(journalEntryEntity);
    this.commandGateway.process(new BookJournalEntryCommand(journalEntry.getTransactionIdentifier()));
    return journalEntry.getTransactionIdentifier();
  }