Class CashSale
problem_domain

public class CashSale
This represents the overall transaction record of the sale. For purposes of eliminating the need to re-calc everything, we can redundantly store subtotal and tax to make it easy to get the info.
Stereotype:
moment-interval
Author:
TogetherSoft
persistent
robustness:
Controller
Since
subtitle:
The entity
See Also:  Node Documentation

Field Summary
anICashSaleSequencerPlugInPoint
This allows us to "plug in" different cash sale sequences to support other ways to take in the payment.
private Sale
private Vector
detailList
This is the list of sale details (line items)
private BigDecimal
discountAmount
This represents a discount at the entire sale level.
private DMServer
private int
id
This will be used as a unique identifier for CashSale objects.
private static IDM
myDm
Access to the Data Management Layer.
private BigDecimal
payment
This is the payment.
private static final int
private static final int
private static final int
private int
status
Indicates if sale is in process or completed.
private BigDecimal
subtotal
Subtotal of all line items.
private BigDecimal
tax
This is the total tax for this sale.
static final double
TAX_RATE
Poor way to do taxes (but it's easy ).
private Date
time
Timestamp of this sale
Constructor Summary
Method Summary
void
addSaleDetail(CashSaleDetail aCashSaleDetail)
static BigDecimal
calcAvgTotalCashSale()
Not implemented
static int
calcAvgTotalCashSaleQty()
Not implemented
static int
calcCashSalesQtyRate()
Not implemented
static int
calcCashSalesRate()
Not implemented
BigDecimal
calcDiscountAmount()
Not implemented
BigDecimal
calcSubtotal()
Calulate the total of all the line items (but no tax).
BigDecimal
calcTax()
INFLEXIBLE IMPLEMENTATION of hard-coded fixed tax rate
BigDecimal
calcTotal()
Sum up the subtotal and the tax.
static BigDecimal
calcTotalCashSales()
Not implemented
static int
calcTotalCashSalesQty()
Not implemented
void
clearValues()
Clear/reset the values
void
completed()
Mark the sale as completed
Vector
Enumeration
int
BigDecimal
BigDecimal
Date
boolean
isCompleted()
Return whether the sale is completed or not.
boolean
isPending()
Indicate if the sale is still pending
static Vector
listCashSales()
Return a list of all cash sales.
BigDecimal
makeCashSale(BigDecimal paymentAmt)
Figure out if the sale and payment match up.
BigDecimal
void
save()
Save this sale to persistent storage.
void
setCompleted(boolean bool)
void
void
void
setId(int id)
void
setSubtotal(BigDecimal subtotal)
void
setTax(BigDecimal tax)
void
setTime(Date time)
boolean
verifyAvailability()
Not yet implemented.
Field Detail
SALE_NEW
private static final int SALE_NEW = 0

SALE_OPEN
private static final int SALE_OPEN = 1

SALE_CLOSED
private static final int SALE_CLOSED = 2

TAX_RATE
public static final double TAX_RATE = 0.06
Poor way to do taxes (but it's easy ).

detailList
private Vector detailList
This is the list of sale details (line items)
link:
aggregation
associates:
problem_domain.CashSaleDetail
supplierCardinality:
1..*

time
private Date time
Timestamp of this sale
rdbLogicalType:
DATE

subtotal
private BigDecimal subtotal
Subtotal of all line items. NOTE: this could be calculated on the fly by iterating through the details, but once we are all done with the transaction, we have decided to purposefully store the result. This is a trade-off based on the fact that this transaction, once completed, is never edited again. By redundantly storing data, we are allowing a quick answer to support the various analysis "runs" made against the data.
rdbLogicalType:
NUMERIC

discountAmount
private BigDecimal discountAmount
This represents a discount at the entire sale level.
rdbLogicalType:
NUMERIC

tax
private BigDecimal tax
This is the total tax for this sale.
rdbLogicalType:
NUMERIC

anICashSaleSequencerPlugInPoint
private IMakeCashSale anICashSaleSequencerPlugInPoint
This allows us to "plug in" different cash sale sequences to support other ways to take in the payment. Examples include: Cash, Credit, Debit, Check.
supplierCardinality:
1
rdbLogicalType:
OTHER

payment
private BigDecimal payment
This is the payment. Based on this value and the total due, we can compute the change due.
supplierCardinality:
0..*
clientCardinality:
1
rdbLogicalType:
NUMERIC

status
private int status = SALE_NEW
Indicates if sale is in process or completed.
rdbLogicalType:
INTEGER

myDm
private static IDM myDm
Access to the Data Management Layer.
rdbLogicalType:
OTHER

dmServer
private DMServer dmServer = null

id
private int id = 0
This will be used as a unique identifier for CashSale objects.

attribute1
private Sale attribute1
Constructor Detail
CashSale
public CashSale()
Method Detail
makeCashSale
public BigDecimal makeCashSale(BigDecimal paymentAmt)
                        throws InsuffPaymentException
Figure out if the sale and payment match up. Throw an exception if payment is too little.

calcSubtotal
public BigDecimal calcSubtotal()
Calulate the total of all the line items (but no tax).

calcDiscountAmount
public BigDecimal calcDiscountAmount()
Not implemented

calcTax
public BigDecimal calcTax()
INFLEXIBLE IMPLEMENTATION of hard-coded fixed tax rate

calcTotal
public BigDecimal calcTotal()
Sum up the subtotal and the tax.
url:
$TG_HOME$\samples\java\CashSales\demoguide.html

recalcTotal
public BigDecimal recalcTotal()

verifyAvailability
public boolean verifyAvailability()
Not yet implemented.

isCompleted
public boolean isCompleted()
Return whether the sale is completed or not.

isPending
public boolean isPending()
Indicate if the sale is still pending

completed
public void completed()
Mark the sale as completed

clearValues
public void clearValues()
Clear/reset the values

save
public void save()
          throws SQLException
Save this sale to persistent storage.

listCashSales
public static Vector listCashSales()
Return a list of all cash sales.

calcTotalCashSales
public static BigDecimal calcTotalCashSales()
Not implemented

calcTotalCashSalesQty
public static int calcTotalCashSalesQty()
Not implemented

calcAvgTotalCashSale
public static BigDecimal calcAvgTotalCashSale()
Not implemented

calcAvgTotalCashSaleQty
public static int calcAvgTotalCashSaleQty()
Not implemented

calcCashSalesRate
public static int calcCashSalesRate()
Not implemented

calcCashSalesQtyRate
public static int calcCashSalesQtyRate()
Not implemented

addSaleDetail
public void addSaleDetail(CashSaleDetail aCashSaleDetail)

getDetails
public Enumeration getDetails()

getDetailList
public Vector getDetailList()

getTime
public Date getTime()

setCompleted
public void setCompleted(boolean bool)

getId
public int getId()

getSubtotal
public BigDecimal getSubtotal()

getTax
public BigDecimal getTax()

setTax
public void setTax(BigDecimal tax)

setSubtotal
public void setSubtotal(BigDecimal subtotal)

setTime
public void setTime(Date time)

setId
public void setId(int id)

setDm
public void setDm(IDM dm)

setDmServer
public void setDmServer(DMServer dmServer)