src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql
author Ainhoa Pagola <ainhoa.pagola@openbravo.com>
Mon, 09 Feb 2009 15:50:01 +0000
changeset 3030 8e933318013b
parent 3024 31a3b2090e77
child 3296 f1b414448f56
permissions -rw-r--r--
Fixes 0007420 Oracle problem in previous solution
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="CreateFromInvoiceData" package="org.openbravo.erpCommon.ad_actionButton">
carlos@0
    26
  <SqlMethod name="selectFromPO" type="preparedStatement" return="multiple">
carlos@0
    27
    <SqlMethodComment></SqlMethodComment>
carlos@0
    28
    <Sql>
carlos@0
    29
      <![CDATA[
carlos@0
    30
        SELECT o.C_ORDER_ID as ID, Ad_Column_Identifier(to_char('C_Order'), to_char(o.c_order_id), to_char(?)) AS NAME, o.DocumentNo AS NAMEORDER,
carlos@0
    31
        o.DocumentNo AS NAMESHIPMENT,
carlos@0
    32
        l.QtyOrdered-SUM(COALESCE(m.Qty,0)) AS QTY, l.C_UOM_ID,uom.UOMSymbol, l.M_Product_ID,p.NAME AS RELATION_NAME, 
carlos@0
    33
        l.C_OrderLine_ID,l.Line, l.ad_org_id, '' as STDPRECISION, 
carlos@0
    34
        '' as M_InOutLine_ID, '' AS PriceActual, '' AS PriceList, '' AS PriceLimit, '' AS Description, '' as PriceStd,
carlos@0
    35
        '' AS QUANTITYORDER, '' AS M_Product_UOM_ID, '' AS M_ATTRIBUTESETINSTANCE_ID, '' AS M_Offer_ID 
carlos@0
    36
        FROM C_ORDERLINE l left join M_MATCHPO m on  l.C_OrderLine_ID=m.C_OrderLine_ID
carlos@0
    37
                                                 AND m.C_InvoiceLine_ID IS NOT NULL, 
carlos@0
    38
        C_ORDER o, C_UOM uom,  M_PRODUCT p
carlos@0
    39
        WHERE o.C_ORDER_ID = l.C_ORDER_ID 
carlos@0
    40
        AND o.IsSOTrx='N' 
carlos@0
    41
        AND o.DocStatus IN ('CL','CO') 
carlos@0
    42
        AND o.AD_Client_ID IN ('1') 
carlos@0
    43
        AND o.AD_Org_ID IN ('1') 
carlos@0
    44
        AND l.C_UOM_ID=uom.C_UOM_ID
carlos@0
    45
        AND l.M_Product_ID=p.M_Product_ID
juanpablo@1605
    46
        AND l.C_Order_ID = ? 
carlos@0
    47
        GROUP BY o.C_ORDER_ID, o.DocumentNo, o.DateOrdered, o.GrandTotal, l.QtyOrdered,l.C_UOM_ID,
carlos@0
    48
        uom.UOMSymbol,l.M_Product_ID,p.NAME,l.Line,l.C_OrderLine_ID, l.ad_org_id
carlos@0
    49
        HAVING (l.QtyOrdered-SUM(COALESCE(m.Qty,0))) <> 0
carlos@0
    50
        ORDER BY NAME, l.Line
carlos@0
    51
      ]]>
carlos@0
    52
    </Sql>
carlos@0
    53
    <Field name="rownum" value="count"/>
carlos@0
    54
    <Parameter name="language"/>
carlos@0
    55
    <Parameter name="adUserClient" type="replace" optional="true" after="o.AD_Client_ID IN (" text="'1'"/>
carlos@0
    56
    <Parameter name="adOrgClient" type="replace" optional="true" after="o.AD_Org_ID IN (" text="'1'"/>
carlos@0
    57
    <Parameter name="poId"/>
carlos@0
    58
  </SqlMethod>
carlos@0
    59
  <SqlMethod name="selectFromPOCombo" type="preparedStatement" return="multiple">
carlos@0
    60
    <SqlMethodComment></SqlMethodComment>
carlos@0
    61
    <Sql>
carlos@0
    62
      <![CDATA[
carlos@0
    63
        SELECT o.C_ORDER_ID as ID, Ad_Column_Identifier(to_char('C_Order'), to_char(o.c_order_id), to_char(?)) AS NAME 
carlos@0
    64
        FROM C_ORDER o 
carlos@0
    65
        WHERE o.IsSOTrx='N' 
carlos@0
    66
        AND o.DocStatus IN ('CL','CO') 
carlos@0
    67
        AND o.AD_Client_ID IN ('1') 
carlos@0
    68
        AND o.AD_Org_ID IN ('1')
juanpablo@1605
    69
        AND o.C_BPartner_ID = ?
carlos@0
    70
        AND EXISTS (SELECT 1 
carlos@0
    71
                     FROM C_ORDERLINE l left join M_MATCHPO m on  l.C_OrderLine_ID=m.C_OrderLine_ID
carlos@0
    72
                                                              and m.C_InvoiceLine_ID IS NOT NULL  
carlos@0
    73
                    WHERE l.C_ORDER_ID = o.C_ORDER_ID  
carlos@0
    74
                    GROUP BY l.QtyOrdered,l.C_OrderLine_ID 
carlos@0
    75
                    HAVING (l.QtyOrdered-SUM(COALESCE(m.Qty,0))) <> 0)
carlos@0
    76
        ORDER BY NAME
carlos@0
    77
      ]]>
carlos@0
    78
    </Sql>
carlos@0
    79
    <Parameter name="language"/>
carlos@0
    80
    <Parameter name="adUserClient" type="replace" optional="true" after="o.AD_Client_ID IN (" text="'1'"/>
carlos@0
    81
    <Parameter name="adOrgClient" type="replace" optional="true" after="o.AD_Org_ID IN (" text="'1'"/>
carlos@0
    82
    <Parameter name="cBpartnerId"/>
carlos@0
    83
  </SqlMethod>
carlos@0
    84
  <SqlMethod name="selectFromPOSOTrx" type="preparedStatement" return="multiple">
carlos@0
    85
    <SqlMethodComment></SqlMethodComment>
carlos@0
    86
    <Sql>
carlos@0
    87
      <![CDATA[
carlos@0
    88
        SELECT o.C_ORDER_ID as ID, Ad_Column_Identifier(to_char('C_Order'), to_char(o.c_order_id), to_char(?)) AS NAME,o.DocumentNo AS NAMEORDER,
carlos@0
    89
        l.QtyOrdered-COALESCE(l.QTYINVOICED,0) AS QTY, l.C_UOM_ID,uom.UOMSymbol, l.M_Product_ID,p.NAME AS RELATION_NAME, 
carlos@0
    90
        l.C_OrderLine_ID,l.Line, l.ad_Org_id
carlos@0
    91
        FROM C_INVOICE_CANDIDATE_V ic, C_UOM uom, C_ORDER o, C_ORDERLINE l, M_PRODUCT p 
carlos@0
    92
        WHERE l.C_UOM_ID=uom.C_UOM_ID
carlos@0
    93
        AND o.C_ORDER_ID = ic.C_ORDER_ID 
carlos@0
    94
        AND o.C_ORDER_ID=l.C_ORDER_ID 
carlos@0
    95
        AND ic.AD_Client_ID IN ('1') 
carlos@0
    96
        AND ic.AD_Org_ID IN ('1') 
carlos@0
    97
        AND l.M_Product_ID=p.M_Product_ID 
juanpablo@1605
    98
        AND ic.C_Order_ID = ? 
carlos@0
    99
        GROUP BY o.C_ORDER_ID, o.DocumentNo, o.DateOrdered, o.GrandTotal, l.QtyOrdered,
carlos@0
   100
        l.C_UOM_ID,uom.UOMSymbol,l.M_Product_ID,p.NAME,l.Line,l.C_OrderLine_ID, l.QTYINVOICED, l.ad_org_id
carlos@0
   101
        ORDER BY NAME, l.Line
carlos@0
   102
      ]]>
carlos@0
   103
    </Sql>
carlos@0
   104
    <Field name="rownum" value="count"/>
carlos@0
   105
    <Parameter name="language"/>
carlos@0
   106
    <Parameter name="adUserClient" type="replace" optional="true" after="ic.AD_Client_ID IN (" text="'1'"/>
carlos@0
   107
    <Parameter name="adOrgClient" type="replace" optional="true" after="ic.AD_Org_ID IN (" text="'1'"/>
carlos@0
   108
    <Parameter name="poId"/>
carlos@0
   109
  </SqlMethod>
carlos@0
   110
  <SqlMethod name="selectFromPOSOTrxCombo" type="preparedStatement" return="multiple">
carlos@0
   111
    <SqlMethodComment></SqlMethodComment>
carlos@0
   112
    <Sql>
carlos@0
   113
      <![CDATA[
carlos@0
   114
        SELECT o.C_ORDER_ID as ID, Ad_Column_Identifier(to_char('C_Order'), to_char(o.c_order_id), to_char(?)) AS NAME 
carlos@0
   115
        FROM C_INVOICE_CANDIDATE_V ic, C_ORDER o 
carlos@0
   116
        WHERE o.C_ORDER_ID = ic.C_ORDER_ID 
carlos@0
   117
        AND ic.AD_Client_ID IN ('1') 
carlos@0
   118
        AND ic.AD_Org_ID IN ('1') 
juanpablo@1605
   119
        AND ic.C_BPartner_ID = ? 
carlos@0
   120
        GROUP BY o.C_ORDER_ID, o.DocumentNo, o.DateOrdered, o.GrandTotal 
carlos@0
   121
        ORDER BY NAME
carlos@0
   122
      ]]>
carlos@0
   123
    </Sql>
carlos@0
   124
    <Parameter name="language"/>
carlos@0
   125
    <Parameter name="adUserClient" type="replace" optional="true" after="ic.AD_Client_ID IN (" text="'1'"/>
carlos@0
   126
    <Parameter name="adOrgClient" type="replace" optional="true" after="ic.AD_Org_ID IN (" text="'1'"/>
carlos@0
   127
    <Parameter name="cBpartnerId"/>
carlos@0
   128
  </SqlMethod>
carlos@0
   129
  <SqlMethod name="selectFromPOTrl" type="preparedStatement" return="multiple">
carlos@0
   130
    <SqlMethodComment></SqlMethodComment>
carlos@0
   131
    <Sql>
carlos@0
   132
      <![CDATA[
carlos@0
   133
        SELECT o.C_ORDER_ID as ID, Ad_Column_Identifier(to_char('C_Order'), to_char(o.c_order_id), to_char(?)) AS NAME, o.DocumentNo AS NAMEORDER,
carlos@0
   134
        l.QtyOrdered-SUM(COALESCE(m.Qty,0)) AS QTY, l.C_UOM_ID, COALESCE(uomt.UOMSYMBOL, uom.UOMSymbol) AS UOMSymbol, 
carlos@0
   135
        l.M_Product_ID,p.NAME AS RELATION_NAME, l.C_OrderLine_ID,l.Line 
carlos@0
   136
        FROM C_UOM uom left join  C_UOM_TRL uomt on uom.C_UOM_ID = uomt.C_UOM_ID
carlos@0
   137
                                                and uomt.AD_Language = ?,
carlos@0
   138
             C_ORDERLINE l left join M_MATCHPO m on l.C_OrderLine_ID=m.C_OrderLine_ID
carlos@0
   139
                                                and m.C_InvoiceLine_ID IS NOT NULL,
carlos@0
   140
        C_ORDER o, M_PRODUCT p
carlos@0
   141
        WHERE o.C_ORDER_ID = l.C_ORDER_ID 
carlos@0
   142
        AND o.IsSOTrx='N' 
carlos@0
   143
        AND o.DocStatus IN ('CL','CO') 
carlos@0
   144
        AND o.AD_Client_ID IN ('1') 
carlos@0
   145
        AND o.AD_Org_ID IN ('1') 
carlos@0
   146
        AND l.C_UOM_ID=uom.C_UOM_ID 
carlos@0
   147
        AND l.M_Product_ID=p.M_Product_ID  
juanpablo@1605
   148
        AND l.C_Order_ID = ? 
carlos@0
   149
        GROUP BY o.C_ORDER_ID, o.DocumentNo, o.DateOrdered, o.GrandTotal, l.QtyOrdered,l.C_UOM_ID,
carlos@0
   150
        uom.UOMSymbol, uomt.UOMSYMBOL,l.M_Product_ID,p.NAME,l.Line,l.C_OrderLine_ID 
carlos@0
   151
        HAVING (l.QtyOrdered-SUM(COALESCE(m.Qty,0))) <> 0
carlos@0
   152
        ORDER BY NAME, l.Line
carlos@0
   153
      ]]>
carlos@0
   154
    </Sql>
carlos@0
   155
    <Field name="rownum" value="count"/>
carlos@0
   156
    <Parameter name="adLanguage"/>
carlos@0
   157
    <Parameter name="adUserClient" type="replace" optional="true" after="o.AD_Client_ID IN (" text="'1'"/>
carlos@0
   158
    <Parameter name="adOrgClient" type="replace" optional="true" after="o.AD_Org_ID IN (" text="'1'"/>
carlos@0
   159
    <Parameter name="adLanguage"/>
carlos@0
   160
    <Parameter name="poId"/>
carlos@0
   161
  </SqlMethod>
carlos@0
   162
  <SqlMethod name="selectFromPOTrlSOTrx" type="preparedStatement" return="multiple">
carlos@0
   163
    <SqlMethodComment></SqlMethodComment>
carlos@0
   164
    <Sql>
carlos@0
   165
      <![CDATA[
carlos@0
   166
        SELECT o.C_ORDER_ID as ID, Ad_Column_Identifier(to_char('C_Order'), to_char(o.c_order_id), to_char(?) ) AS NAME,o.DocumentNo AS NAMEORDER,
carlos@0
   167
        l.QtyOrdered-COALESCE(l.QTYINVOICED,0) AS QTY, l.C_UOM_ID, COALESCE(uomt.UOMSymbol, uom.UOMSymbol) AS UOMSymbol, 
carlos@0
   168
        l.M_Product_ID,p.NAME AS RELATION_NAME, l.C_OrderLine_ID,l.Line
carlos@0
   169
        FROM C_UOM uom left join C_UOM_TRL uomt on uom.C_UOM_ID = uomt.C_UOM_ID
carlos@0
   170
                                               and  uomt.AD_Language = ?, 
carlos@0
   171
        C_INVOICE_CANDIDATE_V ic,   C_ORDER o, C_ORDERLINE l, M_PRODUCT p 
carlos@0
   172
        WHERE l.C_UOM_ID=uom.C_UOM_ID
carlos@0
   173
        AND o.C_ORDER_ID = ic.C_ORDER_ID 
carlos@0
   174
        AND o.C_ORDER_ID=l.C_ORDER_ID 
carlos@0
   175
        AND ic.AD_Client_ID IN ('1') 
carlos@0
   176
        AND ic.AD_Org_ID IN ('1') 
carlos@0
   177
        AND l.M_Product_ID=p.M_Product_ID
juanpablo@1605
   178
        AND ic.C_Order_ID = ? 
carlos@0
   179
        GROUP BY o.C_ORDER_ID, o.DocumentNo, o.DateOrdered, o.GrandTotal, l.QtyOrdered,
carlos@0
   180
        l.C_UOM_ID,uom.UOMSymbol, uomt.UOMSymbol,l.M_Product_ID,p.NAME,l.Line,l.C_OrderLine_ID, l.QTYINVOICED 
carlos@0
   181
        ORDER BY NAME, l.Line
carlos@0
   182
      ]]>
carlos@0
   183
    </Sql>
carlos@0
   184
    <Field name="rownum" value="count"/>
carlos@0
   185
    <Parameter name="adLanguage"/>
carlos@0
   186
    <Parameter name="adUserClient" type="replace" optional="true" after="ic.AD_Client_ID IN (" text="'1'"/>
carlos@0
   187
    <Parameter name="adOrgClient" type="replace" optional="true" after="ic.AD_Org_ID IN (" text="'1'"/>
carlos@0
   188
    <Parameter name="adLanguage"/>
carlos@0
   189
    <Parameter name="poId"/>
carlos@0
   190
  </SqlMethod>
carlos@0
   191
  
carlos@0
   192
  <SqlMethod name="selectFromPOUpdate" type="preparedStatement" connection="true" return="multiple">
carlos@0
   193
    <SqlMethodComment></SqlMethodComment>
carlos@0
   194
    <Sql>
carlos@0
   195
      <![CDATA[
carlos@0
   196
      SELECT (CASE WHEN B.M_InOutLine_ID IS NULL THEN A.QTY ELSE B.QTY END) AS ID, 
carlos@0
   197
      A.C_UOM_ID,uom.UOMSymbol, A.M_Product_ID,p.NAME, A.C_OrderLine_ID,A.Line, uom.stdprecision, 
carlos@0
   198
      B.M_InOutLine_ID, A.Description, (CASE WHEN B.M_InOutLine_ID IS NULL THEN A.quantityOrder ELSE B.quantityOrder END) AS quantityOrder, 
carlos@0
   199
      (CASE WHEN B.M_InOutLine_ID IS NULL THEN A.M_Product_UOM_ID ELSE B.M_Product_UOM_ID END) AS M_Product_UOM_ID, A.M_ATTRIBUTESETINSTANCE_ID, A.ad_org_id
carlos@0
   200
      FROM C_UOM uom, M_PRODUCT p, 
carlos@0
   201
      (SELECT l.ad_org_id, l.C_UOM_ID, l.M_Product_ID, l.Line, l.Description, l.C_OrderLine_ID, (l.QtyOrdered-SUM(COALESCE(mp.Qty,0))) AS QTY,
gorkaion@1787
   202
      l.quantityOrder*C_DIVIDE((l.QtyOrdered-SUM(COALESCE(mp.Qty,0))),l.QtyOrdered) as quantityOrder, l.M_Product_UOM_ID, l.M_ATTRIBUTESETINSTANCE_ID
carlos@0
   203
        FROM C_ORDERLINE l left join M_MATCHPO mp on l.C_OrderLine_ID=mp.C_OrderLine_ID
carlos@0
   204
                                                  and mp.C_InvoiceLine_ID IS NOT NULL
carlos@0
   205
        GROUP BY l.ad_org_id,l.C_UOM_ID, l.M_Product_ID, l.Line, l.Description, l.C_OrderLine_ID, l.QtyOrdered, l.quantityOrder, l.M_Product_UOM_ID,
carlos@0
   206
        l.M_ATTRIBUTESETINSTANCE_ID) A left join 
carlos@0
   207
      (SELECT il.M_InOutLine_ID, il.C_OrderLine_ID, (il.MovementQty-SUM(COALESCE(mi.Qty,0))) AS QTY,
gorkaion@1787
   208
      il.quantityOrder*C_DIVIDE((il.MovementQty-SUM(COALESCE(mi.Qty,0))),(il.MovementQty)) as quantityOrder, il.M_Product_UOM_ID
gorkaion@158
   209
        FROM M_INOUTLINE il left join M_MATCHINV mi on il.M_InOutLine_ID=mi.M_InOutLine_ID,
gorkaion@158
   210
             M_INOUT io
carlos@0
   211
        WHERE il.C_OrderLine_ID IS NOT NULL
gorkaion@158
   212
        AND io.M_InOut_ID = il.M_InOut_ID
gorkaion@158
   213
        AND io.Processed = 'Y'
carlos@0
   214
        GROUP BY il.M_InOutLine_ID, il.C_OrderLine_ID, il.MovementQty, il.quantityOrder, il.M_Product_UOM_ID
carlos@0
   215
        HAVING (il.MovementQty-SUM(COALESCE(mi.Qty,0))) <> 0) B on A.C_OrderLine_ID=B.C_OrderLine_ID
carlos@0
   216
      WHERE A.C_UOM_ID=uom.C_UOM_ID
carlos@0
   217
      AND A.M_Product_ID=p.M_Product_ID
carlos@0
   218
      ORDER BY A.Line
carlos@0
   219
      ]]>
carlos@0
   220
    </Sql>
carlos@0
   221
    <Parameter name="cOrderlineId" optional="true" type="argument" after="AND A.M_Product_ID=p.M_Product_ID" text=" AND A.C_OrderLine_ID IN "/>
carlos@0
   222
  </SqlMethod>
carlos@0
   223
  <SqlMethod name="selectFromPOUpdateSOTrx" type="preparedStatement" connection="true" return="multiple">
carlos@0
   224
    <SqlMethodComment></SqlMethodComment>
carlos@0
   225
    <Sql>
carlos@0
   226
      <![CDATA[
carlos@0
   227
        SELECT (CASE WHEN il.M_INOUTLINE_ID IS NULL THEN (l.QtyOrdered-COALESCE(l.QTYINVOICED ,0)) ELSE il.MOVEMENTQTY END) AS ID, 
carlos@0
   228
        l.C_UOM_ID,uom.UOMSymbol, l.M_Product_ID,p.NAME, 
carlos@0
   229
        l.C_OrderLine_ID,l.Line, max(uom.stdprecision) as stdprecision, il.M_InOutLine_ID as M_InOutLine_ID, l.Description,
gorkaion@1787
   230
        (CASE WHEN il.M_INOUTLINE_ID IS NULL THEN l.quantityOrder*C_DIVIDE((l.QtyOrdered-COALESCE(l.QTYINVOICED ,0)),(l.QtyOrdered)) ELSE il.quantityOrder END) AS quantityOrder, 
carlos@0
   231
        (CASE WHEN il.M_INOUTLINE_ID IS NULL THEN l.M_Product_UOM_ID ELSE il.M_Product_UOM_ID END) AS M_Product_UOM_ID, l.M_ATTRIBUTESETINSTANCE_ID, l.ad_org_id
gorkaion@158
   232
        FROM C_ORDERLINE l left join (SELECT M_InOutLine.* FROM M_InOutLine, M_InOut
gorkaion@158
   233
                                      WHERE M_InOut.M_InOut_ID = M_InOutLine.M_InOut_ID
gorkaion@158
   234
                                      AND M_InOutLine.IsInvoiced = 'N'
gorkaion@158
   235
                                      AND M_InOut.Processed='Y') il  on l.C_OrderLine_ID = il.C_OrderLine_ID,
carlos@0
   236
        C_UOM uom,  M_PRODUCT p  
carlos@0
   237
        WHERE l.C_UOM_ID=uom.C_UOM_ID
carlos@0
   238
        AND l.M_Product_ID=p.M_Product_ID 
carlos@0
   239
        GROUP BY l.QtyOrdered,l.qtydelivered,l.C_UOM_ID,uom.UOMSymbol,l.M_Product_ID,p.NAME,l.Line,l.C_OrderLine_ID, 
carlos@0
   240
        l.QTYINVOICED, il.M_InOutLine_ID, il.MovementQty, l.Description, l.quantityOrder, il.quantityOrder, 
carlos@0
   241
        l.M_Product_UOM_ID, il.M_Product_UOM_ID, l.M_ATTRIBUTESETINSTANCE_ID,l.ad_org_id
carlos@0
   242
        HAVING (l.QtyOrdered-COALESCE(l.QTYINVOICED ,0)) <> 0 
carlos@0
   243
        ORDER BY l.Line
carlos@0
   244
      ]]>
carlos@0
   245
    </Sql>
carlos@0
   246
    <Field name="rownum" value="count"/>
carlos@0
   247
    <Parameter name="cOrderlineId" optional="true" type="argument" after=" AND l.M_Product_ID=p.M_Product_ID " text=" AND l.C_OrderLine_ID IN "/>
carlos@0
   248
  </SqlMethod>
carlos@0
   249
  <SqlMethod name="selectFromShipment" type="preparedStatement" return="multiple">
carlos@0
   250
    <SqlMethodComment></SqlMethodComment>
carlos@0
   251
    <Sql>
carlos@0
   252
      <![CDATA[
carlos@0
   253
        SELECT s.M_InOut_ID AS ID, Ad_Column_Identifier(to_char('M_InOut'), to_char(s.M_InOut_ID), to_char(?)) AS NAME, 
carlos@0
   254
        s.DocumentNo AS NAMESHIPMENT, 
ainhoa@3030
   255
        (l.MovementQty-SUM(COALESCE(mi.Qty,0))) AS QTY, l.C_UOM_ID,uom.UOMSymbol, l.M_Product_ID,p.NAME||' '||(CASE WHEN ma.serno IS NOT NULL THEN TO_CHAR('('||' '||ma.serno||' '||')') ELSE TO_CHAR('')  END) AS RELATION_NAME, 
carlos@0
   256
        l.M_InOutLine_ID,l.Line, l.M_InOutLine_ID as C_OrderLine_ID 
carlos@0
   257
        FROM M_INOUTLINE l left join M_ATTRIBUTESETINSTANCE ma on l.M_ATTRIBUTESETINSTANCE_ID = ma.M_ATTRIBUTESETINSTANCE_ID
carlos@0
   258
                           left join M_MATCHINV mi             on l.M_InOutLine_ID=mi.M_InOutLine_ID,
carlos@0
   259
        M_INOUT s, C_UOM uom,  M_PRODUCT p
carlos@0
   260
        WHERE s.M_INOUT_ID = l.M_INOUT_ID 
carlos@0
   261
        AND s.IsSOTrx='N' 
carlos@0
   262
        AND s.DocStatus IN ('CL','CO') 
carlos@0
   263
        AND s.AD_Client_ID IN ('1') 
carlos@0
   264
        AND s.AD_Org_ID IN ('1') 
carlos@0
   265
        AND l.C_UOM_ID=uom.C_UOM_ID 
carlos@0
   266
        AND l.M_Product_ID=p.M_Product_ID 
juanpablo@1605
   267
        AND l.M_InOut_ID=? 
carlos@0
   268
        GROUP BY s.M_InOut_ID, s.DocumentNo, s.MovementDate, l.MovementQty,l.C_UOM_ID,uom.UOMSymbol,
carlos@0
   269
        l.M_Product_ID,ma.serno,p.NAME, l.M_InOutLine_ID,l.Line,l.C_OrderLine_ID 
carlos@0
   270
        HAVING  (l.MovementQty-SUM(COALESCE(mi.Qty,0))) <> 0
carlos@0
   271
        ORDER BY NAME, l.Line
carlos@0
   272
      ]]>
carlos@0
   273
    </Sql>
carlos@0
   274
    <Field name="rownum" value="count"/>
carlos@0
   275
    <Parameter name="adLanguage"/>
carlos@0
   276
    <Parameter name="adUserClient" type="replace" optional="true" after="s.AD_Client_ID IN (" text="'1'"/>
carlos@0
   277
    <Parameter name="adOrgClient" type="replace" optional="true" after="s.AD_Org_ID IN (" text="'1'"/>
carlos@0
   278
    <Parameter name="mInoutId"/>
carlos@0
   279
  </SqlMethod>
carlos@0
   280
  <SqlMethod name="selectFromShipmentCombo" type="preparedStatement" return="multiple">
carlos@0
   281
    <SqlMethodComment></SqlMethodComment>
carlos@0
   282
    <Sql>
carlos@0
   283
      <![CDATA[
carlos@0
   284
        SELECT s.M_InOut_ID AS ID, Ad_Column_Identifier(to_char('M_InOut'), to_char(s.M_InOut_ID), to_char(?)) AS NAME 
carlos@0
   285
        FROM M_INOUT s 
carlos@0
   286
        WHERE s.IsSOTrx='N' 
carlos@0
   287
        AND s.DocStatus IN ('CL','CO') 
david@1686
   288
        AND s.ISLOGISTIC <> 'Y'
carlos@0
   289
        AND s.AD_Client_ID IN ('1') 
carlos@0
   290
        AND s.AD_Org_ID IN ('1') 
juanpablo@1605
   291
        AND s.C_BPartner_ID = ? 
carlos@0
   292
        AND EXISTS (SELECT 1 
carlos@0
   293
                     FROM M_INOUTLINE l left join M_MATCHINV mi on l.M_InOutLine_ID=mi.M_InOutLine_ID
carlos@0
   294
                      WHERE l.M_INOUT_ID = s.M_INOUT_ID 
carlos@0
   295
                      GROUP BY l.MovementQty, l.M_InOutLine_ID 
carlos@0
   296
                      HAVING  (l.MovementQty-SUM(COALESCE(mi.Qty,0))) <> 0)
carlos@0
   297
        ORDER BY NAME
carlos@0
   298
      ]]>
carlos@0
   299
    </Sql>
carlos@0
   300
    <Field name="rownum" value="count"/>
carlos@0
   301
    <Parameter name="adLanguage"/>
carlos@0
   302
    <Parameter name="adUserClient" type="replace" optional="true" after="s.AD_Client_ID IN (" text="'1'"/>
carlos@0
   303
    <Parameter name="adOrgClient" type="replace" optional="true" after="s.AD_Org_ID IN (" text="'1'"/>
carlos@0
   304
    <Parameter name="cBpartnerId"/>
carlos@0
   305
  </SqlMethod>
carlos@0
   306
  <SqlMethod name="selectFromShipmentSOTrx" type="preparedStatement" return="multiple">
carlos@0
   307
    <SqlMethodComment></SqlMethodComment>
carlos@0
   308
    <Sql>
carlos@0
   309
      <![CDATA[
carlos@0
   310
        SELECT s.M_InOut_ID AS ID, Ad_Column_Identifier(to_char('M_InOut'), to_char(s.M_InOut_ID), to_char(?)) AS NAME,
carlos@0
   311
        s.DocumentNo AS NAMESHIPMENT,
ainhoa@3030
   312
        l.MovementQty AS QTY, l.C_UOM_ID,uom.UOMSymbol, l.M_Product_ID,p.NAME||' '||(CASE WHEN ma.serno IS NOT NULL THEN TO_CHAR('('||' '||ma.serno||' '||')') ELSE TO_CHAR('') END) AS RELATION_NAME, l.M_InOutLine_ID,l.Line,
carlos@0
   313
        l.M_InOutLine_ID as C_OrderLine_ID 
carlos@0
   314
        FROM M_INOUTLINE l left join M_ATTRIBUTESETINSTANCE ma on l.M_ATTRIBUTESETINSTANCE_ID = ma.M_ATTRIBUTESETINSTANCE_ID,
carlos@0
   315
        M_INOUT s, C_UOM uom, M_PRODUCT p 
carlos@0
   316
        WHERE s.M_INOUT_ID = l.M_INOUT_ID
carlos@0
   317
        AND s.IsSOTrx='Y' 
carlos@0
   318
        AND s.DocStatus IN ('CL','CO') 
carlos@0
   319
        AND s.AD_Client_ID IN ('1') 
carlos@0
   320
        AND s.AD_Org_ID IN ('1') 
carlos@0
   321
        AND l.C_UOM_ID=uom.C_UOM_ID 
carlos@0
   322
        AND l.M_Product_ID=p.M_Product_ID 
carlos@0
   323
        AND l.isinvoiced = 'N' 
juanpablo@1605
   324
        AND l.M_InOut_ID=?
carlos@0
   325
        GROUP BY s.M_InOut_ID, s.DocumentNo, s.MovementDate, l.MovementQty,l.C_UOM_ID,uom.UOMSymbol,
carlos@0
   326
        l.M_Product_ID,p.NAME, ma.serno, l.M_InOutLine_ID,l.Line,l.C_OrderLine_ID
carlos@0
   327
        ORDER BY NAME, l.Line
carlos@0
   328
      ]]>
carlos@0
   329
    </Sql>
carlos@0
   330
    <Field name="rownum" value="count"/>
carlos@0
   331
    <Parameter name="adLanguage"/>
carlos@0
   332
    <Parameter name="adUserClient" type="replace" optional="true" after="s.AD_Client_ID IN (" text="'1'"/>
carlos@0
   333
    <Parameter name="adOrgClient" type="replace" optional="true" after="s.AD_Org_ID IN (" text="'1'"/>
carlos@0
   334
    <Parameter name="mInoutId"/>
carlos@0
   335
  </SqlMethod>
carlos@0
   336
  <SqlMethod name="selectFromShipmentSOTrxCombo" type="preparedStatement" return="multiple">
carlos@0
   337
    <SqlMethodComment></SqlMethodComment>
carlos@0
   338
    <Sql>
carlos@0
   339
      <![CDATA[
carlos@0
   340
        SELECT s.M_InOut_ID AS ID, Ad_Column_Identifier(to_char('M_InOut'), to_char(s.M_InOut_ID), to_char(?)) AS NAME 
carlos@0
   341
        FROM M_INOUT s 
carlos@0
   342
        WHERE s.IsSOTrx='Y' 
david@1686
   343
        AND s.ISLOGISTIC <> 'Y'
carlos@0
   344
        AND s.DocStatus IN ('CL','CO') 
carlos@0
   345
        AND s.AD_Client_ID IN ('1') 
carlos@0
   346
        AND s.AD_Org_ID IN ('1')
juanpablo@1605
   347
        AND s.C_BPartner_ID = ?  
carlos@0
   348
        AND EXISTS (SELECT 1 FROM M_INOUTLINE l 
carlos@0
   349
        WHERE l.M_INOUT_ID = s.M_INOUT_ID 
carlos@0
   350
        AND l.isinvoiced = 'N') 
carlos@0
   351
        ORDER BY NAME
carlos@0
   352
      ]]>
carlos@0
   353
    </Sql>
carlos@0
   354
    <Parameter name="adLanguage"/>
carlos@0
   355
    <Parameter name="adUserClient" type="replace" optional="true" after="s.AD_Client_ID IN (" text="'1'"/>
carlos@0
   356
    <Parameter name="adOrgClient" type="replace" optional="true" after="s.AD_Org_ID IN (" text="'1'"/>
carlos@0
   357
    <Parameter name="cBpartnerId"/>
carlos@0
   358
  </SqlMethod>
carlos@0
   359
  <SqlMethod name="selectFromShipmentTrl" type="preparedStatement" return="multiple">
carlos@0
   360
    <SqlMethodComment></SqlMethodComment>
carlos@0
   361
    <Sql>
carlos@0
   362
      <![CDATA[
carlos@0
   363
      SELECT s.M_InOut_ID AS ID, Ad_Column_Identifier(to_char('M_InOut'), to_char(s.M_InOut_ID), to_char(?)) AS NAME,
carlos@0
   364
      s.DocumentNo AS NAMESHIPMENT,
carlos@0
   365
        (l.MovementQty-SUM(COALESCE(mi.Qty,0))) AS QTY, l.C_UOM_ID, COALESCE(uomt.UOMSymbol, uom.UOMSymbol) AS UOMSymbol, 
ainhoa@3030
   366
        l.M_Product_ID,p.NAME||' '||(CASE WHEN ma.serno IS NOT NULL THEN TO_CHAR('('||' '||ma.serno||' '||')') ELSE TO_CHAR('')  END) AS RELATION_NAME, l.M_InOutLine_ID,l.Line, l.M_InOutLine_ID as C_OrderLine_ID 
carlos@0
   367
        FROM M_INOUTLINE l left join M_ATTRIBUTESETINSTANCE ma on l.M_ATTRIBUTESETINSTANCE_ID = ma.M_ATTRIBUTESETINSTANCE_ID
carlos@0
   368
                           left join M_MATCHINV mi             on l.M_InOutLine_ID=mi.M_InOutLine_ID,
carlos@0
   369
             C_UOM uom     left join C_UOM_TRL uomt            on uom.C_UOM_ID = uomt.C_UOM_ID
carlos@0
   370
                                                              and uomt.AD_Language = ?,
carlos@0
   371
        M_INOUT s,   M_PRODUCT p
carlos@0
   372
        WHERE s.M_INOUT_ID = l.M_INOUT_ID 
carlos@0
   373
        AND s.IsSOTrx='N' 
carlos@0
   374
        AND s.DocStatus IN ('CL','CO') 
carlos@0
   375
        AND s.AD_Client_ID IN ('1') 
carlos@0
   376
        AND s.AD_Org_ID IN ('1') 
carlos@0
   377
        AND l.C_UOM_ID=uom.C_UOM_ID 
carlos@0
   378
        AND l.M_Product_ID=p.M_Product_ID 
juanpablo@1605
   379
        AND l.M_InOut_ID=? 
carlos@0
   380
        GROUP BY s.M_InOut_ID, s.DocumentNo, s.MovementDate, l.MovementQty,l.C_UOM_ID,uom.UOMSymbol, uomt.UOMSymbol,
carlos@0
   381
        l.M_Product_ID,p.NAME, ma.serno, l.M_InOutLine_ID,l.Line,l.C_OrderLine_ID 
carlos@0
   382
        HAVING  (l.MovementQty-SUM(COALESCE(mi.Qty,0))) <> 0
carlos@0
   383
        ORDER BY NAME, l.Line
carlos@0
   384
      ]]>
carlos@0
   385
    </Sql>
carlos@0
   386
    <Field name="rownum" value="count"/>
carlos@0
   387
    <Parameter name="adLanguage"/>
carlos@0
   388
    <Parameter name="adUserClient" type="replace" optional="true" after="s.AD_Client_ID IN (" text="'1'"/>
carlos@0
   389
    <Parameter name="adOrgClient" type="replace" optional="true" after="s.AD_Org_ID IN (" text="'1'"/>
carlos@0
   390
    <Parameter name="adLanguage"/>
carlos@0
   391
    <Parameter name="mInoutId"/>
carlos@0
   392
  </SqlMethod>
carlos@0
   393
  <SqlMethod name="selectFromShipmentTrlSOTrx" type="preparedStatement" return="multiple">
carlos@0
   394
    <SqlMethodComment></SqlMethodComment>
carlos@0
   395
    <Sql>
carlos@0
   396
      <![CDATA[
carlos@0
   397
        SELECT s.M_InOut_ID AS ID, Ad_Column_Identifier(to_char('M_InOut'), to_char(s.M_InOut_ID), to_char(?)) AS NAME,
carlos@0
   398
        s.DocumentNo AS NAMESHIPMENT, 
carlos@0
   399
        l.MovementQty AS QTY, l.C_UOM_ID,COALESCE(uomt.UOMSymbol, uom.UOMSymbol) AS UOMSymbol, 
ainhoa@3030
   400
        l.M_Product_ID,p.NAME||' '|| (CASE WHEN ma.serno IS NOT NULL THEN TO_CHAR('('||' '||ma.serno||' '||')') ELSE TO_CHAR('')  END) AS RELATION_NAME, l.M_InOutLine_ID,l.Line, l.M_InOutLine_ID as C_OrderLine_ID 
carlos@0
   401
        FROM M_INOUTLINE l left join M_ATTRIBUTESETINSTANCE ma on l.M_ATTRIBUTESETINSTANCE_ID = ma.M_ATTRIBUTESETINSTANCE_ID,
carlos@0
   402
             C_UOM uom     left join C_UOM_TRL uomt            on uom.C_UOM_ID = uomt.C_UOM_ID
carlos@0
   403
                                                              and uomt.AD_Language = ? ,
carlos@0
   404
        M_INOUT s,    M_PRODUCT p 
carlos@0
   405
        WHERE s.M_INOUT_ID = l.M_INOUT_ID
carlos@0
   406
        AND s.IsSOTrx='Y' 
carlos@0
   407
        AND s.DocStatus IN ('CL','CO') 
carlos@0
   408
        AND s.AD_Client_ID IN ('1') 
carlos@0
   409
        AND s.AD_Org_ID IN ('1') 
carlos@0
   410
        AND l.C_UOM_ID=uom.C_UOM_ID 
carlos@0
   411
        AND l.M_Product_ID=p.M_Product_ID 
carlos@0
   412
        AND l.isinvoiced = 'N' 
juanpablo@1605
   413
        AND l.M_InOut_ID=? 
carlos@0
   414
        GROUP BY s.M_InOut_ID, s.DocumentNo, s.MovementDate, l.MovementQty,l.C_UOM_ID,uom.UOMSymbol, uomt.UOMSymbol,
carlos@0
   415
        l.M_Product_ID,p.NAME,ma.serno, l.M_InOutLine_ID,l.Line,l.C_OrderLine_ID
carlos@0
   416
        ORDER BY NAME, l.Line
carlos@0
   417
      ]]>
carlos@0
   418
    </Sql>
carlos@0
   419
    <Field name="rownum" value="count"/>
carlos@0
   420
    <Parameter name="adLanguage"/>
carlos@0
   421
    <Parameter name="adUserClient" type="replace" optional="true" after="s.AD_Client_ID IN (" text="'1'"/>
carlos@0
   422
    <Parameter name="adOrgClient" type="replace" optional="true" after="s.AD_Org_ID IN (" text="'1'"/>
carlos@0
   423
    <Parameter name="adLanguage"/>
carlos@0
   424
    <Parameter name="mInoutId"/>
carlos@0
   425
  </SqlMethod>
carlos@0
   426
  <SqlMethod name="selectFromShipmentUpdate" type="preparedStatement" connection="true" return="multiple">
carlos@0
   427
    <SqlMethodComment></SqlMethodComment>
carlos@0
   428
    <Sql>
carlos@0
   429
      <![CDATA[
carlos@0
   430
      SELECT (l.MovementQty-SUM(COALESCE(mi.Qty,0))) AS ID, l.C_UOM_ID,uom.UOMSymbol, l.M_Product_ID,p.NAME, l.M_InOutLine_ID,l.Line,
gorkaion@1787
   431
      l.C_OrderLine_ID, max(uom.STDPRECISION) as stdprecision, l.Description, l.quantityOrder*C_DIVIDE((l.MovementQty-SUM(COALESCE(mi.Qty,0))),l.MovementQty) as quantityOrder, 
carlos@0
   432
      l.M_Product_UOM_ID, l.M_ATTRIBUTESETINSTANCE_ID, l.ad_org_id
carlos@0
   433
      FROM M_INOUTLINE l left join M_MATCHINV mi on l.M_InOutLine_ID=mi.M_InOutLine_ID,
carlos@0
   434
      C_UOM uom,  M_PRODUCT p
carlos@0
   435
      WHERE l.C_UOM_ID=uom.C_UOM_ID
carlos@0
   436
      AND l.M_Product_ID=p.M_Product_ID
carlos@0
   437
      GROUP BY l.MovementQty,l.C_UOM_ID,uom.UOMSymbol,l.M_Product_ID,p.NAME, l.M_InOutLine_ID,l.Line,l.C_OrderLine_ID, l.Description,l.quantityOrder, l.M_Product_UOM_ID, l.M_ATTRIBUTESETINSTANCE_ID, l.ad_org_id
carlos@0
   438
      ORDER BY l.Line
carlos@0
   439
      ]]>
carlos@0
   440
    </Sql>
carlos@0
   441
    <Parameter name="cOrderlineId" optional="true" type="argument" after="AND l.M_Product_ID=p.M_Product_ID" text=" AND l.M_InOutLine_ID IN "/>
carlos@0
   442
  </SqlMethod>
carlos@0
   443
  <SqlMethod name="selectFromShipmentUpdateSOTrx" type="preparedStatement" connection="true" return="multiple">
carlos@0
   444
    <SqlMethodComment></SqlMethodComment>
carlos@0
   445
    <Sql>
carlos@0
   446
      <![CDATA[
carlos@0
   447
        SELECT l.MovementQty AS ID, l.C_UOM_ID,uom.UOMSymbol, l.M_Product_ID,p.NAME, l.M_InOutLine_ID,l.Line,
carlos@0
   448
        l.C_OrderLine_ID, max(uom.STDPRECISION) as stdprecision, l.Description,l.quantityOrder, l.M_Product_UOM_ID,
carlos@0
   449
        l.M_ATTRIBUTESETINSTANCE_ID, l.ad_org_id
carlos@0
   450
        FROM C_UOM uom, M_INOUTLINE l, M_PRODUCT p 
carlos@0
   451
        WHERE l.C_UOM_ID=uom.C_UOM_ID
carlos@0
   452
        AND l.M_Product_ID=p.M_Product_ID 
carlos@0
   453
        AND l.isinvoiced = 'N' 
carlos@0
   454
        GROUP BY l.MovementQty,l.C_UOM_ID,uom.UOMSymbol,l.M_Product_ID,p.NAME, l.M_InOutLine_ID,l.Line,l.C_OrderLine_ID, l.Description, l.quantityOrder, l.M_Product_UOM_ID, l.M_ATTRIBUTESETINSTANCE_ID, l.ad_org_id
carlos@0
   455
        ORDER BY l.Line
carlos@0
   456
      ]]>
carlos@0
   457
    </Sql>
carlos@0
   458
    <Field name="rownum" value="count"/>
carlos@0
   459
    <Parameter name="cOrderlineId" optional="true" type="argument" after="AND l.isinvoiced = 'N' " text=" AND l.M_InOutLine_ID IN "/>
carlos@0
   460
  </SqlMethod>
carlos@0
   461
  <SqlMethod name="set" type="constant" return="multiple">
carlos@0
   462
      <SqlMethodComment></SqlMethodComment>
carlos@0
   463
      <Sql></Sql>
carlos@0
   464
  </SqlMethod>
carlos@0
   465
  <SqlMethod name="selectPriceList" type="preparedStatement" connection="true" return="multiple">
carlos@0
   466
    <SqlMethodComment></SqlMethodComment>
carlos@0
   467
    <Sql>
carlos@0
   468
      <![CDATA[
carlos@0
   469
      SELECT plv.M_PriceList_Version_ID AS ID
carlos@0
   470
      FROM M_PRICELIST pl,M_PRICELIST_VERSION plv 
carlos@0
   471
      WHERE pl.M_PriceList_ID=plv.M_PriceList_ID AND plv.IsActive='Y'
juanpablo@1605
   472
      AND plv.ValidFrom <= TO_DATE(?) AND pl.M_PriceList_ID=? 
carlos@0
   473
      ORDER BY plv.ValidFrom DESC
carlos@0
   474
      ]]>
carlos@0
   475
    </Sql>
carlos@0
   476
    <Parameter name="validfrom"/>
carlos@0
   477
    <Parameter name="mPricelistId"/>
carlos@0
   478
  </SqlMethod>
carlos@0
   479
carlos@0
   480
  <SqlMethod name="selectPrices" type="preparedStatement" connection="true" return="multiple">
carlos@0
   481
    <SqlMethodComment></SqlMethodComment>
carlos@0
   482
    <Sql>
carlos@0
   483
      <![CDATA[
carlos@0
   484
      SELECT PriceActual,PriceList,PriceLimit,Description, '' AS C_ORDERLINE_ID, PriceStd
carlos@0
   485
      FROM C_OrderLine 
juanpablo@1605
   486
      WHERE C_OrderLine_ID=?
carlos@0
   487
      ]]>
carlos@0
   488
    </Sql>
carlos@0
   489
    <Parameter name="cOrderlineId"/>
carlos@0
   490
  </SqlMethod>
carlos@0
   491
  <SqlMethod name="selectBOM" type="preparedStatement" connection="true" return="multiple">
carlos@0
   492
    <SqlMethodComment></SqlMethodComment>
carlos@0
   493
    <Sql>
carlos@0
   494
      <![CDATA[
gorkaion@1787
   495
      SELECT M_BOM_PriceStd(pp.M_Product_ID,pp.M_PriceList_Version_ID) AS PriceStd,
gorkaion@1787
   496
      M_BOM_PriceList(pp.M_Product_ID,pp.M_PriceList_Version_ID) AS PriceList,
gorkaion@1787
   497
      M_BOM_PriceLimit(pp.M_Product_ID,pp.M_PriceList_Version_ID) AS PriceLimit, 
gorkaion@1787
   498
      M_GET_OFFER_PRICE(M_GET_OFFER(to_date(?), ?, pp.M_Product_ID), M_BOM_PriceStd(pp.M_Product_ID,pp.M_PriceList_Version_ID)) AS PriceActual, 
juanpablo@1605
   499
      M_GET_OFFER(to_date(?), ?, pp.M_Product_ID) AS M_Offer_ID
carlos@0
   500
      FROM M_PRODUCTPRICE pp 
juanpablo@1605
   501
      WHERE pp.M_Product_ID=? 
juanpablo@1605
   502
      AND pp.M_PriceList_Version_ID=? 
carlos@0
   503
      ]]>
carlos@0
   504
    </Sql>
carlos@0
   505
    <Parameter name="dateinvoiced"/>
carlos@0
   506
    <Parameter name="cBpartnerId"/>
carlos@0
   507
    <Parameter name="dateinvoiced"/>
carlos@0
   508
    <Parameter name="cBpartnerId"/>
carlos@0
   509
    <Parameter name="mProductId"/>
carlos@0
   510
    <Parameter name="mPricelistVersionId"/>
carlos@0
   511
  </SqlMethod>
carlos@0
   512
  <SqlMethod name="insert" type="preparedStatement" connection="true" return="rowCount">
carlos@0
   513
    <SqlMethodComment></SqlMethodComment>
carlos@0
   514
    <Sql>
juanpablo@1605
   515
      INSERT INTO C_INVOICELINE 
juanpablo@1605
   516
        (C_InvoiceLine_ID,C_Invoice_ID, AD_Client_ID,AD_Org_ID,IsActive,
juanpablo@1605
   517
        Created,CreatedBy,Updated,UpdatedBy, 
juanpablo@1605
   518
        C_OrderLine_ID,M_InOutLine_ID, Line,Description, M_Product_ID,
juanpablo@1605
   519
        C_UOM_ID,QtyInvoiced, PriceList,
juanpablo@1605
   520
        PriceActual,PriceLimit, LineNetAmt,
juanpablo@1605
   521
        ChargeAmt,C_Tax_ID, QuantityOrder, M_Product_UOM_ID,
juanpablo@1605
   522
        M_Attributesetinstance_ID, PriceStd)
juanpablo@1605
   523
      VALUES 
juanpablo@1605
   524
        (?, ?, ?, ?, 'Y', 
juanpablo@1605
   525
         now(), ?, now(), ?, 
juanpablo@1605
   526
         ?, ?, (SELECT (COALESCE(Max(Line),0))+10 FROM C_InvoiceLine WHERE C_Invoice_ID=?), ?, ?, 
juanpablo@1605
   527
         ?, TO_NUMBER(?), TO_NUMBER(?), 
juanpablo@1605
   528
         TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), 
juanpablo@1605
   529
         0, ?, TO_NUMBER(?), ?, 
juanpablo@1605
   530
         ?, TO_NUMBER(?))
carlos@0
   531
    </Sql>
carlos@0
   532
    <Parameter name="cInvoicelineId"/>
carlos@0
   533
    <Parameter name="cInvoiceId"/>
carlos@0
   534
    <Parameter name="adClientId"/>
carlos@0
   535
    <Parameter name="adOrgId"/>
carlos@0
   536
    <Parameter name="adUserId"/>
carlos@0
   537
    <Parameter name="adUserId"/>
carlos@0
   538
    <Parameter name="cOrderlineId"/>
carlos@0
   539
    <Parameter name="mInoutlineId"/>
carlos@0
   540
    <Parameter name="cInvoiceId"/>
carlos@0
   541
    <Parameter name="description"/>
carlos@0
   542
    <Parameter name="mProductId"/>
carlos@0
   543
    <Parameter name="cUomId"/>
carlos@0
   544
    <Parameter name="qtyinvoiced"/>
carlos@0
   545
    <Parameter name="pricelist"/>
carlos@0
   546
    <Parameter name="priceactual"/>
carlos@0
   547
    <Parameter name="pricelimit"/>
carlos@0
   548
    <Parameter name="linenetamt"/>
carlos@0
   549
    <Parameter name="cTaxId"/>
carlos@0
   550
    <Parameter name="quantityOrder"/>
carlos@0
   551
    <Parameter name="mProductUomId"/>
carlos@0
   552
    <Parameter name="mAttributesetinstanceId"/>
carlos@0
   553
    <Parameter name="pricestd"/>
carlos@0
   554
  </SqlMethod>
carlos@0
   555
  <SqlMethod name="updateC_Order_ID" type="preparedStatement" connection="true" return="rowCount">
carlos@0
   556
    <SqlMethodComment></SqlMethodComment>
carlos@0
   557
    <Sql><![CDATA[
juanpablo@1605
   558
      UPDATE C_Invoice SET C_Order_id = ?
juanpablo@1605
   559
      WHERE C_Invoice_ID = ?
carlos@0
   560
    ]]></Sql>
carlos@0
   561
    <Parameter name="cOrderId"/>
carlos@0
   562
    <Parameter name="cInvoiceId"/>
carlos@0
   563
  </SqlMethod>
carlos@0
   564
  <SqlMethod name="deleteC_Order_ID" type="preparedStatement" connection="true" return="rowCount">
carlos@0
   565
    <SqlMethodComment></SqlMethodComment>
carlos@0
   566
    <Sql> <![CDATA[
carlos@0
   567
      UPDATE C_INVOICE SET C_Order_ID=NULL
juanpablo@1605
   568
      WHERE C_Invoice_ID=?
juanpablo@1605
   569
      AND C_Order_ID IS NOT NULL AND C_Order_ID <> ?
carlos@0
   570
    ]]></Sql>
carlos@0
   571
    <Parameter name="cInvoiceId"/>
carlos@0
   572
    <Parameter name="cOrderId"/>
carlos@0
   573
  </SqlMethod>
carlos@0
   574
  <SqlMethod name="selectProject" type="preparedStatement" return="String" default="">
carlos@0
   575
    <SqlMethodComment></SqlMethodComment>
carlos@0
   576
    <Sql><![CDATA[
carlos@0
   577
      SELECT C_Project_ID
carlos@0
   578
      FROM C_INVOICE
juanpablo@1605
   579
      WHERE C_INVOICE_ID = ? 
carlos@0
   580
    ]]></Sql>
carlos@0
   581
    <Parameter name="cInvoiceId"/>
carlos@0
   582
  </SqlMethod>
carlos@0
   583
  <SqlMethod name="getTax" type="preparedStatement" return="String" default="">
carlos@0
   584
    <SqlMethodComment></SqlMethodComment>
carlos@0
   585
    <Sql><![CDATA[
carlos@0
   586
      SELECT C_Tax_ID
carlos@0
   587
      FROM C_ORDERLINE
juanpablo@1605
   588
      WHERE C_ORDERLINE_ID = ? 
carlos@0
   589
    ]]></Sql>
carlos@0
   590
    <Parameter name="cOrderLineId"/>
carlos@0
   591
  </SqlMethod>
carlos@0
   592
</SqlClass>