home *** CD-ROM | disk | FTP | other *** search
/ MacFormat UK 160 - Disc 2 / MF_UK_160_2.iso / pc / DiscContent / Trials / oxygen / samples / fo / Invoice / invoice.xsl < prev   
Encoding:
Extensible Markup Language  |  2005-07-21  |  13.7 KB  |  259 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:fo="http://www.w3.org/1999/XSL/Format"
  3.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  4.     <xsl:output indent="yes"/>
  5.     <xsl:param name="showBankInformation" select="'true'"/>
  6.     <xsl:template match="/">
  7.         <xsl:variable name="totalCost">
  8.             <xsl:call-template name="sum">
  9.                 <xsl:with-param name="index" select="1"/>
  10.                 <xsl:with-param name="n" select="count(/invoice/products/product)"/>
  11.             </xsl:call-template>
  12.         </xsl:variable>
  13.         <fo:root>
  14.             <fo:layout-master-set>
  15.                 <!-- A4 size -->
  16.                 <fo:simple-page-master master-name="invoice" page-height="29.7cm" page-width="21cm">
  17.                     <fo:region-before extent="1in" padding="6pt 1in"
  18.                         border-bottom="0.5pt silver solid" display-align="after"/>
  19.                     <fo:region-body margin="1in 1in"/>
  20.                     <fo:region-after extent="1in" padding="6pt 1in" border-top="0.5pt silver solid" display-align="after"/>
  21.                 </fo:simple-page-master>
  22.             </fo:layout-master-set>
  23.             <fo:page-sequence master-reference="invoice">
  24.                 <!-- 
  25.                 Header
  26.                 -->
  27.                 <fo:static-content flow-name="xsl-region-before">
  28.                     <fo:block font="10pt Arial" text-align="center" padding="0.5in">
  29.                         <fo:inline font-size="250%">
  30.                             <fo:inline font-style="italic">
  31.                                 <xsl:if test="/invoice/@type='proforma'">Proforma Invoice - FO Sample</xsl:if>
  32.                                 <xsl:if test="/invoice/@type='normal'">Invoice - FO Sample</xsl:if>
  33.                                 <xsl:if test="/invoice/@type='quote'">Quote - FO Sample</xsl:if>
  34.                             </fo:inline>
  35.                         </fo:inline>
  36.                     </fo:block>
  37.                 </fo:static-content>
  38.                 <!--
  39.                 Footer 
  40.                 -->
  41.                 <fo:static-content flow-name="xsl-region-after" font-size="80%" text-align="center">
  42.                     <fo:block>
  43.                         <fo:leader leader-length="80%" leader-pattern="rule"
  44.                             alignment-baseline="middle" rule-thickness="0.5pt" color="black"/>
  45.                     </fo:block>
  46.                     <fo:block>Bindery Soft srl - www.binderysoft.com - email to:
  47.                         sales@binderysoft.com - tel +99-341-464822 - tel/fax +99-341-464824</fo:block>
  48.                 </fo:static-content>
  49.                 <!--
  50.                 Content
  51.                 -->
  52.                 <fo:flow flow-name="xsl-region-body" font="14pt Times">
  53.                     <!-- Supplier and customer -->
  54.                     <fo:table table-layout="fixed" width="100%" padding="0.1in">
  55.                         <fo:table-column column-width="proportional-column-width(1)"/>
  56.                         <fo:table-column column-width="proportional-column-width(1)"/>
  57.                         <fo:table-body>
  58.                             <fo:table-row font-weight="bold">
  59.                                 <fo:table-cell padding="0.1in">
  60.                                     <fo:block>Supplier:</fo:block>
  61.                                 </fo:table-cell>
  62.                                 <fo:table-cell padding="0.1in">
  63.                                     <fo:block>Customer:</fo:block>
  64.                                 </fo:table-cell>
  65.                             </fo:table-row>
  66.                             <fo:table-row>
  67.                                 <fo:table-cell>
  68.                                     <fo:block>SC BINDERY SOFT SRL</fo:block>
  69.                                     <fo:block>42 North Street</fo:block>
  70.                                     <fo:block>200782 Portos</fo:block>
  71.                                     <fo:block>France</fo:block>
  72.                                 </fo:table-cell>
  73.                                 <fo:table-cell>
  74.                                     <xsl:apply-templates select="//customer/block"/>
  75.                                 </fo:table-cell>
  76.                             </fo:table-row>
  77.                             <fo:table-row>
  78.                                 <fo:table-cell>
  79.                                     <fo:block>Register of companies: J16364/1998</fo:block>
  80.                                     <fo:block>VAT Reg. No. 50559959</fo:block>
  81.                                 </fo:table-cell>
  82.                                 <fo:table-cell>
  83.                                     <xsl:if test="/invoice/customer/vat">
  84.                                         <fo:block>VAT Reg. No. <xsl:value-of select="/invoice/customer/vat"/>
  85.                                         </fo:block>
  86.                                     </xsl:if>
  87.                                 </fo:table-cell>
  88.                             </fo:table-row>
  89.                         </fo:table-body>
  90.                     </fo:table>
  91.                     <fo:block padding="0.1in"/>
  92.                     <!--
  93.                     Bank.
  94.                     -->
  95.                     <xsl:if test="$showBankInformation='true'">
  96.                         <fo:block font-weight="bold" padding="0.1in"> Bank Information:</fo:block>
  97.                         <fo:block>Comercial Bank ITC</fo:block>
  98.                         <fo:block>Wave Str. nr. 3, Bloc 1-3-5</fo:block>
  99.                         <fo:block>220409 Portos</fo:block>
  100.                         <fo:block>SWIFT: CXITXOBU</fo:block>
  101.                         <xsl:choose>
  102.                             <xsl:when test="invoice/@currency = 'USD'">
  103.                                 <fo:block>Account number: XX6 YZT 1710 1186 7100 2000</fo:block>
  104.                             </xsl:when>
  105.                             <xsl:when test="invoice/@currency = 'GBP'">
  106.                                 <fo:block>Account number: XX6 YZT 1710 1186 7100 4000</fo:block>
  107.                             </xsl:when>
  108.                             <xsl:otherwise>
  109.                                 <fo:block>Account number: XX6 YZT 1710 1186 7100 3000</fo:block>
  110.                             </xsl:otherwise>
  111.                         </xsl:choose>
  112.                     </xsl:if>
  113.                     <!--
  114.                     Info about the invoice, appears fully only for proforma and normal invoice.
  115.                     -->
  116.                     <fo:block padding="0.2in"/>
  117.                     <fo:block margin-left="1in" font-weight="bold">
  118.                         <xsl:if test="/invoice/@type='proforma' or /invoice/@type='normal'">
  119.                             <fo:block>
  120.                                 <xsl:if test="/invoice/@type='proforma'"> Proforma </xsl:if> Invoice
  121.                                 Number: <xsl:value-of select="/invoice/@number"/>
  122.                             </fo:block>
  123.                             <fo:block>Payment method: <xsl:value-of select="invoice/payment-method"/>
  124.                             </fo:block>
  125.                             <fo:block>Date: <xsl:value-of select="invoice/date"/>
  126.                             </fo:block>
  127.                             <fo:block>Delivery: <xsl:value-of select="invoice/delivery"/>
  128.                             </fo:block>
  129.                         </xsl:if>
  130.                         <xsl:if test="/invoice/@type='quote'">
  131.                             <fo:block>Date: <xsl:value-of select="invoice/date"/>
  132.                             </fo:block>
  133.                             <fo:block>Delivery: <xsl:value-of select="invoice/delivery"/>
  134.                             </fo:block>
  135.                         </xsl:if>
  136.                     </fo:block>
  137.                     <fo:block padding="0.2in"/>
  138.                     <!--
  139.             Quantities.
  140.             -->
  141.                     <fo:table table-layout="fixed" width="100%">
  142.                         <fo:table-column column-width="0.5in"/>
  143.                         <fo:table-column column-width="4in"/>
  144.                         <fo:table-column column-width="0.9in"/>
  145.                         <fo:table-column column-width="0.9in"/>
  146.                         <fo:table-body>
  147.                             <fo:table-row font-weight="bold">
  148.                                 <fo:table-cell border="thin silver ridge" background-color="silver">
  149.                                     <fo:block>Qty</fo:block>
  150.                                 </fo:table-cell>
  151.                                 <fo:table-cell border="thin silver ridge" background-color="silver">
  152.                                     <fo:block>Product</fo:block>
  153.                                 </fo:table-cell>
  154.                                 <fo:table-cell border="thin silver ridge" background-color="silver">
  155.                                     <fo:block>Unit Cost</fo:block>
  156.                                 </fo:table-cell>
  157.                                 <fo:table-cell border="thin silver ridge" background-color="silver">
  158.                                     <fo:block>Total Cost</fo:block>
  159.                                 </fo:table-cell>
  160.                             </fo:table-row>
  161.                             <xsl:apply-templates select="//product"/>
  162.                         </fo:table-body>
  163.                     </fo:table>
  164.                     <fo:block>
  165.                         <fo:leader/>
  166.                     </fo:block>
  167.                     <fo:block padding="0.1in"/>
  168.                     <!-- The total -->
  169.                     <fo:table table-layout="fixed" width="100%" padding="0.1in">
  170.                         <fo:table-column column-width="proportional-column-width(1)"/>
  171.                         <fo:table-column column-width="1in"/>
  172.                         <fo:table-body>
  173.                             <fo:table-row>
  174.                                 <fo:table-cell>
  175.                                     <fo:block>Total:</fo:block>
  176.                                 </fo:table-cell>
  177.                                 <fo:table-cell>
  178.                                     <fo:block>
  179.                                         <xsl:value-of select="$totalCost"/>
  180.                                         <xsl:text xml:space="preserve"> </xsl:text>
  181.                                         <xsl:value-of select="/invoice/@currency"/>
  182.                                     </fo:block>
  183.                                 </fo:table-cell>
  184.                             </fo:table-row>
  185.                         </fo:table-body>
  186.                     </fo:table>
  187.                     <!-- Signature -->
  188.                     <fo:block padding="0.2in"/>
  189.                     <fo:block text-align="right" padding="0.1in">
  190.                         <fo:block>Checked by: </fo:block>
  191.                         <fo:inline font-style="italic" font-weight="bold">
  192.                             <xsl:value-of select="/invoice/checked-by"/>
  193.                         </fo:inline>
  194.                     </fo:block>
  195.                     <fo:block padding="0.1in"/>
  196.                     <xsl:if test="/invoice/@type='proforma'">
  197.                         <fo:block font-weight="bold">Please ensure that the full proforma invoice
  198.                             amount is transferred to our account (i.e. Bank charges should not be deducted).</fo:block>
  199.                         <fo:block font-weight="bold"> We will send you the final invoice as soon as
  200.                             we receive the amount in our account, or you confirm the payment. </fo:block>
  201.                     </xsl:if>
  202.                 </fo:flow>
  203.             </fo:page-sequence>
  204.         </fo:root>
  205.     </xsl:template>
  206.     <xsl:template match="block">
  207.         <fo:block>
  208.             <xsl:value-of select="."/>
  209.         </fo:block>
  210.     </xsl:template>
  211.     <xsl:template match="product">
  212.         <fo:table-row>
  213.             <fo:table-cell border="thin silver ridge">
  214.                 <fo:block>
  215.                     <xsl:value-of select="quantity"/>
  216.                 </fo:block>
  217.             </fo:table-cell>
  218.             <fo:table-cell border="thin silver ridge">
  219.                 <fo:block>
  220.                     <xsl:value-of select="description"/>
  221.                 </fo:block>
  222.             </fo:table-cell>
  223.             <fo:table-cell border="thin silver ridge">
  224.                 <fo:block text-align="right">
  225.                     <xsl:value-of select="unit-cost"/>
  226.                     <xsl:text xml:space="preserve"> </xsl:text>
  227.                     <xsl:value-of select="/invoice/@currency"/>
  228.                 </fo:block>
  229.             </fo:table-cell>
  230.             <fo:table-cell border="thin silver ridge">
  231.                 <fo:block text-align="right">
  232.                     <xsl:value-of select="quantity*unit-cost"/>
  233.                     <xsl:text xml:space="preserve"> </xsl:text>
  234.                     <xsl:value-of select="/invoice/@currency"/>
  235.                 </fo:block>
  236.             </fo:table-cell>
  237.         </fo:table-row>
  238.     </xsl:template>
  239.     <xsl:template name="sum">
  240.         <xsl:param name="index" select="1"/>
  241.         <xsl:param name="n" select="0"/>
  242.         <xsl:choose>
  243.             <xsl:when test="$index > $n">
  244.                 <xsl:value-of select="0"/>
  245.             </xsl:when>
  246.             <xsl:otherwise>
  247.                 <xsl:variable name="sum2">
  248.                     <xsl:call-template name="sum">
  249.                         <xsl:with-param name="index" select="$index+1"/>
  250.                         <xsl:with-param name="n" select="$n"/>
  251.                     </xsl:call-template>
  252.                 </xsl:variable>
  253.                 <xsl:value-of select="$sum2 + /invoice/products/product[position()=$index]/quantity * /invoice/products/product[position()=$index]/unit-cost"/>
  254.             </xsl:otherwise>
  255.         </xsl:choose>
  256.     </xsl:template>
  257.     <xsl:template match="*"/>
  258. </xsl:stylesheet>
  259.