Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.knowgate.hipergate
Class Invoice

    java.lang.Object
      com.knowgate.dataobjs.DBPersist
          com.knowgate.hipergate.AbstractOrder
              com.knowgate.hipergate.Invoice

All Implemented Interfaces:
  java.io.Serializable, java.util.Map

    public class Invoice

extends AbstractOrder

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
`Invoice()` Default constructor
`Invoice(JDCConnection oConn, int iInvoicePg, java.lang.String sWorkArea)`
`Invoice(JDCConnection oConn, java.lang.String sInvoiceId)` Load Invoice from database
`Invoice(java.lang.String sInvoiceId)` Create Invoice and set its GUID

Method Summary
`int` | `addLine(JDCConnection oConn, java.math.BigDecimal oPrSale, float fQuantity, java.lang.String sIdUnit, java.math.BigDecimal oPrTotal, float fTaxRate, short bTaxIncluded, java.lang.String sNmProduct, java.lang.String sGuProduct, java.lang.String sGuItem, java.lang.String sTxPromo, java.lang.String sTxOptions)` Add an Invoice line This method updates k_invoices.dt_modified to current datetime as a side effect
`boolean` | `delete(JDCConnection oConn)` Delete Invoice
`static java.lang.String` | `getIdFromNumber(JDCConnection oConn, int iInvoicePg, java.lang.String sWorkArea)` Get invoice GUID given its number
`InvoiceLine` | `getLine(JDCConnection oConn, int iPgLine)` Get invoice line by number
`DBSubset` | `getLines(JDCConnection oConn)` Get a DBSubset with all lines of this Invoice
`java.lang.String[]` | `getOrders()` Get Orders for this Invoice Orders can only be get if Invoice has been previously loaded, else this method will return null
`boolean` | `load(JDCConnection oConn, java.lang.Object[] PKVals)` Load Invoice with its associated Order and Addresses
`boolean` | `load(JDCConnection oConn, java.lang.String sGuInvoice)` Load Invoice with its associated Order and Addresses
`static int` | `nextVal(JDCConnection oConn, java.lang.String sGuWorkArea)` Get next value for field pg_invoice in a given WorkArea
`boolean` | `store(JDCConnection oConn)` Store invoice If no value for gu_invoice is specified then a new one is automatically assigned.
`boolean` | `storeLine(JDCConnection oConn, int iLine, java.math.BigDecimal oPrSale, float fQuantity, java.lang.String sIdUnit, java.math.BigDecimal oPrTotal, float fTaxRate, short bTaxIncluded, java.lang.String sNmProduct, java.lang.String sGuProduct, java.lang.String sGuItem, java.lang.String sTxPromo, java.lang.String sTxOptions)` Add or update an Invoice line This method updates k_invoices.dt_modified to current datetime as a side effect
`java.lang.String` | `toXML()` Get invoice as an XML document Character encoding is set to UTF-8
`java.lang.String` | `toXML(JDCConnection oConn, java.lang.String sLocale)` Get invoice as an XML document Character encoding is set to UTF-8
`java.lang.String` | `toXML(java.lang.String sIdent)` Get invoice as an XML document Character encoding is set to UTF-8
`java.lang.String` | `toXML(java.lang.String sIdent, java.lang.String sDelim)` Get invoice 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

### Invoice

    public Invoice()

  Default constructor

### Invoice

    public Invoice(java.lang.String sInvoiceId)

  Create Invoice and set its GUID

### Invoice

    public Invoice(JDCConnection oConn,
                   java.lang.String sInvoiceId)
            throws java.sql.SQLException

  Load Invoice from database

  Parameters:
    `oConn` - JDCConnection
    `sInvoiceId` - String Invoice GUID
  Throws:
    `java.sql.SQLException`

### Invoice

    public Invoice(JDCConnection oConn,
                   int iInvoicePg,
                   java.lang.String sWorkArea)
            throws java.sql.SQLException

Parameters:
  `oConn` - JDCConnection
  `iInvoicePg` - int Invoice number (as at pg_invoice column of k_invoices table)
  `sWorkArea` - String WorkArea to which invoice belongs (as at gu_workarea column of k_invoices table)
Throws:
  `java.sql.SQLException`

Method Detail

### getOrders

    public java.lang.String[] getOrders()

  Get Orders for this Invoice

  Orders can only be get if Invoice has been previously loaded, else this method will return null

  Returns:
    String[] Array with orders GUIDs

### load

    public boolean load(JDCConnection oConn,
                        java.lang.Object[] PKVals)
                 throws java.sql.SQLException

  Load Invoice with its associated Order and Addresses

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

### load

    public boolean load(JDCConnection oConn,
                        java.lang.String sGuInvoice)
                 throws java.sql.SQLException

  Load Invoice with its associated Order and Addresses

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

### store

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

  Store invoice

  If no value for gu_invoice is specified then a new one is automatically assigned.
  If no value for pg_invoice is specified then a new one is automatically assigned by looking at k_invoices_next table and updating it afterwards.
  This method updates dt_modified to current datetime as a side effect iif Invoice did not previously exist at the database.

  Overrides:
    `store` in class `DBPersist`
  Parameters:
    `oConn` - JDCConnection
  Returns:
    boolean
  Throws:
    `java.sql.SQLException`

### storeLine

    public boolean storeLine(JDCConnection oConn,
                             int iLine,
                             java.math.BigDecimal oPrSale,
                             float fQuantity,
                             java.lang.String sIdUnit,
                             java.math.BigDecimal oPrTotal,
                             float fTaxRate,
                             short bTaxIncluded,
                             java.lang.String sNmProduct,
                             java.lang.String sGuProduct,
                             java.lang.String sGuItem,
                             java.lang.String sTxPromo,
                             java.lang.String sTxOptions)
                      throws java.sql.SQLException

  Add or update an Invoice line

  This method updates k_invoices.dt_modified to current datetime as a side effect

  Parameters:
    `oConn` - JDCConnection
    `iLine` - int Line Number
    `oPrSale` - BigDecimal Sale price for one unit
    `fQuantity` - float Number of units sold
    `sIdUnit` - String Measure Unit Identifier, if null then is set to "UNIT" by default
    `oPrTotal` - BigDecimal Total price (oPrSale*fQuantity+oPrSale*fQuantity*fTaxRate)
    `fTaxRate` - float Percentage of taxes [0..0.99]
    `bTaxIncluded` - short 1 if oPrSale includes taxes 0 if not
    `sNmProduct` - String Product Name
    `sGuProduct` - String Product GUID (from k_product.gu_product)
    `sGuItem` - String Item GUID (for products that require a serial number to be assigned when sold)
    `sTxPromo` - String Promotions (free text)
    `sTxOptions` - String Other Options (free text)
  Returns:
    boolean
  Throws:
    `java.sql.SQLException`

### addLine

    public int addLine(JDCConnection oConn,
                       java.math.BigDecimal oPrSale,
                       float fQuantity,
                       java.lang.String sIdUnit,
                       java.math.BigDecimal oPrTotal,
                       float fTaxRate,
                       short bTaxIncluded,
                       java.lang.String sNmProduct,
                       java.lang.String sGuProduct,
                       java.lang.String sGuItem,
                       java.lang.String sTxPromo,
                       java.lang.String sTxOptions)
                throws java.sql.SQLException

  Add an Invoice line

  This method updates k_invoices.dt_modified to current datetime as a side effect

  Parameters:
    `oConn` - JDCConnection
    `oPrSale` - BigDecimal Sale price for one unit
    `fQuantity` - float Number of units sold
    `sIdUnit` - String Measure Unit Identifier, if null then is set to "UNIT" by default
    `oPrTotal` - BigDecimal Total price (oPrSale*fQuantity+oPrSale*fQuantity*fTaxRate)
    `fTaxRate` - float Percentage of taxes [0..0.99]
    `bTaxIncluded` - short 1 if oPrSale includes taxes 0 if not
    `sNmProduct` - String Product Name
    `sGuProduct` - String Product GUID (from k_product.gu_product)
    `sGuItem` - String Item GUID (for products that require a serial number to be assigned when sold)
    `sTxPromo` - String Promotions (free text)
    `sTxOptions` - String Other Options (free text)
  Returns:
    int New line number
  Throws:
    `java.sql.SQLException`

### delete

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

  Delete Invoice

  Overrides:
    `delete` in class `DBPersist`
  Parameters:
    `oConn` - Database Connection
  Returns:
    true if register was successfully erased, false if not.
  Throws:
    `java.sql.SQLException`

### getLine

    public InvoiceLine getLine(JDCConnection oConn,
                               int iPgLine)
                        throws java.sql.SQLException

  Get invoice line by number

  Parameters:
    `oConn` - JDCConnection
    `iPgLine` - int Line number [1..n] as at k_invoice_lines.pg_line
  Returns:
    InvoiceLine 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 a DBSubset with all lines of this Invoice

  Specified by:
    `getLines` in class `AbstractOrder`
  Parameters:
    `oConn` - JDCConnection
  Returns:
    DBSubset with columns gu_invoice,pg_line,pr_sale,nu_quantity,id_unit,pr_total,pct_tax_rate,is_tax_included,nm_product,gu_product,gu_item,tx_promotion,tx_options,id_ref
  Throws:
    `java.sql.SQLException`

### toXML

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

  Get invoice 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"?>
    <Invoice 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">
    <ID>1</ID>
    <GUID>7f000001106832df692100000a45e2d8</GUID>
    <cbc:IssueDate/>
    <InvoiceCurrencyCode>840</InvoiceCurrencyCode>
    <LineItemCountNumeric>2</LineItemCountNumeric>
    <cac:OrderReference>
    <cac:BuyersID><![CDATA[B82568718]]></cac:BuyersID>
    <cac:SellerID><![CDATA[B82568718]]></cac:SellerID>
    <DocumentStatusCode><![CDATA[]]></DocumentStatusCode>
    </cac:OrderReference>
    <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:PaymentMeans>
    <cbc:DuePaymentDate>2005-09-30</cbc:DuePaymentDate>
    <PayeeFinancialAccount>
    <ID>00018888XX1234567890</ID>
    <FinancialInstitutionBranch><![CDATA[1st Boston Bank]]></FinancialInstitutionBranch>
    </PayeeFinancialAccount>
    <PayerFinancialAccount>
    <ID></ID>
    <FinancialInstitutionBranch><![CDATA[]]></FinancialInstitutionBranch>
    </PayerFinancialAccount>
    <Payment>
    <ID/>
    <PaidAmount>268</PaidAmount>
    <cbc:ReceivedDate></cbc:ReceivedDate>
    </Payment>
    </cac:PaymentMeans>
    <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>
    <cac:TaxTotal>
    <cbc:TotalTaxAmount amountCurrencyCodeListVersionID="0.3" amountCurrencyID="840">0</cbc:TotalTaxAmount>
    </cac:TaxTotal>
    <cac:LegalTotal>
    <cbc:LineExtensionTotalAmount amountCurrencyCodeListVersionID="0.3" amountCurrencyID="840">248.00</cbc:LineExtensionTotalAmount>
    <cbc:TaxInclusiveTotalAmount amountCurrencyCodeListVersionID="0.3" amountCurrencyID="840">268.00</cbc:TaxInclusiveTotalAmount>
    </cac:LegalTotal>
    <cac:InvoiceLine>
    <ID>1</ID>
    <cbc:InvoicedQuantity>1</cbc:InvoicedQuantity>
    <cbc:LineExtensionAmount amountCurrencyCodeListVersionID="0.3" amountCurrencyID="840">49.00</cbc:LineExtensionAmount>
    <cac:Item>
    <cbc:Description><![CDATA[Tux Earrings]]></cbc:Description>
    </cac:Item>
    <BasePrice>49.00</BasePrice>
    </cac:InvoiceLine>
    <cac:InvoiceLine>
    <ID>2</ID>
    <cbc:InvoicedQuantity>1</cbc:InvoicedQuantity>
    <cbc:LineExtensionAmount amountCurrencyCodeListVersionID="0.3" amountCurrencyID="840">199.00</cbc:LineExtensionAmount>
    <cac:Item>
    <cbc:Description><![CDATA[Tux Pendant]]></cbc:Description>
    </cac:Item>
    <BasePrice>199.00</BasePrice>
    </cac:InvoiceLine>
    </Invoice>
  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

### toXML

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

  Get invoice 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 invoice 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 invoice 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 invoice 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 invoice 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 invoice lines are not loaded or buyer is not set or seller is not set
  See Also:
    OASIS Universal Business Language 1.0

### getIdFromNumber

    public static java.lang.String getIdFromNumber(JDCConnection oConn,
                                                   int iInvoicePg,
                                                   java.lang.String sWorkArea)
                                            throws java.sql.SQLException

  Get invoice GUID given its number

  Parameters:
    `oConn` - JDCConnection
    `iInvoicePg` - int Invoice number (pg_invoice column at k_invoices table)
    `sWorkArea` - GUID of WorkArea to which invoice belongs
  Returns:
    String Invoice GUID or null if no invoice with such number was found at given WorkArea
  Throws:
    `java.sql.SQLException`

### nextVal

    public static int nextVal(JDCConnection oConn,
                              java.lang.String sGuWorkArea)
                       throws java.sql.SQLException

  Get next value for field pg_invoice in a given WorkArea

  Parameters:
    `oConn` - JDCConnection JDBC Connection
    `sGuWorkArea` - String WorkArea GUID
  Returns:
    int Next unused invoice number
  Throws:
    `java.sql.SQLException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD