Class ProductPrice
problem_domain

public class ProductPrice
This is the class used to hold the price of the product. The intent is to provide a ProductDesc object with the ability to hold more than just a fixed price. With the power of this added class, one can have prices that are valid over different time intervals.

This class is based on Peter Coad's Components from Java Modeling in Color with UML

Stereotype:
moment-interval
Version:
1.0 07/31/99
Author:
TogetherSoft
See Also:
ProductDesc
persistent
See Also:  Node Documentation

Field Summary
private Date
notValidAfter
Used as the end of the applicable interval for determining if price is valid.
private BigDecimal
price
This is the meat of this class...the price
static final int
PRICE_INVALID_STATUS
Public constant to define an invalid price status
static final int
PRICE_VALID_STATUS
Public constant to define a valid price status
private int
priceQty
The quantity that this price is valid for.
private int
priceUOM
The unit of measure that this price is for.
private int
status
Status of price
private Date
validStarting
Used as the start of the applicable interval for determining if price is valid.
Constructor Summary
ProductPrice(Date start)
Method Summary
BigDecimal
Date
BigDecimal
int
int
int
Date
boolean
isValidOnDate(Date date)
Check if this price is valid on the passed-in date.
void
void
void
setPrice(BigDecimal aPrice)
void
setPriceQty(int aPriceQty)
void
setPriceUOM(int aPriceUOM)
void
setStatus(int aStatus)
void
setValidStarting(Date aValidStarting)
Field Detail
validStarting
private Date validStarting
Used as the start of the applicable interval for determining if price is valid.
See Also:
+isValidOnDate()
rdbLogicalType:
DATE

notValidAfter
private Date notValidAfter
Used as the end of the applicable interval for determining if price is valid.
See Also:
+isValidOnDate()
rdbLogicalType:
DATE

price
private BigDecimal price
This is the meat of this class...the price
rdbLogicalType:
NUMERIC

priceQty
private int priceQty = 1
The quantity that this price is valid for. For example: 1, 5, 10

This could be used as a quantity discount differentiator if pricing algorithm accounted for the possible existence of more than one price per valid interval. However, it would be better to model this "feature" explicitly!

rdbLogicalType:
INTEGER

priceUOM
private int priceUOM = 1
The unit of measure that this price is for. For example: each, dozen, gross

In reality, this is generally a completely separate class that would include things like conversion factors between UOMs.

rdbLogicalType:
INTEGER

status
private int status = ProductPrice.PRICE_INVALID_STATUS
Status of price
rdbLogicalType:
INTEGER

PRICE_VALID_STATUS
public static final int PRICE_VALID_STATUS = 1
Public constant to define a valid price status

PRICE_INVALID_STATUS
public static final int PRICE_INVALID_STATUS = 2
Public constant to define an invalid price status
Constructor Detail
ProductPrice
public ProductPrice(Date start)
Method Detail
makeProductPrice
public void makeProductPrice()

calcPriceForQty
public BigDecimal calcPriceForQty(int q)

isValidOnDate
public boolean isValidOnDate(Date date)
Check if this price is valid on the passed-in date.

Price is valid if date being checked is greater than or equal to Starting and not greater than ValidAfter date.

Returns:
True if date is within applicable interval else false.

getValidStarting
public Date getValidStarting()

setValidStarting
public void setValidStarting(Date aValidStarting)

getNotValidAfter
public Date getNotValidAfter()

setNotValidAfter
public void setNotValidAfter(Date nva)

getPrice
public BigDecimal getPrice()

setPrice
public void setPrice(BigDecimal aPrice)

getPriceQty
public int getPriceQty()

setPriceQty
public void setPriceQty(int aPriceQty)

getPriceUOM
public int getPriceUOM()

setPriceUOM
public void setPriceUOM(int aPriceUOM)

getStatus
public int getStatus()

setStatus
public void setStatus(int aStatus)