org.davesag.generica.core
Class ShoppingOrder

java.lang.Object
  extended byorg.davesag.generica.core.ShoppingOrder
All Implemented Interfaces:
Persistable, Serializable

public class ShoppingOrder
extends Object
implements Persistable, Serializable

This ShoppingOrder is a labelled list of shopping items.

Since:
Generica 1.0
Version:
CVS Revision $Id: ShoppingOrder.java,v 1.10 2004/04/08 13:19:08 davesag Exp $
Author:
Dave Sag http://www.davesag.com
See Also:
Serialized Form
Peristable via Hibernate:
table = "shopping_order"

Field Summary
protected  Money theComputedDiscountSubtotal
          The computer total discount value of the order.
protected  Money theComputedSubtotal
          The total price of the order.
protected  Money theComputedTaxSubtotal
          The total price of the order.
protected  Money theDiscount
          The discount of the order.
protected  Money theGrandTotal
          The total price of the order to be paid by the user.
protected  Long theId
          items' id used as a key by hibernate
protected  List theItems
          a list of items that make up this order.
protected  String theLabel
          an arbitrary label for the order
protected  Money theSubtotal
          The total price of the order less discounts and tax.
protected  String theTaxNote
          note about the tax
protected  Money theTaxPaid
          The total tax of the item.
protected  Long theTransactionId
          unique transaction id that is sent to the payment authorisation agent
 
Constructor Summary
ShoppingOrder()
          null constructor required by hibernate.
ShoppingOrder(ShoppingOrder o)
          constructor that takes another order and creates a new one with the same values but a new transaction id.
ShoppingOrder(String label)
          constructor takes a description.
 
Method Summary
 void addItem(ShoppingItem item)
          Add a shopping item and increment the order's price.
 boolean equals(Object o)
          Tests if the supplied object is equal to this ShoppingOrder.
 Money getComputedDiscountSubtotal()
          Returns the computed discount.
 Money getComputedSubtotal()
          Returns the computed subtotal.
 Money getComputedTaxSubtotal()
          Returns the computed discount.
 Money getDiscount()
          Returns the discount.
 Integer getDiscountAmount()
          Returns the total discount amount.
 Money getGrandTotal()
          Returns the grand total.
 Integer getGrandTotalAmount()
          Returns the subtotal amount.
 Long getId()
          Get the ShoppingOrder's ID number.
 ShoppingItem getItem(int index)
          Get the item in the order with index provided.
 List getItems()
          returns the list of items in this order.
 String getLabel()
          Returns the label.
 Money getSubtotal()
          Returns the subtotal.
 Integer getSubtotalAmount()
          Returns the subtotal amount.
 Integer getTaxAmount()
          Returns the total tax.
 String getTaxNote()
          Returns the total taxNote.
 Money getTaxPaid()
          Returns the total tax.
 Long getTransactionId()
          Get the ShoppingOrder's Transaction ID number.
 int hashcode()
          the hashcode.
 void removeItem(ShoppingItem item)
          Remove a shopping item and decrement the order's price.
 void setDiscount(Money dis)
          Set the discount of this ShoppingOrder.
 void setDiscountAmount(Integer discount)
          Set the discount of this ShoppingOrder.
 void setGrandTotal(Money sub)
          Set the grand total of this ShoppingOrder.
 void setGrandTotalAmount(Integer aGrandTotal)
          Set the grand total of this ShoppingOrder.
protected  void setId(Long id)
          Sets the The ShoppingOrder's ID number.
protected  void setItems(List items)
          set the items list.
 void setLabel(String aLabel)
          Set the label for this ShoppingOrder.
 void setSubtotal(Money sub)
          Set the subtotal of this ShoppingOrder.
 void setSubtotalAmount(Integer aSubtotal)
          Set the subtotal of this ShoppingOrder.
 void setTaxAmount(Integer tax)
          Set the tax of this ShoppingOrder.
 void setTaxNote(String note)
          Set the taxNote of this ShoppingOrder.
 void setTaxPaid(Money tax)
          Set the tax of this ShoppingOrder.
 void setTemplateId(Long id)
          Sets the The ShoppingOrder's ID number directly.
protected  void setTransactionId(Long id)
          Sets the The ShoppingOrder's Transaction ID number.
 String toString()
          a simple string description of the order.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

theId

protected Long theId
items' id used as a key by hibernate


theTransactionId

protected Long theTransactionId
unique transaction id that is sent to the payment authorisation agent


theLabel

protected String theLabel
an arbitrary label for the order


theComputedSubtotal

protected Money theComputedSubtotal
The total price of the order. This is computed by adding the price of the individual items and is not persisted.


theSubtotal

protected Money theSubtotal
The total price of the order less discounts and tax. This is persisted.


theGrandTotal

protected Money theGrandTotal
The total price of the order to be paid by the user.


theDiscount

protected Money theDiscount
The discount of the order. This is persisted.


theComputedDiscountSubtotal

protected Money theComputedDiscountSubtotal
The computer total discount value of the order. Not persisted.


theComputedTaxSubtotal

protected Money theComputedTaxSubtotal
The total price of the order. This is computed by adding the price of the individual items and is not persisted.


theTaxPaid

protected Money theTaxPaid
The total tax of the item. This is computed by adding the tax of the individual items.


theTaxNote

protected String theTaxNote
note about the tax


theItems

protected List theItems
a list of items that make up this order. Note that items have their own price, tax, description and notes.

Constructor Detail

ShoppingOrder

public ShoppingOrder()
null constructor required by hibernate.


ShoppingOrder

public ShoppingOrder(String label)
constructor takes a description.


ShoppingOrder

public ShoppingOrder(ShoppingOrder o)
constructor that takes another order and creates a new one with the same values but a new transaction id. it will be regarded as new order.

Parameters:
o - the order to copy from.
Method Detail

getId

public Long getId()
Get the ShoppingOrder's ID number.

Specified by:
getId in interface Persistable
Returns:
The ShoppingOrder's ID number.
Hibernate Unique ID Property:
generator-class = "identity"

setId

protected void setId(Long id)
Sets the The ShoppingOrder's ID number.

Parameters:
id - The ID number to set.

setTemplateId

public void setTemplateId(Long id)
Sets the The ShoppingOrder's ID number directly. This is only to be used when creating a template object, and is not to be used when creating actual objects that will be persisted.

Specified by:
setTemplateId in interface Persistable
Parameters:
id - The ID number to set.

getTransactionId

public Long getTransactionId()
Get the ShoppingOrder's Transaction ID number.

Returns:
The ShoppingOrder's Transaction ID number.
Hibernate Property:

setTransactionId

protected void setTransactionId(Long id)
Sets the The ShoppingOrder's Transaction ID number.

Parameters:
id - The Transaction ID number to set.

setItems

protected void setItems(List items)
set the items list.

Parameters:
items - The List of items

getItems

public List getItems()
returns the list of items in this order.

Returns:
List of ShoppingItems
Hibernate List:
cascade = "all" lazy="true"

addItem

public void addItem(ShoppingItem item)
Add a shopping item and increment the order's price.

Parameters:
item - The item to add.

removeItem

public void removeItem(ShoppingItem item)
Remove a shopping item and decrement the order's price.

Parameters:
item - The item to remove.

getItem

public ShoppingItem getItem(int index)
Get the item in the order with index provided.

Parameters:
index - the index of the item in the list.
Returns:
a ShoppingItem.

getLabel

public String getLabel()
Returns the label.

Returns:
The total tax of this ShoppingOrder.
Hibernate Property:
length="1024"

setLabel

public void setLabel(String aLabel)
Set the label for this ShoppingOrder.

Parameters:
aLabel - The label for this ShoppingOrder.

getDiscount

public Money getDiscount()
Returns the discount.

Returns:
The discount of this ShoppingOrder.

setDiscount

public void setDiscount(Money dis)
Set the discount of this ShoppingOrder.

Parameters:
dis - The discount of this ShoppingOrder.

getComputedDiscountSubtotal

public Money getComputedDiscountSubtotal()
Returns the computed discount.

Returns:
The computed discount of this ShoppingOrder.

getTaxPaid

public Money getTaxPaid()
Returns the total tax.

Returns:
The total tax of this ShoppingOrder.

setTaxPaid

public void setTaxPaid(Money tax)
Set the tax of this ShoppingOrder.

Parameters:
tax - The tax of this ShoppingOrder.

getComputedTaxSubtotal

public Money getComputedTaxSubtotal()
Returns the computed discount.

Returns:
The computed discount of this ShoppingOrder.

getTaxAmount

public Integer getTaxAmount()
Returns the total tax.

Returns:
The total tax of this ShoppingOrder.
Hibernate Property:

setTaxAmount

public void setTaxAmount(Integer tax)
Set the tax of this ShoppingOrder. This is used by hibernate. The tax is normally computed by adding up the list of items.

Parameters:
tax - The tax of this ShoppingOrder.

getSubtotal

public Money getSubtotal()
Returns the subtotal.

Returns:
The subtotal of this ShoppingOrder.

setSubtotal

public void setSubtotal(Money sub)
Set the subtotal of this ShoppingOrder.

Parameters:
sub - The subtotal of this ShoppingOrder.

getSubtotalAmount

public Integer getSubtotalAmount()
Returns the subtotal amount.

Returns:
The subtotal amount of this ShoppingOrder.
Hibernate Property:

getComputedSubtotal

public Money getComputedSubtotal()
Returns the computed subtotal.

Returns:
The computed subtotal of this ShoppingOrder.

setSubtotalAmount

public void setSubtotalAmount(Integer aSubtotal)
Set the subtotal of this ShoppingOrder.

Parameters:
aSubtotal - The subtotal of this ShoppingOrder.

getGrandTotal

public Money getGrandTotal()
Returns the grand total.

Returns:
The grand total of this ShoppingOrder.

setGrandTotal

public void setGrandTotal(Money sub)
Set the grand total of this ShoppingOrder.

Parameters:
sub - The grand total of this ShoppingOrder.

getGrandTotalAmount

public Integer getGrandTotalAmount()
Returns the subtotal amount.

Returns:
The subtotal amount of this ShoppingOrder.
Hibernate Property:

setGrandTotalAmount

public void setGrandTotalAmount(Integer aGrandTotal)
Set the grand total of this ShoppingOrder.

Parameters:
aGrandTotal - The grand total of this ShoppingOrder.

getDiscountAmount

public Integer getDiscountAmount()
Returns the total discount amount.

Returns:
The total discount of this ShoppingOrder.
Hibernate Property:

setDiscountAmount

public void setDiscountAmount(Integer discount)
Set the discount of this ShoppingOrder.

Parameters:
discount - The discount on this ShoppingOrder.

getTaxNote

public String getTaxNote()
Returns the total taxNote.

Returns:
The total taxNote of this ShoppingOrder.
Hibernate Property:
length = "1024"

setTaxNote

public void setTaxNote(String note)
Set the taxNote of this ShoppingOrder. This is used by hibernate. The taxNote is normally computed by adding up the list of items.

Parameters:
note - The taxNote of this ShoppingOrder.

equals

public boolean equals(Object o)
Tests if the supplied object is equal to this ShoppingOrder.

Parameters:
o - The object to test against this ShoppingOrder. Must also be a ShoppingOrder to make sense.
Returns:
true if the two users have the same id.

toString

public String toString()
a simple string description of the order.

Returns:
simple string of the order.

hashcode

public int hashcode()
the hashcode.

Returns:
a valid hashcode for this order.


Dave Sag Generica API version 0.5.9 - (prerelease) Copyright 2003 - 2004 Dave Sag.