org.geebis.books.model.item.nonretail
Class Discount

java.lang.Object
  extended by org.geebis.books.model.item.Item
      extended by org.geebis.books.model.item.nonretail.NonRetailItem
          extended by org.geebis.books.model.item.nonretail.Discount
All Implemented Interfaces:
java.io.Serializable

@Name(value="discount")
public class Discount
extends NonRetailItem
implements java.io.Serializable

The Discount class represents an item that is a discount The default percent is 0 Discounts are represented internally as percents, ie 10% is 10 Discounts greater than 100 are used to represent markups of (percent - 100)%

See Also:
Serialized Form

Constructor Summary
Discount()
           
Discount(java.lang.String name)
           
Discount(java.lang.String name, java.lang.Double percent)
           
 
Method Summary
 double applyDiscount(double value)
          Returns the amount of the value after a discount is calculated
 double calculateDiscountAmount(double value)
          Calculates the amount of discount that this discount would give if applied to the given value
 java.lang.Double getPercent()
          Gets the percent of this discount
 void setPercent(java.lang.Double percent)
          Sets the percent of this discount
 
Methods inherited from class org.geebis.books.model.item.Item
getDescription, getId, getName, getSalesAccount, getVersion, setDescription, setId, setName, setSalesAccount, setVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Discount

public Discount()

Discount

public Discount(java.lang.String name)

Discount

public Discount(java.lang.String name,
                java.lang.Double percent)
Method Detail

getPercent

public java.lang.Double getPercent()
Gets the percent of this discount

Returns:
the percent of this discount

setPercent

public void setPercent(java.lang.Double percent)
Sets the percent of this discount

Parameters:
percent - the new percent for this discount

applyDiscount

public double applyDiscount(double value)
Returns the amount of the value after a discount is calculated

Parameters:
value - the value to calculate the discount amount off of
Returns:
the amount of value after a discount is applied

calculateDiscountAmount

public double calculateDiscountAmount(double value)
Calculates the amount of discount that this discount would give if applied to the given value

Parameters:
value - the value to calculate the discount amount off of
Returns:
the amount of discount that would be given