<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" encoding="UTF-8"/>

<xsl:template match="/">
<xsl:comment>factuurnr;factuurdatum;opdrachtnr;omschrijving;bedrag;btwperc;btwbedrag;document</xsl:comment>
<xsl:for-each select="/cXML/Request/InvoiceDetailRequest/InvoiceDetailOrder/InvoiceDetailItem[Tax/TaxDetail/TaxableAmount/Money != '0.00']">
<xsl:sort select="Extrinsic[@name='orderLineReference']" data-type="number"/>
<xsl:value-of select="../../InvoiceDetailRequestHeader/@invoiceID"/>;<xsl:value-of select="substring(../../InvoiceDetailRequestHeader/@invoiceDate,7,2)"/><xsl:value-of select="substring(../../InvoiceDetailRequestHeader/@invoiceDate,5,2)"/><xsl:value-of select="substring(../../InvoiceDetailRequestHeader/@invoiceDate,1,4)"/>;<xsl:choose><xsl:when test="Extrinsic[@name='customerReference']!='' and not(contains(Extrinsic[@name='customerReference'], 'Pakbon'))"><xsl:value-of select="Extrinsic[@name='customerReference']"/></xsl:when><xsl:otherwise>-</xsl:otherwise></xsl:choose>;<xsl:call-template name="puntkomma"><xsl:with-param name="p_string"><xsl:value-of select="InvoiceDetailItemReference/ItemID/SupplierPartID"/> - <xsl:value-of select="@quantity"/> x <xsl:value-of select="UnitOfMeasure"/><xsl:text>  </xsl:text><xsl:value-of select="substring(InvoiceDetailItemReference/Description/ShortName,1,20)"/> (<xsl:value-of select="Extrinsic[@name='brand']"/>) <xsl:value-of select="Extrinsic[@name='content']"/></xsl:with-param></xsl:call-template>;<xsl:apply-templates select="." mode="bedrag_excl_btw_product"/>;<xsl:value-of select="Tax/TaxDetail/@percentageRate"/>;;\\vogellanden\dfs$\Programs\Facilitor\DigitaleFacturen\DeliXL\Factuur_<xsl:value-of select="../../InvoiceDetailRequestHeader/@invoiceID"/>.pdf;<xsl:value-of select="Extrinsic[@name='classificationCategory']/Classification"/>;&#10;</xsl:for-each>
<xsl:for-each select="/cXML/Request/InvoiceDetailRequest/InvoiceDetailOrder/InvoiceDetailItem[InvoiceDetailLineSpecialHandling/Money != '' and Tax/TaxDetail/TaxableAmount/Money != '0.00']">
<xsl:sort select="Extrinsic[@name='orderLineReference']" data-type="number"/>
<xsl:value-of select="../../InvoiceDetailRequestHeader/@invoiceID"/>;<xsl:value-of select="substring(../../InvoiceDetailRequestHeader/@invoiceDate,7,2)"/><xsl:value-of select="substring(../../InvoiceDetailRequestHeader/@invoiceDate,5,2)"/><xsl:value-of select="substring(../../InvoiceDetailRequestHeader/@invoiceDate,1,4)"/>;C195;<xsl:call-template name="puntkomma"><xsl:with-param name="p_string">EMBALLAGE BIJ REF. <xsl:value-of select="Extrinsic[@name='customerReference']"/>: <xsl:value-of select="InvoiceDetailItemReference/ItemID/SupplierPartID"/> - <xsl:value-of select="@quantity"/> x <xsl:value-of select="UnitOfMeasure"/><xsl:text>  </xsl:text><xsl:value-of select="substring(InvoiceDetailItemReference/Description/ShortName,1,20)"/> (<xsl:value-of select="Extrinsic[@name='brand']"/>) <xsl:value-of select="Extrinsic[@name='content']"/></xsl:with-param></xsl:call-template>;<xsl:apply-templates select="." mode="bedrag_excl_btw_emballage"/>;0;;\\vogellanden\dfs$\Programs\Facilitor\DigitaleFacturen\DeliXL\Factuur_<xsl:value-of select="../../InvoiceDetailRequestHeader/@invoiceID"/>.pdf;032000;&#10;</xsl:for-each>
<xsl:for-each select="/cXML/Request/InvoiceDetailRequest/InvoiceDetailOrder/InvoiceDetailItem[InvoiceDetailLineSpecialHandling/Money != '' and Tax/TaxDetail/TaxableAmount/Money = '0.00']">
<xsl:sort select="Extrinsic[@name='orderLineReference']" data-type="number"/>
<xsl:value-of select="../../InvoiceDetailRequestHeader/@invoiceID"/>;<xsl:value-of select="substring(../../InvoiceDetailRequestHeader/@invoiceDate,7,2)"/><xsl:value-of select="substring(../../InvoiceDetailRequestHeader/@invoiceDate,5,2)"/><xsl:value-of select="substring(../../InvoiceDetailRequestHeader/@invoiceDate,1,4)"/>;<xsl:choose><xsl:when test="Extrinsic[@name='customerReference']!='' and not(contains(Extrinsic[@name='customerReference'], 'Pakbon'))"><xsl:value-of select="Extrinsic[@name='customerReference']"/></xsl:when><xsl:otherwise>-</xsl:otherwise></xsl:choose>;<xsl:call-template name="puntkomma"><xsl:with-param name="p_string"><xsl:value-of select="InvoiceDetailItemReference/ItemID/SupplierPartID"/> - <xsl:value-of select="@quantity"/> x <xsl:value-of select="UnitOfMeasure"/><xsl:text>  </xsl:text><xsl:value-of select="substring(InvoiceDetailItemReference/Description/ShortName,1,20)"/> (<xsl:value-of select="Extrinsic[@name='brand']"/>) <xsl:value-of select="Extrinsic[@name='content']"/></xsl:with-param></xsl:call-template>;<xsl:apply-templates select="." mode="bedrag_excl_btw_emballage"/>;<xsl:value-of select="Tax/TaxDetail/@percentageRate"/>;;\\vogellanden\dfs$\Programs\Facilitor\DigitaleFacturen\DeliXL\Factuur_<xsl:value-of select="../../InvoiceDetailRequestHeader/@invoiceID"/>.pdf;<xsl:value-of select="Extrinsic[@name='classificationCategory']/Classification"/>;&#10;</xsl:for-each>
</xsl:template>

<xsl:template name="puntkomma">
   <xsl:param name="p_string"/>
	<xsl:value-of select="translate($p_string,';',':')"/>
</xsl:template>


<xsl:template match="InvoiceDetailItem" mode="bedrag_excl_btw_product">
	<xsl:value-of select="Tax/TaxDetail/TaxableAmount/Money"/>
</xsl:template>

<xsl:template match="InvoiceDetailItem" mode="bedrag_excl_btw_emballage">
	<xsl:value-of select="InvoiceDetailLineSpecialHandling/Money"/>
</xsl:template>

</xsl:stylesheet>
