// Path: src/main/java/de/onyxbits/tradetrax/services/MoneyRepresentation.java
// public interface MoneyRepresentation {
// 
// 	/**
// 	 * Scaling factor
// 	 */
// 	public static final long FACTOR = 10 * 10 * 10 * 10;
// 
// 	/**
// 	 * @return the currencySymbol
// 	 */
// 	public abstract String getCurrencySymbol();
// 
// 	/**
// 	 * Converts a user submitted value to internal representation
// 	 * 
// 	 * @param value
// 	 *          a string such as "2.99", "4,99" or "-1"
// 	 * @param units
// 	 *          unitcount (in case the user is submitting the price for a stack of
// 	 *          items). No safety checks are performed. Especially not for
// 	 *          division by zero.
// 	 * @return the value as an integer
// 	 * @throws ParseException
// 	 */
// 	public abstract long userToDatabase(String value, int units) throws ParseException;
// 
// 	/**
// 	 * Convert from internal representation to human readable
// 	 * 
// 	 * @param value
// 	 *          an integer such as 499
// 	 * @param precise
// 	 *          false to clip digits, true to print the full value.
// 	 * @param addSymbol
// 	 *          true to add the currencysymbol
// 	 * @return a string such as $4.99
// 	 */
// 	public abstract String databaseToUser(long value, boolean precise, boolean addSymbol);
// 
// }
// 
// Path: src/main/java/de/onyxbits/tradetrax/services/SettingsStore.java
// public interface SettingsStore {
// 
// 	/**
// 	 * The (visual) string that represents the currency of the ledger.
// 	 */
// 	public static final String CURRENCYSYMBOL = "currencysymbol";
// 
// 	/**
// 	 * How many digits to display by default.
// 	 */
// 	public static final String DECIMALS = "decimals";
// 
// 	/**
// 	 * Human readable name of the ledger
// 	 */
// 	public static final String LEDGERTITLE = "ledgertitle";
// 
// 	/**
// 	 * Whether or not to show the instructionsblock in the sidebar.
// 	 */
// 	public static final String HIDEINSTRUCTIONS = "hideinstructions";
// 	
// 	/**
// 	 * Whether or not to show the calculator in the sidebar
// 	 */
// 	public static final String SHOWCALCULATOR = "showcalculator";
// 	
// 	/**
// 	 * Columns to show for the tradecenter ledger.
// 	 */
// 	public static final String TCLCOLUMNS = "tclcolumns";
// 	
// 	/**
// 	 * Fields to show on the tradecenter acquisition form.
// 	 */
// 	public static final String TCACFIELDS = "tcafields";
// 	
// 	/**
// 	 * When the ledger was created
// 	 */
// 	public static final String CREATED = "created";
// 	
// 	/**
// 	 * How wide the page may be
// 	 */
// 	public static final String PAGEWIDTH = "pagewidth";
// 
// 	/**
// 	 * Get a setting
// 	 * 
// 	 * @param key
// 	 *          the kay of the setting
// 	 * @param value
// 	 *          default value if key does not exist
// 	 * @return the value
// 	 */
// 	public String get(String key, String value);
// 
// 	/**
// 	 * Enter a setting into the storage
// 	 * 
// 	 * @param key
// 	 *          key name
// 	 * @param value
// 	 *          value
// 	 */
// 	public void set(String key, String value);
// }


import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import de.onyxbits.tradetrax.services.MoneyRepresentation;
import de.onyxbits.tradetrax.services.SettingsStore;
package de.onyxbits.tradetrax.components;



/**
 * Convert a monetary value from database to user format and wrap it in a
 * loss/profit CSS container before printing it.
 * 
 * @author patrick
 * 
 */
public class MoneyValue {

	/**
	 * Monetary value in database format.
	 */
	@Parameter(required = true)
	private long amount;

	/**
	 * Include the currency symbol when printing?
	 */
	@Parameter
	private boolean addSymbol = true;

	/**
	 * Cut off decimals to get a fixed length fraction?
	 */
	@Parameter
	private boolean precise;

	@Property
	private String value;

	@Property
	private boolean loss;

	@Inject
	private SettingsStore settings;
	
	@Inject
// Path: src/main/java/de/onyxbits/tradetrax/services/MoneyRepresentation.java
// public interface MoneyRepresentation {
// 
// 	/**
// 	 * Scaling factor
// 	 */
// 	public static final long FACTOR = 10 * 10 * 10 * 10;
// 
// 	/**
// 	 * @return the currencySymbol
// 	 */
// 	public abstract String getCurrencySymbol();
// 
// 	/**
// 	 * Converts a user submitted value to internal representation
// 	 * 
// 	 * @param value
// 	 *          a string such as "2.99", "4,99" or "-1"
// 	 * @param units
// 	 *          unitcount (in case the user is submitting the price for a stack of
// 	 *          items). No safety checks are performed. Especially not for
// 	 *          division by zero.
// 	 * @return the value as an integer
// 	 * @throws ParseException
// 	 */
// 	public abstract long userToDatabase(String value, int units) throws ParseException;
// 
// 	/**
// 	 * Convert from internal representation to human readable
// 	 * 
// 	 * @param value
// 	 *          an integer such as 499
// 	 * @param precise
// 	 *          false to clip digits, true to print the full value.
// 	 * @param addSymbol
// 	 *          true to add the currencysymbol
// 	 * @return a string such as $4.99
// 	 */
// 	public abstract String databaseToUser(long value, boolean precise, boolean addSymbol);
// 
// }
// 
// Path: src/main/java/de/onyxbits/tradetrax/services/SettingsStore.java
// public interface SettingsStore {
// 
// 	/**
// 	 * The (visual) string that represents the currency of the ledger.
// 	 */
// 	public static final String CURRENCYSYMBOL = "currencysymbol";
// 
// 	/**
// 	 * How many digits to display by default.
// 	 */
// 	public static final String DECIMALS = "decimals";
// 
// 	/**
// 	 * Human readable name of the ledger
// 	 */
// 	public static final String LEDGERTITLE = "ledgertitle";
// 
// 	/**
// 	 * Whether or not to show the instructionsblock in the sidebar.
// 	 */
// 	public static final String HIDEINSTRUCTIONS = "hideinstructions";
// 	
// 	/**
// 	 * Whether or not to show the calculator in the sidebar
// 	 */
// 	public static final String SHOWCALCULATOR = "showcalculator";
// 	
// 	/**
// 	 * Columns to show for the tradecenter ledger.
// 	 */
// 	public static final String TCLCOLUMNS = "tclcolumns";
// 	
// 	/**
// 	 * Fields to show on the tradecenter acquisition form.
// 	 */
// 	public static final String TCACFIELDS = "tcafields";
// 	
// 	/**
// 	 * When the ledger was created
// 	 */
// 	public static final String CREATED = "created";
// 	
// 	/**
// 	 * How wide the page may be
// 	 */
// 	public static final String PAGEWIDTH = "pagewidth";
// 
// 	/**
// 	 * Get a setting
// 	 * 
// 	 * @param key
// 	 *          the kay of the setting
// 	 * @param value
// 	 *          default value if key does not exist
// 	 * @return the value
// 	 */
// 	public String get(String key, String value);
// 
// 	/**
// 	 * Enter a setting into the storage
// 	 * 
// 	 * @param key
// 	 *          key name
// 	 * @param value
// 	 *          value
// 	 */
// 	public void set(String key, String value);
// }


// Path: src/main/java/de/onyxbits/tradetrax/components/MoneyValue.java
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import de.onyxbits.tradetrax.services.MoneyRepresentation;
import de.onyxbits.tradetrax.services.SettingsStore;

package de.onyxbits.tradetrax.components;



/**
 * Convert a monetary value from database to user format and wrap it in a
 * loss/profit CSS container before printing it.
 * 
 * @author patrick
 * 
 */
public class MoneyValue {

	/**
	 * Monetary value in database format.
	 */
	@Parameter(required = true)
	private long amount;

	/**
	 * Include the currency symbol when printing?
	 */
	@Parameter
	private boolean addSymbol = true;

	/**
	 * Cut off decimals to get a fixed length fraction?
	 */
	@Parameter
	private boolean precise;

	@Property
	private String value;

	@Property
	private boolean loss;

	@Inject
	private SettingsStore settings;
	
	@Inject
	private MoneyRepresentation moneyRepresentation;