use of name.abuchen.portfolio.model.Transaction.Unit in project portfolio by buchen.
the class CheckCurrenciesPortfolioTransactionTest method testNoForexGrossValueExistsIfCurrenciesMatch.
@Test
public void testNoForexGrossValueExistsIfCurrenciesMatch() {
Portfolio portfolio = new Portfolio();
Security security = new Security("", "EUR");
PortfolioTransaction t = new PortfolioTransaction();
t.setType(Type.DELIVERY_INBOUND);
t.setMonetaryAmount(Money.of("EUR", 1_00));
t.setSecurity(security);
t.addUnit(new Unit(Unit.Type.GROSS_VALUE, Money.of("EUR", 1_00), Money.of("USD", 2_00), BigDecimal.valueOf(0.5)));
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.ERROR));
}
use of name.abuchen.portfolio.model.Transaction.Unit in project portfolio by buchen.
the class CheckCurrenciesPortfolioTransactionTest method testNoForexGrossValueExistsIfCurrenciesMatchEvenIfNoForex.
@Test
public void testNoForexGrossValueExistsIfCurrenciesMatchEvenIfNoForex() {
Portfolio portfolio = new Portfolio();
Security security = new Security("", "EUR");
PortfolioTransaction t = new PortfolioTransaction();
t.setType(Type.DELIVERY_INBOUND);
t.setMonetaryAmount(Money.of("EUR", 1_00));
t.setSecurity(security);
t.addUnit(new Unit(Unit.Type.GROSS_VALUE, Money.of("EUR", 1_00)));
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.ERROR));
}
use of name.abuchen.portfolio.model.Transaction.Unit in project portfolio by buchen.
the class CheckCurrenciesPortfolioTransactionTest method testTransactionTaxesAndFeesAddUpForOutboundDeliveries.
@Test
public void testTransactionTaxesAndFeesAddUpForOutboundDeliveries() {
Portfolio portfolio = new Portfolio();
Security security = new Security("", "EUR");
Unit tax = new Unit(Unit.Type.TAX, Money.of("EUR", 5_00));
Unit fee = new Unit(Unit.Type.FEE, Money.of("EUR", 5_00));
PortfolioTransaction t = new PortfolioTransaction();
t.setType(Type.DELIVERY_OUTBOUND);
t.setMonetaryAmount(Money.of("EUR", 20_00));
t.setSecurity(security);
t.addUnit(fee);
t.addUnit(tax);
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.OK));
t.setMonetaryAmount(Money.of("EUR", 7_00));
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.ERROR));
t.setType(Type.DELIVERY_INBOUND);
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.OK));
t.setType(Type.DELIVERY_OUTBOUND);
t.removeUnit(tax);
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.OK));
t.setMonetaryAmount(Money.of("EUR", 3_00));
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.ERROR));
t.setType(Type.DELIVERY_INBOUND);
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.OK));
}
use of name.abuchen.portfolio.model.Transaction.Unit in project portfolio by buchen.
the class CheckCurrenciesPortfolioTransactionTest method testTransactionForexTaxesAndFeesIfCurrenciesMatch.
@Test
public void testTransactionForexTaxesAndFeesIfCurrenciesMatch() {
Portfolio portfolio = new Portfolio();
Security security = new Security("", "EUR");
Unit tax = new Unit(Unit.Type.TAX, Money.of("EUR", 5_00), Money.of("USD", 10_00), BigDecimal.valueOf(0.5));
PortfolioTransaction t = new PortfolioTransaction();
t.setType(Type.DELIVERY_OUTBOUND);
t.setMonetaryAmount(Money.of("EUR", 20_00));
t.setSecurity(security);
t.addUnit(tax);
assertThat(action.process(t, portfolio).getCode(), is(Status.Code.ERROR));
}
use of name.abuchen.portfolio.model.Transaction.Unit in project portfolio by buchen.
the class InsertActionTest method prepare.
@Before
public void prepare() {
client = new Client();
Security security = new Security();
client.addSecurity(security);
Portfolio portfolio = new Portfolio();
client.addPortfolio(portfolio);
Account account = new Account();
client.addAccount(account);
entry = new BuySellEntry();
entry.setType(Type.BUY);
entry.setMonetaryAmount(Money.of(CurrencyUnit.EUR, 9_99));
entry.setShares(99);
entry.setDate(transactionDate);
entry.setSecurity(security);
entry.setNote("note");
entry.getPortfolioTransaction().addUnit(new Unit(Unit.Type.TAX, Money.of(CurrencyUnit.EUR, 1_99)));
}
Aggregations