public void processCashWithdrawal()

in service/src/main/java/org/apache/fineract/cn/teller/service/internal/processor/DepositTransactionHandler.java [168:211]


  public void processCashWithdrawal(final String tellerCode, final TellerTransaction tellerTransaction,
                                    final boolean chargesIncluded) {
    final TellerEntity tellerEntity = getTellerEntity(tellerCode);
    final TellerTransactionCosts tellerTransactionCosts = this.getTellerTransactionCosts(tellerTransaction);

    if (tellerTransactionCosts.getTotalAmount().compareTo(BigDecimal.ZERO) == 0) {
      return;
    }

    final String resolvedCustomerAccount = this.accountingService.resolveAccountIdentifier(tellerTransaction.getCustomerAccountIdentifier());

    final JournalEntry journalEntry = this.prepareJournalEntry(tellerTransaction);

    final HashSet<Debtor> debtors = new HashSet<>();
    journalEntry.setDebtors(debtors);

    final HashSet<Creditor> creditors = new HashSet<>();
    journalEntry.setCreditors(creditors);

    if (tellerTransaction.getAmount().compareTo(BigDecimal.ZERO) > 0) {
      final Debtor customerDebtor = new Debtor();
      customerDebtor.setAccountNumber(resolvedCustomerAccount);
      customerDebtor.setAmount(tellerTransaction.getAmount().toString());
      debtors.add(customerDebtor);

      final Creditor tellerCreditor = new Creditor();
      tellerCreditor.setAccountNumber(tellerEntity.getTellerAccountIdentifier());
      tellerCreditor.setAmount(tellerTransaction.getAmount().toString());
      creditors.add(tellerCreditor);
    }

    if (!tellerTransactionCosts.getCharges().isEmpty()) {
      if (chargesIncluded) {
        debtors.add(this.createChargesDebtor(tellerEntity.getTellerAccountIdentifier(), tellerTransactionCosts));
      } else {
        debtors.add(this.createChargesDebtor(resolvedCustomerAccount, tellerTransactionCosts));
      }
    }

    creditors.addAll(this.createChargeCreditors(tellerTransactionCosts));

    this.accountingService.postJournalEntry(journalEntry);
    this.depositAccountManagementService.transactedProductInstance(resolvedCustomerAccount);
  }