Class CashSale
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 |
Field Summary |
|
|
|
|
|
detailListThis is the list of sale details (line items) |
|
|
|
|
|
idThis will be used as a unique identifier for CashSale objects. |
|
myDmAccess to the Data Management Layer. |
|
|
|
|
|
|
|
|
|
statusIndicates if sale is in process or completed. |
|
|
|
taxThis is the total tax for this sale. |
|
TAX_RATEPoor way to do taxes (but it's easy ). |
|
timeTimestamp of this sale |
Method Summary |
|
|
|
|
|
|
|
|
|
|
|
|
|
calcSubtotal()Calulate the total of all the line items (but no tax). |
|
calcTax()INFLEXIBLE IMPLEMENTATION of hard-coded fixed tax rate |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isCompleted()Return whether the sale is completed or not. |
|
isPending()Indicate if the sale is still pending |
|
|
|
makeCashSale(BigDecimal paymentAmt)Figure out if the sale and payment match up.
|
|
|
|
save()Save this sale to persistent storage. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
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.
discountAmount
private BigDecimal discountAmount
This represents a discount at the entire sale level.
tax
private BigDecimal tax
This is the total tax for this sale.
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.
myDm
Access to the Data Management Layer.
dmServer
id
private int id = 0
This will be used as a unique identifier for CashSale objects.
attribute1
Constructor Detail
CashSale
public CashSale()
Method Detail
makeCashSale
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
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)