Commit 3980006a authored by Brian Long's avatar Brian Long
Browse files

fixed SoFi number handling

parent 0e757183
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
package com.inteligr8.buxfer;

import java.text.NumberFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@@ -50,14 +51,14 @@ public class SofiInvestTransaction implements ParsedTransaction {
			this.throttle();
			
			this.securities = this.estimateSecurites();
			this.perSecurityPrice = this.estimatePrice(securities);
			this.perSecurityPrice = this.estimatePrice(this.securities);
			
			String action = Type.Buy.equals(type) ? "Bought" : "Sold";
			this.description = new StringBuilder()
					.append(action).append(' ')
					.append(this.securities == null ? "NaN" : NumberFormatFactory.getSecuritiesFormatter().format(this.securities)).append(' ')
					.append(this.getRange(NumberFormatFactory.getSecuritiesFormatter(), this.securities)).append(' ')
					.append(this.symbol).append(" @ ")
					.append(this.perSecurityPrice == null ? "NaN" : NumberFormatFactory.getPriceFormatter().format(this.perSecurityPrice)).toString();
					.append(this.getRange(NumberFormatFactory.getPriceFormatter(), this.perSecurityPrice)).toString();
		}
	}
	
@@ -160,4 +161,14 @@ public class SofiInvestTransaction implements ParsedTransaction {
		else return this.perSecurityPrice.getMidpoint();
	}
	
	private String getRange(NumberFormat formatter, NumericRange<? extends Number> range) {
		if (range == null) {
			return "NaN";
		} else if (range.isPoint()) {
			return formatter.format(range.getFrom().doubleValue());
		} else {
			return formatter.format(range.getFrom().doubleValue()) + "-" + formatter.format(range.getTo().doubleValue());
		}
	}

}