src-db/database/model/views/C_ORDER_LINETAX_V.xml
author Eduardo Argal Guibert <eduardo.argal@openbravo.com>
Sat, 03 Apr 2010 15:59:56 +0200
changeset 6917 20af736f8ca9
parent 6912 38c773f35773
child 7022 825f121b6164
permissions -rw-r--r--
wrong views posstgre 8.4
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="VIEW C_ORDER_LINETAX_V">
eduardo@6917
     3
    <view name="C_ORDER_LINETAX_V"><![CDATA[(( SELECT ol.ad_client_id, ol.ad_org_id, ol.isactive, ol.created, ol.createdby, ol.updated, ol.updatedby, 'en_US' AS ad_language, ol.c_order_id, ol.c_orderline_id, ol.c_tax_id, ol.line, ol.qtyordered, uom.uomsymbol, COALESCE(p.name, ol.description) AS name, 
eduardo@6917
     4
        CASE
eduardo@6917
     5
            WHEN p.name IS NOT NULL THEN ol.description
eduardo@6917
     6
            ELSE NULL
eduardo@6917
     7
        END AS description, p.documentnote, p.upc, p.sku, p.value AS productvalue, ra.description AS resourcedescription, 
eduardo@6917
     8
        CASE
eduardo@6917
     9
            WHEN i.isdiscountprinted = 'Y' THEN ol.pricelist
eduardo@6917
    10
            ELSE NULL
eduardo@6917
    11
        END AS pricelist, 
eduardo@6917
    12
        CASE
eduardo@6917
    13
            WHEN i.isdiscountprinted = 'Y' AND ol.pricelist > ol.priceactual THEN (ol.pricelist - ol.priceactual) / ol.pricelist * 100
eduardo@6917
    14
            ELSE NULL
eduardo@6917
    15
        END AS discount, ol.priceactual, ol.linenetamt
eduardo@6917
    16
   FROM c_orderline ol
eduardo@6917
    17
   JOIN c_uom uom ON ol.c_uom_id = uom.c_uom_id
eduardo@6917
    18
   JOIN c_order i ON ol.c_order_id = i.c_order_id
eduardo@6917
    19
   LEFT JOIN m_product p ON ol.m_product_id = p.m_product_id
eduardo@6917
    20
   LEFT JOIN s_resourceassignment ra ON ol.s_resourceassignment_id = ra.s_resourceassignment_id
antonio@776
    21
UNION 
eduardo@6917
    22
 SELECT ol.ad_client_id, ol.ad_org_id, ol.isactive, ol.created, ol.createdby, ol.updated, ol.updatedby, 'en_US' AS ad_language, ol.c_order_id, ol.c_orderline_id, ol.c_tax_id, ol.line + b.line / 100 AS line, ol.qtyordered * b.bomqty AS qtyordered, uom.uomsymbol, p.name, b.description, p.documentnote, p.upc, p.sku, p.value AS productvalue, NULL AS resourcedescription, NULL AS pricelist, NULL AS discount, NULL AS priceactual, NULL AS linenetamt
eduardo@6917
    23
   FROM m_product_bom b
eduardo@6917
    24
   JOIN c_orderline ol ON b.m_product_id = ol.m_product_id
eduardo@6917
    25
   JOIN m_product bp ON bp.m_product_id = ol.m_product_id AND bp.isbom = 'Y' AND bp.isverified = 'Y' AND bp.isinvoiceprintdetails = 'Y'
eduardo@6917
    26
   JOIN m_product p ON b.m_productbom_id = p.m_product_id
eduardo@6917
    27
   JOIN c_uom uom ON p.c_uom_id = uom.c_uom_id)
eduardo@6917
    28
UNION 
eduardo@6917
    29
 SELECT c_order.ad_client_id, c_order.ad_org_id, c_order.isactive, c_order.created, c_order.createdby, c_order.updated, c_order.updatedby, 'en_US' AS ad_language, c_order.c_order_id, NULL AS c_orderline_id, NULL AS c_tax_id, NULL AS line, NULL AS qtyordered, NULL AS uomsymbol, NULL AS name, NULL AS description, NULL AS documentnote, NULL AS upc, NULL AS sku, NULL AS productvalue, NULL AS resourcedescription, NULL AS pricelist, NULL AS discount, NULL AS priceactual, NULL AS linenetamt
eduardo@6917
    30
   FROM c_order)
eduardo@6917
    31
UNION 
eduardo@6917
    32
 SELECT ot.ad_client_id, ot.ad_org_id, ot.isactive, ot.created, ot.createdby, ot.updated, ot.updatedby, 'en_US' AS ad_language, ot.c_order_id, NULL AS c_orderline_id, ot.c_tax_id, NULL AS line, NULL AS qtyordered, NULL AS uomsymbol, t.name, NULL AS description, NULL AS documentnote, NULL AS upc, NULL AS sku, NULL AS productvalue, NULL AS resourcedescription, NULL AS pricelist, NULL AS discount, ot.taxbaseamt AS priceactual, ot.taxamt AS linenetamt
eduardo@6917
    33
   FROM c_ordertax ot
eduardo@6917
    34
   JOIN c_tax t ON ot.c_tax_id = t.c_tax_id]]></view>
adrian@94
    35
  </database>