src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending_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 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@0
    15
 * All portions are Copyright (C) 2001-2006 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
carlos@0
    23
carlos@0
    24
carlos@0
    25
<SqlClass name="MaterialReceiptPendingData" package="org.openbravo.erpCommon.ad_forms">
carlos@0
    26
  <SqlClassComment></SqlClassComment>
carlos@0
    27
  <SqlMethod name="select" type="preparedStatement" return="multiple">
carlos@0
    28
    <SqlMethodComment></SqlMethodComment>
carlos@0
    29
    <Sql>
carlos@0
    30
    <![CDATA[
carlos@0
    31
      SELECT C_ORDER.C_ORDER_ID, C_ORDER.AD_CLIENT_ID, C_ORDER.AD_ORG_ID, C_ORDER.ISACTIVE, C_ORDER.CREATED, C_ORDER.CREATEDBY, C_ORDER.UPDATED, C_ORDER.UPDATEDBY, C_ORDER.ISSOTRX, C_ORDER.DOCUMENTNO, C_ORDER.DOCSTATUS, C_ORDER.DOCACTION, C_ORDER.PROCESSING, C_ORDER.PROCESSED, C_ORDER.C_DOCTYPE_ID, C_ORDER.C_DOCTYPETARGET_ID, C_ORDER.DESCRIPTION, C_ORDER.ISAPPROVED, C_ORDER.ISCREDITAPPROVED, C_ORDER.ISDELIVERED, C_ORDER.ISINVOICED, C_ORDER.ISPRINTED, C_ORDER.ISTRANSFERRED, C_ORDER.ISSELECTED, C_ORDER.SALESREP_ID, C_ORDER.DATEORDERED, C_ORDER.DATEPROMISED, C_ORDER.DATEPRINTED, C_ORDER.DATEACCT, C_ORDER.C_BPARTNER_ID, C_ORDER.BILLTO_ID, C_ORDER.C_BPARTNER_LOCATION_ID, C_ORDER.POREFERENCE, C_ORDER.ISDISCOUNTPRINTED, C_ORDER.C_CURRENCY_ID, C_ORDER.PAYMENTRULE, C_ORDER.C_PAYMENTTERM_ID, C_ORDER.INVOICERULE, C_ORDER.DELIVERYRULE, C_ORDER.FREIGHTCOSTRULE, C_ORDER.FREIGHTAMT, C_ORDER.DELIVERYVIARULE, C_ORDER.M_SHIPPER_ID, C_ORDER.C_CHARGE_ID, C_ORDER.CHARGEAMT, C_ORDER.PRIORITYRULE, C_ORDER.TOTALLINES, C_ORDER.GRANDTOTAL, C_ORDER.M_WAREHOUSE_ID, C_ORDER.M_PRICELIST_ID, C_ORDER.ISTAXINCLUDED, C_ORDER.C_CAMPAIGN_ID, C_ORDER.C_PROJECT_ID, C_ORDER.C_ACTIVITY_ID, C_ORDER.POSTED, C_ORDER.SENDEMAIL, C_ORDER.AD_USER_ID, C_ORDER.COPYFROM, C_ORDER.DROPSHIP_BPARTNER_ID, C_ORDER.DROPSHIP_LOCATION_ID, C_ORDER.DROPSHIP_USER_ID, C_ORDER.ISSELFSERVICE, C_ORDER.AD_ORGTRX_ID, C_ORDER.USER1_ID, C_ORDER.USER2_ID, C_ORDER.DELIVERYNOTES, C_ORDER.C_INCOTERMS_ID, C_ORDER.INCOTERMSDESCRIPTION, C_ORDER.GENERATETEMPLATE, '' AS ID, '' AS PARTNER_NAME, '' AS PRODUCT_NAME, '' AS TOTAL_QTY, '' AS QTYORDERED, '' AS DATE_FORMAT
carlos@0
    32
      FROM C_ORDER, C_ORDERLINE
carlos@0
    33
      WHERE C_ORDER.C_ORDER_ID = C_ORDERLINE.C_ORDER_ID
carlos@0
    34
      AND C_ORDER.DOCSTATUS = 'CO'
carlos@423
    35
      AND C_ORDERLINE.C_ORDERLINE_ID = TO_NUMBER(?)
carlos@0
    36
      ]]></Sql>
carlos@0
    37
	<Field name="rownum" value="count"/>
carlos@0
    38
    <Parameter name="cOrderlineId"/>
carlos@0
    39
  </SqlMethod>
carlos@0
    40
  <SqlMethod name="set" type="constant" return="multiple">
carlos@0
    41
      <SqlMethodComment></SqlMethodComment>
carlos@0
    42
      <Sql></Sql>
carlos@0
    43
  </SqlMethod>
carlos@0
    44
  <SqlMethod name="selectLines" type="preparedStatement" return="multiple">
carlos@0
    45
    <SqlMethodComment></SqlMethodComment>
carlos@0
    46
    <Sql>
carlos@0
    47
    <![CDATA[
carlos@0
    48
      SELECT ID, C_ORDER_ID, DOCUMENTNO, DATEORDERED, C_BPARTNER_ID, PARTNER_NAME, PRODUCT_NAME, DESCRIPTION, TOTAL_QTY, QTYORDERED, ISACTIVE, ? AS DATE_FORMAT
carlos@0
    49
      FROM(  
carlos@0
    50
      SELECT C_ORDERLINE.C_ORDERLINE_ID AS ID, C_ORDER.C_ORDER_ID AS C_ORDER_ID, C_ORDER.DOCUMENTNO AS DOCUMENTNO, C_ORDER.DATEORDERED AS DATEORDERED, 
carlos@0
    51
      C_BPARTNER.C_BPARTNER_ID AS C_BPARTNER_ID, C_BPARTNER.NAME AS PARTNER_NAME, 
carlos@0
    52
      AD_COLUMN_IDENTIFIER(TO_CHAR('M_Product'), TO_CHAR(C_ORDERLINE.M_PRODUCT_ID), TO_CHAR('es_ES')) AS PRODUCT_NAME, M_ATTRIBUTESETINSTANCE.DESCRIPTION AS DESCRIPTION, C_ORDERLINE.QTYORDERED AS TOTAL_QTY,
carlos@0
    53
      C_ORDERLINE.QTYORDERED-SUM(COALESCE(M_MATCHPO.QTY,0)) AS QTYORDERED, '-1' AS ISACTIVE
carlos@0
    54
      FROM C_ORDERLINE left join M_MATCHPO on C_ORDERLINE.C_ORDERLINE_ID = M_MATCHPO.C_ORDERLINE_ID
carlos@0
    55
                                           and M_MATCHPO.M_INOUTLINE_ID IS NOT NULL
carlos@0
    56
                       left join M_ATTRIBUTESETINSTANCE on C_ORDERLINE.M_ATTRIBUTESETINSTANCE_ID = M_ATTRIBUTESETINSTANCE.M_ATTRIBUTESETINSTANCE_ID,
carlos@0
    57
      C_ORDER,   C_BPARTNER
carlos@0
    58
      WHERE C_ORDER.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
carlos@0
    59
      AND C_ORDER.C_ORDER_ID = C_ORDERLINE.C_ORDER_ID
carlos@0
    60
      AND C_ORDER.AD_CLIENT_ID IN ('1')
carlos@0
    61
      AND C_ORDER.AD_ORG_ID IN ('1')
carlos@0
    62
      AND C_ORDER.ISSOTRX='N'
carlos@0
    63
      AND C_ORDER.DOCSTATUS = 'CO'
carlos@0
    64
      GROUP BY C_ORDERLINE.C_ORDERLINE_ID, C_ORDER.C_ORDER_ID, C_ORDER.DOCUMENTNO, C_ORDER.DATEORDERED, C_BPARTNER.C_BPARTNER_ID,
carlos@0
    65
      C_BPARTNER.NAME, C_ORDERLINE.M_PRODUCT_ID, M_ATTRIBUTESETINSTANCE.DESCRIPTION, C_ORDERLINE.QTYORDERED
carlos@0
    66
      ORDER BY PARTNER_NAME, DOCUMENTNO, DATEORDERED) A
carlos@0
    67
      WHERE QTYORDERED <>0
carlos@0
    68
      ORDER BY C_BPARTNER_ID, ID
carlos@0
    69
      ]]></Sql>
carlos@0
    70
	<Field name="rownum" value="count"/>
carlos@0
    71
    <Parameter name="dateFormat"/>
carlos@0
    72
    <Parameter name="adUserClient" type="replace" optional="true" after="AND C_ORDER.AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
    73
    <Parameter name="adOrgId" optional="true" type="replace" after="AND C_ORDER.AD_ORG_ID IN (" text="'1'"/>
carlos@0
    74
    <Parameter name="parDateFrom" optional="true" after="AND C_ORDER.ISSOTRX='N'"><![CDATA[ AND C_ORDER.DATEORDERED >= TO_DATE(?)]]></Parameter>
carlos@0
    75
    <Parameter name="parDateTo" optional="true" after="AND C_ORDER.ISSOTRX='N'"><![CDATA[ AND C_ORDER.DATEORDERED < TO_DATE(?)]]></Parameter>
carlos@423
    76
    <Parameter name="parBPartner" optional="true" after="AND C_ORDER.ISSOTRX='N'"> AND C_BPARTNER.C_BPARTNER_ID = TO_NUMBER(?)</Parameter>
gorkaion@310
    77
    <Parameter name="parDocumentNo" optional="true" after="AND C_ORDER.ISSOTRX='N'"> AND C_ORDER.DOCUMENTNO = ?</Parameter>
carlos@0
    78
  </SqlMethod>
carlos@0
    79
  <SqlMethod name="insert" connection="true" type="preparedStatement" return="rowCount">
carlos@0
    80
    <SqlMethodComment></SqlMethodComment>
carlos@0
    81
    <Sql>
carlos@0
    82
      INSERT INTO M_INOUT(M_INOUT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, ISSOTRX, DOCUMENTNO, DOCACTION, DOCSTATUS, POSTED, PROCESSING, PROCESSED, C_DOCTYPE_ID, DESCRIPTION, C_ORDER_ID, DATEORDERED, ISPRINTED, MOVEMENTTYPE, MOVEMENTDATE, DATEACCT, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID, M_WAREHOUSE_ID, POREFERENCE, DELIVERYRULE, FREIGHTCOSTRULE, FREIGHTAMT, DELIVERYVIARULE, M_SHIPPER_ID, C_CHARGE_ID, CHARGEAMT, PRIORITYRULE, DATEPRINTED, C_INVOICE_ID, CREATEFROM, GENERATETO, SENDEMAIL, AD_USER_ID, SALESREP_ID, NOPACKAGES, PICKDATE, SHIPDATE, TRACKINGNO, AD_ORGTRX_ID, C_PROJECT_ID, C_CAMPAIGN_ID, C_ACTIVITY_ID, USER1_ID, USER2_ID, UPDATELINES, ISLOGISTIC, GENERATELINES)
carlos@0
    83
      VALUES(TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),?,now(),TO_NUMBER(?),now(),TO_NUMBER(?),?,?,?,?,?,?,?,TO_NUMBER(?),?,TO_NUMBER(?),TO_DATE(?),?,?,TO_DATE(?),TO_DATE(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),?,?,?,TO_NUMBER(?),?,TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),?,NULL,NULL,?,?,?,TO_NUMBER(?),TO_NUMBER(?),NULL,NULL,NULL,NULL,TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),TO_NUMBER(?),?,?,?)
carlos@0
    84
      </Sql>
carlos@0
    85
      <Parameter name="mInoutId"/>
carlos@0
    86
      <Parameter name="adClientId"/>
carlos@0
    87
      <Parameter name="adOrgId"/>
carlos@0
    88
      <Parameter name="isactive"/>
carlos@0
    89
      <Parameter name="createdby"/>
carlos@0
    90
      <Parameter name="updatedby"/>
carlos@0
    91
      <Parameter name="issotrx"/>
carlos@0
    92
      <Parameter name="documentno"/>
carlos@0
    93
      <Parameter name="docaction"/>
carlos@0
    94
      <Parameter name="docstatus"/>
carlos@0
    95
      <Parameter name="posted"/>
carlos@0
    96
      <Parameter name="processing"/>
carlos@0
    97
      <Parameter name="processed"/>
carlos@0
    98
      <Parameter name="cDoctypeId"/>
carlos@0
    99
      <Parameter name="description"/>
carlos@0
   100
      <Parameter name="cOrderId"/>
carlos@0
   101
      <Parameter name="dateordered"/>
carlos@0
   102
      <Parameter name="isprinted"/>
carlos@0
   103
      <Parameter name="movementtype"/>
carlos@0
   104
      <Parameter name="movementdate"/>
carlos@0
   105
      <Parameter name="dateacct"/>
carlos@0
   106
      <Parameter name="cBpartnerId"/>
carlos@0
   107
      <Parameter name="cBpartnerLocationId"/>
carlos@0
   108
      <Parameter name="mWarehouseId"/>
carlos@0
   109
      <Parameter name="poreference"/>
carlos@0
   110
      <Parameter name="deliveryrule"/>
carlos@0
   111
      <Parameter name="freightcostrule"/>
carlos@0
   112
      <Parameter name="freightamt"/>
carlos@0
   113
      <Parameter name="deliveryviarule"/>
carlos@0
   114
      <Parameter name="mShipperId"/>
carlos@0
   115
      <Parameter name="cChargeId"/>
carlos@0
   116
      <Parameter name="chargeamt"/>
carlos@0
   117
      <Parameter name="priorityrule"/>
carlos@0
   118
      <Parameter name="generateto"/>
carlos@0
   119
      <Parameter name="createfrom"/>
carlos@0
   120
      <Parameter name="sendemail"/>
carlos@0
   121
      <Parameter name="adUserId"/>
carlos@0
   122
      <Parameter name="salesrepId"/>
carlos@0
   123
      <Parameter name="adOrgtrxId"/>
carlos@0
   124
      <Parameter name="cProjectId"/>
carlos@0
   125
      <Parameter name="cCampaignId"/>
carlos@0
   126
      <Parameter name="cActivityId"/>
carlos@0
   127
      <Parameter name="user1Id"/>
carlos@0
   128
      <Parameter name="user2Id"/>
carlos@0
   129
      <Parameter name="updatelines"/>
carlos@0
   130
      <Parameter name="islogistic"/>
carlos@0
   131
      <Parameter name="generatelines"/>
carlos@0
   132
  </SqlMethod>
carlos@0
   133
  <SqlMethod name="mInoutPost0" connection="true" type="callableStatement" return="object" object="MaterialReceiptPendingData">
carlos@0
   134
      <SqlMethodComment></SqlMethodComment>
carlos@0
   135
      <Sql><![CDATA[
carlos@0
   136
        CALL M_InOut_Post0(TO_NUMBER(?))
carlos@0
   137
      ]]></Sql>
carlos@0
   138
      <Parameter name="adPinstanceId"></Parameter>
carlos@0
   139
   </SqlMethod>
carlos@0
   140
  <SqlMethod name="cDoctypeTarget" type="preparedStatement" return="string" default="">
carlos@0
   141
    <SqlMethodComment></SqlMethodComment>
carlos@0
   142
    <Sql>
carlos@0
   143
      <![CDATA[
carlos@0
   144
        SELECT C_DOCTYPE_ID 
carlos@0
   145
        FROM C_DOCTYPE
carlos@0
   146
        WHERE DOCBASETYPE = 'MMR' 
carlos@0
   147
        AND AD_CLIENT_ID IN ('1') 
carlos@0
   148
        AND AD_ORG_ID IN ('1')
carlos@0
   149
      ]]>
carlos@0
   150
    </Sql>
carlos@0
   151
    <Parameter name="adUserClient" type="replace" optional="true" after="AD_CLIENT_ID IN (" text="'1'"/>
carlos@0
   152
    <Parameter name="adOrgClient" type="replace" optional="true" after="AD_ORG_ID IN (" text="'1'"/>
carlos@0
   153
  </SqlMethod>
carlos@0
   154
  <SqlMethod name="cDoctypeId" type="preparedStatement" return="string" default="">
carlos@0
   155
    <SqlMethodComment></SqlMethodComment>
carlos@0
   156
    <Sql>
carlos@0
   157
      <![CDATA[
carlos@0
   158
        SELECT C_DocTypeShipment_ID
carlos@0
   159
        FROM C_DOCTYPE
carlos@423
   160
        WHERE C_DocType_ID = TO_NUMBER(?)
carlos@0
   161
      ]]>
carlos@0
   162
    </Sql>
carlos@0
   163
    <Parameter name="cDoctypeId"/>
carlos@0
   164
  </SqlMethod>
carlos@0
   165
  <SqlMethod name="bPartnerDescription" type="preparedStatement" return="String" default="">
carlos@0
   166
    <SqlMethodComment></SqlMethodComment>
carlos@0
   167
    <Sql>
carlos@0
   168
    <![CDATA[
carlos@0
   169
    SELECT NAME FROM C_BPARTNER 
carlos@423
   170
    WHERE C_BPARTNER_ID = TO_NUMBER(?)
carlos@0
   171
    ]]></Sql>
carlos@0
   172
    <Parameter name="cBpartnerId"/>
carlos@0
   173
  </SqlMethod>
carlos@0
   174
  <SqlMethod name="treeOrg" type="preparedStatement" return="string">
carlos@0
   175
    <SqlMethodComment></SqlMethodComment>
carlos@0
   176
    <Sql>
carlos@0
   177
        SELECT AD_TREE_ORG_ID FROM AD_CLIENTINFO
carlos@423
   178
        WHERE AD_CLIENT_ID = TO_NUMBER(?)
carlos@0
   179
    </Sql>
carlos@0
   180
    <Parameter name="client"/>
carlos@0
   181
  </SqlMethod>
carlos@0
   182
</SqlClass>