Accounting export template Ebp2012

Revision as of 08:35, 18 September 2012 by Jcheng (Talk | contribs) (Created page with "<xml><?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" media-type="text/plain" ...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text" media-type="text/plain" indent="no" standalone="yes"
        omit-xml-declaration="yes" encoding="ISO-8859-1"/>
    <xsl:strip-space elements="*"/>
 
    <xsl:include href="xsl/str.template.xsl"/>
    <xsl:include href="xsl/formatFunctions.xsl"/>
    <xsl:include href="xsl/accountingFormatFunction.xsl"/>
 
    <!--      Main       -->
    <xsl:template match="/">
        <output-format>
            <content_type>text/plain</content_type>
            <charset>ISO-8859-15</charset>
            <file_prefix>ecriture_</file_prefix>
            <file_extension>txt</file_extension>
            <converter>ISO</converter>
        </output-format>
        <xsl:apply-templates select="account_entrys/account_entry">
            <xsl:sort select="@id" order="ascending" data-type="number"/>
        </xsl:apply-templates>
    </xsl:template>
 
    <!--show account line -->
    <xsl:template match="account_entry">
        <xsl:variable name="flow_id" select="flow_id"/>
        <xsl:variable name="accounts"
            select="/account_entrys/account_entry[flow_id=$flow_id]/account/export_account"/>
        <!-- entry number-->
        <xsl:call-template name="replace-zero-head-by-white-space">
            <xsl:with-param name="entry">
                <xsl:value-of select="format-number($flow_id, '0')"/>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:text>,</xsl:text>
        <!-- date on 6 strings -->
          <xsl:call-template name="displayDate">
            <xsl:with-param name="date">
                <xsl:call-template name="dateTimeISO">
                    <xsl:with-param name="dateTime" select="converted_account_date"/>
                </xsl:call-template>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:text>,</xsl:text>
        <!-- paper on 2 strings -->
        <xsl:call-template name="choose-paper">
            <xsl:with-param name="SalePaperLabel">VE</xsl:with-param>
            <xsl:with-param name="flowAccounts" select="$accounts"/>
        </xsl:call-template>
        <xsl:text>,</xsl:text>
        <!-- account number -->
        <xsl:value-of select="account/export_account"/>
        <xsl:text>,</xsl:text>
        <!-- label on 2 strings -->
        <xsl:text>,</xsl:text>
        <!-- account name on 40 strings -->
        <xsl:text>"</xsl:text>
        <xsl:call-template name="accountExportName">
            <xsl:with-param name="entry" select="account_entry"/>
            <xsl:with-param name="forbiddenCharacter">
                <xsl:text>,</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:text>"</xsl:text>
        <xsl:text>,</xsl:text>
        <!-- Ident number 15 string-->
        <xsl:text>"OF</xsl:text>
        <xsl:value-of select="format-number($flow_id, '000')"/>
        <xsl:text>",</xsl:text>
        <!-- amount + 1 string to write D or C -->
        <xsl:choose>
            <xsl:when test="debit!=0">
                <xsl:value-of select="format-number(debit,'0.00')"/>
                <xsl:text>,D</xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="format-number(credit,'0.00')"/>
                <xsl:text>,C</xsl:text>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:text>,</xsl:text>
        <!-- deadline -->
        <xsl:text>,</xsl:text>
        <xsl:value-of select="$LF"/>
    </xsl:template>
 
    <xsl:template name="displayDate">
        <xsl:param name="date"/>
        <xsl:value-of select="substring($date,9,2)"/>
        <xsl:value-of select="substring($date,6,2)"/>
        <xsl:value-of select="substring($date,3,2)"/>
    </xsl:template>
 
</xsl:stylesheet>