src/org/openbravo/erpCommon/ad_actionButton/CreateFrom_Invoice_data.xsql
author Harikrishnan Raja <harikrishnan.raja@openbravo.com>
Thu, 06 Aug 2009 15:20:12 +0530
changeset 4494 b1a726132510
parent 3296 f1b414448f56
child 5094 ff6ccc39f03c
permissions -rw-r--r--
Fixes Issue 10130: The discounts are not correctly copied when using create lines from in the invoice window
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,
david@3296
    31
        '' 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, 
harikrishnan@4494
   197
      A.C_UOM_ID,uom.UOMSymbol, A.M_Product_ID,p.NAME, A.C_OrderLine_ID,A.Line, cur.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
harikrishnan@4494
   200
      FROM c_currency cur,C_UOM uom, M_PRODUCT p, 
harikrishnan@4494
   201
      (SELECT l.ad_org_id,l.C_CURRENCY_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
harikrishnan@4494
   205
        GROUP BY l.ad_org_id,l.C_CURRENCY_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
harikrishnan@4494
   217
      AND cur.C_CURRENCY_ID=A.C_CURRENCY_ID
carlos@0
   218
      AND A.M_Product_ID=p.M_Product_ID
carlos@0
   219
      ORDER BY A.Line
carlos@0
   220
      ]]>
carlos@0
   221
    </Sql>
carlos@0
   222
    <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
   223
  </SqlMethod>
carlos@0
   224
  <SqlMethod name="selectFromPOUpdateSOTrx" type="preparedStatement" connection="true" return="multiple">
carlos@0
   225
    <SqlMethodComment></SqlMethodComment>
carlos@0
   226
    <Sql>
carlos@0
   227
      <![CDATA[
carlos@0
   228
        SELECT (CASE WHEN il.M_INOUTLINE_ID IS NULL THEN (l.QtyOrdered-COALESCE(l.QTYINVOICED ,0)) ELSE il.MOVEMENTQTY END) AS ID, 
carlos@0
   229
        l.C_UOM_ID,uom.UOMSymbol, l.M_Product_ID,p.NAME, 
harikrishnan@4494
   230
        l.C_OrderLine_ID,l.Line, max(cur.stdprecision) as stdprecision, il.M_InOutLine_ID as M_InOutLine_ID, l.Description,
gorkaion@1787
   231
        (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
   232
        (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
   233
        FROM C_ORDERLINE l left join (SELECT M_InOutLine.* FROM M_InOutLine, M_InOut
gorkaion@158
   234
                                      WHERE M_InOut.M_InOut_ID = M_InOutLine.M_InOut_ID
gorkaion@158
   235
                                      AND M_InOutLine.IsInvoiced = 'N'
gorkaion@158
   236
                                      AND M_InOut.Processed='Y') il  on l.C_OrderLine_ID = il.C_OrderLine_ID,
harikrishnan@4494
   237
        C_UOM uom,  M_PRODUCT p  ,c_currency cur
harikrishnan@4494
   238
        WHERE cur.C_CURRENCY_ID=l.C_CURRENCY_ID AND l.C_UOM_ID=uom.C_UOM_ID
carlos@0
   239
        AND l.M_Product_ID=p.M_Product_ID 
carlos@0
   240
        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
   241
        l.QTYINVOICED, il.M_InOutLine_ID, il.MovementQty, l.Description, l.quantityOrder, il.quantityOrder, 
carlos@0
   242
        l.M_Product_UOM_ID, il.M_Product_UOM_ID, l.M_ATTRIBUTESETINSTANCE_ID,l.ad_org_id
carlos@0
   243
        HAVING (l.QtyOrdered-COALESCE(l.QTYINVOICED ,0)) <> 0 
carlos@0
   244
        ORDER BY l.Line
carlos@0
   245
      ]]>
carlos@0
   246
    </Sql>
carlos@0
   247
    <Field name="rownum" value="count"/>
carlos@0
   248
    <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
   249
  </SqlMethod>
carlos@0
   250
  <SqlMethod name="selectFromShipment" type="preparedStatement" return="multiple">
carlos@0
   251
    <SqlMethodComment></SqlMethodComment>
carlos@0
   252
    <Sql>
carlos@0
   253
      <![CDATA[
carlos@0
   254
        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
   255
        s.DocumentNo AS NAMESHIPMENT, 
ainhoa@3030
   256
        (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
   257
        l.M_InOutLine_ID,l.Line, l.M_InOutLine_ID as C_OrderLine_ID 
carlos@0
   258
        FROM M_INOUTLINE l left join M_ATTRIBUTESETINSTANCE ma on l.M_ATTRIBUTESETINSTANCE_ID = ma.M_ATTRIBUTESETINSTANCE_ID
carlos@0
   259
                           left join M_MATCHINV mi             on l.M_InOutLine_ID=mi.M_InOutLine_ID,
carlos@0
   260
        M_INOUT s, C_UOM uom,  M_PRODUCT p
carlos@0
   261
        WHERE s.M_INOUT_ID = l.M_INOUT_ID 
carlos@0
   262
        AND s.IsSOTrx='N' 
carlos@0
   263
        AND s.DocStatus IN ('CL','CO') 
carlos@0
   264
        AND s.AD_Client_ID IN ('1') 
carlos@0
   265
        AND s.AD_Org_ID IN ('1') 
carlos@0
   266
        AND l.C_UOM_ID=uom.C_UOM_ID 
carlos@0
   267
        AND l.M_Product_ID=p.M_Product_ID 
juanpablo@1605
   268
        AND l.M_InOut_ID=? 
carlos@0
   269
        GROUP BY s.M_InOut_ID, s.DocumentNo, s.MovementDate, l.MovementQty,l.C_UOM_ID,uom.UOMSymbol,
carlos@0
   270
        l.M_Product_ID,ma.serno,p.NAME, l.M_InOutLine_ID,l.Line,l.C_OrderLine_ID 
carlos@0
   271
        HAVING  (l.MovementQty-SUM(COALESCE(mi.Qty,0))) <> 0
carlos@0
   272
        ORDER BY NAME, l.Line
carlos@0
   273
      ]]>
carlos@0
   274
    </Sql>
carlos@0
   275
    <Field name="rownum" value="count"/>
carlos@0
   276
    <Parameter name="adLanguage"/>
carlos@0
   277
    <Parameter name="adUserClient" type="replace" optional="true" after="s.AD_Client_ID IN (" text="'1'"/>
carlos@0
   278
    <Parameter name="adOrgClient" type="replace" optional="true" after="s.AD_Org_ID IN (" text="'1'"/>
carlos@0
   279
    <Parameter name="mInoutId"/>
carlos@0
   280
  </SqlMethod>
carlos@0
   281
  <SqlMethod name="selectFromShipmentCombo" type="preparedStatement" return="multiple">
carlos@0
   282
    <SqlMethodComment></SqlMethodComment>
carlos@0
   283
    <Sql>
carlos@0
   284
      <![CDATA[
carlos@0
   285
        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
   286
        FROM M_INOUT s 
carlos@0
   287
        WHERE s.IsSOTrx='N' 
carlos@0
   288
        AND s.DocStatus IN ('CL','CO') 
david@1686
   289
        AND s.ISLOGISTIC <> 'Y'
carlos@0
   290
        AND s.AD_Client_ID IN ('1') 
carlos@0
   291
        AND s.AD_Org_ID IN ('1') 
juanpablo@1605
   292
        AND s.C_BPartner_ID = ? 
carlos@0
   293
        AND EXISTS (SELECT 1 
carlos@0
   294
                     FROM M_INOUTLINE l left join M_MATCHINV mi on l.M_InOutLine_ID=mi.M_InOutLine_ID
carlos@0
   295
                      WHERE l.M_INOUT_ID = s.M_INOUT_ID 
carlos@0
   296
                      GROUP BY l.MovementQty, l.M_InOutLine_ID 
carlos@0
   297
                      HAVING  (l.MovementQty-SUM(COALESCE(mi.Qty,0))) <> 0)
carlos@0
   298
        ORDER BY NAME
carlos@0
   299
      ]]>
carlos@0
   300
    </Sql>
carlos@0
   301
    <Field name="rownum" value="count"/>
carlos@0
   302
    <Parameter name="adLanguage"/>
carlos@0
   303
    <Parameter name="adUserClient" type="replace" optional="true" after="s.AD_Client_ID IN (" text="'1'"/>
carlos@0
   304
    <Parameter name="adOrgClient" type="replace" optional="true" after="s.AD_Org_ID IN (" text="'1'"/>
carlos@0
   305
    <Parameter name="cBpartnerId"/>
carlos@0
   306
  </SqlMethod>
carlos@0
   307
  <SqlMethod name="selectFromShipmentSOTrx" type="preparedStatement" return="multiple">
carlos@0
   308
    <SqlMethodComment></SqlMethodComment>
carlos@0
   309
    <Sql>
carlos@0
   310
      <![CDATA[
carlos@0
   311
        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
   312
        s.DocumentNo AS NAMESHIPMENT,
ainhoa@3030
   313
        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
   314
        l.M_InOutLine_ID as C_OrderLine_ID 
carlos@0
   315
        FROM M_INOUTLINE l left join M_ATTRIBUTESETINSTANCE ma on l.M_ATTRIBUTESETINSTANCE_ID = ma.M_ATTRIBUTESETINSTANCE_ID,
carlos@0
   316
        M_INOUT s, C_UOM uom, M_PRODUCT p 
carlos@0
   317
        WHERE s.M_INOUT_ID = l.M_INOUT_ID
carlos@0
   318
        AND s.IsSOTrx='Y' 
carlos@0
   319
        AND s.DocStatus IN ('CL','CO') 
carlos@0
   320
        AND s.AD_Client_ID IN ('1') 
carlos@0
   321
        AND s.AD_Org_ID IN ('1') 
carlos@0
   322
        AND l.C_UOM_ID=uom.C_UOM_ID 
carlos@0
   323
        AND l.M_Product_ID=p.M_Product_ID 
carlos@0
   324
        AND l.isinvoiced = 'N' 
juanpablo@1605
   325
        AND l.M_InOut_ID=?
carlos@0
   326
        GROUP BY s.M_InOut_ID, s.DocumentNo, s.MovementDate, l.MovementQty,l.C_UOM_ID,uom.UOMSymbol,
carlos@0
   327
        l.M_Product_ID,p.NAME, ma.serno, l.M_InOutLine_ID,l.Line,l.C_OrderLine_ID
carlos@0
   328
        ORDER BY NAME, l.Line
carlos@0
   329
      ]]>
carlos@0
   330
    </Sql>
carlos@0
   331
    <Field name="rownum" value="count"/>
carlos@0
   332
    <Parameter name="adLanguage"/>
carlos@0
   333
    <Parameter name="adUserClient" type="replace" optional="true" after="s.AD_Client_ID IN (" text="'1'"/>
carlos@0
   334
    <Parameter name="adOrgClient" type="replace" optional="true" after="s.AD_Org_ID IN (" text="'1'"/>
carlos@0
   335
    <Parameter name="mInoutId"/>
carlos@0
   336
  </SqlMethod>
carlos@0
   337
  <SqlMethod name="selectFromShipmentSOTrxCombo" type="preparedStatement" return="multiple">
carlos@0
   338
    <SqlMethodComment></SqlMethodComment>
carlos@0
   339
    <Sql>
carlos@0
   340
      <![CDATA[
carlos@0
   341
        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
   342
        FROM M_INOUT s 
carlos@0
   343
        WHERE s.IsSOTrx='Y' 
david@1686
   344
        AND s.ISLOGISTIC <> 'Y'
carlos@0
   345
        AND s.DocStatus IN ('CL','CO') 
carlos@0
   346
        AND s.AD_Client_ID IN ('1') 
carlos@0
   347
        AND s.AD_Org_ID IN ('1')
juanpablo@1605
   348
        AND s.C_BPartner_ID = ?  
carlos@0
   349
        AND EXISTS (SELECT 1 FROM M_INOUTLINE l 
carlos@0
   350
        WHERE l.M_INOUT_ID = s.M_INOUT_ID 
carlos@0
   351
        AND l.isinvoiced = 'N') 
carlos@0
   352
        ORDER BY NAME
carlos@0
   353
      ]]>
carlos@0
   354
    </Sql>
carlos@0
   355
    <Parameter name="adLanguage"/>
carlos@0
   356
    <Parameter name="adUserClient" type="replace" optional="true" after="s.AD_Client_ID IN (" text="'1'"/>
carlos@0
   357
    <Parameter name="adOrgClient" type="replace" optional="true" after="s.AD_Org_ID IN (" text="'1'"/>
carlos@0
   358
    <Parameter name="cBpartnerId"/>
carlos@0
   359
  </SqlMethod>
carlos@0
   360
  <SqlMethod name="selectFromShipmentTrl" type="preparedStatement" return="multiple">
carlos@0
   361
    <SqlMethodComment></SqlMethodComment>
carlos@0
   362
    <Sql>
carlos@0
   363
      <![CDATA[
carlos@0
   364
      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
   365
      s.DocumentNo AS NAMESHIPMENT,
carlos@0
   366
        (l.MovementQty-SUM(COALESCE(mi.Qty,0))) AS QTY, l.C_UOM_ID, COALESCE(uomt.UOMSymbol, uom.UOMSymbol) AS UOMSymbol, 
ainhoa@3030
   367
        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
   368
        FROM M_INOUTLINE l left join M_ATTRIBUTESETINSTANCE ma on l.M_ATTRIBUTESETINSTANCE_ID = ma.M_ATTRIBUTESETINSTANCE_ID
carlos@0
   369
                           left join M_MATCHINV mi             on l.M_InOutLine_ID=mi.M_InOutLine_ID,
carlos@0
   370
             C_UOM uom     left join C_UOM_TRL uomt            on uom.C_UOM_ID = uomt.C_UOM_ID
carlos@0
   371
                                                              and uomt.AD_Language = ?,
carlos@0
   372
        M_INOUT s,   M_PRODUCT p
carlos@0
   373
        WHERE s.M_INOUT_ID = l.M_INOUT_ID 
carlos@0
   374
        AND s.IsSOTrx='N' 
carlos@0
   375
        AND s.DocStatus IN ('CL','CO') 
carlos@0
   376
        AND s.AD_Client_ID IN ('1') 
carlos@0
   377
        AND s.AD_Org_ID IN ('1') 
carlos@0
   378
        AND l.C_UOM_ID=uom.C_UOM_ID 
carlos@0
   379
        AND l.M_Product_ID=p.M_Product_ID 
juanpablo@1605
   380
        AND l.M_InOut_ID=? 
carlos@0
   381
        GROUP BY s.M_InOut_ID, s.DocumentNo, s.MovementDate, l.MovementQty,l.C_UOM_ID,uom.UOMSymbol, uomt.UOMSymbol,
carlos@0
   382
        l.M_Product_ID,p.NAME, ma.serno, l.M_InOutLine_ID,l.Line,l.C_OrderLine_ID 
carlos@0
   383
        HAVING  (l.MovementQty-SUM(COALESCE(mi.Qty,0))) <> 0
carlos@0
   384
        ORDER BY NAME, l.Line
carlos@0
   385
      ]]>
carlos@0
   386
    </Sql>
carlos@0
   387
    <Field name="rownum" value="count"/>
carlos@0
   388
    <Parameter name="adLanguage"/>
carlos@0
   389
    <Parameter name="adUserClient" type="replace" optional="true" after="s.AD_Client_ID IN (" text="'1'"/>
carlos@0
   390
    <Parameter name="adOrgClient" type="replace" optional="true" after="s.AD_Org_ID IN (" text="'1'"/>
carlos@0
   391
    <Parameter name="adLanguage"/>
carlos@0
   392
    <Parameter name="mInoutId"/>
carlos@0
   393
  </SqlMethod>
carlos@0
   394
  <SqlMethod name="selectFromShipmentTrlSOTrx" type="preparedStatement" return="multiple">
carlos@0
   395
    <SqlMethodComment></SqlMethodComment>
carlos@0
   396
    <Sql>
carlos@0
   397
      <![CDATA[
carlos@0
   398
        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
   399
        s.DocumentNo AS NAMESHIPMENT, 
carlos@0
   400
        l.MovementQty AS QTY, l.C_UOM_ID,COALESCE(uomt.UOMSymbol, uom.UOMSymbol) AS UOMSymbol, 
ainhoa@3030
   401
        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
   402
        FROM M_INOUTLINE l left join M_ATTRIBUTESETINSTANCE ma on l.M_ATTRIBUTESETINSTANCE_ID = ma.M_ATTRIBUTESETINSTANCE_ID,
carlos@0
   403
             C_UOM uom     left join C_UOM_TRL uomt            on uom.C_UOM_ID = uomt.C_UOM_ID
carlos@0
   404
                                                              and uomt.AD_Language = ? ,
carlos@0
   405
        M_INOUT s,    M_PRODUCT p 
carlos@0
   406
        WHERE s.M_INOUT_ID = l.M_INOUT_ID
carlos@0
   407
        AND s.IsSOTrx='Y' 
carlos@0
   408
        AND s.DocStatus IN ('CL','CO') 
carlos@0
   409
        AND s.AD_Client_ID IN ('1') 
carlos@0
   410
        AND s.AD_Org_ID IN ('1') 
carlos@0
   411
        AND l.C_UOM_ID=uom.C_UOM_ID 
carlos@0
   412
        AND l.M_Product_ID=p.M_Product_ID 
carlos@0
   413
        AND l.isinvoiced = 'N' 
juanpablo@1605
   414
        AND l.M_InOut_ID=? 
carlos@0
   415
        GROUP BY s.M_InOut_ID, s.DocumentNo, s.MovementDate, l.MovementQty,l.C_UOM_ID,uom.UOMSymbol, uomt.UOMSymbol,
carlos@0
   416
        l.M_Product_ID,p.NAME,ma.serno, l.M_InOutLine_ID,l.Line,l.C_OrderLine_ID
carlos@0
   417
        ORDER BY NAME, l.Line
carlos@0
   418
      ]]>
carlos@0
   419
    </Sql>
carlos@0
   420
    <Field name="rownum" value="count"/>
carlos@0
   421
    <Parameter name="adLanguage"/>
carlos@0
   422
    <Parameter name="adUserClient" type="replace" optional="true" after="s.AD_Client_ID IN (" text="'1'"/>
carlos@0
   423
    <Parameter name="adOrgClient" type="replace" optional="true" after="s.AD_Org_ID IN (" text="'1'"/>
carlos@0
   424
    <Parameter name="adLanguage"/>
carlos@0
   425
    <Parameter name="mInoutId"/>
carlos@0
   426
  </SqlMethod>
carlos@0
   427
  <SqlMethod name="selectFromShipmentUpdate" type="preparedStatement" connection="true" return="multiple">
carlos@0
   428
    <SqlMethodComment></SqlMethodComment>
carlos@0
   429
    <Sql>
carlos@0
   430
      <![CDATA[
carlos@0
   431
      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
   432
      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
   433
      l.M_Product_UOM_ID, l.M_ATTRIBUTESETINSTANCE_ID, l.ad_org_id
carlos@0
   434
      FROM M_INOUTLINE l left join M_MATCHINV mi on l.M_InOutLine_ID=mi.M_InOutLine_ID,
carlos@0
   435
      C_UOM uom,  M_PRODUCT p
carlos@0
   436
      WHERE l.C_UOM_ID=uom.C_UOM_ID
carlos@0
   437
      AND l.M_Product_ID=p.M_Product_ID
carlos@0
   438
      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
   439
      ORDER BY l.Line
carlos@0
   440
      ]]>
carlos@0
   441
    </Sql>
carlos@0
   442
    <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
   443
  </SqlMethod>
carlos@0
   444
  <SqlMethod name="selectFromShipmentUpdateSOTrx" type="preparedStatement" connection="true" return="multiple">
carlos@0
   445
    <SqlMethodComment></SqlMethodComment>
carlos@0
   446
    <Sql>
carlos@0
   447
      <![CDATA[
carlos@0
   448
        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
   449
        l.C_OrderLine_ID, max(uom.STDPRECISION) as stdprecision, l.Description,l.quantityOrder, l.M_Product_UOM_ID,
carlos@0
   450
        l.M_ATTRIBUTESETINSTANCE_ID, l.ad_org_id
carlos@0
   451
        FROM C_UOM uom, M_INOUTLINE l, M_PRODUCT p 
carlos@0
   452
        WHERE l.C_UOM_ID=uom.C_UOM_ID
carlos@0
   453
        AND l.M_Product_ID=p.M_Product_ID 
carlos@0
   454
        AND l.isinvoiced = 'N' 
carlos@0
   455
        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
   456
        ORDER BY l.Line
carlos@0
   457
      ]]>
carlos@0
   458
    </Sql>
carlos@0
   459
    <Field name="rownum" value="count"/>
carlos@0
   460
    <Parameter name="cOrderlineId" optional="true" type="argument" after="AND l.isinvoiced = 'N' " text=" AND l.M_InOutLine_ID IN "/>
carlos@0
   461
  </SqlMethod>
carlos@0
   462
  <SqlMethod name="set" type="constant" return="multiple">
carlos@0
   463
      <SqlMethodComment></SqlMethodComment>
carlos@0
   464
      <Sql></Sql>
carlos@0
   465
  </SqlMethod>
carlos@0
   466
  <SqlMethod name="selectPriceList" type="preparedStatement" connection="true" return="multiple">
carlos@0
   467
    <SqlMethodComment></SqlMethodComment>
carlos@0
   468
    <Sql>
carlos@0
   469
      <![CDATA[
carlos@0
   470
      SELECT plv.M_PriceList_Version_ID AS ID
carlos@0
   471
      FROM M_PRICELIST pl,M_PRICELIST_VERSION plv 
carlos@0
   472
      WHERE pl.M_PriceList_ID=plv.M_PriceList_ID AND plv.IsActive='Y'
juanpablo@1605
   473
      AND plv.ValidFrom <= TO_DATE(?) AND pl.M_PriceList_ID=? 
carlos@0
   474
      ORDER BY plv.ValidFrom DESC
carlos@0
   475
      ]]>
carlos@0
   476
    </Sql>
carlos@0
   477
    <Parameter name="validfrom"/>
carlos@0
   478
    <Parameter name="mPricelistId"/>
carlos@0
   479
  </SqlMethod>
carlos@0
   480
carlos@0
   481
  <SqlMethod name="selectPrices" type="preparedStatement" connection="true" return="multiple">
carlos@0
   482
    <SqlMethodComment></SqlMethodComment>
carlos@0
   483
    <Sql>
carlos@0
   484
      <![CDATA[
carlos@0
   485
      SELECT PriceActual,PriceList,PriceLimit,Description, '' AS C_ORDERLINE_ID, PriceStd
carlos@0
   486
      FROM C_OrderLine 
juanpablo@1605
   487
      WHERE C_OrderLine_ID=?
carlos@0
   488
      ]]>
carlos@0
   489
    </Sql>
carlos@0
   490
    <Parameter name="cOrderlineId"/>
carlos@0
   491
  </SqlMethod>
carlos@0
   492
  <SqlMethod name="selectBOM" type="preparedStatement" connection="true" return="multiple">
carlos@0
   493
    <SqlMethodComment></SqlMethodComment>
carlos@0
   494
    <Sql>
carlos@0
   495
      <![CDATA[
gorkaion@1787
   496
      SELECT M_BOM_PriceStd(pp.M_Product_ID,pp.M_PriceList_Version_ID) AS PriceStd,
gorkaion@1787
   497
      M_BOM_PriceList(pp.M_Product_ID,pp.M_PriceList_Version_ID) AS PriceList,
gorkaion@1787
   498
      M_BOM_PriceLimit(pp.M_Product_ID,pp.M_PriceList_Version_ID) AS PriceLimit, 
gorkaion@1787
   499
      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
   500
      M_GET_OFFER(to_date(?), ?, pp.M_Product_ID) AS M_Offer_ID
carlos@0
   501
      FROM M_PRODUCTPRICE pp 
juanpablo@1605
   502
      WHERE pp.M_Product_ID=? 
juanpablo@1605
   503
      AND pp.M_PriceList_Version_ID=? 
carlos@0
   504
      ]]>
carlos@0
   505
    </Sql>
carlos@0
   506
    <Parameter name="dateinvoiced"/>
carlos@0
   507
    <Parameter name="cBpartnerId"/>
carlos@0
   508
    <Parameter name="dateinvoiced"/>
carlos@0
   509
    <Parameter name="cBpartnerId"/>
carlos@0
   510
    <Parameter name="mProductId"/>
carlos@0
   511
    <Parameter name="mPricelistVersionId"/>
carlos@0
   512
  </SqlMethod>
carlos@0
   513
  <SqlMethod name="insert" type="preparedStatement" connection="true" return="rowCount">
carlos@0
   514
    <SqlMethodComment></SqlMethodComment>
carlos@0
   515
    <Sql>
juanpablo@1605
   516
      INSERT INTO C_INVOICELINE 
juanpablo@1605
   517
        (C_InvoiceLine_ID,C_Invoice_ID, AD_Client_ID,AD_Org_ID,IsActive,
juanpablo@1605
   518
        Created,CreatedBy,Updated,UpdatedBy, 
juanpablo@1605
   519
        C_OrderLine_ID,M_InOutLine_ID, Line,Description, M_Product_ID,
juanpablo@1605
   520
        C_UOM_ID,QtyInvoiced, PriceList,
juanpablo@1605
   521
        PriceActual,PriceLimit, LineNetAmt,
juanpablo@1605
   522
        ChargeAmt,C_Tax_ID, QuantityOrder, M_Product_UOM_ID,
juanpablo@1605
   523
        M_Attributesetinstance_ID, PriceStd)
juanpablo@1605
   524
      VALUES 
juanpablo@1605
   525
        (?, ?, ?, ?, 'Y', 
juanpablo@1605
   526
         now(), ?, now(), ?, 
juanpablo@1605
   527
         ?, ?, (SELECT (COALESCE(Max(Line),0))+10 FROM C_InvoiceLine WHERE C_Invoice_ID=?), ?, ?, 
juanpablo@1605
   528
         ?, TO_NUMBER(?), TO_NUMBER(?), 
juanpablo@1605
   529
         TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?), 
juanpablo@1605
   530
         0, ?, TO_NUMBER(?), ?, 
juanpablo@1605
   531
         ?, TO_NUMBER(?))
carlos@0
   532
    </Sql>
carlos@0
   533
    <Parameter name="cInvoicelineId"/>
carlos@0
   534
    <Parameter name="cInvoiceId"/>
carlos@0
   535
    <Parameter name="adClientId"/>
carlos@0
   536
    <Parameter name="adOrgId"/>
carlos@0
   537
    <Parameter name="adUserId"/>
carlos@0
   538
    <Parameter name="adUserId"/>
carlos@0
   539
    <Parameter name="cOrderlineId"/>
carlos@0
   540
    <Parameter name="mInoutlineId"/>
carlos@0
   541
    <Parameter name="cInvoiceId"/>
carlos@0
   542
    <Parameter name="description"/>
carlos@0
   543
    <Parameter name="mProductId"/>
carlos@0
   544
    <Parameter name="cUomId"/>
carlos@0
   545
    <Parameter name="qtyinvoiced"/>
carlos@0
   546
    <Parameter name="pricelist"/>
carlos@0
   547
    <Parameter name="priceactual"/>
carlos@0
   548
    <Parameter name="pricelimit"/>
carlos@0
   549
    <Parameter name="linenetamt"/>
carlos@0
   550
    <Parameter name="cTaxId"/>
carlos@0
   551
    <Parameter name="quantityOrder"/>
carlos@0
   552
    <Parameter name="mProductUomId"/>
carlos@0
   553
    <Parameter name="mAttributesetinstanceId"/>
carlos@0
   554
    <Parameter name="pricestd"/>
carlos@0
   555
  </SqlMethod>
carlos@0
   556
  <SqlMethod name="updateC_Order_ID" type="preparedStatement" connection="true" return="rowCount">
carlos@0
   557
    <SqlMethodComment></SqlMethodComment>
carlos@0
   558
    <Sql><![CDATA[
juanpablo@1605
   559
      UPDATE C_Invoice SET C_Order_id = ?
juanpablo@1605
   560
      WHERE C_Invoice_ID = ?
carlos@0
   561
    ]]></Sql>
carlos@0
   562
    <Parameter name="cOrderId"/>
carlos@0
   563
    <Parameter name="cInvoiceId"/>
carlos@0
   564
  </SqlMethod>
carlos@0
   565
  <SqlMethod name="deleteC_Order_ID" type="preparedStatement" connection="true" return="rowCount">
carlos@0
   566
    <SqlMethodComment></SqlMethodComment>
carlos@0
   567
    <Sql> <![CDATA[
carlos@0
   568
      UPDATE C_INVOICE SET C_Order_ID=NULL
juanpablo@1605
   569
      WHERE C_Invoice_ID=?
juanpablo@1605
   570
      AND C_Order_ID IS NOT NULL AND C_Order_ID <> ?
carlos@0
   571
    ]]></Sql>
carlos@0
   572
    <Parameter name="cInvoiceId"/>
carlos@0
   573
    <Parameter name="cOrderId"/>
carlos@0
   574
  </SqlMethod>
carlos@0
   575
  <SqlMethod name="selectProject" type="preparedStatement" return="String" default="">
carlos@0
   576
    <SqlMethodComment></SqlMethodComment>
carlos@0
   577
    <Sql><![CDATA[
carlos@0
   578
      SELECT C_Project_ID
carlos@0
   579
      FROM C_INVOICE
juanpablo@1605
   580
      WHERE C_INVOICE_ID = ? 
carlos@0
   581
    ]]></Sql>
carlos@0
   582
    <Parameter name="cInvoiceId"/>
carlos@0
   583
  </SqlMethod>
carlos@0
   584
  <SqlMethod name="getTax" type="preparedStatement" return="String" default="">
carlos@0
   585
    <SqlMethodComment></SqlMethodComment>
carlos@0
   586
    <Sql><![CDATA[
carlos@0
   587
      SELECT C_Tax_ID
carlos@0
   588
      FROM C_ORDERLINE
juanpablo@1605
   589
      WHERE C_ORDERLINE_ID = ? 
carlos@0
   590
    ]]></Sql>
carlos@0
   591
    <Parameter name="cOrderLineId"/>
carlos@0
   592
  </SqlMethod>
carlos@0
   593
</SqlClass>