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