Accounting export template CielXimport

Revision as of 14:16, 30 January 2013 by Jcheng (Talk | contribs) (Created page with "<xml><?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" media-type="text/pl...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
<?xml version="1.0" encoding="ISO-8859-1"?>
<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>cp850</charset>
            <file_prefix>xImport_</file_prefix>
            <file_extension>txt</file_extension>
            <converter>ISO2ASCII</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"/>
        <xsl:variable name="line">
            <!-- entry number on 5 strings -->
            <xsl:call-template name="replace-zero-head-by-white-space">
                <xsl:with-param name="entry" select="format-number($flow_id, '00000')"/>
            </xsl:call-template>
            <!-- paper on 2 strings -->
            <xsl:call-template name="choose-paper">
                <xsl:with-param name="flowAccounts" select="$accounts"/>
            </xsl:call-template>
            <!-- date on 16 strings -->
            <xsl:call-template name="displayDate">
                <xsl:with-param name="date">
                    <xsl:call-template name="dateTimeISO">
                        <xsl:with-param name="dateTime">
                            <xsl:value-of select="converted_account_date"/>
                        </xsl:with-param>
                    </xsl:call-template>
                </xsl:with-param>
            </xsl:call-template>
            <!-- 8 strings -->
            <xsl:text>        </xsl:text>
            <!-- type on 12 strings -->
            <xsl:text>            </xsl:text>
            <!-- account number on 11 strings -->
            <xsl:call-template name="format-text">
                <xsl:with-param name="text" select="account/export_account"/>
                <xsl:with-param name="size" select="11"/>
            </xsl:call-template>
            <!-- account name on 25 strings -->
            <xsl:call-template name="accountExportName">
                <xsl:with-param name="entry" select="account_entry"/>
                <xsl:with-param name="size" select="25"/>
            </xsl:call-template>
            <!-- amount on 13 strings + 1 string to write D or C -->
            <xsl:choose>
                <xsl:when test="debit!=0">
                    <xsl:value-of select="format-number(debit,'0000000000.00')"/>
                    <xsl:text>D</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="format-number(credit,'0000000000.00')"/>
                    <xsl:text>C</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <!-- check number 12 strings -->
            <xsl:text>            </xsl:text>
            <!-- code budget 6 strings -->
            <xsl:text>      </xsl:text>
            <!-- label on 34 strings -->
            <xsl:call-template name="format-text">
                <xsl:with-param name="text">
                    <xsl:call-template name="str.characterRemover">
                        <xsl:with-param name="string2Clean">
                            <xsl:value-of select="comments"/>
                            <xsl:text>&#160;</xsl:text>
                            <xsl:value-of select="flight/comments"/>
                        </xsl:with-param>
                        <xsl:with-param name="character2Remove">
                            <xsl:text></xsl:text>
                        </xsl:with-param>
                    </xsl:call-template>
                </xsl:with-param>
                <xsl:with-param name="size" select="34"/>
            </xsl:call-template>
            <xsl:value-of select="$CR"/><xsl:value-of select="$LF"/>
        </xsl:variable>
        <xsl:value-of select="$line" disable-output-escaping="yes"/>
    </xsl:template>
 
    <xsl:template name="displayDate">
        <xsl:param name="date"/>
        <xsl:value-of select="substring($date,1,4)"/>
        <xsl:value-of select="substring($date,6,2)"/>
        <xsl:value-of select="substring($date,9,2)"/>
    </xsl:template>
 
</xsl:stylesheet>