use of name.abuchen.portfolio.model.Account in project portfolio by buchen.
the class PortfolioBuilder method buysell.
private PortfolioBuilder buysell(Type type, Security security, String date, long shares, long amount, int fees) {
if (portfolio.getReferenceAccount() == null) {
account = new Account(UUID.randomUUID().toString());
portfolio.setReferenceAccount(account);
}
BuySellEntry entry = new BuySellEntry(portfolio, portfolio.getReferenceAccount());
entry.setType(type);
entry.setDate(AccountBuilder.asDateTime(date));
entry.setSecurity(security);
entry.setShares(shares);
entry.setCurrencyCode(CurrencyUnit.EUR);
entry.setAmount(amount);
entry.getPortfolioTransaction().addUnit(new Unit(Unit.Type.FEE, Money.of(CurrencyUnit.EUR, fees)));
entry.insert();
return this;
}
use of name.abuchen.portfolio.model.Account in project portfolio by buchen.
the class CrossEntryCheckTest method setupClient.
@Before
public void setupClient() {
client = new Client();
account = new Account();
client.addAccount(account);
portfolio = new Portfolio();
client.addPortfolio(portfolio);
security = new Security();
client.addSecurity(security);
}
use of name.abuchen.portfolio.model.Account in project portfolio by buchen.
the class CrossEntryCheckTest method testThatNotTheSameAccountIsMatched.
@Test
public void testThatNotTheSameAccountIsMatched() {
Account second = new Account();
client.addAccount(second);
LocalDateTime date = LocalDateTime.now();
account.addTransaction(new AccountTransaction(date, CurrencyUnit.EUR, 2, security, AccountTransaction.Type.TRANSFER_IN));
AccountTransaction umatched = new AccountTransaction(date, CurrencyUnit.EUR, 2, security, AccountTransaction.Type.TRANSFER_OUT);
account.addTransaction(umatched);
second.addTransaction(new AccountTransaction(date, CurrencyUnit.EUR, 2, 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(account.getTransactions(), hasItem(umatched));
assertThat(second.getTransactions().get(0).getCrossEntry(), notNullValue());
assertThat(second.getTransactions().get(0).getType(), is(AccountTransaction.Type.TRANSFER_OUT));
applyFixes(client, issues);
}
use of name.abuchen.portfolio.model.Account in project portfolio by buchen.
the class PortfolioListView method addNewButton.
private void addNewButton(ToolBar toolBar) {
SimpleAction.Runnable newPortfolioAction = a -> {
Portfolio portfolio = new Portfolio();
portfolio.setName(Messages.LabelNoName);
if (!getClient().getAccounts().isEmpty()) {
portfolio.setReferenceAccount(getClient().getAccounts().get(0));
} else {
Account account = new Account();
account.setName(Messages.LabelDefaultReferenceAccountName);
getClient().addAccount(account);
portfolio.setReferenceAccount(account);
}
getClient().addPortfolio(portfolio);
markDirty();
setInput();
portfolios.editElement(portfolio, 0);
};
AbstractDropDown.create(toolBar, Messages.MenuCreatePortfolioOrTransaction, Images.PLUS.image(), SWT.NONE, (dd, manager) -> {
manager.add(new SimpleAction(Messages.PortfolioMenuAdd, newPortfolioAction));
manager.add(new Separator());
Portfolio portfolio = (Portfolio) portfolios.getStructuredSelection().getFirstElement();
new SecurityContextMenu(PortfolioListView.this).menuAboutToShow(manager, null, portfolio);
});
}
use of name.abuchen.portfolio.model.Account in project portfolio by buchen.
the class ReviewExtractedItemsPage method preselectDropDowns.
private void preselectDropDowns() {
// idea: generally one type of document (i.e. from the same bank) will
// be imported into the same account
List<Account> activeAccounts = client.getActiveAccounts();
if (!activeAccounts.isEmpty()) {
String uuid = preferences.getString(IMPORT_TARGET_ACCOUNT + extractor.getClass().getSimpleName());
// do not trigger selection listener (-> do not user #setSelection)
primaryAccount.getCombo().select(IntStream.range(0, activeAccounts.size()).filter(i -> activeAccounts.get(i).getUUID().equals(uuid)).findAny().orElse(0));
secondaryAccount.getCombo().select(0);
}
List<Portfolio> activePortfolios = client.getActivePortfolios();
if (!activePortfolios.isEmpty()) {
String uuid = preferences.getString(IMPORT_TARGET_PORTFOLIO + extractor.getClass().getSimpleName());
// do not trigger selection listener (-> do not user #setSelection)
primaryPortfolio.getCombo().select(IntStream.range(0, activePortfolios.size()).filter(i -> activePortfolios.get(i).getUUID().equals(uuid)).findAny().orElse(0));
secondaryPortfolio.getCombo().select(0);
}
if (extractor instanceof AssistantPDFExtractor) {
String clazz = preferences.getString(IMPORT_TARGET_EXTRACTOR);
List<Extractor> availableExtractors = ((AssistantPDFExtractor) extractor).getAvailableExtractors();
OptionalInt index = IntStream.range(0, availableExtractors.size()).filter(i -> clazz.equals(availableExtractors.get(i).getClass().getName())).findAny();
index.ifPresent(ii -> comboExtractors.getCombo().select(ii));
}
}
Aggregations