<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <global name="SQL" module="Products.ZSQLMethods.SQL"/>
    </pickle>
    <pickle>
      <dictionary>
        <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
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
input_simulation_state:list\r\n
output_simulation_state:list\r\n
group_by_expression\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></string> </value>
        </item>
        <item>
            <key> <string>class_name_</string> </key>
            <value> <string></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_zGetInventory</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>1000</int> </value>
        </item>
        <item>
            <key> <string>src</string> </key>
            <value> <string encoding="cdata"><![CDATA[

SELECT\n
<dtml-if expr="precision is not None">\n
  SUM(ROUND(stock.quantity, <dtml-var precision>)) AS inventory,\n
  SUM(ROUND(stock.quantity, <dtml-var precision>)) AS total_quantity,\n
  SUM(ROUND(stock.total_price, <dtml-var precision>)) AS total_price,\n
<dtml-else>\n
  SUM(stock.quantity) AS inventory,\n
  SUM(stock.quantity) AS total_quantity,\n
  SUM(stock.total_price) AS total_price,\n
</dtml-if>\n
  COUNT(DISTINCT stock.variation_text) AS variation_text,\n
  MAX(stock.resource_uid) AS resource_uid,\n
  COUNT(DISTINCT stock.uid) AS stock_uid,\n
  MAX(stock.date) AS date\n
\n
FROM\n
  stock\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>,\n
    <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain)"> </dtml-if>\n
  <dtml-if selection_report>,\n
    <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report)"> </dtml-if>\n
\n
WHERE\n
  1 = 1\n
<dtml-if where_expression>\n
  AND <dtml-var where_expression>\n
</dtml-if>\n
\n
<dtml-if omit_simulation>\n
  AND stock.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
\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>\'<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>\'<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>\'<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>\'<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>\'<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 <dtml-var group_by_expression>\n
</dtml-if>\n
<dtml-if order_by_expression>\n
ORDER BY\n
  <dtml-var order_by_expression>\n
</dtml-if>\n
\n


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