Create E-Tax Invoice

program.cs

  1.     using CreateETDAInvoiceFromXml;
  2.     using iTextSharp.text;
  3.     using iTextSharp.text.pdf;
  4.     using Saxon.Api;
  5.     using System;
  6.     using System.IO;
  7.  
  8.     namespace CreateEtaxInvoiceUsingXslt2
  9.     {
  10.         class Program
  11.         {
  12.             static void Main(string[] args)
  13.             {
  14.                 string xsltfilename = @"ExampleDesignForETDA_1p0_c1p0_s1p0_2.xsl";
  15.                 string inputfilename = @"Example_TaxInvoice_v2-0.xml";
  16.                 string outputpdfilename = "result.pdf";
  17.  
  18.                 var xslt = new FileInfo(xsltfilename);
  19.                 var input = new FileInfo(inputfilename);
  20.                 var output = new FileInfo(@"result.html");
  21.                 var outputpdf = new FileInfo(outputpdfilename);
  22.  
  23.                 Processor proc = new Processor();
  24.                 proc.RegisterExtensionFunction(new BahtText());
  25.                 XsltCompiler xsltc = proc.NewXsltCompiler();
  26.                 var executable = xsltc.Compile(new Uri(xslt.FullName));
  27.  
  28.                 // Do transformation to a destination
  29.                 var destination = new DomDestination();
  30.  
  31.                 using (var inputStream = input.OpenRead())
  32.                 {
  33.                     var transformer = executable.Load();
  34.                     transformer.SetInputStream(inputStream, new Uri(input.DirectoryName));
  35.                     transformer.Run(destination);
  36.                 }
  37.  
  38.                 File.WriteAllBytes("result.pdf", createPDF(destination.XmlDocument.OuterXml).ToArray());
  39.  
  40.                 // Save result to a file (or whatever else you wanna do)
  41.                 destination.XmlDocument.Save(output.FullName);
  42.                 System.Diagnostics.Process.Start("result.pdf");
  43.             }
  44.  
  45.             private static MemoryStream createPDF(string html)
  46.             {
  47.                 MemoryStream msOutput = new MemoryStream();
  48.                 TextReader reader = new StringReader(html);
  49.  
  50.                 // step 1: creation of a document-object
  51.                 Document document = new Document(PageSize.A4, 30, 30, 30, 30);
  52.  
  53.                 // step 2:
  54.                 // we create a writer that listens to the document
  55.                 // and directs a XML-stream to a file
  56.                 PdfWriter writer = PdfWriter.GetInstance(document, msOutput);
  57.  
  58.                 // step 3: we create a worker parse the document
  59.  
  60.                 //  var worker = new XMLWorker(document);
  61.  
  62.                 /**************************************************
  63.                  * Example #2                                     *
  64.                  *                                                *
  65.                  * Use the XMLWorker to parse the HTML.           *
  66.                  * Only inline CSS and absolutely linked          *
  67.                  * CSS is supported                               *
  68.                  * ************************************************/
  69.                 document.Open();
  70.                 //XMLWorker also reads from a TextReader and not directly from a string
  71.  
  72.                 //Parse the HTML
  73.                 iTextSharp.tool.xml.XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, reader);
  74.  
  75.                 // step 4: we open document and start the worker on the document
  76.  
  77.                 //worker.StartDocument();
  78.  
  79.                 //// step 5: parse the html into the document
  80.                 //worker.Parse(reader);
  81.  
  82.                 //// step 6: close the document and the worker
  83.                 //worker.EndDocument();
  84.                 //  worker.Close();
  85.                 document.Close();
  86.  
  87.                 return msOutput;
  88.             }
  89.         }
  90.     }

Here are some examples on how to use the program (please click on the document to see the sourcecode).

example_taxinvoice.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2.     <rsm:CrossIndustryDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.                                xmlns:rsm="urn:ferd:CrossIndustryDocument:invoice:1p0"
  4.                                xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12"
  5.                                xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15">
  6.         <rsm:SpecifiedExchangedDocumentContext>
  7.             <ram:TestIndicator>
  8.                 <udt:Indicator>false</udt:Indicator>
  9.             </ram:TestIndicator>
  10.             <ram:GuidelineSpecifiedDocumentContextParameter>
  11.                 <ram:ID>urn:ferd:CrossIndustryDocument:invoice:1p0:extended</ram:ID>
  12.             </ram:GuidelineSpecifiedDocumentContextParameter>
  13.         </rsm:SpecifiedExchangedDocumentContext>
  14.         <rsm:HeaderExchangedDocument>
  15.             <ram:ID>322567-53654816</ram:ID>
  16.             <ram:Name>Beitragsrechnung für GS1 Complete 2015</ram:Name>
  17.             <ram:TypeCode>380</ram:TypeCode>
  18.             <ram:IssueDateTime>
  19.                 <udt:DateTimeString format="102">20150731</udt:DateTimeString>
  20.             </ram:IssueDateTime>
  21.             <ram:IncludedNote>
  22.                 <ram:Content></ram:Content>
  23.             </ram:IncludedNote>
  24.             <ram:IncludedNote>
  25.                 <ram:Content>Ihr Antrag vom: 28.07.2015, Herr Johannes Döring</ram:Content>
  26.             </ram:IncludedNote>
  27.             <ram:IncludedNote>
  28.                 <ram:Content>
  29.     Hiermit berechnen wir Ihnen gem. Ziffer III, 1 der Allg. Geschäftsbedingungen im Rahmen Ihrer Teilnahme an GS1 Complete für die Lokationsnummer (GLN):
  30.  
  31.     42 6044293 000 6 Johannes Döring</ram:Content>
  32.             </ram:IncludedNote>
  33.             <ram:IncludedNote>
  34.                 <ram:Content></ram:Content>
  35.             </ram:IncludedNote>
  36.             <ram:IncludedNote>
  37.                 <ram:Content>
  38.     Die Berechnung des jährlichen Nutzungspreises erfolgt auf Basis des von Ihnen gemeldeten Gesamtumsatzes Ihres Unternehmens. Wir behalten uns eine Prüfung und eventuelle Umgruppierung, verbunden mit Nachberechnungen, vor.
  39.     </ram:Content>
  40.             </ram:IncludedNote>
  41.             <ram:IncludedNote>
  42.                 <ram:Content>Vorsitzender des Aufsichtsrates: Erich Harsch Geschäftsführung: Jörg Pretzel Gesellschafter der GS1 Germany: EHI Retail Institute, Markenverband Amtsgericht Köln HRB 6276</ram:Content>
  43.                 <ram:SubjectCode>REG</ram:SubjectCode>
  44.             </ram:IncludedNote>
  45.         </rsm:HeaderExchangedDocument>
  46.         <rsm:SpecifiedSupplyChainTradeTransaction>
  47.             <ram:ApplicableSupplyChainTradeAgreement>
  48.                 <ram:SellerTradeParty>
  49.                     <ram:GlobalID schemeID="0088">4000001000005</ram:GlobalID>
  50.                     <ram:Name>GS1 Germany GmbH</ram:Name>
  51.                     <ram:DefinedTradeContact>
  52.                         <ram:PersonName>yj</ram:PersonName>
  53.                         <ram:TelephoneUniversalCommunication>
  54.                             <ram:CompleteNumber>+49 (221) 94714-333</ram:CompleteNumber>
  55.                         </ram:TelephoneUniversalCommunication>
  56.                         <ram:FaxUniversalCommunication>
  57.                             <ram:CompleteNumber>+49 (221) 94714-7291</ram:CompleteNumber>
  58.                         </ram:FaxUniversalCommunication>
  59.                         <ram:EmailURIUniversalCommunication>
  60.                             <ram:URIID>rechnung@gs1-germany.de</ram:URIID>
  61.                         </ram:EmailURIUniversalCommunication>
  62.                     </ram:DefinedTradeContact>
  63.                     <ram:PostalTradeAddress>
  64.                         <ram:PostcodeCode>50825</ram:PostcodeCode>
  65.                         <ram:LineOne>Maarweg 133</ram:LineOne>
  66.                         <ram:CityName>Köln</ram:CityName>
  67.                         <ram:CountryID>DE</ram:CountryID>
  68.                     </ram:PostalTradeAddress>
  69.                     <ram:SpecifiedTaxRegistration>
  70.                         <ram:ID schemeID="VA">DE122775856</ram:ID>
  71.                     </ram:SpecifiedTaxRegistration>
  72.                 </ram:SellerTradeParty>
  73.                 <ram:BuyerTradeParty>
  74.                     <ram:ID>D322567</ram:ID>
  75.                     <ram:GlobalID schemeID="0088">4260442930006</ram:GlobalID>
  76.                     <ram:Name>Johannes Döring</ram:Name>
  77.                     <ram:PostalTradeAddress>
  78.                         <ram:PostcodeCode>56567</ram:PostcodeCode>
  79.                         <ram:LineOne>Melsbacher Str. 25</ram:LineOne>
  80.                         <ram:CityName>Neuwied</ram:CityName>
  81.                         <ram:CountryID>DE</ram:CountryID>
  82.                     </ram:PostalTradeAddress>
  83.                     <ram:SpecifiedTaxRegistration>
  84.                         <ram:ID schemeID="VA">DE211477959</ram:ID>
  85.                     </ram:SpecifiedTaxRegistration>
  86.                 </ram:BuyerTradeParty>
  87.             </ram:ApplicableSupplyChainTradeAgreement>
  88.             <ram:ApplicableSupplyChainTradeDelivery>
  89.                 <ram:ActualDeliverySupplyChainEvent>
  90.                     <ram:OccurrenceDateTime>
  91.                         <udt:DateTimeString format="102">20150731</udt:DateTimeString>
  92.                     </ram:OccurrenceDateTime>
  93.                 </ram:ActualDeliverySupplyChainEvent>
  94.             </ram:ApplicableSupplyChainTradeDelivery>
  95.             <ram:ApplicableSupplyChainTradeSettlement>
  96.                 <ram:PaymentReference>322567-53654816</ram:PaymentReference>
  97.                 <ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
  98.                 <ram:SpecifiedTradeSettlementPaymentMeans>
  99.                     <ram:TypeCode>31</ram:TypeCode>
  100.                     <ram:Information>sofort netto ohne Abzug</ram:Information>
  101.                     <ram:PayeePartyCreditorFinancialAccount>
  102.                         <ram:IBANID>DE86570900001052005000</ram:IBANID>
  103.                     </ram:PayeePartyCreditorFinancialAccount>
  104.                     <ram:PayeeSpecifiedCreditorFinancialInstitution>
  105.                         <ram:BICID>GENODE51KOB</ram:BICID>
  106.                         <ram:Name>Volksbank Koblenz Mittelrhein eG</ram:Name>
  107.                     </ram:PayeeSpecifiedCreditorFinancialInstitution>
  108.                 </ram:SpecifiedTradeSettlementPaymentMeans>
  109.                 <ram:ApplicableTradeTax>
  110.                     <ram:CalculatedAmount currencyID="EUR">77.90</ram:CalculatedAmount>
  111.                     <ram:TypeCode>VAT</ram:TypeCode>
  112.                     <ram:BasisAmount currencyID="EUR">410.00</ram:BasisAmount>
  113.                     <ram:CategoryCode>S</ram:CategoryCode>
  114.                     <ram:ApplicablePercent>19.00</ram:ApplicablePercent>
  115.                 </ram:ApplicableTradeTax>
  116.                 <ram:BillingSpecifiedPeriod>
  117.                     <ram:StartDateTime>
  118.                         <udt:DateTimeString format="102">20150731</udt:DateTimeString>
  119.                     </ram:StartDateTime>
  120.                     <ram:EndDateTime>
  121.                         <udt:DateTimeString format="102">20151231</udt:DateTimeString>
  122.                     </ram:EndDateTime>
  123.                 </ram:BillingSpecifiedPeriod>
  124.                 <ram:SpecifiedTradePaymentTerms>
  125.                     <ram:Description>Zahlbar sofort ohne Abzug</ram:Description>
  126.                     <ram:DueDateDateTime>
  127.                         <udt:DateTimeString format="102">20150731</udt:DateTimeString>
  128.                     </ram:DueDateDateTime>
  129.                 </ram:SpecifiedTradePaymentTerms>
  130.                 <ram:SpecifiedTradeSettlementMonetarySummation>
  131.                     <ram:LineTotalAmount currencyID="EUR">410.00</ram:LineTotalAmount>
  132.                     <ram:ChargeTotalAmount currencyID="EUR">0.00</ram:ChargeTotalAmount>
  133.                     <ram:AllowanceTotalAmount currencyID="EUR">0.00</ram:AllowanceTotalAmount>
  134.                     <ram:TaxBasisTotalAmount currencyID="EUR">410.00</ram:TaxBasisTotalAmount>
  135.                     <ram:TaxTotalAmount currencyID="EUR">77.90</ram:TaxTotalAmount>
  136.                     <ram:GrandTotalAmount currencyID="EUR">487.25</ram:GrandTotalAmount>
  137.                     <ram:TotalPrepaidAmount currencyID="EUR">0.00</ram:TotalPrepaidAmount>
  138.                     <ram:DuePayableAmount currencyID="EUR">487.90</ram:DuePayableAmount>
  139.                 </ram:SpecifiedTradeSettlementMonetarySummation>
  140.             </ram:ApplicableSupplyChainTradeSettlement>
  141.             <ram:IncludedSupplyChainTradeLineItem>
  142.                 <ram:AssociatedDocumentLineDocument>
  143.                     <ram:LineID>1</ram:LineID>
  144.                 </ram:AssociatedDocumentLineDocument>
  145.                 <ram:SpecifiedSupplyChainTradeAgreement>
  146.                     <ram:GrossPriceProductTradePrice>
  147.                         <ram:ChargeAmount currencyID="EUR">230.0000</ram:ChargeAmount>
  148.                         <ram:BasisQuantity unitCode="C62">1.0000</ram:BasisQuantity>
  149.                     </ram:GrossPriceProductTradePrice>
  150.                     <ram:NetPriceProductTradePrice>
  151.                         <ram:ChargeAmount currencyID="EUR">230.0000</ram:ChargeAmount>
  152.                         <ram:BasisQuantity unitCode="C62">1.0000</ram:BasisQuantity>
  153.                     </ram:NetPriceProductTradePrice>
  154.                 </ram:SpecifiedSupplyChainTradeAgreement>
  155.                 <ram:SpecifiedSupplyChainTradeDelivery>
  156.                     <ram:BilledQuantity unitCode="C62">1.0000</ram:BilledQuantity>
  157.                     <ram:ActualDeliverySupplyChainEvent>
  158.                         <ram:OccurrenceDateTime>
  159.                             <udt:DateTimeString format="102">20150731</udt:DateTimeString>
  160.                         </ram:OccurrenceDateTime>
  161.                     </ram:ActualDeliverySupplyChainEvent>
  162.                 </ram:SpecifiedSupplyChainTradeDelivery>
  163.                 <ram:SpecifiedSupplyChainTradeSettlement>
  164.                     <ram:ApplicableTradeTax>
  165.                         <ram:TypeCode>VAT</ram:TypeCode>
  166.                         <ram:CategoryCode>S</ram:CategoryCode>
  167.                         <ram:ApplicablePercent>19.00</ram:ApplicablePercent>
  168.                     </ram:ApplicableTradeTax>
  169.                     <ram:BillingSpecifiedPeriod>
  170.                         <ram:StartDateTime>
  171.                             <udt:DateTimeString format="102">20150731</udt:DateTimeString>
  172.                         </ram:StartDateTime>
  173.                         <ram:EndDateTime>
  174.                             <udt:DateTimeString format="102">20150731</udt:DateTimeString>
  175.                         </ram:EndDateTime>
  176.                     </ram:BillingSpecifiedPeriod>
  177.                     <ram:SpecifiedTradeSettlementMonetarySummation>
  178.                         <ram:LineTotalAmount currencyID="EUR">230.00</ram:LineTotalAmount>
  179.                     </ram:SpecifiedTradeSettlementMonetarySummation>
  180.                 </ram:SpecifiedSupplyChainTradeSettlement>
  181.                 <ram:SpecifiedTradeProduct>
  182.                     <ram:GlobalID schemeID="0088">4000001016495</ram:GlobalID>
  183.                     <ram:SellerAssignedID>4000001016495</ram:SellerAssignedID>
  184.                     <ram:Name>Bereitstellungspreis für 9-stellige Basisnummer</ram:Name>
  185.                 </ram:SpecifiedTradeProduct>
  186.             </ram:IncludedSupplyChainTradeLineItem>
  187.             <ram:IncludedSupplyChainTradeLineItem>
  188.                 <ram:AssociatedDocumentLineDocument>
  189.                     <ram:LineID>2</ram:LineID>
  190.                 </ram:AssociatedDocumentLineDocument>
  191.                 <ram:SpecifiedSupplyChainTradeAgreement>
  192.                     <ram:GrossPriceProductTradePrice>
  193.                         <ram:ChargeAmount currencyID="EUR">150.0000</ram:ChargeAmount>
  194.                         <ram:BasisQuantity unitCode="C62">1.0000</ram:BasisQuantity>
  195.                     </ram:GrossPriceProductTradePrice>
  196.                     <ram:NetPriceProductTradePrice>
  197.                         <ram:ChargeAmount currencyID="EUR">150.0000</ram:ChargeAmount>
  198.                         <ram:BasisQuantity unitCode="C62">1.0000</ram:BasisQuantity>
  199.                     </ram:NetPriceProductTradePrice>
  200.                 </ram:SpecifiedSupplyChainTradeAgreement>
  201.                 <ram:SpecifiedSupplyChainTradeDelivery>
  202.                     <ram:BilledQuantity unitCode="C62">1.0000</ram:BilledQuantity>
  203.                     <ram:ActualDeliverySupplyChainEvent>
  204.                         <ram:OccurrenceDateTime>
  205.                             <udt:DateTimeString format="102">20150731</udt:DateTimeString>
  206.                         </ram:OccurrenceDateTime>
  207.                     </ram:ActualDeliverySupplyChainEvent>
  208.                 </ram:SpecifiedSupplyChainTradeDelivery>
  209.                 <ram:SpecifiedSupplyChainTradeSettlement>
  210.                     <ram:ApplicableTradeTax>
  211.                         <ram:TypeCode>VAT</ram:TypeCode>
  212.                         <ram:CategoryCode>S</ram:CategoryCode>
  213.                         <ram:ApplicablePercent>19.00</ram:ApplicablePercent>
  214.                     </ram:ApplicableTradeTax>
  215.                     <ram:BillingSpecifiedPeriod>
  216.                         <ram:StartDateTime>
  217.                             <udt:DateTimeString format="102">20150731</udt:DateTimeString>
  218.                         </ram:StartDateTime>
  219.                         <ram:EndDateTime>
  220.                             <udt:DateTimeString format="102">20151231</udt:DateTimeString>
  221.                         </ram:EndDateTime>
  222.                     </ram:BillingSpecifiedPeriod>
  223.                     <ram:SpecifiedTradeSettlementMonetarySummation>
  224.                         <ram:LineTotalAmount currencyID="EUR">150.00</ram:LineTotalAmount>
  225.                     </ram:SpecifiedTradeSettlementMonetarySummation>
  226.                 </ram:SpecifiedSupplyChainTradeSettlement>
  227.                 <ram:SpecifiedTradeProduct>
  228.                     <ram:GlobalID schemeID="0088">4000001020300</ram:GlobalID>
  229.                     <ram:SellerAssignedID>4000001020300</ram:SellerAssignedID>
  230.                     <ram:Name>Jährlicher Nutzungspreis Umsatzstufe 1</ram:Name>
  231.                 </ram:SpecifiedTradeProduct>
  232.             </ram:IncludedSupplyChainTradeLineItem>
  233.             <ram:IncludedSupplyChainTradeLineItem>
  234.                 <ram:AssociatedDocumentLineDocument>
  235.                     <ram:LineID>3</ram:LineID>
  236.                 </ram:AssociatedDocumentLineDocument>
  237.                 <ram:SpecifiedSupplyChainTradeAgreement>
  238.                     <ram:GrossPriceProductTradePrice>
  239.                         <ram:ChargeAmount currencyID="EUR">30.0000</ram:ChargeAmount>
  240.                         <ram:BasisQuantity unitCode="C62">1.0000</ram:BasisQuantity>
  241.                     </ram:GrossPriceProductTradePrice>
  242.                     <ram:NetPriceProductTradePrice>
  243.                         <ram:ChargeAmount currencyID="EUR">30.0000</ram:ChargeAmount>
  244.                         <ram:BasisQuantity unitCode="C62">1.0000</ram:BasisQuantity>
  245.                     </ram:NetPriceProductTradePrice>
  246.                 </ram:SpecifiedSupplyChainTradeAgreement>
  247.                 <ram:SpecifiedSupplyChainTradeDelivery>
  248.                     <ram:BilledQuantity unitCode="C62">1.0000</ram:BilledQuantity>
  249.                     <ram:ActualDeliverySupplyChainEvent>
  250.                         <ram:OccurrenceDateTime>
  251.                             <udt:DateTimeString format="102">20150731</udt:DateTimeString>
  252.                         </ram:OccurrenceDateTime>
  253.                     </ram:ActualDeliverySupplyChainEvent>
  254.                 </ram:SpecifiedSupplyChainTradeDelivery>
  255.                 <ram:SpecifiedSupplyChainTradeSettlement>
  256.                     <ram:ApplicableTradeTax>
  257.                         <ram:TypeCode>VAT</ram:TypeCode>
  258.                         <ram:CategoryCode>S</ram:CategoryCode>
  259.                         <ram:ApplicablePercent>19.00</ram:ApplicablePercent>
  260.                     </ram:ApplicableTradeTax>
  261.                     <ram:BillingSpecifiedPeriod>
  262.                         <ram:StartDateTime>
  263.                             <udt:DateTimeString format="102">20150731</udt:DateTimeString>
  264.                         </ram:StartDateTime>
  265.                         <ram:EndDateTime>
  266.                             <udt:DateTimeString format="102">20150731</udt:DateTimeString>
  267.                         </ram:EndDateTime>
  268.                     </ram:BillingSpecifiedPeriod>
  269.                     <ram:SpecifiedTradeSettlementMonetarySummation>
  270.                         <ram:LineTotalAmount currencyID="EUR">30.00</ram:LineTotalAmount>
  271.                     </ram:SpecifiedTradeSettlementMonetarySummation>
  272.                 </ram:SpecifiedSupplyChainTradeSettlement>
  273.                 <ram:SpecifiedTradeProduct>
  274.                     <ram:GlobalID schemeID="0088">4000001021109</ram:GlobalID>
  275.                     <ram:SellerAssignedID>4000001021109</ram:SellerAssignedID>
  276.                     <ram:Name>Zertifikat Englisch/Deutsch</ram:Name>
  277.                 </ram:SpecifiedTradeProduct>
  278.             </ram:IncludedSupplyChainTradeLineItem>
  279.         </rsm:SpecifiedSupplyChainTradeTransaction>
  280.     </rsm:CrossIndustryDocument>

example_design-for-ETDA.xsl

  1.  
  2.     <?xml version="1.0" encoding="utf-8"?>
  3.     <xsl:stylesheet exclude-result-prefixes="rsm ram udt" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12" xmlns:rsm="urn:ferd:CrossIndustryDocument:invoice:1p0" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15" version="1.0">
  4.       <xsl:output method="xml" indent="yes" encoding="UTF-8" />
  5.       <xsl:template match="/rsm:CrossIndustryDocument">
  6.         <html>
  7.           <head>
  8.             <link rel="stylesheet" type="text/css" href="invoice.css" />
  9.           </head>
  10.           <body>
  11.             <img src="logo.png" alt="Das Company - logo" />
  12.             <br />
  13.             <xsl:apply-templates />
  14.           </body>
  15.         </html>
  16.       </xsl:template>
  17.  
  18.       <xsl:template match="rsm:SpecifiedExchangedDocumentContext" />
  19.       <xsl:template match="rsm:HeaderExchangedDocument">
  20.         <h1 id="header">
  21.           <xsl:value-of select="ram:Name" />
  22.           <xsl:text> </xsl:text>
  23.           <xsl:value-of select="ram:ID" />
  24.         </h1>
  25.         <xsl:apply-templates select="ram:IssueDateTime" />
  26.       </xsl:template>
  27.       <xsl:template match="rsm:SpecifiedSupplyChainTradeTransaction">
  28.         <table width="100%" border="0" id="addresses">
  29.           <tr>
  30.             <td valign="Top" width="10%">
  31.               <b>From:</b>
  32.             </td>
  33.             <td valign="Top" width="40%">
  34.               <xsl:for-each select="ram:ApplicableSupplyChainTradeAgreement/ram:SellerTradeParty">
  35.                 <xsl:call-template name="address" />
  36.               </xsl:for-each>
  37.             </td>
  38.             <td valign="Top" width="10%">
  39.               <b>To:</b>
  40.             </td>
  41.             <td valign="Top" width="40%">
  42.               <xsl:for-each select="ram:ApplicableSupplyChainTradeAgreement/ram:BuyerTradeParty">
  43.                 <xsl:call-template name="address" />
  44.               </xsl:for-each>
  45.             </td>
  46.           </tr>
  47.         </table>
  48.         <table width="100%" id="products">
  49.           <tr class="headerrow">
  50.             <th>#</th>
  51.             <th>Product</th>
  52.             <th>Unit</th>
  53.             <th>Qty.</th>
  54.             <th>Sub.</th>
  55.             <th>Tax%</th>
  56.             <th>Tax</th>
  57.             <th>Total</th>
  58.             <th>Curr.</th>
  59.           </tr>
  60.           <xsl:for-each select="ram:IncludedSupplyChainTradeLineItem">
  61.             <tr>
  62.               <td align="Right">
  63.                 <xsl:value-of select="ram:AssociatedDocumentLineDocument/ram:LineID" />.
  64.               </td>
  65.               <td class="bold">
  66.                 <xsl:value-of select="ram:SpecifiedTradeProduct/ram:Name" />
  67.               </td>
  68.               <td align="Right">
  69.                 <xsl:call-template name="twodecimals">
  70.                   <xsl:with-param name="number" select="ram:SpecifiedSupplyChainTradeAgreement/ram:GrossPriceProductTradePrice/ram:ChargeAmount" />
  71.                 </xsl:call-template>
  72.               </td>
  73.               <td align="Right">
  74.                 <xsl:call-template name="twodecimals">
  75.                   <xsl:with-param name="number" select="ram:SpecifiedSupplyChainTradeDelivery/ram:BilledQuantity" />
  76.                 </xsl:call-template>
  77.               </td>
  78.               <td align="Right">
  79.                 <xsl:value-of select="ram:SpecifiedSupplyChainTradeSettlement/ram:SpecifiedTradeSettlementMonetarySummation/ram:LineTotalAmount" />
  80.               </td>
  81.               <td align="Right">
  82.                 <xsl:value-of select="ram:SpecifiedSupplyChainTradeSettlement/ram:ApplicableTradeTax/ram:ApplicablePercent" />%
  83.               </td>
  84.               <td align="Right">
  85.                 <xsl:call-template name="calcTax">
  86.                   <xsl:with-param name="basis" select="ram:SpecifiedSupplyChainTradeSettlement/ram:SpecifiedTradeSettlementMonetarySummation/ram:LineTotalAmount" />
  87.                   <xsl:with-param name="tax" select="ram:SpecifiedSupplyChainTradeSettlement/ram:ApplicableTradeTax/ram:ApplicablePercent" />
  88.                 </xsl:call-template>
  89.               </td>
  90.               <td align="Right" class="bold">
  91.                 <xsl:call-template name="calcWithTax">
  92.                   <xsl:with-param name="basis" select="ram:SpecifiedSupplyChainTradeSettlement/ram:SpecifiedTradeSettlementMonetarySummation/ram:LineTotalAmount" />
  93.                   <xsl:with-param name="tax" select="ram:SpecifiedSupplyChainTradeSettlement/ram:ApplicableTradeTax/ram:ApplicablePercent" />
  94.                 </xsl:call-template>
  95.               </td>
  96.               <td>
  97.                 <xsl:value-of select="ram:SpecifiedSupplyChainTradeSettlement/ram:SpecifiedTradeSettlementMonetarySummation/ram:LineTotalAmount/@currencyID" />
  98.               </td>
  99.             </tr>
  100.           </xsl:for-each>
  101.         </table>
  102.         <table width="100%" id="totals">
  103.           <tr class="headerrow">
  104.             <th>Tax</th>
  105.             <th>%</th>
  106.             <th>Base amount:</th>
  107.             <th>Tax amount:</th>
  108.             <th>Total</th>
  109.             <th>Curr.</th>
  110.           </tr>
  111.           <xsl:for-each select="ram:ApplicableSupplyChainTradeSettlement/ram:ApplicableTradeTax">
  112.             <tr>
  113.               <td align="Right">
  114.                 <xsl:value-of select="ram:TypeCode" />
  115.               </td>
  116.               <td align="Right">
  117.                 <xsl:value-of select="ram:ApplicablePercent" />
  118.               </td>
  119.               <td align="Right">
  120.                 <xsl:value-of select="ram:BasisAmount" />
  121.               </td>
  122.               <td align="Right">
  123.                 <xsl:value-of select="ram:CalculatedAmount" />
  124.               </td>
  125.               <td align="Right">
  126.                 <xsl:call-template name="calcWithTax">
  127.                   <xsl:with-param name="basis" select="ram:BasisAmount" />
  128.                   <xsl:with-param name="tax" select="ram:ApplicablePercent" />
  129.                 </xsl:call-template>
  130.               </td>
  131.               <td>
  132.                 <xsl:value-of select="ram:CalculatedAmount/@currencyID" />
  133.               </td>
  134.             </tr>
  135.           </xsl:for-each>
  136.           <tr>
  137.             <td class="total" align="Right" colspan="2">Grand total:</td>
  138.             <td class="total" align="Right">
  139.               <xsl:value-of select="ram:ApplicableSupplyChainTradeSettlement/ram:SpecifiedTradeSettlementMonetarySummation/ram:TaxBasisTotalAmount" />
  140.             </td>
  141.             <td class="total" align="Right">
  142.               <xsl:value-of select="ram:ApplicableSupplyChainTradeSettlement/ram:SpecifiedTradeSettlementMonetarySummation/ram:TaxTotalAmount" />
  143.             </td>
  144.             <td class="total" align="Right">
  145.               <xsl:value-of select="ram:ApplicableSupplyChainTradeSettlement/ram:SpecifiedTradeSettlementMonetarySummation/ram:GrandTotalAmount" />
  146.             </td>
  147.             <td class="total">
  148.               <xsl:value-of select="ram:ApplicableSupplyChainTradeSettlement/ram:SpecifiedTradeSettlementMonetarySummation/ram:GrandTotalAmount/@currencyID" />
  149.             </td>
  150.           </tr>
  151.         </table>
  152.         <table id="wireinfo">
  153.           <tr>
  154.             <td colspan="4">
  155.               Please wire the amount due to our bank account using the following reference: <xsl:value-of select="ram:ApplicableSupplyChainTradeSettlement/ram:PaymentReference" />
  156.             </td>
  157.           </tr>
  158.           <tr>
  159.             <th></th>
  160.             <th class="wireheader">Bank</th>
  161.             <th class="wireheader">BIC ID</th>
  162.             <th class="wireheader">IBAN Number</th>
  163.           </tr>
  164.           <xsl:for-each select="ram:ApplicableSupplyChainTradeSettlement/ram:SpecifiedTradeSettlementPaymentMeans">
  165.             <tr>
  166.               <td></td>
  167.               <td>
  168.                 <xsl:value-of select="ram:PayeeSpecifiedCreditorFinancialInstitution/ram:Name" />
  169.               </td>
  170.               <td>
  171.                 <xsl:value-of select="ram:PayeeSpecifiedCreditorFinancialInstitution/ram:BICID" />
  172.               </td>
  173.               <td>
  174.                 <xsl:value-of select="ram:PayeePartyCreditorFinancialAccount/ram:IBANID" />
  175.               </td>
  176.             </tr>
  177.           </xsl:for-each>
  178.         </table>
  179.       </xsl:template>
  180.  
  181.  
  182.       <xsl:template match="udt:DateTimeString">
  183.         <h2 id="date">
  184.           <xsl:choose>
  185.             <xsl:when test="@format='610'">
  186.               <xsl:call-template name="YYYYMM">
  187.                 <xsl:with-param name="date" select="." />
  188.               </xsl:call-template>
  189.             </xsl:when>
  190.             <xsl:when test="@format='616'">
  191.               <xsl:call-template name="YYYYWW">
  192.                 <xsl:with-param name="date" select="." />
  193.               </xsl:call-template>
  194.             </xsl:when>
  195.             <xsl:otherwise>
  196.               <xsl:call-template name="YYYYMMDD">
  197.                 <xsl:with-param name="date" select="." />
  198.               </xsl:call-template>
  199.             </xsl:otherwise>
  200.           </xsl:choose>
  201.         </h2>
  202.       </xsl:template>
  203.  
  204.       <xsl:template name="address">
  205.         <span class="name">
  206.           <xsl:value-of select="ram:Name" />
  207.         </span><br />
  208.         <xsl:value-of select="ram:PostalTradeAddress/ram:LineOne" /><br />
  209.         <xsl:value-of select="ram:PostalTradeAddress/ram:LineTwo" /><br />
  210.         <xsl:value-of select="ram:PostalTradeAddress/ram:CountryID" />-<xsl:value-of select="ram:PostalTradeAddress/ram:PostcodeCode" /><xsl:text> </xsl:text><xsl:value-of select="ram:PostalTradeAddress/ram:CityName" /><br />
  211.         <xsl:for-each select="ram:SpecifiedTaxRegistration/ram:ID">
  212.           <xsl:value-of select="@schemeID" />: <xsl:value-of select="." /><br />
  213.         </xsl:for-each>
  214.       </xsl:template>
  215.  
  216.       <xsl:template name="calcTax">
  217.         <xsl:param name="basis" />
  218.         <xsl:param name="tax" />
  219.         <xsl:call-template name="twodecimals">
  220.           <xsl:with-param name="number" select="($basis * $tax) div 100" />
  221.         </xsl:call-template>
  222.       </xsl:template>
  223.       <xsl:template name="calcWithTax">
  224.         <xsl:param name="basis" />
  225.         <xsl:param name="tax" />
  226.         <xsl:call-template name="twodecimals">
  227.           <xsl:with-param name="number" select="$basis + (($basis * $tax) div 100)" />
  228.         </xsl:call-template>
  229.       </xsl:template>
  230.       <xsl:template name="twodecimals">
  231.         <xsl:param name="number" />
  232.         <xsl:value-of select="format-number(round($number*100) div 100, '0.00')"/>
  233.       </xsl:template>
  234.       <xsl:template name="YYYYMMDD">
  235.         <xsl:param name="date" />
  236.         <xsl:value-of select="substring($date,1,4)" />-<xsl:value-of select="substring($date,5,2)" />-<xsl:value-of select="substring($date,7,2)" />
  237.       </xsl:template>
  238.       <xsl:template name="YYYYMM">
  239.         <xsl:param name="date" />
  240.         <xsl:value-of select="substring($date,1,4)" />-<xsl:value-of select="substring($date,5,2)" />
  241.       </xsl:template>
  242.       <xsl:template name="YYYYWW">
  243.         <xsl:param name="date" />
  244.         <xsl:value-of select="substring($date,1,4)" />; week <xsl:value-of select="substring($date,5,2)" />
  245.       </xsl:template>
  246.     </xsl:stylesheet>