# HG changeset patch
# User Olivier CAYROL (Logilab) <Olivier.Cayrol@logilab.fr>
# Date 1381255114 -7200
# Tue Oct 08 19:58:34 2013 +0200
# Node ID 303104f5754e1e85f8b68e5ad14a8069269d31f0
# Parent 9c86c5fe0d13ef751dd9a047f828bc7d5f9da94c
Export du grand livre au format CSV (closes #256948)
# User Olivier CAYROL (Logilab) <Olivier.Cayrol@logilab.fr>
# Date 1381255114 -7200
# Tue Oct 08 19:58:34 2013 +0200
# Node ID 303104f5754e1e85f8b68e5ad14a8069269d31f0
# Parent 9c86c5fe0d13ef751dd9a047f828bc7d5f9da94c
Export du grand livre au format CSV (closes #256948)
@@ -203,10 +203,11 @@
1 """ 2 cmd = '%s %s %s' % (FOP_CMD, src, dest) 3 os.system(cmd) 4 5 CSV_XSL = {'balance': 'balance2csv.xslt', 6 + 'grand-livre': 'grand-livre2csv.xslt', 7 } 8 9 def write_csv(config, compta, date_ext, debut, fin): 10 """ 11 Ecrit tout en csv
@@ -0,0 +1,147 @@
12 +<?xml version="1.0" encoding="ISO-8859-1"?> 13 + 14 +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 15 + 16 + <xsl:import href="common.xslt"/> 17 + 18 + <xsl:output method="text" encoding="ISO-8859-1" /> 19 + 20 + <xsl:param name="societe.def" select="'../xml/societe.xml'"/> 21 + 22 + <xsl:decimal-format decimal-separator="," grouping-separator="."/> 23 + 24 + <xsl:variable name="societe" select="document($societe.def)/societe"/> 25 + <xsl:variable name="plan_comptable" select="document($societe/plan-comptable/text())/plan-comptable"/> 26 + 27 + <xsl:variable name="ext"> 28 + <xsl:choose> 29 + <xsl:when test="substring(/grand-livre/@debut,0,8) = substring(/grand-livre/@fin,0,8)"> 30 + <!-- Grand Livre mensuel --> 31 + <xsl:value-of select="substring(/grand-livre/@debut,0,8)"/> 32 + <xsl:text>.</xsl:text> 33 + </xsl:when> 34 + <xsl:otherwise> 35 + <!-- Grand Livre annuel --> 36 + <xsl:text></xsl:text> 37 + </xsl:otherwise> 38 + </xsl:choose> 39 + </xsl:variable> 40 + 41 + 42 +<xsl:template match="grand-livre"> 43 + <xsl:text>Comptabilit� </xsl:text> 44 + <xsl:value-of select="$societe/nom"/> 45 + <xsl:text> -- Grand Livre du </xsl:text> 46 + <xsl:value-of select="@debut"/> 47 + <xsl:text> au </xsl:text> 48 + <xsl:value-of select="@fin"/> 49 + <xsl:text> 50 +</xsl:text> 51 + <xsl:text>Les sommes sont port�es en Euros. Le s�parateur d�cimal est la virgule. Le fichier utilise le jeu de caract�res 'Europe de l'Ouest' (ISO-8859-1). 52 +</xsl:text> 53 + 54 + <xsl:apply-templates select="compte"/> 55 + 56 +</xsl:template> 57 + 58 + 59 +<!-- compte --> 60 +<xsl:template match="compte"> 61 + 62 + <xsl:text> 63 + 64 +Compte </xsl:text> 65 + <xsl:value-of select="@num"/> 66 + <xsl:text>�- </xsl:text> 67 + <xsl:apply-templates select="$plan_comptable"> 68 + <xsl:with-param name="numero" select="@num"/> 69 + </xsl:apply-templates> 70 + <xsl:text> 71 + 72 +</xsl:text> 73 + 74 + <xsl:text>Date;Libell�;D�bit;Cr�dit 75 +</xsl:text> 76 + 77 + <!-- Report --> 78 + <xsl:text> 79 +</xsl:text> 80 + <xsl:choose> 81 + <xsl:when test="@report-debit > @report-credit"> 82 + <xsl:text>;"Report d�bit";</xsl:text> 83 + <xsl:value-of select="format-number( 84 + (@report-debit - @report-credit) div 100, 85 + '###0,00' )"/> 86 + <xsl:text>; 87 +</xsl:text> 88 + </xsl:when> 89 + <xsl:when test="@report-debit = @report-credit"> 90 + <xsl:text>;"Report �quilibr�";; 91 +</xsl:text> 92 + </xsl:when> 93 + <xsl:otherwise> 94 + <xsl:text>;"Report cr�dit";;</xsl:text> 95 + <xsl:value-of select="format-number( 96 + (@report-credit - @report-debit) div 100, 97 + '###0,00' )"/> 98 + <xsl:text> 99 +</xsl:text> 100 + </xsl:otherwise> 101 + </xsl:choose> 102 + 103 + <xsl:text> 104 +</xsl:text> 105 + 106 + <!-- �critures de d�bit et cr�dit --> 107 + <xsl:apply-templates select="debit|credit"/> 108 + 109 + <!-- Total compte --> 110 + <xsl:text> 111 +</xsl:text> 112 + <xsl:choose> 113 + <xsl:when test="@debit > @credit"> 114 + <xsl:text>;"COMPTE D�BITEUR";</xsl:text> 115 + <xsl:value-of select="format-number( 116 + (@debit - @credit) div 100, 117 + '###0,00' )"/> 118 + <xsl:text>; 119 +</xsl:text> 120 + </xsl:when> 121 + <xsl:when test="@debit = @credit"> 122 + <xsl:text>;"COMPTE �QUILIBR�";; 123 +</xsl:text> 124 + </xsl:when> 125 + <xsl:otherwise> 126 + <xsl:text>;"COMPTE CR�DITEUR";;</xsl:text> 127 + <xsl:value-of select="format-number( 128 + (@credit - @debit) div 100, 129 + '###0,00' )"/> 130 + <xsl:text> 131 +</xsl:text> 132 + </xsl:otherwise> 133 + </xsl:choose> 134 + 135 +</xsl:template> 136 + 137 + 138 +<!-- ligne d�bit ou cr�dit --> 139 +<xsl:template match="debit | credit"> 140 + 141 + <xsl:value-of select="@date"/> 142 + <xsl:text>;</xsl:text> 143 + <xsl:text>"</xsl:text> 144 + <xsl:value-of select="translate(text(),'"',"'")"/> 145 + <xsl:text>";</xsl:text> 146 + <xsl:if test="self::credit"> 147 + <xsl:text>;</xsl:text> 148 + </xsl:if> 149 + <xsl:value-of select="format-number(@montant div 100,'###0,00')"/> 150 + <xsl:if test="self::debit"> 151 + <xsl:text>;</xsl:text> 152 + </xsl:if> 153 + <xsl:text> 154 +</xsl:text> 155 + 156 +</xsl:template> 157 + 158 +</xsl:stylesheet>