Search in sources :

Example 56 with AccountTransaction

use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.

the class CheckCurrenciesAccountTransactionTest method testTransactionIfSecurityIsIndex.

@Test
public void testTransactionIfSecurityIsIndex() {
    Account account = new Account();
    account.setCurrencyCode("EUR");
    Security security = new Security("", null);
    AccountTransaction t = new AccountTransaction();
    t.setMonetaryAmount(Money.of("EUR", 1_00));
    t.setSecurity(security);
    assertThat(action.process(t, account).getCode(), is(Status.Code.ERROR));
}
Also used : Account(name.abuchen.portfolio.model.Account) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Security(name.abuchen.portfolio.model.Security) Test(org.junit.Test)

Example 57 with AccountTransaction

use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.

the class CheckCurrenciesAccountTransactionTest method testTransactionCurrencyMatchesSecurity.

@Test
public void testTransactionCurrencyMatchesSecurity() {
    Account account = new Account();
    account.setCurrencyCode("EUR");
    Security security = new Security("", "EUR");
    AccountTransaction t = new AccountTransaction();
    t.setMonetaryAmount(Money.of("EUR", 1_00));
    t.setSecurity(security);
    assertThat(action.process(t, account).getCode(), is(Status.Code.OK));
    security.setCurrencyCode("USD");
    assertThat(action.process(t, account).getCode(), is(Status.Code.ERROR));
}
Also used : Account(name.abuchen.portfolio.model.Account) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Security(name.abuchen.portfolio.model.Security) Test(org.junit.Test)

Example 58 with AccountTransaction

use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.

the class CheckValidTypesActionTest method testAccountTransaction.

@Test
public void testAccountTransaction() {
    Account account = new Account();
    account.setCurrencyCode("EUR");
    AccountTransaction t = new AccountTransaction();
    t.setMonetaryAmount(Money.of("EUR", 1_00));
    t.setType(AccountTransaction.Type.BUY);
    assertThat(action.process(t, account).getCode(), is(Status.Code.ERROR));
    t.setType(AccountTransaction.Type.SELL);
    assertThat(action.process(t, account).getCode(), is(Status.Code.ERROR));
    t.setType(AccountTransaction.Type.TRANSFER_IN);
    assertThat(action.process(t, account).getCode(), is(Status.Code.ERROR));
    t.setType(AccountTransaction.Type.TRANSFER_OUT);
    assertThat(action.process(t, account).getCode(), is(Status.Code.ERROR));
    t.setType(AccountTransaction.Type.DEPOSIT);
    assertThat(action.process(t, account).getCode(), is(Status.Code.OK));
    t.setType(AccountTransaction.Type.DIVIDENDS);
    assertThat(action.process(t, account).getCode(), is(Status.Code.OK));
    t.setType(AccountTransaction.Type.FEES);
    assertThat(action.process(t, account).getCode(), is(Status.Code.OK));
    t.setType(AccountTransaction.Type.FEES_REFUND);
    assertThat(action.process(t, account).getCode(), is(Status.Code.OK));
    t.setType(AccountTransaction.Type.INTEREST);
    assertThat(action.process(t, account).getCode(), is(Status.Code.OK));
    t.setType(AccountTransaction.Type.INTEREST_CHARGE);
    assertThat(action.process(t, account).getCode(), is(Status.Code.OK));
    t.setType(AccountTransaction.Type.REMOVAL);
    assertThat(action.process(t, account).getCode(), is(Status.Code.OK));
    t.setType(AccountTransaction.Type.TAX_REFUND);
    assertThat(action.process(t, account).getCode(), is(Status.Code.OK));
    t.setType(AccountTransaction.Type.TAXES);
    assertThat(action.process(t, account).getCode(), is(Status.Code.OK));
}
Also used : Account(name.abuchen.portfolio.model.Account) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Test(org.junit.Test)

Example 59 with AccountTransaction

use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.

the class CSVAccountTransactionExtractorTest method testTaxesOnDividends.

@Test
public void testTaxesOnDividends() {
    Client client = new Client();
    CSVExtractor extractor = new CSVAccountTransactionExtractor(client);
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(0, // 
    Arrays.<String[]>asList(new String[] { "2013-01-01", "DE0007164600", "SAP.DE", "", "100", "EUR", "DIVIDENDS", "SAP SE", "10", "Notiz", "10" }), buildField2Column(extractor), errors);
    assertThat(results.size(), is(2));
    new AssertImportActions().check(results, CurrencyUnit.EUR);
    AccountTransaction t = (AccountTransaction) results.stream().filter(i -> i instanceof TransactionItem).findAny().get().getSubject();
    assertThat(t.getType(), is(AccountTransaction.Type.DIVIDENDS));
    assertThat(t.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 100_00)));
    assertThat(t.getUnitSum(Unit.Type.TAX), is(Money.of(CurrencyUnit.EUR, 10_00)));
}
Also used : Item(name.abuchen.portfolio.datatransfer.Extractor.Item) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) ArrayList(java.util.ArrayList) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Client(name.abuchen.portfolio.model.Client) ParseException(java.text.ParseException) AssertImportActions(name.abuchen.portfolio.datatransfer.actions.AssertImportActions) Test(org.junit.Test)

Example 60 with AccountTransaction

use of name.abuchen.portfolio.model.AccountTransaction in project portfolio by buchen.

the class CSVAccountTransactionExtractorTest method testTransferTransaction.

@Test
public void testTransferTransaction() {
    Client client = new Client();
    CSVExtractor extractor = new CSVAccountTransactionExtractor(client);
    List<Exception> errors = new ArrayList<Exception>();
    List<Item> results = extractor.extract(0, // 
    Arrays.<String[]>asList(new String[] { "2013-01-01", "", "", "", "100", "EUR", "TRANSFER_OUT", "", "", "Notiz" }), buildField2Column(extractor), errors);
    assertThat(results.size(), is(1));
    assertThat(errors, empty());
    AccountTransferEntry entry = (AccountTransferEntry) results.get(0).getSubject();
    AccountTransaction t = entry.getSourceTransaction();
    assertThat(t.getType(), is(AccountTransaction.Type.TRANSFER_OUT));
    assertThat(t.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 100_00)));
    assertThat(t.getNote(), is("Notiz"));
    assertThat(t.getDateTime(), is(LocalDateTime.parse("2013-01-01T00:00")));
    assertThat(t.getShares(), is(0L));
    assertThat(t.getSecurity(), is(nullValue()));
}
Also used : Item(name.abuchen.portfolio.datatransfer.Extractor.Item) SecurityItem(name.abuchen.portfolio.datatransfer.Extractor.SecurityItem) TransactionItem(name.abuchen.portfolio.datatransfer.Extractor.TransactionItem) ArrayList(java.util.ArrayList) AccountTransferEntry(name.abuchen.portfolio.model.AccountTransferEntry) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Client(name.abuchen.portfolio.model.Client) ParseException(java.text.ParseException) Test(org.junit.Test)

Aggregations

AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)218 Client (name.abuchen.portfolio.model.Client)169 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)152 Money (name.abuchen.portfolio.money.Money)148 IOException (java.io.IOException)141 Unit (name.abuchen.portfolio.model.Transaction.Unit)135 Test (org.junit.Test)133 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)131 Security (name.abuchen.portfolio.model.Security)129 ArrayList (java.util.ArrayList)125 Values (name.abuchen.portfolio.money.Values)117 List (java.util.List)110 LocalDateTime (java.time.LocalDateTime)109 CurrencyUnit (name.abuchen.portfolio.money.CurrencyUnit)103 CoreMatchers.is (org.hamcrest.CoreMatchers.is)102 Assert.assertThat (org.junit.Assert.assertThat)102 Item (name.abuchen.portfolio.datatransfer.Extractor.Item)99 SecurityItem (name.abuchen.portfolio.datatransfer.Extractor.SecurityItem)99 TransactionItem (name.abuchen.portfolio.datatransfer.Extractor.TransactionItem)99 Optional (java.util.Optional)87