Skip to content

Commit

Permalink
Removed obsolete code, fixed some issues reported by Sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
buchen committed Feb 23, 2014
1 parent e44bd7b commit b58c1dd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public void apply()

private interface Modifier
{
static final Object UNMODIFIED = new Object();
Object UNMODIFIED = new Object();

Object getValue(Object element) throws Exception;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ public class DividendTransaction extends Transaction

private long fifoCost;

private boolean isDiv12;
private int divEventId;

public DividendTransaction()
{}

Expand Down Expand Up @@ -70,57 +67,12 @@ public double getPersonalDividendYield()
return amount / (double) fifoCost;
}

public boolean getIsDiv12()
{
return isDiv12;
}

public void setIsDiv12(boolean isDiv12)
{
this.isDiv12 = isDiv12;
}

public int getDivEventId()
{
return divEventId;
}

public void setDivEventId(int divEventId)
{
this.divEventId = divEventId;
}

static public long amountFractionPerShare(long amount, long shares)
static long amountFractionPerShare(long amount, long shares)
{
if (shares == 0)
return 0;

return Math.round((double) (amount * (Values.AmountFraction.factor() / Values.Amount.factor()) * Values.Share
.divider()) / (double) shares);
}

static public long amountPerShare(long amount, long shares)
{
if (shares != 0)
{
return Math.round((double) amount / (double) shares * Values.Share.divider());
}
else
{
return 0;
}
}

static public long amountTimesShares(long price, long shares)
{
if (shares != 0)
{
return Math.round((double) price * (double) shares / Values.Share.divider());
}
else
{
return 0;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import name.abuchen.portfolio.snapshot.PerformanceIndex;
import name.abuchen.portfolio.snapshot.ReportingPeriod;

public class SecurityPerformanceRecord implements Adaptable
public final class SecurityPerformanceRecord implements Adaptable
{
public enum Periodicity
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,37 +91,26 @@ private static void extractSecurityRelatedAccountTransactions(Account account, D
{
for (AccountTransaction t : account.getTransactions())
{
if (t.getDate().getTime() > startDate.getTime() && t.getDate().getTime() <= endDate.getTime())
{
switch (t.getType())
{
case INTEREST:
case DIVIDENDS:
if (t.getSecurity() != null)
{
DividendTransaction dt = new DividendTransaction();
dt.setDate(t.getDate());
dt.setSecurity(t.getSecurity());
dt.setAccount(account);
dt.setAmount(t.getAmount());
dt.setShares(t.getShares());
dt.setNote(t.getNote());
records.get(t.getSecurity()).addTransaction(dt);
}
break;
case FEES:
case TAXES:
case DEPOSIT:
case REMOVAL:
case BUY:
case SELL:
case TRANSFER_IN:
case TRANSFER_OUT:
break;
default:
throw new UnsupportedOperationException();
}
}
if (t.getSecurity() == null)
continue;

if (t.getType() != AccountTransaction.Type.DIVIDENDS && t.getType() != AccountTransaction.Type.INTEREST)
continue;

if (t.getDate().getTime() <= startDate.getTime())
continue;

if (t.getDate().getTime() > endDate.getTime())
continue;

DividendTransaction dt = new DividendTransaction();
dt.setDate(t.getDate());
dt.setSecurity(t.getSecurity());
dt.setAccount(account);
dt.setAmount(t.getAmount());
dt.setShares(t.getShares());
dt.setNote(t.getNote());
records.get(t.getSecurity()).addTransaction(dt);
}
}

Expand Down

0 comments on commit b58c1dd

Please sign in to comment.