Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Summary

This article provides sample code which can be used based on the scenarios listed below. These are meant to be examples only and should be customized to reflect the format and data that you wish to show in the invoice. These may be used in conjunction with other XSL code in order to create a complete invoice template. Please refer to the basic invoice template and customize that as needed. Related Link:

For details on customizing templates and advanced configuration help beyond what is provided in this article, please look at these good sites which will provide ways to manipulate data in XSL:

Further references are available by simply 'googling' the question you have or to solve formatting problems.

Package Group

Display Packages without services broken out. Packages will also display the period as shown below in the image.

HTML SECTION

<xsl:apply-templates select="PackageGroup"/>

XSL SECTION

<xsl:template match="PackageGroup"> <xsl:apply-templates select="ItemGroup"/>
</xsl:template><xsl:template match="ItemGroup"> <tr> <td colspan="5"></td> </tr> <tr> <td colspan="5"> <span> <h2> Monthly Charges for <xsl:apply-templates select="UserTopParent"/> </h2> </span> </td> </tr>
<xsl:if test="count(Item)>0"> <tr> <td colspan="5"> <span> <h3> <xsl:apply-templates select="User"/> </h3> </span> </td> </tr> <tr> <td width="2%"></td> <td width="48%">Package</td> <td width="40%">Period Billed</td> <td width="10%" align="center">Amount</td> </tr> <xsl:apply-templates select="Item"/>
</xsl:if>
</xsl:template> <xsl:template match="Item"> <xsl:if test="not(Amount = '0.00')"> <tr> <td></td> <td> <b> <xsl:apply-templates select="Detail"/> </b> </td> <xsl:if test="count(CurrentBilldate)>0"> <td> <b> <xsl:apply-templates select="CurrentBilldate"/> - <xsl:apply-templates select="NextBilldate"/> </b> </td>
</xsl:if>
<xsl:if test="count(CurrentBilldate)=0"> <td> <b> <xsl:apply-templates select="TransactionDate"/> - <xsl:apply-templates select="TransactionDate"/> </b> </td>
</xsl:if><td align="center"> <b> <xsl:apply-templates select="Amount"/> </b> </td> </tr>
</xsl:if>
</xsl:template>

Monthly Recurring Package Grouping Summary

This will provide a breakdown of monthly recurring packages, their quantity on the account and the total charge by package.

HTML SECTION

<xsl:apply-templates select="PackageGroupRecurring"/>

XSL SECTION

<xsl:template match="PackageGroupRecurring"> <xsl:for-each select="PackageGroupItem"> <xsl:variable name="packagename"> <xsl:value-of select="Package"/> </xsl:variable> <xsl:if test="$packagename != 'Long Distance Rate Plan (3.9)'"> <tr> <td colspan="3" align="left"> <xsl:value-of select="Package"/> </td> <td align="right"> <b> <xsl:value-of select="Quantity"/> </b> </td> <td align="right"> <b> $<xsl:value-of select="Amount"/> </b> </td> </tr> </xsl:if> </xsl:for-each> <tr> <td colspan="5"> <HR width="40%" align="right" /> </td> </tr> <tr> <td colspan="4" align="right"> Recurring Total: </td> <td align="right"> $<xsl:value-of select="PackageGroupRecurringTotal"/> </td> </tr> <tr> <td colspan="5"> <HR width="100%" align="right"/> <HR width="100%" align="right"/> </td> </tr> </xsl:template>Profile Answers for Services


Profile Answers for Services

Displays profile answers attached to services that are show on the customer invoice As shown above, we have created the profile question ‘What is your favourite colour?’ on the Dialup Service. Once the XML is in place, we can then show that profile question answer on the invoice, in this case, the answer is ‘RED’ Complete Invoice Template Sample: InvoiceWithProfileAnswer

HTML SECTION

<xsl:apply-templates select="InvoiceGroup"/>

XSL SECTION

<xsl:template match="InvoiceGroup"> <xsl:apply-templates select="ItemGroup"/> </xsl:template> <xsl:template match="ItemGroup"> <tr> <td colspan="6"></td> </tr> <tr> <td colspan="6"> <span> <h2> Monthly Charges for <xsl:apply-templates select="User"/><xsl:apply-templates select="ItemGroupUserProfile" /> </h2> </span> </td> </tr> <xsl:apply-templates select="Item"/> <xsl:apply-templates select="InvoiceItemsSubtotal"/></xsl:template><xsl:template match="Item"> <xsl:if test="not(Amount = '$0.00')"><tr> <td width="2%"> </td> <td width="58%">Service</td> <td width="10%">Date</td> <td width="20%" colspan="2" align="center">Period</td> <td width="10%" align="center">Amount</td> </tr> <tr> <td> </td> <td> <xsl:apply-templates select="Detail"/> ; <xsl:apply-templates select="ItemUserServiceProfile"/> </td> <td> <xsl:apply-templates select="Date"/> </td> <td align="right" width="10%"> <xsl:apply-templates select="PeriodStart"/> </td> <td align="left" width="10%"> <xsl:apply-templates select="PeriodEnd"/> </td> <td align="right"> <xsl:apply-templates select="Amount"/> </td> </tr> </xsl:if> </xsl:template><xsl:template match="Detail"> <xsl:value-of select="." /> </xsl:template> <xsl:template match="ItemUserServiceProfile"> <xsl:if test="count(Profile)>0"> <xsl:for-each select="Profile"> <xsl:if test="ProfileQuestion = 'What is your favourite colour?'"> <br/>Favourite Colour:<xsl:value-of select="ProfileAnswer"/> </xsl:if> <xsl:if test="ProfileQuestion = 'Macaddress'">Macaddress:<xsl:value-of select="ProfileAnswer"/> </xsl:if> </xsl:for-each> </xsl:if> </xsl:template>

Show Profile Answers on Roles

Displays answers based on profile questions on roles if the question is answered on the customer account Note: Currently at least one transaction is required to be on the account before this will appear - this will be changed in a future release.

HTML SECTION

<xsl:apply-templates select="InvoiceUserProfileGroup"/>

XSL SECTION

<xsl:template match="InvoiceUserProfileGroup">
<xsl:if test="count(Profile)>0">
<xsl:for-each select="Profile">
<xsl:if test="ProfileQuestion = 'PO Number'">
<xsl:value-of select="ProfileAnswer"/>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:template>
Invoice Detail

Invoice Detail
 

Token in the invoice is 'Extra Detail' - The 'invoice detail' component on packages allows you to insert additional information or notes about a particular package on an invoice. Remember that this is a global setting for anyone who signs up for this package and is not configurable per account. The 'extra detail' token as referred to here displays the 'invoice detail' component data.

HTML SECTION

<xsl:apply-templates select="ExtraDetail"/>

XSL SECTION

<xsl:template match="ExtraDetail"> <xsl:value-of select="." /> </xsl:template>Invoice Identifier

Invoice Identifier

The invoice identifier option allows you to tag packages and/or services with a specific identifier for the purpose of applying formatting to the item on the invoice. For example, if you would like to hide specific services on invoices so that they are not seen by your customers you could create an invoice identifier named HIDE. In your invoice template you would look for any services which have an identifier value of HIDE and then react by not showing them on the invoice. The same could be done to hide services which do not have an amount ($0.00) on invoices, to highlight a particular discount or promotional service with different font formatting than the others listed.

  1. Click Setup tab

  2. Click Invoice Identifiers

  3. Add your invoice identifiers

  4. Click the service you want to identify

  5. Select the identifier from the invoice identifier dropdown menu

  6. Click Save

  7. Once an invoice is generated with that package and service, the tag will appear in the xsl: <ServiceInvoiceIdentifier>HIDE</ServiceInvoiceIdentifier>

HTML SECTION

<xsl:template match="PackageService">
<xsl:if test="not(ServiceInvoiceIdentifier = 'X')"> <td></td> <td> $<xsl:apply-templates select="ExtraDetail"/><xsl:apply-templates select="PeriodStart"/><xsl:apply-templates select="PeriodEnd"/> </td> <tr></tr> </xsl:if> <xsl:if test="(ServiceInvoiceIdentifier = 'No')">
</xsl:if>
</xsl:template>

IF Statements and Logic Within XML

Adding logic within XML for flexibility of data display.
The below code can be used as an example for using IF statements to output the data needed.

Equals Check

<xsl:if test="not(ServiceInvoiceIdentifier = 'X')"> <td></td> <td> $<xsl:apply-templates select="ExtraDetail"/><xsl:apply-templates select="PeriodStart"/><xsl:apply-templates select="PeriodEnd"/> </td> <tr></tr>
</xsl:if>
<xsl:if test="(ServiceInvoiceIdentifier = 'No')"> </xsl:if>Greater Or Less Than Check:<xsl:if test="NonRecurringTotal>0"> -- Output Invoice data, etc
</xsl:if>
Dollar Amount Check:<xsl:if test="not(Amount = '0.00')"> -- Output invoice data, etc
</xsl:if>



Manual Transaction Listing


If you want to display only a list of manual transactions, in the case where you might be using package grouping as well, you can use this code below to show only those manual transactions

HTML SECTION

<xsl:if test="count(PackageGroup/ItemGroup) = 0"> <xsl:apply-templates select="InvoiceGroup" />
</xsl:if>

XSL SECTION

<xsl:template match="InvoiceGroup"> <xsl:variable name="loop"> <xsl:value-of select="ItemGroup/Item[(ManualTransaction='Yes') ]"/>
</xsl:variable>
<xsl:if test="($loop != '')"> <tr> <td colspan="5"></td> </tr> <tr> <td colspan="5"> <span> <h2> Monthly Charges for <xsl:apply-templates select="ItemGroup/UserTopParent"/> </h2> </span> </td> </tr> <tr> <td colspan="5"> <span> <h3> <xsl:apply-templates select="ItemGroup/User"/> </h3> </span> </td> </tr> <tr> <td width="2%"></td> <td width="48%">Detail</td> <td width="40%">Period Billed</td> <td width="10%" align="center">Amount</td> </tr>
</xsl:if>
<xsl:for-each select="ItemGroup/Item"> <xsl:variable name="manual"> <xsl:value-of select="ManualTransaction"/> </xsl:variable> <xsl:if test="($manual = 'Yes')"> <tr> <td></td> <td> <b> <xsl:value-of select="Detail"/> </b> </td> <xsl:if test="count(PeriodStart)>0"> <td> <b> <xsl:value-of select="PeriodStart"/> - <xsl:value-of select="PeriodEnd"/> </b> </td> </xsl:if> <xsl:if test="count(PeriodStart)=0"> <td> <b> <xsl:value-of select="TransactionDate"/> - <xsl:value-of select="TransactionDate"/> </b> </td> </xsl:if> <td align="center"> <b> $<xsl:value-of select="Amount"/> </b> </td> </tr>
</xsl:if>
</xsl:for-each>
</xsl:template>


How to Omit Account Detail Rows Where All Transactions are Zero


In the invoice detail, if you have accounts with zero dollar transactions, you can make sure they don’t show up in the detail with this piece of code

Note: the below code as inserted into the 'ItemGroup' element

HTML SECTION

<xsl:template match="ItemGroup">
<xsl:variable name="showsubaccount">
<xsl:for-each select="Item">
<xsl:if test="Amount != 0.00"> <xsl:value-of select="Amount"></xsl:value-of>
</xsl:if>
</xsl:for-each> </xsl:variable> <xsl:if test="$showsubaccount !=''"> <tr> <td colspan="6"></td> </tr> <tr> <td colspan="6"> <span> <h2> Monthly Charges for <xsl:apply-templates select="User"/> </h2> </span> </td> </tr> <tr> <td width="2%"></td> <td width="58%">Service</td> <td width="20%" colspan="2" align="center">Period</td> <td width="10%" align="center">Amount</td> </tr> <xsl:apply-templates select="Item"/> <xsl:apply-templates select="InvoiceItemsSubtotal"/>
</xsl:if>
</xsl:template>This allows you to create new tokens if one does not exist, for example when you want to add taxes token with the invoice charges token and display the sum of the two.


Adding XSL Tokens

This allows you to create new tokens if one does not exist, for example when you want to add taxes token with the invoice charges token and display the sum of the two.

Note: When adding variables / tokens, if your format includes commas  (ie $1,234.00 as opposed to $1234.00) to delineate thousands for example, you need to first strip the comma out of the token, perform the calculation, then add it back in using the XML formatting of numbers.

HTML SECTION

<xsl:copy-ofselect="$totalDue"/>

XSL SECTION

<xsl:variablename="previousBalance">
<xsl:value-ofselect="InvoicePreviousAccountBalance"/>
</xsl:variable>
<xsl:variablename="invoiceTotal">
<xsl:value-ofselect="InvoiceTotal"/>
</xsl:variable>
<xsl:variablename="totalDue"select="$previousBalance + $invoiceTotal" />Formatting Token ValuesTo format the value from tokens to 2 decimal places (ie: $278.00), insert the extra code here within your select tags.<xsl:copy-of select="format-number(TokenNamehere,'#,###.00')"/>

Formatting Token Values

To format the value from tokens to 2 decimal places (ie: $278.00), insert the extra code here within your select tags.
<xsl:copy-of select=”format-number(TokenNamehere,’#,###.00′)”/>


Defining the Sort Order of Your Data

This code provides a way to sort your returned data, ascending, descending, based on a particular column of data

The below is an example and an article link for how you might sort your data. The below example can be found and its detailed here: http://msdn.microsoft.com/en-us/library/ms950734.aspx

<xsl:template match="ItemUserServiceProfile">
<xsl:if test="count(Profile)>0">
<xsl:for-each select="Profile">
<xsl:sort data-type="text" select="ProfileQuestion" order="asecending" />
<xsl:if test="ProfileQuestion = 'Access Circuit Type'">
<xsl:if test="ProfileAnswer = 'DSL'">
<xsl:value-of select="ProfileAnswer"/>
</xsl:if>
</xsl:if>
<xsl:if test="ProfileQuestion = 'Location'">
<xsl:value-of select="ProfileAnswer"/>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:template>

Breakout Prorated Charges and Full Period Charges

This allows you to separate out prorated charges and full period charges on the invoice

HTML SECTION

<xsl:apply-templates select="InvoiceServiceGroupRecurringAndProrate"/>

XSL SECTION

<xsl:template match="InvoiceServiceGroupRecurringAndProrate">
<xsl:apply-templates select="InvoiceServiceItem"/> <tr> <td width="1%"></td> <td colspan="4"> <HR width="40%" align="right" /> </td> </tr> <tr> <td width="1%"></td> <td colspan="3" align="right"> Recurring Total: </td> <td align="right">
<xsl:apply-templates select="RecurringAndProrateTotal"/> </td> </tr> <tr> <td colspan="5"> <HR width="100%" align="right"/> <HR width="100%" align="right"/> </td> </tr>
</xsl:template>Convert Duration to Minutes


Convert Duration to Minutes


This allows you to convert the duration for telecom invoices to minutes

<xsl:template name="convertdurationtomin">
<xsl:param name="duration"/>
<xsl:variable name="hour" select='substring-before($duration, ":")' />
<xsl:variable name="rest" select='substring-after($duration, ":")' />
<xsl:variable name="min" select='substring-before($rest, ":")' />
<xsl:variable name="sec" select='substring-after($rest, ":")' />
<xsl:value-of select="floor( $hour * 60) + $min + ($sec div 60)" />
</xsl:template>

PAID Invoice Stamp

This code allows you to add an image showing that the invoice is PAID already when sending to customers.

Enter the following XLT code your template wherever you would like the PAID stamp to show. Make sure the URL or directory location is accessible to your end user (e.g. a customer portal webserver is a good place to put the image).

<xsl:if test="(Total)='0.00'"><img border="0" src="C:/Program Files/EngageIP/AdminPortal/images/paid.gif" width="255" height="60"></img>
</xsl:if>

Tax Breakout (not per user)

This is a breakout of taxes at the bottom of your invoice. This is not displayed per user.

HTML HEADER

<style type="text/css">.taxh {font-family:Arial; font-size:12px; font-weight:bold; color:798200; border-top:solid 3px #000000; border-bottom:solid 1px #000000; margin-bottom:5px;} .taxch {font-family:Arial; font-size:10px;font-weight:bold;} .taxb {font-family:Arial; font-size:10px;} .taxf {font-family:Arial; font-size:10px;font-weight:bold;}
</style>

HTML BODY

<!--TAX-->
<xsl:variable name="Tax" select="sum(/Invoice/UserTaxesByDisplayName/UserTax/Tax/TaxAmount)"/>
<xsl:if test ="$Tax!=0"><tr> <td colspan="6" align="center"> <p>Taxes</p> </td> </tr>
<xsl:for-each select="/Invoice/UserTaxesByDisplayName/UserTax/Tax">
<xsl:sort select="TaxName"/> <tr>
<xsl:apply-templates select="TaxName"/><xsl:apply-templates select="TaxAmount"/> </tr>
</xsl:for-each> <tr>
<td colspan="6"> <hr /> </td> </tr><tr> <td colspan="3" align="left"> <b>Total Taxes and Surcharges</b> </td> <td colspan="3" align="right"> <b> $
<xsl:value-of select="format-number(($Tax), '#,###,##0.00')"/> </b> </td> </tr>
</xsl:if> Place this after the </Body> Tag.
<xsl:template match="TaxName"> <td colspan="3">
<xsl:value-of select="." /> </td>
</xsl:template>
<xsl:template match="TaxAmount"> <td align="right" colspan="3"> $<xsl:value-of select="." /> </td>
</xsl:template>


Tax Breakout PER User


Install before  <xsl:template match="Invoice"> <xsl:key name="keyAccountType" match="Invoice/UserTaxesByDisplayName/UserTax" use="User" />   Install in line of the page structure.

<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="5"> <h1>Tax Summary</h1> </td> </tr> <tr> <td Width="40%">Description</td> <td Width="20%">From</td> <td Width="12%" align="right">Price</td> <td Width="10%" align="right">Qty</td> <td Width="13%" align="right">Charge</td> </tr>
<xsl:apply-templates select="Taxes"/> <tr> <td colspan="5" style="color:#fff">.</td> </tr> <tr><td colspan="4" align="left"> <b>Total Tax Summary</b> </td> <td align="right"><xsl:choose> <xsl:when test="Taxtotal>0 or Taxtotal=0"> $
<xsl:value-of select="format-number(Taxtotal,'#,###,##0.00')" />
</xsl:when>
<xsl:otherwise> ($<xsl:value-of select="format-number(user:RemoveMinus(Taxtotal),'#,###,##0.00')" />)
</xsl:otherwise>
</xsl:choose>
</td> </tr> </table>3) Bottom Section - install with other template at bottom
<xsl:template match="Taxes"> <xsl:for-each select="//Invoice/UserTaxesByDisplayName/UserTax[generate-id(.) = generate-id(key('keyAccountType', User)[1])]"> <xsl:sort select="User"/>
<xsl:variable name="User" select="User"/><tr> <td> <b> <xsl:copy-of select="$User"/> </b> </td> </tr>
<xsl:for-each select="//Invoice/UserTaxesByDisplayName/UserTax[User=$User]/Tax"><tr> <td><xsl:value-of select="TaxName"/> </td> <td colspan="4" align="right">
<xsl:choose>
<xsl:when test="TaxAmount>0 or TaxAmount=0"> $<xsl:value-of select="format-number(TaxAmount,'#,###,##0.00')" /> </xsl:when> <xsl:otherwise> ($<xsl:value-of select="format-number(user:RemoveMinus(TaxAmount),'#,###,##0.00')" />)
</xsl:otherwise>
</xsl:choose> </td> </tr> </xsl:for-each> <xsl:variable name ="UserTax" select="sum(//Invoice/UserTaxesByDisplayName/UserTax[User=$User]/Tax/TaxAmount)"/> <tr> <td> <b> Total for <xsl:copy-of select="$User"/> </b> </td> <td colspan="5" align="right"> <b>
<xsl:choose>
<xsl:when test="$UserTax>0 or $UserTax=0"> $<xsl:value-of select="format-number($UserTax,'#,###,##0.00')" />
</xsl:when>
<xsl:otherwise> ($<xsl:value-of select="format-number(user:RemoveMinus($UserTax),'#,###,##0.00')" />)
</xsl:otherwise>
</xsl:choose> </b> </td> </tr>
</xsl:for-each>
</xsl:template >


Date Formatting

If you need to format your date, you can use a substring method for example to trim a 4 digit year to a 2 digit year. Because the date is not in a UTC format, you cannot currently use the standard XSL date formatting methods

  • No labels