src/org/openbravo/erpCommon/ad_actionButton/CopyFromPOOrder_data.xsql
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Wed, 03 Sep 2008 17:55:37 +0000
changeset 1605 8a0fe0193bef
parent 822 e1461ebeeabe
child 1675 825158077da0
permissions -rw-r--r--
Merge r2.5x intro trunk
carlos@0
     1
<?xml version="1.0" encoding="ISO-8859-1" ?>
carlos@0
     2
<!--
carlos@0
     3
 *************************************************************************
carlos@0
     4
 * The contents of this file are subject to the Openbravo  Public  License
carlos@0
     5
 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
carlos@0
     6
 * Version 1.1  with a permitted attribution clause; you may not  use this
carlos@0
     7
 * file except in compliance with the License. You  may  obtain  a copy of
carlos@0
     8
 * the License at http://www.openbravo.com/legal/license.html 
carlos@0
     9
 * Software distributed under the License  is  distributed  on  an "AS IS"
carlos@0
    10
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
carlos@0
    11
 * License for the specific  language  governing  rights  and  limitations
carlos@0
    12
 * under the License. 
carlos@0
    13
 * The Original Code is Openbravo ERP. 
carlos@0
    14
 * The Initial Developer of the Original Code is Openbravo SL 
carlos@818
    15
 * All portions are Copyright (C) 2001-2008 Openbravo SL 
carlos@0
    16
 * All Rights Reserved. 
carlos@0
    17
 * Contributor(s):  ______________________________________.
carlos@0
    18
 ************************************************************************
carlos@0
    19
-->
carlos@0
    20
carlos@0
    21
carlos@0
    22
<SqlClass name="CopyFromPOOrderData" package="org.openbravo.erpCommon.ad_actionButton">
carlos@0
    23
  <SqlMethod name="select" type="preparedStatement" return="multiple">
carlos@0
    24
    <SqlMethodComment>Principal select</SqlMethodComment>
carlos@0
    25
    <Sql>
carlos@0
    26
      <![CDATA[
carlos@0
    27
        SELECT O.C_BPARTNER_ID, O.C_BPARTNER_LOCATION_ID, O.M_WAREHOUSE_ID, O.C_CURRENCY_ID, O.C_PROJECT_ID,
carlos@0
    28
        O.M_PRICELIST_ID, COALESCE(MAX(OL.LINE),0) AS LINE, O.AD_ORG_ID, O.AD_CLIENT_ID, '' AS C_UOM_ID, '' AS M_PRODUCT_ID,
carlos@0
    29
        '' AS QTYORDERED, '' AS QUANTITYORDER, '' AS M_PRODUCT_UOM_ID,
carlos@0
    30
        '' AS DESCRIPTION, '' AS PRICESTD, '' AS M_OFFER_ID, '' as orderline
carlos@0
    31
        FROM C_ORDER O LEFT JOIN C_ORDERLINE OL ON O.C_ORDER_ID = OL.C_ORDER_ID
juanpablo@1605
    32
        WHERE O.C_ORDER_ID = ?
carlos@0
    33
        GROUP BY O.C_BPARTNER_ID, O.C_BPARTNER_LOCATION_ID, O.M_WAREHOUSE_ID, O.C_CURRENCY_ID, O.C_PROJECT_ID,
carlos@0
    34
        O.M_PRICELIST_ID, O.AD_ORG_ID, O.AD_CLIENT_ID
carlos@0
    35
      ]]>
carlos@0
    36
    </Sql>
carlos@0
    37
    <Parameter name="cOrderId"/>
carlos@0
    38
  </SqlMethod>
carlos@0
    39
  <SqlMethod name="selectLines" type="preparedStatement" return="multiple">
carlos@0
    40
    <SqlMethodComment>select de las lineas</SqlMethodComment>
carlos@0
    41
    <Sql>
carlos@0
    42
      <![CDATA[
carlos@0
    43
        SELECT C_ORDERLINE_ID as orderline, C_UOM_ID, M_PRODUCT_ID, QTYORDERED, QUANTITYORDER,
carlos@0
    44
        M_PRODUCT_UOM_ID, DESCRIPTION, C_CURRENCY_ID
carlos@0
    45
        FROM C_ORDERLINE
juanpablo@1605
    46
        WHERE C_ORDER_ID = ?
carlos@0
    47
      ]]>
carlos@0
    48
    </Sql>
carlos@0
    49
    <Parameter name="cOrderLineId"/>
carlos@0
    50
  </SqlMethod>
carlos@0
    51
  <SqlMethod name="insertCOrderline" type="preparedStatement" connection="true" return="rowCount">
carlos@0
    52
    <SqlMethodComment>Principal select</SqlMethodComment>
carlos@0
    53
    <Sql>
carlos@0
    54
      <![CDATA[
juanpablo@1605
    55
        INSERT INTO C_ORDERLINE 
juanpablo@1605
    56
          (C_ORDERLINE_ID, AD_CLIENT_ID, AD_ORG_ID, CREATED, CREATEDBY, UPDATED, UPDATEDBY,
juanpablo@1605
    57
        C_ORDER_ID, LINE, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID, 
juanpablo@1605
    58
        DATEORDERED, DATEPROMISED, DESCRIPTION, M_PRODUCT_ID, 
juanpablo@1605
    59
        M_WAREHOUSE_ID, C_UOM_ID, QTYORDERED, QUANTITYORDER, QTYINVOICED, QTYDELIVERED, QTYRESERVED, 
juanpablo@1605
    60
        C_CURRENCY_ID, PRICELIST, PRICEACTUAL, 
carlos@818
    61
        PRICELIMIT, C_TAX_ID, DISCOUNT, M_PRODUCT_UOM_ID, PRICESTD, M_OFFER_ID, REF_ORDERLINE_ID) 
juanpablo@1605
    62
        VALUES 
juanpablo@1605
    63
          (?,?,?,TO_DATE(NOW()),?,TO_DATE(NOW()),?,
juanpablo@1605
    64
           ?,TO_NUMBER(?),?,?,
juanpablo@1605
    65
           TO_DATE(?),TO_DATE(?),?,?,
juanpablo@1605
    66
           ?,?,TO_NUMBER(?),TO_NUMBER(?),0,0,0,
juanpablo@1605
    67
           ?,?,M_GET_OFFER_PRICE(M_GET_OFFER(TO_DATE(now()), ?, ?), ?),
juanpablo@1605
    68
           ?,?,?,?,?,M_GET_OFFER(TO_DATE(now()), ?, ?),?)
carlos@0
    69
      ]]>
carlos@0
    70
    </Sql>
carlos@0
    71
    <Parameter name="cOrderlineId"/>
carlos@0
    72
    <Parameter name="adClientId"/>
carlos@0
    73
    <Parameter name="adOrgId"/>
carlos@0
    74
    <Parameter name="user"/>
carlos@0
    75
    <Parameter name="user"/>
carlos@0
    76
    <Parameter name="cOrderId"/>
carlos@0
    77
    <Parameter name="line"/>
carlos@0
    78
    <Parameter name="cBpartnerId"/>
carlos@0
    79
    <Parameter name="cBpartnerLocationId"/>
carlos@0
    80
    <Parameter name="dateordered"/>
carlos@0
    81
    <Parameter name="datepromised"/>
carlos@0
    82
    <Parameter name="description"/>
carlos@0
    83
    <Parameter name="mProductId"/>
carlos@0
    84
    <Parameter name="mWarehouseId"/>
carlos@0
    85
    <Parameter name="cUomId"/>
carlos@0
    86
    <Parameter name="qtyordered"/>
carlos@0
    87
    <Parameter name="quantityorder"/>
carlos@0
    88
    <Parameter name="cCurrencyId"/>
carlos@0
    89
    <Parameter name="pricelist"/>
carlos@0
    90
    <Parameter name="cBpartnerId"/>
carlos@0
    91
    <Parameter name="mProductId"/>
carlos@0
    92
    <Parameter name="priceactual"/>
carlos@0
    93
    <Parameter name="pricelimit"/>
carlos@0
    94
    <Parameter name="cTaxId"/>
carlos@0
    95
    <Parameter name="discount"/>
carlos@0
    96
    <Parameter name="mProductUomId"/>
carlos@0
    97
    <Parameter name="priceactual"/>
carlos@0
    98
    <Parameter name="cBpartnerId"/>
carlos@0
    99
    <Parameter name="mProductId"/>
carlos@0
   100
    <Parameter name="refOrdeline"/>
carlos@0
   101
  </SqlMethod>
carlos@0
   102
  <SqlMethod name="cBPartnerLocationId" type="preparedStatement" return="string">
carlos@0
   103
    <SqlMethodComment>Names of the columns of the fields of a tab</SqlMethodComment>
carlos@0
   104
    <Sql>
carlos@0
   105
      <![CDATA[
carlos@818
   106
        SELECT MAX(C_BPARTNER_LOCATION_ID) AS C_BPARTNER_LOCATION_ID 
carlos@818
   107
        FROM C_BPARTNER_LOCATION
juanpablo@1605
   108
        WHERE C_BPARTNER_ID = ?
carlos@0
   109
        AND C_BPartner_Location.IsActive='Y'
carlos@0
   110
      ]]>
carlos@0
   111
    </Sql>
carlos@0
   112
    <Parameter name="cBpartnerId"/>
carlos@0
   113
  </SqlMethod>
carlos@0
   114
  <SqlMethod name="defaultPriceList" type="preparedStatement" return="string">
carlos@0
   115
    <SqlMethodComment>priceList por defecto</SqlMethodComment>
carlos@0
   116
    <Sql>
carlos@0
   117
      <![CDATA[
carlos@0
   118
        SELECT M_PRICELIST_ID FROM M_PRICELIST
carlos@0
   119
        WHERE ISDEFAULT = 'Y'
carlos@0
   120
        AND ISSOPRICELIST = 'N'
carlos@0
   121
      ]]>
carlos@0
   122
    </Sql>
carlos@0
   123
  </SqlMethod>
carlos@0
   124
</SqlClass>