com.knowgate.hipergate
Class Order

java.lang.Object
  extended by com.knowgate.dataobjs.DBPersist
      extended by com.knowgate.hipergate.AbstractOrder
          extended by com.knowgate.hipergate.Order
All Implemented Interfaces:
java.io.Serializable, java.util.Map

public class Order
extends AbstractOrder

Shopping Order.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
static short ClassId
           
 
Fields inherited from class com.knowgate.hipergate.AbstractOrder
oBuyer, oLines, oSeller, sLinesTable, sPrimaryKey
 
Fields inherited from class com.knowgate.dataobjs.DBPersist
AllVals, sAuditCls, sAuditUsr, sTransactId
 
Constructor Summary
Order()
          Create empty Order
Order(JDCConnection oConn, java.lang.String sOrderId)
          Load Order from database including all its lines
Order(java.lang.String sOrderId)
          Create Order and set its GUID
 
Method Summary
 void activate(JDCConnection oConn, java.lang.String sOrderId)
          Activate an Order For a given WorkArea only one order can be active at a time.
 DespatchAdvice createDespatchAdvice(JDCConnection oConn, boolean bIncludePrices)
          Create a Dispatch Note for this Order The new Dispatch Note is given the same GUID as the current order
 Invoice createInvoice(JDCConnection oConn)
          Create an Invoice for this Order The new Invoice is given the same GUID as the current order
 boolean delete(JDCConnection oConn)
          Delete Order
static boolean delete(JDCConnection oConn, java.lang.String sOrderId)
          Delete order
 boolean despatched()
          Whether or not this order has an associated despatch advice
static Order getActiveOrder(JDCConnection oConn, java.lang.String sWorkAreaId)
          Get active order for a WorkArea
 java.lang.String getDespatchAdvice()
          Get despatch advice associated to this order
 java.lang.String getInvoice()
          Get invoice associated to this order
 OrderLine getLine(JDCConnection oConn, int iPgLine)
          Get order line by number
 DBSubset getLines(JDCConnection oConn)
          Get Order Lines as a DBSubset
 boolean invoiced()
          Whether or not this order has an associated invoice
 boolean load(JDCConnection oConn, java.lang.Object[] PKVals)
          Load Order with its associated Addresses
 boolean load(JDCConnection oConn, java.lang.String sGuOrder)
          Load Order with its associated Addresses
 boolean store(JDCConnection oConn)
          Store Order
 java.lang.String toXML()
          Get order as an XML document Character encoding is set to UTF-8
 java.lang.String toXML(JDCConnection oConn, java.lang.String sLocale)
          Get despatch advice as an XML document Character encoding is set to UTF-8
 java.lang.String toXML(java.lang.String sIdent)
          Get order as an XML document Character encoding is set to UTF-8
 java.lang.String toXML(java.lang.String sIdent, java.lang.String sDelim)
          Get order as an XML document Character encoding is set to UTF-8
 
Methods inherited from class com.knowgate.hipergate.AbstractOrder
addProduct, addProduct, addProduct, computeSubtotal, computeSubtotal, computeTaxes, computeTaxes, computeTotal, computeTotal, formatCurrency, formatPercentage, getBillAddress, getCurrencyFormat, getDecimalFormated, getFloatFormated, getLines, getLocale, removeAllProducts, removeProduct, setCurrencyFormat, setLocale, setLocale, setLocale
 
Methods inherited from class com.knowgate.dataobjs.DBPersist
allcaps, allcaps, changelog, clear, clone, containsKey, containsValue, entrySet, exists, get, get, getAuditClassName, getCreationDate, getDate, getDateFormated, getDateShort, getDateTime, getDateTime24, getDecimal, getDecimalFormated, getDecimalFormated, getDouble, getDoubleFormated, getFloat, getFloatFormated, getInt, getInteger, getIntervalPart, getItemMap, getItems, getMoney, getShort, getSQLDate, getSQLTime, getString, getStringHtml, getStringNull, getTable, getTable, getTableName, getTime, getTimeOfDay, getTimestamp, getUIdFromName, isEmpty, isNull, iterator, keySet, parseXML, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putAll, putAll, remove, remove, replace, replace, replace, replace, replace, replace, replace, replace, setAuditTransact, setAuditUser, setCreationDate, size, toLowerCase, toUpperCase, toXML, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

ClassId

public static final short ClassId
See Also:
Constant Field Values
Constructor Detail

Order

public Order()
Create empty Order


Order

public Order(java.lang.String sOrderId)
Create Order and set its GUID


Order

public Order(JDCConnection oConn,
             java.lang.String sOrderId)
      throws java.sql.SQLException

Load Order from database including all its lines

Parameters:
oConn - Database Connection
sOrderId - Order GUID
Throws:
java.sql.SQLException
Method Detail

load

public boolean load(JDCConnection oConn,
                    java.lang.Object[] PKVals)
             throws java.sql.SQLException
Load Order with its associated Addresses

Overrides:
load in class AbstractOrder
Parameters:
oConn - JDCConnection
PKVals - Array with a single element Object[1]{(String)gu_order}
Returns:
boolean true is Order was found, false otherwise
Throws:
java.sql.SQLException

load

public boolean load(JDCConnection oConn,
                    java.lang.String sGuOrder)
             throws java.sql.SQLException
Load Order with its associated Addresses

Overrides:
load in class DBPersist
Parameters:
oConn - JDCConnection
sGuOrder - Order GUID
Returns:
boolean true is Order was found, false otherwise
Throws:
java.sql.SQLException

store

public boolean store(JDCConnection oConn)
              throws java.sql.SQLException
Store Order

Overrides:
store in class DBPersist
Parameters:
oConn - Database Connection If gu_order is null then a new GUID is automatically assigned.
If pg_order is null then next value for sequence seq_k_orders is automatically assigned.
If id_legal is null and gu_contact or gu_company is provided for customer then that one is automatically set.
dt_modified field is set to current date.
Returns:
boolean true if register was stored for the first time, false if register already existed.
Throws:
java.sql.SQLException

delete

public boolean delete(JDCConnection oConn)
               throws java.sql.SQLException

Delete Order

Overrides:
delete in class DBPersist
Parameters:
oConn -
Returns:
Throws:
java.sql.SQLException

getLine

public OrderLine getLine(JDCConnection oConn,
                         int iPgLine)
                  throws java.sql.SQLException
Get order line by number

Parameters:
oConn - JDCConnection
iPgLine - int Line number [1..n] as as at k_order_lines.pg_line
Returns:
OrderLine or null if no line with such number was found
Throws:
java.sql.SQLException

getLines

public DBSubset getLines(JDCConnection oConn)
                  throws java.sql.SQLException
Get Order Lines as a DBSubset

Specified by:
getLines in class AbstractOrder
Parameters:
oConn - Database Connection
Returns:
A DBSubset with the following columns:
gu_orderpg_linegu_productnm_productpr_salenu_quantityid_unitpr_totalpct_tax_rateis_tax_includedtx_promotiontx_optionsgu_itemid_ref
Order GUIDLine NumberProduct GUIDProduct NameSale PriceQuantity OrderedUnit for quantityTotal Price% of Tax Rate1 if tax includedPromotion TextAdditional OptionsGUID of ordered item
Throws:
java.sql.SQLException

getDespatchAdvice

public java.lang.String getDespatchAdvice()
Get despatch advice associated to this order

Returns:
GUID of associated despatch advice or null if there is no despatch advice associated with this order at k_x_orders_despatch table.
Since:
4.0

getInvoice

public java.lang.String getInvoice()
Get invoice associated to this order

Returns:
GUID of associated invoice or null if there is no invoice associated with this order at k_x_orders_invoice table.
Since:
4.0

createDespatchAdvice

public DespatchAdvice createDespatchAdvice(JDCConnection oConn,
                                           boolean bIncludePrices)
                                    throws java.sql.SQLException

Create a Dispatch Note for this Order

The new Dispatch Note is given the same GUID as the current order

Parameters:
oConn - JDCConnection
bIncludePrices - boolean whether or not to save prices at the new Dispatch Order
Returns:
Invoice
Throws:
java.sql.SQLException

createInvoice

public Invoice createInvoice(JDCConnection oConn)
                      throws java.sql.SQLException

Create an Invoice for this Order

The new Invoice is given the same GUID as the current order

Parameters:
oConn - JDCConnection
Returns:
Invoice
Throws:
java.sql.SQLException

activate

public void activate(JDCConnection oConn,
                     java.lang.String sOrderId)
              throws java.sql.SQLException

Activate an Order

For a given WorkArea only one order can be active at a time.

Parameters:
oConn - Database Connection
sOrderId - GUID of Order to Activate
Throws:
java.sql.SQLException

despatched

public boolean despatched()
Whether or not this order has an associated despatch advice

Since:
4.0

invoiced

public boolean invoiced()
Whether or not this order has an associated invoice

Since:
4.0

toXML

public java.lang.String toXML()
                       throws java.lang.IllegalStateException

Get order as an XML document

Character encoding is set to UTF-8

Overrides:
toXML in class DBPersist
Returns:
An XML String formatted according to OASIS Universal Universal Business Language Specification
Throws:
java.lang.IllegalStateException - if order lines are not loaded or buyer is not set or seller is not set
See Also:
OASIS Universal Business Language 1.0

toXML

public java.lang.String toXML(java.lang.String sIdent,
                              java.lang.String sDelim)
                       throws java.lang.IllegalStateException

Get order as an XML document

Character encoding is set to UTF-8

Overrides:
toXML in class DBPersist
Parameters:
sIdent - Number of blank spaces for left padding at every line.
sDelim - Line delimiter (usually "\n" or "\r\n")
Returns:
An XML String formatted according to OASIS Universal Universal Business Language Specification
Throws:
java.lang.IllegalStateException - if order lines are not loaded or buyer is not set or seller is not set
See Also:
OASIS Universal Business Language 1.0

toXML

public java.lang.String toXML(java.lang.String sIdent)
                       throws java.lang.IllegalStateException

Get order as an XML document

Character encoding is set to UTF-8

Overrides:
toXML in class DBPersist
Parameters:
sIdent - Number of blank spaces for left padding at every line.
Returns:
An XML String formatted according to OASIS Universal Universal Business Language Specification
Throws:
java.lang.IllegalStateException - if order lines are not loaded or buyer is not set or seller is not set
See Also:
OASIS Universal Business Language 1.0

toXML

public java.lang.String toXML(JDCConnection oConn,
                              java.lang.String sLocale)
                       throws java.lang.IllegalStateException

Get despatch advice as an XML document

Character encoding is set to UTF-8

Parameters:
oConn - JDCConnection Openend JDBC database connection
sLocale - String Locale for output formatting
Returns:
An XML String formatted according to OASIS Universal Universal Business Language Specification
Sample output <?xml version="1.0" encoding="UTF-8"?>
<Order xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-1.0" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-1.0" xmlns:cur="urn:oasis:names:specification:ubl:schema:xsd:CurrencyCode-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <cac:BuyersID><![CDATA[8574922]]></cac:BuyersID>
    <cac:SellerID><![CDATA[B82568718]]></cac:SellerID>
  <ID>1000000000</ID>
  <GUID>7f000001106a7371a7d10000095a8c5e</GUID>
  <cbc:IssueDate/>
  <cbc:Note><![CDATA[]]></cbc:Note>
  <TransactionCurrencyCode>840</TransactionCurrencyCode>
  <cbc:TotalTaxAmount amountCurrencyCodeListVersionID="0.3" amountCurrencyID="840"></cbc:TotalTaxAmount>
  <cbc:LineExtensionTotalAmount amountCurrencyCodeListVersionID="0.3" amountCurrencyID="840"></cbc:LineExtensionTotalAmount>
  <LineItemCountNumeric>2</LineItemCountNumeric>
  <DocumentStatusCode>RECEIVED</DocumentStatusCode>
  <LineItemCountNumeric>2</LineItemCountNumeric>
  <cac:BuyerParty>
    <cac:Party>
      <cac:PartyName><cbc:Name><![CDATA[Paul Klein]]></cbc:Name></cac:PartyName>
      <cac:Address>
        <ID>7f000001106709e1bda10000ec419d26</ID>
        <cbc:PostBox></cbc:PostBox>
        <cbc:StreetName><![CDATA[Bulbury]]></cbc:StreetName>
        <cbc:AdditionalStreetName><![CDATA[ST]]></cbc:AdditionalStreetName>
        <cbc:BuildingName><![CDATA[]]></cbc:BuildingName>
        <cbc:BuildingNumber><![CDATA[80]]></cbc:BuildingNumber>
        <cbc:CityName><![CDATA[]]></cbc:CityName>
        <cbc:PostalZone></cbc:PostalZone>
        <cbc:CountrySubentity><![CDATA[]]></cbc:CountrySubentity>
        <cbc:CountrySubentityCode></cbc:CountrySubentityCode>
        <cbc:AddressLine><![CDATA[]]></cbc:AddressLine>
        <Country><![CDATA[]]></Country>
      </cac:Address>
    </cac:Party>
    <cac:AccountsContact>
      <cbc:Name><![CDATA[]]></cbc:Name>
      <cbc:Telephone><![CDATA[]]></cbc:Telephone>
    </cac:AccountsContact>
  </cac:BuyerParty>
  <cac:SellerParty>
    <cac:Party>
      <cac:PartyName><cbc:Name><![CDATA[Know Gate Ltd.]]></cbc:Name></cac:PartyName>
      <cac:Address>
        <ID>7f0000011067057c4ef100008c688128</ID>
        <cbc:StreetName><![CDATA[Wesleyan]]></cbc:StreetName>
        <cbc:AdditionalStreetName><![CDATA[ST]]></cbc:AdditionalStreetName>
        <cbc:BuildingName><![CDATA[]]></cbc:BuildingName>
        <cbc:BuildingNumber><![CDATA[107]]></cbc:BuildingNumber>
        <cbc:CityName><![CDATA[Boston]]></cbc:CityName>
        <cbc:PostalZone></cbc:PostalZone>
        <cbc:CountrySubentity><![CDATA[MA]]></cbc:CountrySubentity>
        <cbc:CountrySubentityCode></cbc:CountrySubentityCode>
        <cbc:AddressLine><![CDATA[]]></cbc:AddressLine>
        <Country><![CDATA[United States]]></Country>
      </cac:Address>
    </cac:Party>
    <cac:AccountsContact>
      <cbc:Name><![CDATA[]]></cbc:Name>
      <cbc:Telephone><![CDATA[]]></cbc:Telephone>
    </cac:AccountsContact>
  </cac:SellerParty>
  <cac:Delivery>
    <cac:DeliveryAddress>
        <ID>7f00000110670211e12100002a4874df</ID>
        <cbc:StreetName><![CDATA[Yokohama]]></cbc:StreetName>
        <cbc:AdditionalStreetName><![CDATA[ST]]></cbc:AdditionalStreetName>
        <cbc:BuildingName><![CDATA[]]></cbc:BuildingName>
        <cbc:BuildingNumber><![CDATA[1310]]></cbc:BuildingNumber>
        <cbc:CityName><![CDATA[]]></cbc:CityName>
        <cbc:PostalZone></cbc:PostalZone>
        <cbc:CountrySubentity><![CDATA[]]></cbc:CountrySubentity>
        <cbc:CountrySubentityCode></cbc:CountrySubentityCode>
        <cbc:AddressLine><![CDATA[]]></cbc:AddressLine>
        <Country><![CDATA[us]]></Country>
    </cac:DeliveryAddress>
  </cac:Delivery>
    <DestinationCountry>us</DestinationCountry>
  <cac:OrderLine>
    <ID>1</ID>
    <cbc:DeliveredQuantity>1</cbc:DeliveredQuantity>
    <cac:Item>
      <cbc:Description><![CDATA[Tux Earrings]]></cbc:Description>
    </cac:Item>
  </cac:OrderLine>
  <cac:OrderLine>
    <ID>2</ID>
    <cbc:DeliveredQuantity>1</cbc:DeliveredQuantity>
    <cac:Item>
      <cbc:Description><![CDATA[Tux Pendant]]></cbc:Description>
    </cac:Item>
  </cac:OrderLine>
  <cac:PaymentMeans>
    <PaymentMeansCode>T</PaymentMeansCode>
    <cbc:DuePaymentDate>2005-09-30</cbc:DuePaymentDate>
    <CardAccount></CardAccount>
    <PayerFinancialAccount>00101234990123456789</PayerFinancialAccount>
  </cac:PaymentMeans>
</Order>
Throws:
java.lang.IllegalStateException - if invoice lines are not loaded or buyer is not set or seller is not set
See Also:
OASIS Universal Business Language 1.0

delete

public static boolean delete(JDCConnection oConn,
                             java.lang.String sOrderId)
                      throws java.sql.SQLException
Delete order

Parameters:
oConn - JDCConnection
sOrderId - String Order GUID
Returns:
boolean
Throws:
java.sql.SQLException

getActiveOrder

public static Order getActiveOrder(JDCConnection oConn,
                                   java.lang.String sWorkAreaId)
                            throws java.sql.SQLException
Get active order for a WorkArea

Parameters:
oConn - JDCConnection
sWorkAreaId - String WorkArea GUID
Returns:
Order
Throws:
java.sql.SQLException