The following example shows how to create a document template for the invoices due and how to generate that document by using information from multiple tables of the database. It also shows how to use the content selector, table select, and XPath expression to merge the data into the document template from the database, the construction of the XPath based on the XML root and child elements, and how the child elements of the XML can be categorized based on the SQL select statements.
Sr #. | Text/Content | Database Table | Database Column Name |
1 | General Electric Company | Lessee (ral) | nam_long_s |
2 | GE LIGHTING | Lessee (ral) | add_s |
3 | Nela Park | Lessee (ral) | add2_s |
4 | Cleveland, OH 44112 | Lessee (ral) | cty_s, st_s, zip_s |
5 | JOHN SMITH | Lessee (ral) | short_cont_nam_s |
6 | 41 | Lease (rls) | lse_s |
7 | 154, 191 | Accounts Receivable (rar) | invo_s |
8 | 3/1/1989 4/1/1989 |
Accounts Receivable (rar) | d_pmtdu_s |
9 | 678 1260 |
Accounts Receivable (rar) | (tamt_b_d - tamt_p_d) as amt_due_d |
To calculate totals and to count the number of outstanding invoices user must set parameter name to calculate and merge the calculated value. In this example, the total number of outstanding invoices will be calculated by using the COUNT function of SQL via SQL select statement in the next steps of this document. Whereas to calculate the total outstanding amount the SUM function of the SQL select statement will be used to sum up the outstanding invoice amounts. These column names and values does not exist in the database. | |||
10 | 2 | Count | |
11 | 1938 | tot_amt_due_d |
Tracking Modules | LeasePak Component | Database Table.Column name |
Application | Application | rap.app_s |
Collection | Lessee/Lease | ral.les_s/rls.lse_s |
Customer Summary, Insurance, Maturing Lease, Recovery, Lease Summary |
Lease | rls.lse_s |
Collateral | Asset | req.unit_s |
lse_s
)Tracking Module | Base Parameter | Database Table.Column name | SQLs that builds parameter list | Parameter available to use in ROOT and Other SQLs |
Application | Application | rap.app_s | SELECT * FROM RAP WHERE APP_S = '<selected application number>, |
The parameter would be: • {arg.app_s} • {arg.les_s} • {arg.dlr_s} • {arg.d_com_s} … |
Collection | Lessee/Lease | ral.les_s/rls.lse_s | SELECT * FROM RAL SELECT * FROM RLS |
If lessee is selected then the parameters can be: • {arg.les_s} • {arg.cus_s} • {arg.def_por_s} • {arg.st_s} If lease is selected then the parameters can be: • {arg.lse_s} • {arg.les_s} • {arg.dlr_s} • {arg.d_com_s} … |
Customer Summary Insurance Maturing Lease Recovery Lease Summary |
Lease | rls.lse_s | SELECT * FROM RLS WHERE LSE_S = ‘<selected lease number>’ |
• {arg.lse_s} • {arg.les_s} • {arg.dlr_s} • {arg.d_com_s} … |
Collateral | Asset | req.unit_s | SELECT * FROM REQ WHERE UNIT_S = ‘<selected asset number>’ |
• {arg.lse_s} • {arg.unit_s} • {arg.dlr_s} • {arg.d_acq_s} • {arg.cls_s} … |
SELECT lse_s
FROM rls
WHERE lse_s = '{lse_s}'
SELECT les_s, short_cont_nam_s, nam_long_s, add_s, add2_s, cty_s, st_s, zip_s
FROM ral
WHERE les_s = '{les_s}'
SELECT invo_s, d_pmtdu_s, (tamt_b_d - tamt_p_d) as amt_due_d
FROM rar
WHERE lse_s = '{lse_s}'
<count>
and <total>
. The fifth SQL at level 1 would be as follows:
SELECT COUNT(*) as count, SUM(tamt_b_d - tamt_p_d) AS tot_amt_due_d
FROM rar
WHERE lse_s = '{lse_s}'
The SQLs are retrieving records based on lease number. In this example when user enters a lease number, Document Generation looks for the associated lessee address information from ral table. The second SQL at level 1 is retrieving the lessee number attached to lease. The third SQL at level 1 is retrieving the address information of lessee from ral table. Whereas the fourth SQL at level is retrieving the invoices of the lease including the invoice number, due date, and payment amount due from rar table. To calculate totals, the fifth SQL at level 1 is calculating the total number of outstanding invoices and payment amount due.
<data>
element. In this XML, the second SQL is retrieving the lessee associated to the selected lease number. The third SQL at level is retrieving the address information of the lessee. The fourth SQL at level 1 is retrieving invoice details of the lease and are grouped as <lease_invoices>
. A lease can have multiple invoices therefore; the result record of invoices is grouped into the <lease_invoices>
. Each invoice detail is named as <invoice_info>
. The fifth SQL at level 1 is counting the number of outstanding invoices as <count>
and sum of the total amount due as <tot_amt_due_d>
. This SQL statement is setting the XML parameter names in fifth SQL at level 1 because it is calculating the result records retrieved from fourth SQL at level 1.
SQL Statement | SQL Column Names | XML Element Names |
SELECT lse_s, les_s FROM rls WHERE lse_s = '{ar.lse_s}' SELECT lse_s FROM rls WHERE lse_s = '{lse_s}' SELECT les_s, short_cont_nam_s, nam_long_s, add_s, add2_s, cty_s, st_s, zip_s FROM ral WHERE les_s = '{les_s}' SELECT invo_s, d_pmtdu_s, (tamt_b_d - tamt_p_d) as amt_due_d FROM rar WHERE lse_s = '{lse_s}' SELECT COUNT(*) as count, SUM(tamt_b_d - tamt_p_d) AS tot_amt_due_d FROM rar WHERE lse_s = '{lse_s}' |
<?xml version="1.0"?> | |
<data> | ||
rls.lse_s | <lse_s>41</lse_s> | |
ral.les_s | <les_s>32</les_s> | |
ral.short_cont_nam_s | <short_cont_nam_s>JOHN SMITH</short_cont_nam_s> | |
ral.nam_long_s | <nam_long_s>General Electric Company</nam_long_s> | |
ral.add_s | <add_s>GE LIGHTING</add_s> | |
ral.add2_s | <add2_s>Nela Park</add2_s> | |
ral.cty_s | <cty_s>Cleveland</cty_s> | |
ral.st_s | <st_s>OH</st_s> | |
ral.zip_s | <zip_s>44112</zip_s> | |
<lease_invoices count="2"> | ||
<invoice_info> | ||
rar.invo_s | <invo_s>154</invo_s> | |
rar.d_pmtdu_s | <d_pmtdu_s>3/1/1989</d_pmtdu_s> | |
rar.(tamt_b_d - tamt_p_d) as amt_due_d | <amt_due_d>678</amt_due_d> | |
</invoice_info> | ||
<invoice_info> | ||
rar.invo_s | <invo_s>191</invo_s> | |
rar.d_pmtdu_s | <d_pmtdu_s>4/1/1989</d_pmtdu_s> | |
rar.(tamt_b_d - tamt_p_d) as amt_due_d | <amt_due_d>1260</amt_due_d> | |
</invoice_info> | ||
</lease_invoices> | ||
<totals> | ||
count | <count>2</count> | |
tot_amt_due_d | <tot_amt_due_d>1938</tot_amt_due_d> | |
</totals> | ||
</data> |
XML | XPath Expression |
<?xml version="1.0"?> | |
<data> | |
<lse_s>41</lse_s> | /data/lse_s |
<les_s>32</les_s> | /data/les_s |
<short_cont_nam_s>JOHN SMITH</short_cont_nam_s> | /data/short_cont_nam_s |
<nam_long_s>General Electric Company</nam_long_s> | /data/nam_long_s |
<add_s>GE LIGHTING</add_s> | /data/add_s |
<add2_s>Nela Park</add2_s> | /data/add2_s |
<cty_s>Cleveland</cty_s> | /data/cty_s |
<st_s>OH</st_s> | /data/st_s |
<zip_s>44112</zip_s> | /data/zip_s |
<lease_invoices count="2"> | |
<invoice_info> | |
<invo_s>154</invo_s> | ./invo_s |
<d_pmtdu_s>3/1/1989</d_pmtdu_s> | ./d_pmtdu_s |
<amt_due_d>678</amt_due_d> | ./amt_due_d |
</invoice_info> | |
<invoice_info> | |
<invo_s>191</invo_s> | ./invo_s |
<d_pmtdu_s>4/1/1989</d_pmtdu_s> | ./d_pmtdu_s |
<amt_due_d>1260</amt_due_d> | ./amt_due_d |
</invoice_info> | |
</lease_invoices> | |
<totals> | |
<count>2</count> | /data/total/count |
<tot_amt_due_d>1938</tot_amt_due_d> | /data/totals/tot_amt_due_d |
</totals> | |
</data> |
<# <Content Select="/data/les_s" /> #>
<data>
. Users can skip this in XPath.
<# <Table Select="/data/lease_invoices/invoice_info" /> #>
./invo_s
, ./d_pmtdu_s
, ./amt_due_d
/data/totals/count
/data/totals/tot_amt_due_d
Sr #. | Text/Content | Database Table.Column Name | Content Selector/XPath Expression |
1 | General Electric Company | ral.nam_long_s | <# <Content Select="/data/nam_long_s" /> #> |
2 | GE LIGHTING | ral.add_s | <# <Content Select="/data/add_s" /> #> |
3 | Nela Park | ral.add2_s | <# <Content Select="/data/add2_s" /> #> |
4 | Cleveland, OH 44112 | ral.cty_s , ral.st_s , ral.zip_s | <# <Content Select="/data/cty_s" /> #> , <# <Content Select="/data/st_s" /> #>, <# <Content Select="/data/zip_s" /> #>, |
5 | JOHN SMITH | ral.short_cont_nam_s | <# <Content Select="/data/short_cont_nam_s" /> #> |
6 | 41 | rls.lse_s | <# <Content Select="/data/lse_s" /> #> |
This XPath will be used to gather collection of records. | <# <Table Select="/data/lease_invoices/invoice_info" /> #> | ||
7 | 154, 191 | rar.invo_s | ./invo_s |
8 | 3/1/1989 4/1/1989 |
rar.d_pmtdu_s | ./d_pmtdu_s |
9 | 678 1260 |
rar.(tamt_b_d - tamt_p_d) as amt_due_d | ./amt_due_d |
For totals | |||
10 | 2 | /data/totals/count | |
11 | 1938 | /data/totals/total_amt_due_d |