Package name.abuchen.portfolio.model

Examples of name.abuchen.portfolio.model.AccountTransaction


    @Override
    public void onModified(Object element, Object newValue, Object oldValue)
    {
        if (element instanceof AccountTransaction)
        {
            AccountTransaction t = (AccountTransaction) element;
            if (t.getCrossEntry() != null)
                t.getCrossEntry().updateFrom(t);
            accounts.refresh(true);
        }

        markDirty();
    }
View Full Code Here


        column.setLabelProvider(new ColumnLabelProvider()
        {
            @Override
            public String getText(Object e)
            {
                AccountTransaction t = (AccountTransaction) e;
                return Values.Date.format(t.getDate());
            }

            @Override
            public Color getForeground(Object element)
            {
                return colorFor((AccountTransaction) element);
            }
        });
        ColumnViewerSorter.create(AccountTransaction.class, "date").attachTo(column, SWT.DOWN); //$NON-NLS-1$
        new DateEditingSupport(AccountTransaction.class, "date").addListener(this).attachTo(column); //$NON-NLS-1$
        transactionsColumns.addColumn(column);

        column = new Column(Messages.ColumnTransactionType, SWT.None, 100);
        column.setLabelProvider(new ColumnLabelProvider()
        {
            @Override
            public String getText(Object e)
            {
                AccountTransaction t = (AccountTransaction) e;
                return t.getType().toString();
            }

            @Override
            public Color getForeground(Object element)
            {
                return colorFor((AccountTransaction) element);
            }
        });
        column.setSorter(ColumnViewerSorter.create(AccountTransaction.class, "type")); //$NON-NLS-1$
        transactionsColumns.addColumn(column);

        column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
        column.setLabelProvider(new ColumnLabelProvider()
        {
            @Override
            public String getText(Object e)
            {
                AccountTransaction t = (AccountTransaction) e;
                long v = t.getAmount();
                if (EnumSet.of(Type.REMOVAL, Type.FEES, Type.TAXES, Type.BUY, Type.TRANSFER_OUT).contains(t.getType()))
                    v = -v;
                return Values.Amount.format(v);
            }

            @Override
            public Color getForeground(Object element)
            {
                return colorFor((AccountTransaction) element);
            }
        });
        column.setSorter(ColumnViewerSorter.create(AccountTransaction.class, "amount")); //$NON-NLS-1$
        new ValueEditingSupport(AccountTransaction.class, "amount", Values.Amount).addListener(this).attachTo(column); //$NON-NLS-1$
        transactionsColumns.addColumn(column);

        column = new Column(Messages.ColumnSecurity, SWT.None, 250);
        column.setLabelProvider(new ColumnLabelProvider()
        {
            @Override
            public String getText(Object e)
            {
                AccountTransaction t = (AccountTransaction) e;
                return t.getSecurity() != null ? String.valueOf(t.getSecurity()) : null;
            }

            @Override
            public Color getForeground(Object element)
            {
                return colorFor((AccountTransaction) element);
            }
        });
        column.setSorter(ColumnViewerSorter.create(AccountTransaction.class, "security")); //$NON-NLS-1$
        List<Security> securities = new ArrayList<Security>(getClient().getSecurities());
        Collections.sort(securities, new Security.ByName());
        new ListEditingSupport(AccountTransaction.class, "security", securities) //$NON-NLS-1$
        {
            @Override
            public boolean canEdit(Object element)
            {
                AccountTransaction t = (AccountTransaction) element;

                return t.getType() == AccountTransaction.Type.BUY //
                                || t.getType() == AccountTransaction.Type.SELL //
                                || t.getType() == AccountTransaction.Type.DIVIDENDS;
            }
        }.addListener(this).attachTo(column);
        transactionsColumns.addColumn(column);

        column = new Column(Messages.ColumnShares, SWT.RIGHT, 80);
        column.setLabelProvider(new SharesLabelProvider()
        {
            @Override
            public Long getValue(Object e)
            {
                AccountTransaction t = (AccountTransaction) e;
                if (t.getCrossEntry() instanceof BuySellEntry)
                {
                    return ((BuySellEntry) t.getCrossEntry()).getPortfolioTransaction().getShares();
                }
                else if (t.getType() == Type.DIVIDENDS && t.getShares() != 0)
                {
                    return t.getShares();
                }
                else
                {
                    return null;
                }
            }

            @Override
            public Color getForeground(Object element)
            {
                return colorFor((AccountTransaction) element);
            }
        });
        new ValueEditingSupport(AccountTransaction.class, "shares", Values.Share) //$NON-NLS-1$
        {
            @Override
            public boolean canEdit(Object element)
            {
                AccountTransaction t = (AccountTransaction) element;
                return t.getType() == AccountTransaction.Type.DIVIDENDS;
            }
        }.addListener(this).attachTo(column);
        transactionsColumns.addColumn(column);

        column = new Column(Messages.ColumnPurchasePrice, SWT.RIGHT, 80);
        column.setLabelProvider(new ColumnLabelProvider()
        {
            @Override
            public String getText(Object e)
            {
                AccountTransaction t = (AccountTransaction) e;
                if (t.getCrossEntry() instanceof BuySellEntry)
                {
                    PortfolioTransaction portfolioTransaction = ((BuySellEntry) t.getCrossEntry())
                                    .getPortfolioTransaction();
                    return Values.Amount.format(portfolioTransaction.getActualPurchasePrice());
                }
                else if (t.getType() == Type.DIVIDENDS && t.getShares() != 0)
                {
                    return Values.Amount.format(Math.round(t.getAmount() * Values.Share.divider() / t.getShares()));
                }
                else
                {
                    return null;
                }
            }

            @Override
            public Color getForeground(Object element)
            {
                return colorFor((AccountTransaction) element);
            }
        });
        transactionsColumns.addColumn(column);

        column = new Column(Messages.ColumnOffsetAccount, SWT.None, 120);
        column.setLabelProvider(new ColumnLabelProvider()
        {
            @Override
            public String getText(Object e)
            {
                AccountTransaction t = (AccountTransaction) e;
                return t.getCrossEntry() != null ? t.getCrossEntry().getCrossEntity(t).toString() : null;
            }

            @Override
            public Color getForeground(Object element)
            {
View Full Code Here

            manager.add(new Action(Messages.AccountMenuDeleteTransaction)
            {
                @Override
                public void run()
                {
                    AccountTransaction transaction = (AccountTransaction) ((IStructuredSelection) transactions
                                    .getSelection()).getFirstElement();
                    Account account = (Account) transactions.getData(Account.class.toString());

                    if (transaction == null || account == null)
                        return;

                    if (transaction.getCrossEntry() != null)
                    {
                        transaction.getCrossEntry().delete();

                        // possibly remove from investment plan
                        Transaction t = transaction.getCrossEntry().getCrossTransaction(transaction);
                        if (t instanceof PortfolioTransaction)
                        {
                            for (InvestmentPlan plan : getClient().getPlans())
                                plan.removeTransaction((PortfolioTransaction) t);
                        }
View Full Code Here

        public void applyChanges()
        {
            if (security == null)
                throw new UnsupportedOperationException(Messages.MsgMissingSecurity);

            AccountTransaction ta = new AccountTransaction();
            ta.setAmount(amount);
            ta.setShares(shares);
            ta.setDate(date);
            ta.setSecurity(security);
            ta.setType(AccountTransaction.Type.DIVIDENDS);
            account.addTransaction(ta);
        }
View Full Code Here

        public void applyChanges()
        {
            if (account == null)
                throw new UnsupportedOperationException(Messages.MsgMissingAccount);

            AccountTransaction t = new AccountTransaction();
            t.setAmount(amount);
            t.setDate(date);
            t.setType(type);
            account.addTransaction(t);
        }
View Full Code Here

                                MessageFormat.format(Messages.CSVImportMissingField, Messages.CSVColumn_Value), 0);

            AccountTransaction.Type type = convertEnum(Messages.CSVColumn_Type, AccountTransaction.Type.class,
                            rawValues, field2column);

            AccountTransaction transaction = new AccountTransaction();
            transaction.setDate(date);
            transaction.setAmount(Math.abs(amount));

            String isin = getTextValue(Messages.CSVColumn_ISIN, rawValues, field2column);
            String tickerSymbol = getTextValue(Messages.CSVColumn_TickerSymbol, rawValues, field2column);
            String wkn = getTextValue(Messages.CSVColumn_WKN, rawValues, field2column);

            if (isin != null || tickerSymbol != null || wkn != null)
            {
                Security security = lookupSecurity(client, isin, tickerSymbol, wkn, true);
                transaction.setSecurity(security);
            }

            if (type != null)
                transaction.setType(type);
            else if (transaction.getSecurity() != null)
                transaction.setType(amount < 0 ? AccountTransaction.Type.FEES : AccountTransaction.Type.DIVIDENDS);
            else
                transaction.setType(amount < 0 ? AccountTransaction.Type.REMOVAL : AccountTransaction.Type.DEPOSIT);

            account.addTransaction(transaction);
        }
View Full Code Here

            // only buy/sell/dividend transactions
            for (Transaction t : transactions)
            {
                if (t instanceof AccountTransaction)
                {
                    AccountTransaction ta = (AccountTransaction) t;

                    if (ta.getSecurity() != null
                                    && (ta.getType() == AccountTransaction.Type.INTEREST || ta.getType() == AccountTransaction.Type.DIVIDENDS))
                        writeDividend(printer, ta, dateFormat);

                }
                else if (t instanceof PortfolioTransaction)
                {
View Full Code Here

TOP

Related Classes of name.abuchen.portfolio.model.AccountTransaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.