use of name.abuchen.portfolio.datatransfer.Extractor.PortfolioTransferItem in project portfolio by buchen.
the class CSVPortfolioTransactionExtractorTest method testTransferTransaction.
@Test
public void testTransferTransaction() throws ParseException {
Client client = new Client();
Security security = new Security();
security.setTickerSymbol("SAP.DE");
client.addSecurity(security);
CSVExtractor extractor = new CSVPortfolioTransactionExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(0, Arrays.<String[]>asList(new String[] { "2013-01-01", "DE0007164600", "SAP.DE", "", "SAP SE", "100", "EUR", "11", "10", "", "", "", "1,2", "TRANSFER_IN", "Notiz" }), buildField2Column(extractor), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.EUR);
PortfolioTransferEntry entry = (PortfolioTransferEntry) results.stream().filter(i -> i instanceof PortfolioTransferItem).findAny().get().getSubject();
PortfolioTransaction source = entry.getSourceTransaction();
assertThat(source.getType(), is(PortfolioTransaction.Type.TRANSFER_OUT));
assertThat(source.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 100_00)));
assertThat(source.getNote(), is("Notiz"));
assertThat(source.getDateTime(), is(LocalDateTime.parse("2013-01-01T00:00")));
assertThat(source.getShares(), is(Values.Share.factorize(1.2)));
assertThat(source.getSecurity(), is(security));
// security transfers do not support fees and taxes at the moment
assertThat(source.getUnitSum(Unit.Type.FEE), is(Money.of("EUR", 0)));
assertThat(source.getUnitSum(Unit.Type.TAX), is(Money.of("EUR", 0)));
PortfolioTransaction target = entry.getTargetTransaction();
assertThat(target.getType(), is(PortfolioTransaction.Type.TRANSFER_IN));
assertThat(target.getUnitSum(Unit.Type.FEE), is(Money.of("EUR", 0)));
assertThat(target.getUnitSum(Unit.Type.TAX), is(Money.of("EUR", 0)));
}
Aggregations