Search in sources :

Example 1 with Account

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

the class CheckCurrenciesAccountTransactionTest method testTransactionCurrencyMatchesAccount.

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

Example 2 with Account

use of name.abuchen.portfolio.model.Account 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 3 with Account

use of name.abuchen.portfolio.model.Account 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 4 with Account

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

the class CheckCurrenciesBuySellEntryTest method testBuySellEntry.

@Test
public void testBuySellEntry() {
    Account account = new Account();
    account.setCurrencyCode("EUR");
    Security security = new Security();
    security.setCurrencyCode("USD");
    Portfolio portfolio = new Portfolio();
    BuySellEntry entry = new BuySellEntry();
    entry.setType(PortfolioTransaction.Type.BUY);
    entry.setSecurity(security);
    entry.setMonetaryAmount(Money.of("EUR", 100_00));
    entry.getPortfolioTransaction().addUnit(new Unit(Unit.Type.GROSS_VALUE, Money.of("EUR", 80_00), Money.of("USD", 100_00), BigDecimal.valueOf(0.8)));
    assertThat(action.process(entry, account, portfolio).getCode(), is(Status.Code.OK));
}
Also used : Account(name.abuchen.portfolio.model.Account) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) Portfolio(name.abuchen.portfolio.model.Portfolio) Security(name.abuchen.portfolio.model.Security) Unit(name.abuchen.portfolio.model.Transaction.Unit) Test(org.junit.Test)

Example 5 with Account

use of name.abuchen.portfolio.model.Account 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)

Aggregations

Account (name.abuchen.portfolio.model.Account)75 Security (name.abuchen.portfolio.model.Security)39 Client (name.abuchen.portfolio.model.Client)38 Portfolio (name.abuchen.portfolio.model.Portfolio)37 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)35 Test (org.junit.Test)31 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)25 CurrencyConverter (name.abuchen.portfolio.money.CurrencyConverter)22 TestCurrencyConverter (name.abuchen.portfolio.TestCurrencyConverter)21 ArrayList (java.util.ArrayList)17 LocalDate (java.time.LocalDate)16 AccountBuilder (name.abuchen.portfolio.AccountBuilder)14 Unit (name.abuchen.portfolio.model.Transaction.Unit)14 SecurityBuilder (name.abuchen.portfolio.SecurityBuilder)13 PortfolioBuilder (name.abuchen.portfolio.PortfolioBuilder)12 Money (name.abuchen.portfolio.money.Money)12 Collections (java.util.Collections)11 List (java.util.List)11 AccountTransferEntry (name.abuchen.portfolio.model.AccountTransferEntry)11 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)11