package at.outdated.bitcoin.exchange.api.market.fee;

import at.outdated.bitcoin.exchange.api.currency.CurrencyValue;
import at.outdated.bitcoin.exchange.api.market.OrderType;

import java.math.BigDecimal;
import java.text.NumberFormat;

/**
 * Created with IntelliJ IDEA.
 * User: ebirn
 * Date: 09.06.13
 * Time: 17:37
 * To change this template use File | Settings | File Templates.
 */
public class SimplePercentageFee extends Fee {

    BigDecimal percentage = BigDecimal.ZERO;

    public SimplePercentageFee() {

    }

    public SimplePercentageFee(String percentage) {
        this.percentage = new BigDecimal(percentage);
    }

    public SimplePercentageFee(BigDecimal percentage) {
       this.percentage = percentage;
    }

    @Deprecated
    public SimplePercentageFee(double percentage) {
        this.percentage = new BigDecimal(percentage);
    }

    @Override
    public CurrencyValue calculate(OrderType type, CurrencyValue volume) {

        CurrencyValue fee = new CurrencyValue(volume);
        fee.multiply(percentage);

        return fee;
    }

    @Override
    public String toString() {
        String percentStr = NumberFormat.getPercentInstance().format(percentage.doubleValue());

        return super.toString() + percentStr;
    }
}

@@ -1126,25 +1126,27 @@
     
-String percentStr
+NumberFormat format
  = N
@@ -1177,16 +1177,98 @@
 stance()
+;%0A%0A        format.setMinimumFractionDigits(2);%0A%0A        String percentStr = format
 .format(

fix toString() formatting