Include additional information or notes in the PDF image for XML invoices

XML invoices can contain important information that does not need to be extracted but that should be visible in the invoices to help Verify operators do their job. This could be contact information or special instructions, for example. A single note field for this purpose can be displayed at the end of the PDF image.

To provide this ability, the InvoiceNote field is located at the end of the Fields category on the Fields tab of the XML Mapper. The XML element <Notes></Notes> is mapped to this.

For XML invoice standards that utilize a single note element for additional information

This is automatically built in to those supported XML invoice standards that include additional information in a single XML element (Svefaktura, OIOUBL, OIOXML, General XML).

  • If the <Notes> element is found in the expected location, the information it contains is added to the end of the invoice as an appendix (if the information is long enough, additional appendix pages are added to accommodate it).
  • If the element is in the invoice but not in the correct location, you can map the information to the InvoiceNote field.
  • If the element exists in the XML but is empty, nothing is displayed in the invoice image.
  • XSL can be used in connection with the InvoiceNote field to include all of the XML code in the PDF image (see Examples below).

For XML invoice standards that allow multiple elements for additional information

XML invoice standards such as E2B and Finvoice allow additional information to be added to invoices from multiple XML elements. To be able to include this information at the end of these invoices, XSL snippets need to be specified for the InvoiceNote field:

  1. While in the XML Mapper when optimizing an E2B or Finvoice invoice definition, select the Fields tab to the right in the window, expand the Fields section, and select the InvoiceNote field found at the bottom of the list.
  2. On the Field mapping rules tab to the left in the window towards the bottom, select Use XSL.
  3. Paste the appropriate XSL snippet below in the text box:
    • E2B snippet

The first code sample below should be used if a default XML namespace is declared in the XML file using xmlns, such as <Invoice xmlns="http://www.e2b.no/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance":

<xsl:template match="/">
     <xsl:for-each select="x:Invoice/x:InvoiceHeader/x:FreeText">
               <xsl:value-of select="."/>
               <xsl:text>&#13;</xsl:text>
     </xsl:for-each>
</xsl:template>

If such a declaration is not found, use this code snippet:

<xsl:template match="/">
     <xsl:for-each select="Invoice/InvoiceHeader/FreeText">
               <xsl:value-of select="."/>
               <xsl:text>&#13;</xsl:text>
     </xsl:for-each>
</xsl:template>
  • Finvoice snippet

The first code sample below should be used if a default XML namespace is declared in the XML file using xmlns, such as <Invoice xmlns="http://www.e2b.no/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance:

<xsl:template match="/">
     <xsl:for-each select="x:Finvoice/x:SpecificationDetails/x:SpecificationFreeText">
               <xsl:value-of select="."/>
               <xsl:text>&#13;</xsl:text>
     </xsl:for-each>
</xsl:template>

If such a declaration is not found, use this code snippet:

<xsl:template match="/">
     <xsl:for-each select="Finvoice/SpecificationDetails/SpecificationFreeText">
               <xsl:value-of select="."/>
               <xsl:text>&#13;</xsl:text>
     </xsl:for-each>
</xsl:template>
  1. Click Extract and verify that the extracted comment value is shown in the InvoiceNote field in the list and then click the Image tab to ensure that it appears in the invoice image.

Consider if the change(s) should apply to all documents or only those for the current XML invoice definition. Click Save XML definition to save the change for the current XML invoice definition only (that is, the current sender). Click Save XML profile if you want the rule to apply to all XML invoices that match the XML invoice profile regardless of the XML invoice definition.

  1. Remember to delete invoices and invoice definitions that are connected with the optimized XML invoice definition before the invoices are reinterpreted. (More information.)
Note Every E2B or Finvoice invoice definition in which a note or additional information is to be included in the PDF image must be optimized in this way in order for this to be possible.

Examples

Follow the steps as they are outlined in the previous section for any XML invoice standard (that is, not only E2B and Finvoice), but in step 3, use one of the following XSL snippets instead:

  • Displaying all XML code at the end of the invoice with no special formatting
    <xsl:template match="/">
    <xsl:copy-of select="."/>
    </xsl:template>
  • Listing XML code elements at the end of the invoice in alphabetical order together with the corresponding value in the invoice
<xsl:template match="/">
<xsl:variable name="unique-list" select="//*[not(.=following::*)]"/>
<xsl:for-each select="$unique-list">
<xsl:sort select="name(.)"/>
<xsl:value-of select="name(.)"/>=<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
  • Displaying a simple invoice summary per person at the end of the invoice
<xsl:template match="/">
<!-- Get all unique values of ‘Description‘ -->
      <xsl:for-each select="//cac:InvoiceLine[not(cac:Item/cbc:Description = preceding::cac:Item/cbc:Description)]">
                               <xsl:sort select="cac:Item/cbc:Description"/> <!-- Sort by Description  -->
                             <!-- For each Description -->
                             <xsl:variable name='CurrentPerson' select="cac:Item/cbc:Description" />      <!-- Get value of Description -->
                             <xsl:variable name='NodeForCurrentPerson' select="//cac:InvoiceLine[cac:Item/cbc:Description=$CurrentPerson]" />         <!-- Get node set of Description -->
                             <xsl:variable name='NumOfRows' select="count($NodeForCurrentPerson)" />      <!-- Count number of nodes for Description -->
                             <xsl:variable name='SumOfCost' select="sum($NodeForCurrentPerson/cac:Item/cac:BasePrice/cbc:PriceAmount)" />       <!-- Sum of value of all PriceAmount nodes for Description -->
             Person: <xsl:value-of select="$CurrentPerson"/> #Rows: <xsl:value-of select="$NumOfRows"/>  Totalt:<xsl:value-of select="$SumOfCost"/>         <!-- Compose the value of the Note field -->
      </xsl:for-each>
</xsl:template>