throws ParseException
{
if (!(target instanceof Account))
throw new IllegalArgumentException();
Account account = (Account) target;
Date date = convertDate(Messages.CSVColumn_Date, rawValues, field2column);
if (date == null)
throw new ParseException(MessageFormat.format(Messages.CSVImportMissingField, Messages.CSVColumn_Date),
0);
Long amount = convertAmount(Messages.CSVColumn_Value, rawValues, field2column);
if (amount == null)
throw new ParseException(
MessageFormat.format(Messages.CSVImportMissingField, Messages.CSVColumn_Value), 0);
AccountTransaction.Type type = convertEnum(Messages.CSVColumn_Type, AccountTransaction.Type.class,
rawValues, field2column);
AccountTransaction transaction = new AccountTransaction();
transaction.setDate(date);
transaction.setAmount(Math.abs(amount));
String isin = getTextValue(Messages.CSVColumn_ISIN, rawValues, field2column);
String tickerSymbol = getTextValue(Messages.CSVColumn_TickerSymbol, rawValues, field2column);
String wkn = getTextValue(Messages.CSVColumn_WKN, rawValues, field2column);
if (isin != null || tickerSymbol != null || wkn != null)
{
Security security = lookupSecurity(client, isin, tickerSymbol, wkn, true);
transaction.setSecurity(security);
}
if (type != null)
transaction.setType(type);
else if (transaction.getSecurity() != null)
transaction.setType(amount < 0 ? AccountTransaction.Type.FEES : AccountTransaction.Type.DIVIDENDS);
else
transaction.setType(amount < 0 ? AccountTransaction.Type.REMOVAL : AccountTransaction.Type.DEPOSIT);
account.addTransaction(transaction);
}