src/org/openbravo/erpCommon/ad_forms/DocOrder_data.xsql
author Iván Perdomo <ivan.perdomo@openbravo.com>
Thu, 24 Apr 2008 17:12:02 +0000
changeset 770 8850d5956eba
parent 423 ecf368072c48
child 799 fef2c5e2feb7
permissions -rw-r--r--
Bug fix [0000111]. Modified mapping name used on manual code.
carlos@0
     1
<?xml version="1.0" encoding="UTF-8" ?>
carlos@0
     2
<!--
carlos@0
     3
 ******************************************************************************
carlos@0
     4
 * The contents of this file are subject to the   Compiere License  Version 1.1
carlos@0
     5
 * ("License"); You may not use this file except in compliance with the License
carlos@0
     6
 * You may obtain a copy of the License at http://www.compiere.org/license.html
carlos@0
     7
 * Software distributed under the License is distributed on an  "AS IS"  basis,
carlos@0
     8
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
carlos@0
     9
 * the specific language governing rights and limitations under the License.
carlos@0
    10
 * The Original Code is                  Compiere  ERP & CRM  Business Solution
carlos@0
    11
 * The Initial Developer of the Original Code is Jorg Janke  and ComPiere, Inc.
carlos@0
    12
 * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
carlos@0
    13
 * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
carlos@0
    14
 * Contributor(s): Openbravo SL
carlos@0
    15
 * Contributions are Copyright (C) 2001-2006 Openbravo S.L.
carlos@0
    16
 ******************************************************************************
carlos@0
    17
-->
carlos@0
    18
carlos@0
    19
carlos@0
    20
carlos@0
    21
carlos@0
    22
carlos@0
    23
<SqlClass name="DocOrderData" package="org.openbravo.erpCommon.ad_forms">
carlos@0
    24
  <SqlClassComment></SqlClassComment>
carlos@0
    25
  <SqlMethod name="select" type="preparedStatement" return="multiple">
carlos@0
    26
    <SqlMethodComment></SqlMethodComment>
carlos@0
    27
    <Sql>
carlos@0
    28
      <![CDATA[
carlos@0
    29
        SELECT it.C_Tax_ID, t.Name, t.Rate, it.TaxBaseAmt, it.TaxAmt, '' AS C_ORDER_ID, '' AS AD_CLIENT_ID, '' AS AD_ORG_ID, '' AS ISACTIVE,
carlos@0
    30
        '' AS CREATED, '' AS CREATEDBY, '' AS UPDATED, '' AS UPDATEDBY, '' AS ISSOTRX, '' AS DOCUMENTNO, '' AS DOCSTATUS, '' AS DOCACTION,
carlos@0
    31
        '' AS PROCESSING, '' AS PROCESSED, '' AS C_DOCTYPE_ID, '' AS C_DOCTYPETARGET_ID, '' AS DESCRIPTION, '' AS ISAPPROVED, '' AS ISCREDITAPPROVED,
carlos@0
    32
        '' AS ISDELIVERED, '' AS ISPRINTED, '' AS ISSELECTED, '' AS SALESREP_ID, '' AS DATEORDERED, '' AS DATEPROMISED, '' AS DATEPRINTED,
carlos@0
    33
        '' AS DATEACCT, '' AS C_BPARTNER_ID, '' AS BILLTO_ID, '' AS C_BPARTNER_LOCATION_ID, '' AS POREFERENCE, '' AS ISDISCOUNTPRINTED,
carlos@0
    34
        '' AS C_CURRENCY_ID, '' AS PAYMENTRULE, '' AS C_PAYMENTTERM_ID, '' AS INVOICERULE, '' AS DELIVERYRULE, '' AS FREIGHTCOSTRULE,
carlos@0
    35
        '' AS FREIGHTAMT, '' AS DELIVERYVIARULE, '' AS M_SHIPPER_ID, '' AS C_CHARGE_ID, '' AS CHARGEAMT, '' AS PRIORITYRULE, '' AS TOTALLINES,
carlos@0
    36
        '' AS GRANDTOTAL, '' AS M_WAREHOUSE_ID, '' AS M_PRICELIST_ID, '' AS ISTAXINCLUDED, '' AS C_CAMPAIGN_ID, '' AS C_PROJECT_ID, '' AS C_ACTIVITY_ID,
carlos@0
    37
        '' AS POSTED, '' AS SENDEMAIL, '' AS AD_USER_ID, '' AS COPYFROM, '' AS DROPSHIP_BPARTNER_ID, '' AS DROPSHIP_LOCATION_ID,
carlos@0
    38
        '' AS DROPSHIP_USER_ID, '' AS ISSELFSERVICE, '' AS AD_ORGTRX_ID, '' AS USER1_ID, '' AS USER2_ID, '' AS DELIVERYNOTES, '' AS C_INCOTERMS_ID,
carlos@0
    39
        '' AS INCOTERMSDESCRIPTION, '' AS GENERATETEMPLATE, '' AS ISINVOICED, '' AS ISTRANSFERRED
carlos@0
    40
        FROM C_Tax t, C_OrderTax it 
carlos@423
    41
        WHERE t.C_Tax_ID=it.C_Tax_ID AND it.C_Order_ID = TO_NUMBER(?)
carlos@0
    42
     ]]>
carlos@0
    43
     </Sql>
carlos@0
    44
     <Parameter name="C_Order_ID"/>
carlos@0
    45
   </SqlMethod>
carlos@0
    46
  <SqlMethod name="selectRegistro" type="preparedStatement" return="multiple">
carlos@0
    47
    <SqlMethodComment></SqlMethodComment>
carlos@0
    48
    <Sql>
carlos@0
    49
      <![CDATA[
carlos@0
    50
        SELECT O.AD_CLIENT_ID, O.AD_ORG_ID, O.C_BPARTNER_ID, O.AD_ORGTRX_ID, O.C_PROJECT_ID, 
carlos@0
    51
        O.C_CAMPAIGN_ID, O.C_ACTIVITY_ID, O.USER1_ID, O.USER2_ID, O.DOCUMENTNO, O.DATEACCT,
carlos@0
    52
        O.C_CURRENCY_ID, O.C_DOCTYPE_ID, O.C_CHARGE_ID, O.CHARGEAMT, O.POSTED, O.DATEORDERED,
carlos@0
    53
        O.ISTAXINCLUDED, O.GRANDTOTAL, O.TOTALLINES
carlos@0
    54
        FROM C_ORDER O          
carlos@423
    55
        WHERE AD_Client_ID = TO_NUMBER(?) 
carlos@423
    56
        AND C_ORDER_ID = TO_NUMBER(?)
carlos@0
    57
     ]]>
carlos@0
    58
     </Sql>
carlos@0
    59
     <Parameter name="client"/>
carlos@0
    60
     <Parameter name="id"/>
carlos@0
    61
   </SqlMethod>
carlos@0
    62
  <SqlMethod name="updateProductPO" type="preparedStatement" connection="true" return="rowCount">
carlos@0
    63
    <SqlMethodComment></SqlMethodComment>
carlos@0
    64
    <Sql>
carlos@0
    65
      <![CDATA[
carlos@0
    66
          UPDATE M_Product_PO SET PriceLastPO = (SELECT AVG(C_Currency_Convert(to_number(ol.PriceActual),to_number(ol.C_Currency_ID),to_number(M_Product_PO.C_Currency_ID),to_date(o.DateOrdered),to_char(null),to_number(o.AD_Client_ID),to_number(o.AD_Org_ID)))
carlos@0
    67
                  FROM C_Order o, C_OrderLine ol 
carlos@0
    68
                  WHERE o.C_Order_ID = ol.C_Order_ID
carlos@0
    69
                  AND M_Product_PO.M_Product_ID = ol.M_Product_ID AND M_Product_PO.C_BPartner_ID=o.C_BPartner_ID
carlos@423
    70
                  AND o.C_Order_ID = TO_NUMBER(?))
carlos@0
    71
          WHERE EXISTS (SELECT * FROM C_Order o, C_OrderLine ol 
carlos@0
    72
                  WHERE o.C_Order_ID = ol.C_Order_ID
carlos@0
    73
                  AND M_Product_PO.M_Product_ID = ol.M_Product_ID AND M_Product_PO.C_BPartner_ID=o.C_BPartner_ID
carlos@423
    74
                  AND o.C_Order_ID = TO_NUMBER(?))
carlos@0
    75
     ]]>
carlos@0
    76
     </Sql>
carlos@0
    77
     <Parameter name="Record_ID"/>
carlos@0
    78
     <Parameter name="Record_ID"/>
carlos@0
    79
   </SqlMethod>
carlos@0
    80
  <SqlMethod name="updateProductCosting" type="preparedStatement" connection="true" return="rowCount">
carlos@0
    81
    <SqlMethodComment></SqlMethodComment>
carlos@0
    82
    <Sql>
carlos@0
    83
      <![CDATA[
carlos@0
    84
        UPDATE M_Product_Costing 
carlos@0
    85
        SET PriceLastPO = (SELECT AVG(C_Currency_Convert(to_number(ol.PriceActual),to_number(ol.C_Currency_ID),to_number(a.C_Currency_ID),to_date(o.DateOrdered),to_char(null),to_number(o.AD_Client_ID),to_number(o.AD_Org_ID)))
carlos@0
    86
                FROM C_Order o, C_OrderLine ol, C_AcctSchema a 
carlos@0
    87
                WHERE o.C_Order_ID=ol.C_Order_ID
carlos@0
    88
                AND M_Product_Costing.M_Product_ID=ol.M_Product_ID AND M_Product_Costing.C_AcctSchema_ID=a.C_AcctSchema_ID
carlos@423
    89
                AND M_Product_Costing.C_AcctSchema_ID = TO_NUMBER(?)
carlos@423
    90
                AND o.C_Order_ID = TO_NUMBER(?))
carlos@0
    91
        WHERE EXISTS (SELECT * FROM C_Order o, C_OrderLine ol, C_AcctSchema a 
carlos@0
    92
                WHERE o.C_Order_ID = ol.C_Order_ID
carlos@0
    93
                AND M_Product_Costing.M_Product_ID=ol.M_Product_ID AND M_Product_Costing.C_AcctSchema_ID=a.C_AcctSchema_ID
carlos@423
    94
                AND M_Product_Costing.C_AcctSchema_ID = TO_NUMBER(?)
carlos@423
    95
                AND o.C_Order_ID = TO_NUMBER(?))
carlos@0
    96
     ]]>
carlos@0
    97
     </Sql>
carlos@0
    98
     <Parameter name="C_AcctSchema_ID"/>
carlos@0
    99
     <Parameter name="Record_ID"/>
carlos@0
   100
     <Parameter name="C_AcctSchema_ID"/>
carlos@0
   101
     <Parameter name="Record_ID"/>
carlos@0
   102
   </SqlMethod>
carlos@0
   103
   </SqlClass>