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));
}
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));
}
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));
}
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)));
}
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()));
}
Aggregations