use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class CrossEntryCheckTest method testMissingAccountTransferInIssue.
@Test
public void testMissingAccountTransferInIssue() {
account.addTransaction(new AccountTransaction(LocalDateTime.now(), CurrencyUnit.EUR, 1, security, AccountTransaction.Type.TRANSFER_OUT));
List<Issue> issues = new CrossEntryCheck().execute(client);
assertThat(issues.size(), is(1));
assertThat(issues.get(0), is(instanceOf(MissingAccountTransferIssue.class)));
assertThat(issues.get(0).getEntity(), is((Object) account));
applyFixes(client, issues);
}
use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class CrossEntryCheckTest method testThatAlmostMatchingBuySellEntriesAreNotMatched.
@Test
public void testThatAlmostMatchingBuySellEntriesAreNotMatched() {
LocalDateTime date = LocalDateTime.now();
portfolio.addTransaction(new PortfolioTransaction(date, CurrencyUnit.EUR, 1, security, 1, PortfolioTransaction.Type.SELL, 1, 0));
account.addTransaction(new AccountTransaction(date, CurrencyUnit.EUR, 2, security, AccountTransaction.Type.SELL));
List<Issue> issues = new CrossEntryCheck().execute(client);
assertThat(issues.size(), is(2));
List<Object> objects = new ArrayList<Object>(issues);
assertThat(objects, hasItem(instanceOf(MissingBuySellAccountIssue.class)));
assertThat(objects, hasItem(instanceOf(MissingBuySellPortfolioIssue.class)));
applyFixes(client, issues);
}
use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class CrossEntryCheckTest method testThatAccountTransactionsWithoutSecurity.
@Test
public void testThatAccountTransactionsWithoutSecurity() {
Portfolio second = new Portfolio();
client.addPortfolio(second);
account.addTransaction(new AccountTransaction(LocalDateTime.now(), CurrencyUnit.EUR, 1, null, AccountTransaction.Type.BUY));
List<Issue> issues = new CrossEntryCheck().execute(client);
assertThat(issues.size(), is(1));
assertThat(issues.get(0).getAvailableFixes().get(0), is(instanceOf(DeleteTransactionFix.class)));
applyFixes(client, issues);
ClientSnapshot.create(client, new TestCurrencyConverter(), LocalDate.now());
}
use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class CrossEntryCheckTest method testMissingAccountTransferOutIssue.
@Test
public void testMissingAccountTransferOutIssue() {
account.addTransaction(new AccountTransaction(LocalDateTime.now(), CurrencyUnit.EUR, 1, security, AccountTransaction.Type.TRANSFER_IN));
List<Issue> issues = new CrossEntryCheck().execute(client);
assertThat(issues.size(), is(1));
assertThat(issues.get(0), is(instanceOf(MissingAccountTransferIssue.class)));
assertThat(issues.get(0).getEntity(), is((Object) account));
applyFixes(client, issues);
}
use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.
the class IBFlexStatementExtractorTest method testIBAcitvityStatement.
@Test
public void testIBAcitvityStatement() throws IOException {
InputStream activityStatement = getClass().getResourceAsStream("IBActivityStatement.xml");
Client client = new Client();
IBFlexStatementExtractor extractor = new IBFlexStatementExtractor(client);
Extractor.InputFile tempFile = createTempFile(activityStatement);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(Collections.singletonList(tempFile), errors);
results.stream().filter(i -> !(i instanceof SecurityItem)).forEach(i -> assertThat(i.getAmount(), notNullValue()));
assertThat(results.size(), is(29));
assertFirstSecurity(results.stream().filter(i -> i instanceof SecurityItem).findFirst());
assertFirstTransaction(results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst());
assertSecondSecurity(results.stream().filter(i -> i instanceof SecurityItem).reduce((previous, current) -> current).get());
assertFourthTransaction(results.stream().filter(i -> i instanceof BuySellEntryItem).skip(3).findFirst());
assertInterestCharge(results.stream().filter(i -> i instanceof TransactionItem).filter(i -> i.getSubject() instanceof AccountTransaction && ((AccountTransaction) i.getSubject()).getType() == Type.INTEREST_CHARGE).findFirst());
assertTax(results.stream().filter(i -> i instanceof TransactionItem).filter(i -> i.getSubject() instanceof AccountTransaction && ((AccountTransaction) i.getSubject()).getType() == Type.TAXES).findFirst());
assertFee(results.stream().filter(i -> i instanceof TransactionItem).filter(i -> i.getSubject() instanceof AccountTransaction && ((AccountTransaction) i.getSubject()).getType() == Type.FEES).skip(2).findFirst());
assertFeeRefund(results.stream().filter(i -> i instanceof TransactionItem).filter(i -> i.getSubject() instanceof AccountTransaction && ((AccountTransaction) i.getSubject()).getType() == Type.FEES_REFUND).findFirst());
// TODO Check CorporateActions
}
Aggregations