浏览代码

fixed merged from schma

a.binder 8 年之前
父节点
当前提交
0b179ce6d4

+ 69 - 0
SE/schema/WPS_Functions/csv2xml/csv2xml.xsl

@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    exclude-result-prefixes="xs"
+    version="2.0">
+    
+    
+    <xsl:param name="csv2xml" required="yes"/>
+    <xsl:param name="input" required="yes"/>
+    <xsl:param name="output" required="yes"/>
+    <xsl:param name="basedir" required="yes"/>
+    
+    <xsl:output indent="yes"/>
+    <xsl:strip-space elements="*"/>
+    
+    <xsl:template match="csv2xml_dir">
+        <project basedir="{$basedir}" name="csv2xml_dir.child" default="csv2xml_dir.child.run">
+            <target name="csv2xml_dir.child.run">
+                <xsl:for-each select="tokenize(.,';')">
+                    <xsl:variable name="file" select="replace(.,' ','\\ ')"/>
+                    <xsl:variable name="file_out" select="replace(replace(.,' ','_'),'.csv','.xml')"/>
+                    <exec executable="bash"  >
+                        <!--<env key="PATH" path="$PATH:${PATH_ADD}"/>-->
+                        <arg value="-c"/>
+                        <arg value="{$csv2xml} &lt; {$input}/{$file} &gt; {$output}/{$file_out}"/>
+                    </exec>
+                </xsl:for-each>
+            </target>
+        </project>
+    </xsl:template>
+    
+    <xsl:template match="any2xml_dir">
+        <project basedir="{$basedir}" name="csv2xml_dir.child" default="csv2xml_dir.child.run">
+            <target name="csv2xml_dir.child.run">
+                <xsl:for-each select="tokenize(.,';')">
+                    <xsl:variable name="file" select="replace(.,' ',' ')"/>
+                    <xsl:variable name="file_out" select="concat(replace(.,' ','_'),'.xml')"/>
+                    
+                    <xsl:choose>
+                        <xsl:when test=" contains($file,'.xml')">
+                            <mkdir dir="{$output}/{$file_out}"/>
+                            <delete dir="{$output}/{$file_out}"/>
+                            <copy file="{$input}/{$file}" tofile="{$output}/{$file}"/>
+                        </xsl:when>
+                        <!--<xsl:when test="1 = 2"/>-->
+                        <xsl:otherwise>
+                            <loadfile property="{$file}" srcfile="{$input}/{$file}"/>
+                            <mkdir dir="{$output}/{$file_out}"/>
+                            <delete dir="{$output}/{$file_out}"/>
+                            
+                            <echoxml file="{$output}/{$file_out}" >
+                                <any2xml>
+                                    ${<xsl:value-of select="$file"/>}
+                                </any2xml>
+                            </echoxml>
+                        </xsl:otherwise>
+                    </xsl:choose>
+                    
+                </xsl:for-each>
+            </target>
+        </project>
+    </xsl:template>
+    
+    
+    
+    
+    
+    
+</xsl:stylesheet>

+ 56 - 7
SE/schema/WPS_Functions/object_install_se_ant_object/build_object_install_se_ant_object.xsl

@@ -33,10 +33,23 @@
         </system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external>
     </xsl:template>
    
-    <xsl:template match="system_cache__appinfo:get_all_xsd|system_cache__appinfo:get_all_xsd_external_schema" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external"/>
+    <xsl:template match="system_cache__appinfo:get_all_xsd_external_schema" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external"/>
         
    
-    <xsl:template match="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external">
+    <xsl:template match="system_cache__appinfo:get_all_xsd[ schema/( 
+        @targetNamespace='http://biuro.biall-net.pl/xmlschema_procesy5/system_cache/graph_relation_elements.xsd' or
+        @targetNamespace='http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd' or
+        @targetNamespace='http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/p5_obj_vars.xsd'
+        or contains(@targetNamespace,'/default_db_xml_cache/')
+        or contains(@targetNamespace,'/system_cache/')
+        or contains(@targetNamespace,'/default_db/SystemObjects/')
+        ) or contains(@system_cache__appinfo:document-uri,'default_db_xml_cache.public/')]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:message>#44 bypassed @targetNamespace <xsl:value-of select="schema/@targetNamespace" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"/></xsl:message>
+    </xsl:template>
+   
+    
+   
+    <xsl:template match="system_cache__appinfo:get_all_xsd_external_schema_id_namespace_prefix|system_cache__appinfo:get_all_xsd[xs:schema/@targetNamespace='https://biuro.biall-net.pl/wfs/default_db/table/ADMIN_USERS.xsd']" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external">
         <xsl:apply-templates mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external">
             <xsl:with-param name="system_cache__appinfo:document-uri-orig" select="@system_cache__appinfo:document-uri-orig"/>
         </xsl:apply-templates>
@@ -131,9 +144,7 @@
             </xsl:variable>
             <xsl:copy-of select="$schema"/>
             <xsl:comment>#123 saving to <xsl:value-of select="concat($external_schema_table.path,'/',$system_cache__appinfo:document-uri-orig,'/',$schema.prefix,'.xsd')"/></xsl:comment>
-            <xsl:result-document href="{ concat($external_schema_table.path,'/',$system_cache__appinfo:document-uri-orig,'/',$schema.prefix,'.xsd')}">
-                <xsl:copy-of select="$schema"/>
-            </xsl:result-document>
+            
             
             <xsl:message>#135 ant-object install - todo dependency, than install </xsl:message>
             <xsl:for-each select="$schema/schema/element" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
@@ -402,6 +413,25 @@
     
     
     
+    <xsl:template match="element|complexType[contains(@system_cache__appinfo:namespace_uri,$default_db_targetNamespace_detect_string)]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:param name="generate_tables_from_external_root.name" select="@name"/>
+        <xsl:param name="generate_tables_from_external_root.path" select="@name"/>
+        <xsl:param name="targetNamespace" required="yes"/>
+        <xsl:param name="prefix" required="yes"/>
+        <xsl:param name="prefix_root"  required="yes"/>
+        <xsl:param name="targetNamespace_root" required="yes"/>
+        
+        
+        <system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root>
+            <xsl:attribute name="generate_tables_from_external_root.name" select="$generate_tables_from_external_root.name"/>
+            <xsl:attribute name="generate_tables_from_external_root.path" select="$generate_tables_from_external_root.path"/>
+            <xsl:attribute name="prefix" select="$prefix"/>
+            <xsl:attribute name="targetNamespace" select="$targetNamespace"/>
+            <xsl:comment>#427 root element/complexType of $default_db_targetNamespace_detect_string(<xsl:value-of select="$default_db_targetNamespace_detect_string"/>) - we just copying without testing models in this @targetNamespace - To Be modified @2017-10-23</xsl:comment>
+            <xsl:copy-of select="."/>
+        </system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root>
+    </xsl:template>
+    
     <xsl:template match="element" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
         <xsl:param name="generate_tables_from_external_root.name" select="@name"/>
         <xsl:param name="generate_tables_from_external_root.path" select="@name"/>
@@ -543,7 +573,7 @@
         </system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root>
     </xsl:template>-->
     
-    <xsl:template match="complexType[complexType/@name]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+    <xsl:template match="complexType[complexType/@name and not( contains(@system_cache__appinfo:namespace_uri,$default_db_targetNamespace_detect_string))]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_root" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
         <xsl:param name="generate_tables_from_external_root.name" select="@name"/>
         <xsl:param name="generate_tables_from_external_root.path" select="@name"/>
         <xsl:param name="targetNamespace" required="yes"/>
@@ -776,6 +806,9 @@
     
     <xsl:template match="*|text()|comment()" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child.annotation" xpath-default-namespace="http://www.w3.org/2001/XMLSchema"/>
     
+    <xsl:template match="documentation" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child.annotation" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:copy-of select="."/>
+    </xsl:template>
     <xsl:template match="annotation|appinfo" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_child.annotation" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
         <xsl:param name="targetNamespace" required="yes"/>
         <xsl:param name="prefix" required="yes"/>
@@ -1185,7 +1218,23 @@
         </xsl:element>
     </xsl:template>
     
-    <xsl:template match="*" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_mktables">
+    <xsl:template match="element[ contains(.././@targetNamespace,$default_db_targetNamespace_detect_string)]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_mktables" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:element name="{name()}">
+            <xsl:copy-of select="../@*"/>
+            <xsl:copy-of select="@*"/>
+            <xsl:copy-of select="*"/>
+        </xsl:element>
+    </xsl:template>
+    
+    <xsl:template match="complexType[ contains(.././@targetNamespace,$default_db_targetNamespace_detect_string)]" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_mktables" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
+        <xsl:element name="{name()}">
+            <xsl:copy-of select="../@*"/>
+            <xsl:copy-of select="@*"/>
+            <xsl:copy-of select="*"/>
+        </xsl:element>
+    </xsl:template>
+    
+    <xsl:template match="*" mode="system_cache__appinfo:object_install_se_ant_object.generate_tables_from_external_mktables" xpath-default-namespace="http://www.w3.org/2001/XMLSchema">
         <xsl:param name="generate_tables_from_external_root.required_by.path_init"/>
         <xsl:element name="{name()}">
             <xsl:copy-of select="../@*"/>

+ 199 - 62
SE/schema/WPS_Functions/stock_optimize_calculations_raszczyk/stock_optimize_calculations_raszczyk.xsl

@@ -20,7 +20,14 @@
     </xsl:variable>
     
     
-    <xsl:template match="Types__x3A__xlsx:main">
+    <xsl:variable name="cennik_2_sheet_name">
+        <cennik_2_sheet_name>
+            <sheet_source sheet_name="spacerowa">leclerc GD</sheet_source>
+            <sheet_source sheet_name="nowowiejska">leclerc GD</sheet_source>
+            <sheet_source sheet_name="Żeromskiego">leclerc GD</sheet_source>
+            <sheet_source sheet_name="polanki">leclerc GD</sheet_source>
+        </cennik_2_sheet_name>
+    </xsl:variable><xsl:template match="Types__x3A__xlsx:main">
         
         <RelatedFeatureRoot>
             <map title="raport przetwarzania Procesy5 A.Binder"
@@ -37,57 +44,29 @@
                  </xsl:variable>
                 
                 
-                <xsl:variable name="raszczyk_row_prod_local_sum">
+                <xsl:result-document href="temp/raszczyk_row_prod">
+                    <xsl:copy-of select="$raszczyk_row_prod"/>
+                </xsl:result-document><xsl:variable name="raszczyk_row_prod_local_sum">
                     <raszczyk_row_prod_local_sum>
-                        <xsl:apply-templates select="$raszczyk_row_prod" mode="raszczyk_row_prod_local_sum"/>
-                    </raszczyk_row_prod_local_sum>
+                        <xsl:apply-templates select="$raszczyk_row_prod" mode="raszczyk_row_prod_local_sum"><xsl:with-param name="raszczyk_row_prod" select="$raszczyk_row_prod"/>
+                    </xsl:apply-templates></raszczyk_row_prod_local_sum>
                 </xsl:variable>
                 
                  <!--<xsl:copy-of select="$raszczyk_row_prod"/>-->
                 <!--<xsl:copy-of select="$raszczyk_row_prod_local_sum"/>-->
                  
-                <xsl:apply-templates mode="raszczyk_row_prod_local_sum.errors" select="$raszczyk_row_prod_local_sum"/>
-                 
-                <topic id="topic_tabele_efektywnosci_4bb{generate-id()}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-                    xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:topic.xsd">
-                    <title>Sklepy efektywność tabela porownawcza</title>
-                    <body>
-                        <p>
-                            
-                        </p>
-                    </body>
-                    <xsl:apply-templates mode="SKLEPY_EFEKTYWNOSC_TABELE" select="$raszczyk_row_prod_local_sum"/>
-                </topic>
-                 
-                 <topic id="topic_x5j_mrk_4bb{generate-id()}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-                     xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:topic.xsd">
-                     <title>Sklepy efektywność wykresy</title>
-                     <body>
-                         <p>
-                             
-                         </p>
-                     </body>
-                     <xsl:apply-templates mode="SKLEPY_EFEKTYWNOSC" select="$raszczyk_row_prod_local_sum"/>
-                 </topic>
-            
-            
-                <topic id="topic_x5j_mrk_4baab{generate-id()}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-                    xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:topic.xsd">
-                    <title>Całość rapor wykresy</title>
-                    <body>
-                        <p>
-                            
-                        </p>
-                    </body>
-                    <xsl:apply-templates mode="CALOSC" select="$raszczyk_row_prod_local_sum"/>
-                </topic>
+                <xsl:result-document href="temp/raszczyk_row_prod_local_sum">
+                    <xsl:copy-of select="$raszczyk_row_prod_local_sum"></xsl:copy-of>
+                </xsl:result-document>
+                    <xsl:apply-templates mode="raszczyk_row_prod_local_sum.errors" select="$raszczyk_row_prod_local_sum"/><xsl:apply-templates mode="SKLEPY_EFEKTYWNOSC_TABELE" select="$raszczyk_row_prod_local_sum"/>
+                
             
             </map>
         </RelatedFeatureRoot>
     </xsl:template>
     
     
-    <xsl:template match="row[ Nazwa = Grupa ]" mode="raszczyk_row_prod_local_sum">
+    <xsl:template match="row[  lower-case(normalize-space(Nazwa)) =  lower-case(normalize-space(Grupa)) ]" mode="raszczyk_row_prod_local_sum">
         <xsl:message>#77 group ignored <xsl:value-of select="Grupa"/> = <xsl:value-of select="Nazwa"/></xsl:message>
     </xsl:template> <!-- ignore groups -->
     
@@ -138,23 +117,54 @@
     
     
     <xsl:template match="row" mode="raszczyk_row_prod_local_sum">
-        <row><xsl:copy-of select="@*"/>
+        <xsl:param name="raszczyk_row_prod" required="yes"/>
+        <xsl:variable name="Cena">
+            <xsl:choose>
+                <xsl:when test="$cennik_2_sheet_name//sheet_source[@sheet_name = current()/@sheet_name]">
+                    <xsl:variable name="sheet_source" select="$cennik_2_sheet_name//sheet_source[@sheet_name = current()/@sheet_name]/text()"/>
+                    <xsl:message>#158 ustawiam cennik dla <xsl:value-of select="@sheet_name"/> ; produkt <xsl:value-of select="Nazwa"/> , dla zrodla <xsl:value-of select="$sheet_source"/></xsl:message>
+                    <xsl:value-of select="$raszczyk_row_prod//row[@sheet_name = $sheet_source and Nazwa = current()/Nazwa ][1]/Cena"/>
+                </xsl:when>
+                <xsl:otherwise>
+                    <xsl:value-of select="Cena"/>
+                </xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
+        
+        <xsl:variable name="Cena">
+            <xsl:choose>
+                <xsl:when test=" string-length($Cena)  &lt; 1 ">
+                    <xsl:message>#178 Nie bylo ceny na <xsl:value-of select="Nazwa"/> w cenniku doscelowym - ustalam cene x2 <xsl:value-of select="Cena * 2"/> </xsl:message>
+                    <xsl:value-of select="Cena * 2"/>
+                </xsl:when>
+                <xsl:otherwise><xsl:value-of select="$Cena"/></xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
+        
+        <xsl:message>#166 ustalam cene na <xsl:value-of select="$Cena"/> - oryg <xsl:value-of select="Cena"/></xsl:message><row><xsl:copy-of select="@*"/>
         <xsl:apply-templates mode="raszczyk_row_prod_local_sum"/>
         <xsl:element name="wynik">
-            <xsl:value-of select="( Sprzed *  Cena ) - ( Il_zw * build_stock_optimize_calculations_raszczyk:koszt_wytworzenia(Nazwa) )  "/>
+            <xsl:value-of select="( ( Sprzed - Il_zw ) * ( $Cena - build_stock_optimize_calculations_raszczyk:koszt_wytworzenia_all(Nazwa)  )  ) - ( Il_zw * build_stock_optimize_calculations_raszczyk:koszt_wytworzenia(Nazwa) )  "/>
         </xsl:element>
         <xsl:element name="koszt_zwrotu">
             <xsl:value-of select="Il_zw * build_stock_optimize_calculations_raszczyk:koszt_wytworzenia(Nazwa)  "/>
         </xsl:element>
-            <xsl:element name="koszt_wytworzenia">
+            <xsl:element name="Cena_cennik">
+                <xsl:value-of select="$Cena"/>
+            </xsl:element>
+            <xsl:element name="wynik_bez_zwrotu">
+                <xsl:value-of select="( ( Sprzed - Il_zw ) * ( $Cena - build_stock_optimize_calculations_raszczyk:koszt_wytworzenia_all(Nazwa)  )  )   "/>
+            </xsl:element><xsl:element name="koszt_wytworzenia">
                 <xsl:value-of select="build_stock_optimize_calculations_raszczyk:koszt_wytworzenia(Nazwa)  "/>
             </xsl:element>
-        </row>
+        <xsl:element name="koszt_wytworzenia_sur_i_prac">
+                <xsl:value-of select="build_stock_optimize_calculations_raszczyk:koszt_wytworzenia_all(Nazwa)  "/>
+            </xsl:element></row>
     </xsl:template>
     
     <xsl:template match="raszczyk_row_prod" mode="raszczyk_row_prod_local_sum">
-            <xsl:apply-templates mode="raszczyk_row_prod_local_sum"/>
-    </xsl:template>
+            <xsl:param name="raszczyk_row_prod" required="yes"/><xsl:apply-templates mode="raszczyk_row_prod_local_sum"><xsl:with-param name="raszczyk_row_prod" select="$raszczyk_row_prod"/>
+    </xsl:apply-templates></xsl:template>
     
     <xsl:template match="*" mode="raszczyk_row_prod_local_sum">
             <xsl:copy-of select="."/>
@@ -428,10 +438,7 @@
     <xsl:template match="raszczyk_row_prod_local_sum" mode="SKLEPY_EFEKTYWNOSC_TABELE">
        
             
-            <topic id="topic_x5j_{generate-id()}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-                xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:topic.xsd">
-                <title>Tabela wyników dla produktów/sklepów (dla dwóch miesięcy na raz - todo rozdzielenie)  </title>
-                <body>
+            <xsl:variable name="row" select="row"/>
                     
                   <xsl:variable name="Grupy">
                       <Grupy>
@@ -443,7 +450,18 @@
                     
                     <!--<xsl:copy-of select="$Grupy"/>-->
                     
-                    <p><simpletable frame="all" id="simplet_sklep_able_56_{ generate-id()}">
+                    <topic id="topic_x5aaaj_{generate-id()}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:topic.xsd">
+                <title>Tabela wyników dla produktów/sklepów  (2) </title>
+                <body>
+                  
+                    <!--<xsl:copy-of select="$Grupy"/>-->
+                    
+                    
+                    <xsl:for-each-group select="row" group-by="@miesiac">
+                        <xsl:variable name="miesiac" select="@miesiac"/>
+                        <xsl:variable name="miesiac_group" select=" current-group()"/>
+                        <p>Miesiąc <xsl:value-of select="@miesiac"/></p><p><simpletable frame="all" id="simplet_sklep_ablMiese_{position()}_56_{ generate-id()}">
                         
                         <sthead>
                             <stentry>Sklep</stentry>
@@ -455,19 +473,19 @@
                             <stentry>suma</stentry>
                         </sthead>
                         
-                         <xsl:for-each-group select="row" group-by="@sheet_name">
+                         <xsl:for-each-group select="current-group()" group-by="@sheet_name">
                              <strow>
                                     <stentry>
                                         <xsl:value-of select="@sheet_name"/>
                                     </stentry>
-                                    <xsl:variable name="sheet_name" select="current-group()"/>
+                                    <xsl:variable name="sheet_name_group" select="current-group()"/>
                                     <xsl:for-each select="$Grupy/Grupy/Grupa">
                                        <stentry>
-                                           <xsl:value-of select="round(sum($sheet_name/wynik[ ../Grupa = current() and text()]))"/> <!-- [ ../Grupa = current()] -->
+                                           <xsl:value-of select="round(sum($sheet_name_group[Grupa = current()]/wynik[ text()]))"/> <!-- [ ../Grupa = current()] -->
                                        </stentry>
                                     </xsl:for-each>
                                        <stentry>
-                                           <xsl:value-of select="round(sum($sheet_name/wynik [text()]))"/>
+                                           <xsl:value-of select="round(sum( current-group()/wynik [ text()]))"/>
                                        </stentry>
                              </strow>
                             </xsl:for-each-group>
@@ -475,9 +493,9 @@
                             <stentry></stentry>
                             <xsl:for-each select="$Grupy/Grupy/Grupa" >
                                 <stentry>
-                                </stentry>
+                                <xsl:value-of select="round(sum( $miesiac_group [ Grupa = current()]/wynik [text()])) "/></stentry>
                             </xsl:for-each>
-                            <stentry><xsl:value-of select="format-number(sum(row/wynik [text()]),'#.####') "/></stentry>
+                            <stentry><xsl:value-of select="round(sum( current-group()/wynik[ text()])) "/></stentry>
                         </strow>
                         
                         
@@ -488,7 +506,109 @@
                     
                     
                     
+                </xsl:for-each-group>
+                    
+                            <!--<p><simpletable frame="all" id="simplet_sklep_able_56_{ generate-id()}">
+                                <sthead>
+                                    <stentry>Sklep</stentry>
+                                    <xsl:for-each select="$Grupy/Grupy/Grupa" >
+                                        <stentry>
+                                            <xsl:value-of select="."/>
+                                        </stentry>
+                                    </xsl:for-each>
+                                    <stentry>suma</stentry>
+                                </sthead>
+                                
+                                 <xsl:for-each-group select="row" group-by="@sheet_name">
+                                     <strow>
+                                            <stentry>
+                                                <xsl:value-of select="@sheet_name"/>
+                                            </stentry>
+                                            <xsl:variable name="sheet_name" select="current-group()"/>
+                                            <xsl:for-each select="$Grupy/Grupy/Grupa">
+                                               <stentry>
+                                                   <xsl:value-of select="round(sum($sheet_name/wynik[ ../Grupa = current() and text()]))"/> <!-\- [ ../Grupa = current()] -\->
+                                               </stentry>
+                                            </xsl:for-each>
+                                               <stentry>
+                                                   <xsl:value-of select="round(sum($sheet_name/wynik [text()]))"/>
+                                               </stentry>
+                                     </strow>
+                                    </xsl:for-each-group>
+                                <strow>
+                                    <stentry></stentry>
+                                    <xsl:for-each select="$Grupy/Grupy/Grupa" >
+                                        <stentry>
+                                        </stentry>
+                                    </xsl:for-each>
+                                    <stentry><xsl:value-of select="format-number(sum(row/wynik [text()]),'#.####') "/></stentry>
+                                </strow>
+                                
+                                
+                            </simpletable>
+                            </p>-->
+                    
                 </body>
+            <topic id="topic_x5jffas_{generate-id()}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                    xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:topic.xsd">
+                    <title>Tabela sprzedazy dla produktów/sklepów  (2A) </title>  
+                    <body>
+                    <xsl:for-each-group select="row" group-by="@miesiac">
+                        <xsl:variable name="miesiac" select="@miesiac"/>
+                        <xsl:variable name="miesiac_group" select=" current-group()"/>
+                        <p>Miesiąc - Wart_sprzed  <xsl:value-of select="@miesiac"/></p>
+                        <p><simpletable frame="all" id="simplaaet_sklep_ablMissese_{position()}_56_{ generate-id()}">
+                            <sthead>
+                                <stentry>Sklep</stentry>
+                                <xsl:for-each select="$Grupy/Grupy/Grupa" >
+                                    <stentry>
+                                        <xsl:value-of select="."/>
+                                    </stentry>
+                                </xsl:for-each>
+                                <stentry>suma</stentry>
+                            </sthead>
+                            
+                            <xsl:for-each-group select="current-group()" group-by="@sheet_name"> <!-- [@sheet_name='real Gdynia'] -->
+                                <xsl:variable name="current_group" select="current-group()"/>
+                                <strow>
+                                    <stentry>
+                                        <xsl:value-of select="@sheet_name"/>
+                                    </stentry>
+                                    <xsl:variable name="sheet_name" select="@sheet_name"/>
+                                    <xsl:message>#661 anal dla <xsl:value-of select="$sheet_name"/> and miesiac <xsl:value-of select="$miesiac"/></xsl:message>
+                                    <xsl:for-each select="$Grupy/Grupy/Grupa">
+                                        <xsl:variable name="grupa" select="."/>
+                                        <stentry>
+                                            <!--<xsl:value-of select="round(sum(current-group()[ @miesiac = $miesiac and @sheet_name = $sheet_name  and   Grupa = $grupa ]/Wart_sprzed[ text()]))"/>--> <!-- [ ../Grupa = current()] -->
+                                            <xsl:value-of select="round(sum($current_group[ Grupa = $grupa ]/Wart_sprzed[ text()]))"/>
+                                            <!--<debug><xsl:copy-of select="$row[ @miesiac = $miesiac and @sheet_name = $sheet_name  and   Grupa = $grupa ]"></xsl:copy-of></debug>-->
+                                        </stentry>
+                                    </xsl:for-each>
+                                    <stentry>
+                                        <!--<xsl:value-of select="round(sum($row [  @miesiac = $miesiac and @sheet_name = $sheet_name  ]/Wart_sprzed [ text()] ))"/>-->
+                                        <xsl:value-of select="round(sum(current-group()/Wart_sprzed [ text()] ))"/>
+                                    </stentry>
+                                </strow>
+                            </xsl:for-each-group>
+                            <strow>
+                                <stentry></stentry>
+                                <!--<xsl:variable name="curr_gr" select="current-group()"/>-->
+                                <xsl:for-each select="$Grupy/Grupy/Grupa" >
+                                    <stentry>
+                                        <!--<xsl:value-of select="round(sum( $row [  @miesiac = $miesiac and ../Grupa = current()]/Wart_sprzed [text()])) "/>-->
+                                        <xsl:value-of select="round(sum( $miesiac_group [ Grupa = current()]/Wart_sprzed [text()])) "/>
+                                    </stentry>
+                                </xsl:for-each>
+                                <stentry><xsl:value-of select="round(sum(  current-group()/Wart_sprzed[text()]) div 1000 ) "/> kpln</stentry>
+                            </strow>
+                            
+                            
+                        </simpletable>
+                        </p>
+                    </xsl:for-each-group>
+                    </body>
+                </topic>
+                
             </topic>
             
             
@@ -819,11 +939,11 @@
                 <row>
                     <xsl:attribute name="sheet_name" select=" normalize-space($sheet_name)"/>
                     <xsl:choose>
-                        <xsl:when test="@r &lt; $row_month">
+                        <xsl:when test=" number(@r) &lt; number($row_month)">
                             <xsl:attribute name="miesiac" select="'biezacy'"/>
                         </xsl:when>
-                        <xsl:otherwise><xsl:attribute name="miesiac" select="'poprzedni'"/></xsl:otherwise>
-                    </xsl:choose>
+                        <xsl:when test="number(@r) &gt; number($row_month)"><xsl:attribute name="miesiac" select="'poprzedni'"/></xsl:when>
+                    <xsl:otherwise><xsl:message terminate="yes">#979 error with <xsl:copy-of select="@*"></xsl:copy-of> </xsl:message></xsl:otherwise></xsl:choose>
                     <xsl:attribute name="row_month" select="$row_month"/>
                     <xsl:attribute name="r" select="@r"/>
                     <xsl:variable name="c" select="c"/>
@@ -940,7 +1060,22 @@
     </xsl:function>
     
     
-    <xsl:template match="koszty_wytworzenia.csv" mode="build_stock_optimize_calculations_raszczyk:koszty_wytworzenia.xml" xpath-default-namespace="build_stock_optimize_calculations_raszczyk">
+    <xsl:function name="build_stock_optimize_calculations_raszczyk:koszt_wytworzenia_all">
+        <xsl:param name="Nazwa"/>
+        <xsl:message>#991 analyzing <xsl:value-of select="$Nazwa"/></xsl:message>
+        <xsl:choose>
+            <xsl:when test=" count($build_stock_optimize_calculations_raszczyk:koszty_wytworzenia.xml//row[Nazwa = $Nazwa]) &gt; 1">
+                <xsl:message>#993 PODWOJNA CENA KOSZTU DLA <xsl:value-of select="$Nazwa"/></xsl:message>
+                <xsl:value-of select="$build_stock_optimize_calculations_raszczyk:koszty_wytworzenia.xml//row[Nazwa = $Nazwa][1]/KOSZTYLACZNIE"/>
+            </xsl:when>
+            <xsl:when test="$build_stock_optimize_calculations_raszczyk:koszty_wytworzenia.xml//row[Nazwa = $Nazwa]/KOSZTYLACZNIE">
+                <xsl:value-of select="$build_stock_optimize_calculations_raszczyk:koszty_wytworzenia.xml//row[Nazwa = $Nazwa]/KOSZTYLACZNIE"/>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:message>#993B Nie znany produkt <xsl:value-of select="$Nazwa"/></xsl:message>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:function><xsl:template match="koszty_wytworzenia.csv" mode="build_stock_optimize_calculations_raszczyk:koszty_wytworzenia.xml" xpath-default-namespace="build_stock_optimize_calculations_raszczyk">
         <koszty_wytworzenia.xml>
             <xsl:for-each select=" tokenize( text(),'\n')">
                 <row>
@@ -958,7 +1093,9 @@
                         <xsl:when test=" position()=4">
                             <KOSZTPRACY><xsl:value-of select="."/></KOSZTPRACY>
                         </xsl:when>
-                        <xsl:otherwise><col><xsl:value-of select="."/></col></xsl:otherwise>
+                        <xsl:when test=" position()=5">
+                            <KOSZTYLACZNIE><xsl:value-of select="."/></KOSZTYLACZNIE>
+                        </xsl:when><xsl:otherwise><col><xsl:value-of select="."/></col></xsl:otherwise>
                     </xsl:choose>
                     
                 </xsl:for-each>