<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <global name="SQL" module="Products.ZSQLMethods.SQL"/>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>_col</string> </key>
            <value>
              <list>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>path</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>0</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>t</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>155</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>uid</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>0</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>i</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>11</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>relative_url</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>0</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>t</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>147</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>start_date</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>1</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>d</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>19</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>stop_date</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>1</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>d</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>19</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>source_uid</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>1</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>i</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>11</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>destination_uid</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>1</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>i</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>11</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>price</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>1</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>n</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>4</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>total_price</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>1</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>n</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>4</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>quantity</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>1</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>n</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>16</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>node_uid</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>0</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>i</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>11</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>node_title</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>1</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>t</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>26</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>node_relative_url</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>0</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>t</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>27</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>section_uid</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>0</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>i</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>10</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>section_title</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>1</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>t</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>6</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>section_relative_url</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>0</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>t</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>15</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>resource_title</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>1</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>t</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>5</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>resource_uid</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>0</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>i</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>9</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>resource_relative_url</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>0</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>t</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>11</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>variation_text</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>1</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>t</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>41</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>explanation_uid</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>1</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>i</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>11</int> </value>
                  </item>
                </dictionary>
                <dictionary>
                  <item>
                      <key> <string>name</string> </key>
                      <value> <string>simulation_state</string> </value>
                  </item>
                  <item>
                      <key> <string>null</string> </key>
                      <value> <int>1</int> </value>
                  </item>
                  <item>
                      <key> <string>type</string> </key>
                      <value> <string>t</string> </value>
                  </item>
                  <item>
                      <key> <string>width</string> </key>
                      <value> <int>9</int> </value>
                  </item>
                </dictionary>
              </list>
            </value>
        </item>
        <item>
            <key> <string>allow_simple_one_argument_traversal</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>arguments_src</string> </key>
            <value> <string>from_table_list:list\r\n
where_expression\r\n
order_by_expression\r\n
group_by_expression\r\n
limit_expression\r\n
selection_domain\r\n
selection_report\r\n
ignore_variation\r\n
standardize\r\n
omit_simulation\r\n
omit_input\r\n
omit_output\r\n
omit_asset_increase\r\n
omit_asset_decrease\r\n
section_filtered\r\n
initial_running_total_quantity\r\n
initial_running_total_price\r\n
input_simulation_state:list\r\n
output_simulation_state:list\r\n
precision</string> </value>
        </item>
        <item>
            <key> <string>cache_time_</string> </key>
            <value> <int>0</int> </value>
        </item>
        <item>
            <key> <string>class_file_</string> </key>
            <value> <string>ERP5.InventoryBrain</string> </value>
        </item>
        <item>
            <key> <string>class_name_</string> </key>
            <value> <string>MovementHistoryListBrain</string> </value>
        </item>
        <item>
            <key> <string>connection_hook</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>connection_id</string> </key>
            <value> <string>erp5_sql_connection</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Resource_zGetMovementHistoryList</string> </value>
        </item>
        <item>
            <key> <string>max_cache_</string> </key>
            <value> <int>100</int> </value>
        </item>
        <item>
            <key> <string>max_rows_</string> </key>
            <value> <int>0</int> </value>
        </item>
        <item>
            <key> <string>src</string> </key>
            <value> <string encoding="cdata"><![CDATA[

SET @running_total_quantity := <dtml-var initial_running_total_quantity>,\n
    @running_total_price := <dtml-var initial_running_total_price>;\n
<dtml-var sql_delimiter>\n
\n
SELECT \n
  q1.*,\n
  @running_total_quantity := q1.total_quantity + \n
            @running_total_quantity AS running_total_quantity,\n
  @running_total_price := IFNULL(q1.total_price, 0) + \n
            @running_total_price AS running_total_price\n
FROM (\n
SELECT\n
  catalog.path as path,\n
  catalog.uid as uid,\n
  catalog.relative_url as relative_url,\n
  stock.date AS date,\n
<dtml-if expr="precision is not None">\n
  <dtml-if group_by_expression>SUM</dtml-if>(ROUND(stock.quantity, <dtml-var precision>)) AS total_quantity,\n
  <dtml-if group_by_expression>SUM</dtml-if>(ROUND(stock.total_price, <dtml-var precision>)) AS total_price,\n
<dtml-else>\n
  <dtml-if group_by_expression>SUM</dtml-if>(stock.quantity) AS total_quantity,\n
  <dtml-if group_by_expression>SUM</dtml-if>(stock.total_price) AS total_price,\n
</dtml-if>\n
  stock.variation_text AS variation_text,\n
  stock.simulation_state AS simulation_state,\n
  stock.mirror_section_uid AS mirror_section_uid,\n
  stock.mirror_node_uid AS mirror_node_uid,\n
  stock.function_uid AS function_uid,\n
  stock.project_uid AS project_uid,\n
  node.uid AS node_uid,\n
  node.title AS node_title,\n
  node.relative_url AS node_relative_url,\n
  section.uid AS section_uid,\n
  section.title AS section_title,\n
  section.relative_url AS section_relative_url\n
FROM\n
  stock\n
  <dtml-if section_filtered> INNER <dtml-else> LEFT </dtml-if>  \n
        JOIN catalog AS section ON (section.uid = stock.section_uid)\n
<dtml-in prefix="table" expr="from_table_list"> \n
  <dtml-if expr="table_key != \'stock\'">\n
  , <dtml-var table_item> AS <dtml-var table_key>\n
  </dtml-if>\n
</dtml-in>\n
  <dtml-if selection_domain>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain)"> </dtml-if>\n
  <dtml-if selection_report>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report)"> </dtml-if>\n
  , catalog as node, catalog as resource\n
\n
WHERE\n
  1 = 1\n
<dtml-if where_expression>\n
  AND <dtml-var where_expression>\n
</dtml-if>\n
\n
  AND node.uid = stock.node_uid\n
  AND resource.uid = stock.resource_uid\n
\n
<dtml-if omit_simulation>\n
  AND catalog.portal_type != \'Simulation Movement\'\n
</dtml-if>\n
\n
<dtml-if omit_input>\n
  AND ( ( stock.is_cancellation AND stock.quantity > 0 )\n
        OR ( not stock.is_cancellation AND stock.quantity < 0 ))\n
  AND ( stock.node_uid <> stock.mirror_node_uid\n
        OR stock.section_uid <> stock.mirror_section_uid\n
        OR stock.mirror_node_uid IS NULL\n
        OR stock.mirror_section_uid IS NULL\n
        OR stock.payment_uid IS NOT NULL )\n
</dtml-if>\n
<dtml-if omit_output>\n
  AND ( ( stock.is_cancellation AND stock.quantity < 0 )\n
        OR ( not stock.is_cancellation AND stock.quantity > 0 ))\n
  AND ( stock.node_uid <> stock.mirror_node_uid\n
        OR stock.section_uid <> stock.mirror_section_uid\n
        OR stock.mirror_node_uid IS NULL\n
        OR stock.mirror_section_uid IS NULL\n
        OR stock.payment_uid IS NOT NULL )\n
</dtml-if>\n
<dtml-if omit_asset_increase>\n
  AND ( ( stock.is_cancellation AND stock.total_price > 0 )\n
        OR ( not stock.is_cancellation AND stock.total_price < 0 ))\n
  AND ( stock.node_uid <> stock.mirror_node_uid\n
        OR stock.section_uid <> stock.mirror_section_uid\n
        OR stock.mirror_node_uid IS NULL\n
        OR stock.mirror_section_uid IS NULL\n
        OR stock.payment_uid IS NOT NULL )\n
</dtml-if>\n
<dtml-if omit_asset_decrease>\n
  AND ( ( stock.is_cancellation AND stock.total_price < 0 )\n
        OR ( not stock.is_cancellation AND stock.total_price > 0 ))\n
  AND ( stock.node_uid <> stock.mirror_node_uid\n
        OR stock.section_uid <> stock.mirror_section_uid\n
        OR stock.mirror_node_uid IS NULL\n
        OR stock.mirror_section_uid IS NULL\n
        OR stock.payment_uid IS NOT NULL )\n
</dtml-if>\n
\n
<dtml-if input_simulation_state>\n
  <dtml-if output_simulation_state>\n
    <dtml-if "input_simulation_state == output_simulation_state">\n
      AND (<dtml-in input_simulation_state>stock.simulation_state = \'<dtml-var sequence-item>\'\n
        <dtml-unless sequence-end> OR </dtml-unless></dtml-in>)\n
    <dtml-else>\n
      AND ((stock.quantity>0\n
        AND (<dtml-in input_simulation_state>stock.simulation_state = \'<dtml-var sequence-item>\'\n
          <dtml-unless sequence-end> OR </dtml-unless></dtml-in>))\n
      OR (stock.quantity<0\n
        AND (<dtml-in output_simulation_state>stock.simulation_state = \'<dtml-var sequence-item>\'\n
          <dtml-unless sequence-end> OR </dtml-unless></dtml-in>)))\n
    </dtml-if>\n
  <dtml-else>\n
    AND stock.quantity>0\n
    AND (<dtml-in input_simulation_state>stock.simulation_state = \'<dtml-var sequence-item>\'\n
      <dtml-unless sequence-end> OR </dtml-unless></dtml-in>)\n
  </dtml-if>\n
<dtml-elif output_simulation_state>\n
  AND stock.quantity<0\n
  AND (<dtml-in output_simulation_state>stock.simulation_state = \'<dtml-var sequence-item>\'\n
    <dtml-unless sequence-end> OR </dtml-unless></dtml-in>)\n
</dtml-if>\n
\n
<dtml-if selection_domain>\n
  AND <dtml-var "portal_selections.buildSQLExpressionFromDomainSelection(selection_domain, join_table=\'stock\', join_column=\'node_uid\')">\n
</dtml-if>\n
<dtml-if selection_report>\n
  AND <dtml-var "portal_selections.buildSQLExpressionFromDomainSelection(selection_report, strict_membership=1)">\n
</dtml-if>\n
\n
<dtml-if group_by_expression>\n
GROUP BY\n
    <dtml-var group_by_expression>\n
</dtml-if>\n
\n
<dtml-if order_by_expression>\n
ORDER BY\n
  <dtml-var order_by_expression>\n
</dtml-if>\n
\n
<dtml-if limit_expression>\n
LIMIT\n
  <dtml-var limit_expression>\n
</dtml-if>\n
\n
) AS q1\n


]]></string> </value>
        </item>
        <item>
            <key> <string>title</string> </key>
            <value> <string></string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
