public static void transferBankToBank(Properties ctx,int fromBankAccountId,int toBankAccountId,int currencyId,BigDecimal amount,Timestamp dateAcct,String trxName) throws OperationException {
  MBankAccount fromBankAccount=new MBankAccount(ctx,fromBankAccountId,trxName);
  MBankAccount toBankAccount=new MBankAccount(ctx,toBankAccountId,trxName);
  int fromCashBookId=OrganisationManager.getCreateTransferCashBook(ctx,fromBankAccount.getAD_Org_ID(),currencyId,trxName);
  int toCashBookId=OrganisationManager.getCreateTransferCashBook(ctx,toBankAccount.getAD_Org_ID(),currencyId,trxName);
  MCash fromCashJournal=MCash.get(ctx,fromCashBookId,dateAcct,trxName);
  if (fromCashJournal == null) {
    throw new OperationException("Could not create Cash Journal entry");
  }
  MCash toCashJournal=MCash.get(ctx,toCashBookId,dateAcct,trxName);
  if (toCashJournal == null) {
    throw new OperationException("Could not create Cash Journal entry");
  }
  String description=fromBankAccount.getAccountNo() + " (BA) -> " + toBankAccount.getAccountNo()+ " (BA)";
  MCashLine fromCashLine=new MCashLine(fromCashJournal);
  fromCashLine.setC_Currency_ID(currencyId);
  fromCashLine.setDescription(description);
  fromCashLine.setCashType(MCashLine.CASHTYPE_BankAccountTransfer);
  fromCashLine.setC_BankAccount_ID(fromBankAccountId);
  fromCashLine.setAmount(amount);
  fromCashLine.setIsGenerated(true);
  PoManager.save(fromCashLine);
  MCashLine toCashLine=new MCashLine(toCashJournal);
  toCashLine.setC_Currency_ID(currencyId);
  toCashLine.setDescription(description);
  toCashLine.setCashType(MCashLine.CASHTYPE_BankAccountTransfer);
  toCashLine.setC_BankAccount_ID(toBankAccountId);
  toCashLine.setAmount(amount.negate());
  toCashLine.setIsGenerated(true);
  PoManager.save(toCashLine);
  PoManager.processIt(fromCashJournal,DocumentEngine.ACTION_Complete);
  if (fromCashJournal.get_ID() != toCashJournal.get_ID()) {
    PoManager.processIt(toCashJournal,DocumentEngine.ACTION_Complete);
  }
}

public static void transferBankToBank ( Properties ctx , int fromBankAccountId , int toBankAccountId , int currencyId , BigDecimal amount , Timestamp dateAcct , String trxName ) throws OperationException { MBankAccount fromBankAccount = new MBankAccount ( ctx , fromBankAccountId , trxName ) ; MBankAccount toBankAccount = new MBankAccount ( ctx , toBankAccountId , trxName ) ; int fromCashBookId = OrganisationManager . getCreateTransferCashBook ( ctx , fromBankAccount . getAD_Org_ID ( ) , currencyId , trxName ) ; int toCashBookId = OrganisationManager . getCreateTransferCashBook ( ctx , toBankAccount . getAD_Org_ID ( ) , currencyId , trxName ) ; MCash fromCashJournal = MCash . get ( ctx , fromCashBookId , dateAcct , trxName ) ; if ( fromCashJournal == null ) { throw new OperationException ( "Could not create Cash Journal entry" ) ; } MCash toCashJournal = MCash . get ( ctx , toCashBookId , dateAcct , trxName ) ; if ( toCashJournal == null ) { throw new OperationException ( "Could not create Cash Journal entry" ) ; } String description = fromBankAccount . getAccountNo ( ) + " (BA) -> " + toBankAccount . getAccountNo ( ) + " (BA)" ; MCashLine fromCashLine = new MCashLine ( fromCashJournal ) ; fromCashLine . setC_Currency_ID ( currencyId ) ; fromCashLine . setDescription ( description ) ; fromCashLine . setCashType ( MCashLine . CASHTYPE_BankAccountTransfer ) ; fromCashLine . setC_BankAccount_ID ( fromBankAccountId ) ; fromCashLine . setAmount ( amount ) ; fromCashLine . setIsGenerated ( true ) ; PoManager . save ( fromCashLine ) ; MCashLine toCashLine = new MCashLine ( toCashJournal ) ; toCashLine . setC_Currency_ID ( currencyId ) ; toCashLine . setDescription ( description ) ; toCashLine . setCashType ( MCashLine . CASHTYPE_BankAccountTransfer ) ; toCashLine . setC_BankAccount_ID ( toBankAccountId ) ; toCashLine . setAmount ( amount . negate ( ) ) ; toCashLine . setIsGenerated ( true ) ; PoManager . save ( toCashLine ) ; PoManager . processIt ( fromCashJournal , DocumentEngine . ACTION_Complete ) ; if ( fromCashJournal . get_ID ( ) != toCashJournal . get_ID ( ) ) { PoManager . processIt ( toCashJournal , DocumentEngine . ACTION_Complete ) ; } }
transfers money from a bank account to another one .
