Package name.abuchen.portfolio.model

Examples of name.abuchen.portfolio.model.PortfolioTransaction


            @Override
            public String getText(Object t)
            {
                if (t instanceof PortfolioTransaction)
                {
                    PortfolioTransaction p = (PortfolioTransaction) t;
                    return p.getCrossEntry() != null ? p.getCrossEntry().getCrossEntity(p).toString() : null;
                }
                else if (t instanceof DividendTransaction)
                {
                    return ((DividendTransaction) t).getAccount().getName();
                }
View Full Code Here


    }

    @Override
    public void onModified(Object element, Object newValue, Object oldValue)
    {
        PortfolioTransaction t = (PortfolioTransaction) element;
        if (t.getCrossEntry() != null)
            t.getCrossEntry().updateFrom(t);

        owner.markDirty();
        owner.notifyModelUpdated();
    }
View Full Code Here

        column.setLabelProvider(new TransactionLabelProvider()
        {
            @Override
            public String getText(Object element)
            {
                PortfolioTransaction t = (PortfolioTransaction) element;
                return t.getSecurity() != null ? String.valueOf(t.getSecurity()) : null;
            }
        });
        ColumnViewerSorter.create(PortfolioTransaction.class, "security").attachTo(column); //$NON-NLS-1$
        List<Security> securities = new ArrayList<Security>(owner.getClient().getSecurities());
        Collections.sort(securities, new Security.ByName());
        new ListEditingSupport(PortfolioTransaction.class, "security", securities).addListener(this).attachTo(column); //$NON-NLS-1$
        support.addColumn(column);

        column = new Column(Messages.ColumnShares, SWT.RIGHT, 80);
        column.setLabelProvider(new SharesLabelProvider()
        {
            private TransactionLabelProvider colors = new TransactionLabelProvider();

            @Override
            public Long getValue(Object element)
            {
                return ((PortfolioTransaction) element).getShares();
            }

            @Override
            public Color getForeground(Object element)
            {
                return colors.getForeground(element);
            }

            @Override
            public Color getBackground(Object element)
            {
                return colors.getBackground(element);
            }
        });
        ColumnViewerSorter.create(PortfolioTransaction.class, "shares").attachTo(column); //$NON-NLS-1$
        new ValueEditingSupport(PortfolioTransaction.class, "shares", Values.Share).addListener(this).attachTo(column); //$NON-NLS-1$
        support.addColumn(column);

        column = new Column(Messages.ColumnQuote, SWT.RIGHT, 80);
        column.setLabelProvider(new TransactionLabelProvider()
        {
            @Override
            public String getText(Object element)
            {
                PortfolioTransaction t = (PortfolioTransaction) element;
                return t.getShares() != 0 ? Values.Amount.format(t.getActualPurchasePrice()) : null;
            }
        });
        ColumnViewerSorter.create(PortfolioTransaction.class, "actualPurchasePrice").attachTo(column); //$NON-NLS-1$
        support.addColumn(column);

        column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
        column.setLabelProvider(new TransactionLabelProvider()
        {
            @Override
            public String getText(Object element)
            {
                return Values.Amount.format(((PortfolioTransaction) element).getLumpSumPrice());
            }
        });
        ColumnViewerSorter.create(PortfolioTransaction.class, "lumpSumPrice").attachTo(column); //$NON-NLS-1$
        support.addColumn(column);

        column = new Column(Messages.ColumnFees, SWT.RIGHT, 80);
        column.setLabelProvider(new TransactionLabelProvider()
        {
            @Override
            public String getText(Object element)
            {
                return Values.Amount.format(((PortfolioTransaction) element).getFees());
            }
        });
        ColumnViewerSorter.create(PortfolioTransaction.class, "fees").attachTo(column); //$NON-NLS-1$
        new ValueEditingSupport(PortfolioTransaction.class, "fees", Values.Amount).addListener(this).attachTo(column); //$NON-NLS-1$
        support.addColumn(column);

        column = new Column(Messages.ColumnTaxes, SWT.RIGHT, 80);
        column.setLabelProvider(new TransactionLabelProvider()
        {
            @Override
            public String getText(Object element)
            {
                return Values.Amount.format(((PortfolioTransaction) element).getTaxes());
            }
        });
        ColumnViewerSorter.create(PortfolioTransaction.class, "taxes").attachTo(column); //$NON-NLS-1$
        new ValueEditingSupport(PortfolioTransaction.class, "taxes", Values.Amount).addListener(this).attachTo(column); //$NON-NLS-1$
        support.addColumn(column);

        column = new Column(Messages.ColumnLumpSumPrice, SWT.RIGHT, 80);
        column.setLabelProvider(new TransactionLabelProvider()
        {
            @Override
            public String getText(Object element)
            {
                return Values.Amount.format(((PortfolioTransaction) element).getAmount());
            }
        });
        ColumnViewerSorter.create(PortfolioTransaction.class, "amount").attachTo(column); //$NON-NLS-1$
        new ValueEditingSupport(PortfolioTransaction.class, "amount", Values.Amount).addListener(this).attachTo(column); //$NON-NLS-1$
        support.addColumn(column);

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

        column = new Column(Messages.ColumnNote, SWT.None, 200);
View Full Code Here

    private void fillTransactionsContextMenu(IMenuManager manager)
    {
        if (portfolio == null)
            return;

        final PortfolioTransaction transaction = (PortfolioTransaction) ((IStructuredSelection) tableViewer
                        .getSelection()).getFirstElement();

        if (fullContextMenu && transaction != null)
            new SecurityContextMenu(owner).menuAboutToShow(manager, transaction.getSecurity(), portfolio);
        else if (fullContextMenu)
            new SecurityContextMenu(owner).menuAboutToShow(manager, null, portfolio);
        else if (transaction != null)
            manager.add(new WebLocationMenu(transaction.getSecurity()));

        if (transaction != null)
        {
            manager.add(new Separator());
            manager.add(new Action(Messages.MenuTransactionDelete)
View Full Code Here

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

            PortfolioTransaction t = new PortfolioTransaction();
            t.setType(type);
            t.setDate(date);
            t.setSecurity(security);
            t.setFees(fees);
            t.setTaxes(taxes);
            t.setShares(shares);
            t.setAmount(total);

            portfolio.addTransaction(t);
        }
View Full Code Here

        }

        @Override
        public void execute()
        {
            PortfolioTransaction t = new PortfolioTransaction();
            t.setType(target);
            t.setDate(transaction.getDate());
            t.setSecurity(transaction.getSecurity());
            t.setShares(transaction.getShares());
            t.setFees(transaction.getFees());
            t.setTaxes(transaction.getTaxes());
            t.setAmount(transaction.getAmount());
            portfolio.addTransaction(t);

            portfolio.getTransactions().remove(transaction);
        }
View Full Code Here

            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()));
                }
View Full Code Here

        public Color getForeground(Object element)
        {
            if (marked.contains(element))
                return Display.getDefault().getSystemColor(SWT.COLOR_INFO_FOREGROUND);

            PortfolioTransaction t = (PortfolioTransaction) element;

            if (t.getType() == Type.SELL || t.getType() == Type.TRANSFER_OUT)
                return Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED);
            else
                return Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN);
        }
View Full Code Here

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

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

            PortfolioTransaction transaction = new PortfolioTransaction();
            transaction.setDate(date);
            transaction.setAmount(Math.abs(amount));
            transaction.setSecurity(lookupSecurity(client, isin, tickerSymbol, wkn, true));
            transaction.setShares(Math.abs(shares));
            transaction.setFees(Math.abs(fees));
            transaction.setTaxes(Math.abs(taxes));

            if (type != null)
                transaction.setType(type);
            else
                transaction.setType(amount < 0 ? PortfolioTransaction.Type.BUY : PortfolioTransaction.Type.SELL);

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

                        writeDividend(printer, ta, dateFormat);

                }
                else if (t instanceof PortfolioTransaction)
                {
                    PortfolioTransaction tp = (PortfolioTransaction) t;

                    switch (tp.getType())
                    {
                        case BUY:
                        case DELIVERY_INBOUND:
                            writeBuySell(printer, tp, "Kauf", dateFormat); //$NON-NLS-1$
                            break;
View Full Code Here

TOP

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

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.