src-db/database/model/views/C_ORDER_LINETAX_VT.xml
changeset 6917 20af736f8ca9
parent 6912 38c773f35773
child 7022 825f121b6164
equal deleted inserted replaced
6916:bbc68a0afe71 6917:20af736f8ca9
     1 <?xml version="1.0"?>
     1 <?xml version="1.0"?>
     2   <database name="VIEW C_ORDER_LINETAX_VT">
     2   <database name="VIEW C_ORDER_LINETAX_VT">
     3     <view name="C_ORDER_LINETAX_VT"><![CDATA[(        (         SELECT ol.ad_client_id, ol.ad_org_id, ol.isactive, ol.created, ol.createdby, ol.updated, ol.updatedby, uom.ad_language, ol.c_order_id, ol.c_orderline_id, ol.c_tax_id, ol.line, ol.qtyordered, uom.uomsymbol, COALESCE(COALESCE(pt.name, p.name), ol.description) AS name, 
     3     <view name="C_ORDER_LINETAX_VT"><![CDATA[(( SELECT ol.ad_client_id, ol.ad_org_id, ol.isactive, ol.created, ol.createdby, ol.updated, ol.updatedby, uom.ad_language, ol.c_order_id, ol.c_orderline_id, ol.c_tax_id, ol.line, ol.qtyordered, uom.uomsymbol, COALESCE(COALESCE(pt.name, p.name), ol.description) AS name, 
     4                                 CASE
     4         CASE
     5                                     WHEN COALESCE(pt.name, p.name) IS NOT NULL THEN ol.description
     5             WHEN COALESCE(pt.name, p.name) IS NOT NULL THEN ol.description
     6                                     ELSE NULL
     6             ELSE NULL
     7                                 END AS description, COALESCE(pt.documentnote, p.documentnote) AS documentnote, p.upc, p.sku, p.value AS productvalue, ra.description AS resourcedescription, 
     7         END AS description, COALESCE(pt.documentnote, p.documentnote) AS documentnote, p.upc, p.sku, p.value AS productvalue, ra.description AS resourcedescription, 
     8                                 CASE
     8         CASE
     9                                     WHEN i.isdiscountprinted = 'Y' THEN ol.pricelist
     9             WHEN i.isdiscountprinted = 'Y' THEN ol.pricelist
    10                                     ELSE NULL
    10             ELSE NULL
    11                                 END AS pricelist, 
    11         END AS pricelist, 
    12                                 CASE
    12         CASE
    13                                     WHEN i.isdiscountprinted = 'Y' AND ol.pricelist > ol.priceactual THEN (ol.pricelist - ol.priceactual) / ol.pricelist * 100
    13             WHEN i.isdiscountprinted = 'Y' AND ol.pricelist > ol.priceactual THEN (ol.pricelist - ol.priceactual) / ol.pricelist * 100
    14                                     ELSE NULL
    14             ELSE NULL
    15                                 END AS discount, ol.priceactual, ol.linenetamt
    15         END AS discount, ol.priceactual, ol.linenetamt
    16                            FROM c_orderline ol
    16    FROM c_orderline ol
    17                       JOIN c_uom_trl uom ON ol.c_uom_id = uom.c_uom_id
    17    JOIN c_uom_trl uom ON ol.c_uom_id = uom.c_uom_id
    18                  JOIN c_order i ON ol.c_order_id = i.c_order_id
    18    JOIN c_order i ON ol.c_order_id = i.c_order_id
    19             LEFT JOIN m_product p ON ol.m_product_id = p.m_product_id
    19    LEFT JOIN m_product p ON ol.m_product_id = p.m_product_id
    20        LEFT JOIN m_product_trl pt ON ol.m_product_id = pt.m_product_id AND uom.ad_language = pt.ad_language
    20    LEFT JOIN m_product_trl pt ON ol.m_product_id = pt.m_product_id AND uom.ad_language = pt.ad_language
    21    LEFT JOIN s_resourceassignment ra ON ol.s_resourceassignment_id = ra.s_resourceassignment_id
    21    LEFT JOIN s_resourceassignment ra ON ol.s_resourceassignment_id = ra.s_resourceassignment_id
    22                 UNION 
    22 UNION 
    23                          SELECT ol.ad_client_id, ol.ad_org_id, ol.isactive, ol.created, ol.createdby, ol.updated, ol.updatedby, uom.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, COALESCE(pt.name, p.name) AS name, b.description, COALESCE(pt.documentnote, p.documentnote) AS documentnote, p.upc, p.sku, p.value AS productvalue, NULL AS resourcedescription, NULL AS pricelist, NULL AS discount, NULL AS priceactual, NULL AS linenetamt
    23  SELECT ol.ad_client_id, ol.ad_org_id, ol.isactive, ol.created, ol.createdby, ol.updated, ol.updatedby, uom.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, COALESCE(pt.name, p.name) AS name, b.description, COALESCE(pt.documentnote, p.documentnote) AS documentnote, p.upc, p.sku, p.value AS productvalue, NULL AS resourcedescription, NULL AS pricelist, NULL AS discount, NULL AS priceactual, NULL AS linenetamt
    24                            FROM m_product_bom b
    24    FROM m_product_bom b
    25                       JOIN c_orderline ol ON b.m_product_id = ol.m_product_id
    25    JOIN c_orderline ol ON b.m_product_id = ol.m_product_id
    26                  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'
    26    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'
    27             JOIN m_product p ON b.m_productbom_id = p.m_product_id
    27    JOIN m_product p ON b.m_productbom_id = p.m_product_id
    28        JOIN c_uom_trl uom ON p.c_uom_id = uom.c_uom_id
    28    JOIN c_uom_trl uom ON p.c_uom_id = uom.c_uom_id
    29    JOIN m_product_trl pt ON b.m_productbom_id = pt.m_product_id AND uom.ad_language = pt.ad_language)
    29    JOIN m_product_trl pt ON b.m_productbom_id = pt.m_product_id AND uom.ad_language = pt.ad_language)
    30         UNION 
       
    31                  SELECT o.ad_client_id, o.ad_org_id, o.isactive, o.created, o.createdby, o.updated, o.updatedby, l.ad_language, o.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
       
    32                    FROM c_order o, ad_language l
       
    33                   WHERE l.isbaselanguage = 'N' AND l.issystemlanguage = 'Y')
       
    34 UNION 
    30 UNION 
    35          SELECT ot.ad_client_id, ot.ad_org_id, ot.isactive, ot.created, ot.createdby, ot.updated, ot.updatedby, l.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
    31  SELECT o.ad_client_id, o.ad_org_id, o.isactive, o.created, o.createdby, o.updated, o.updatedby, l.ad_language, o.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
    36            FROM c_ordertax ot
    32    FROM c_order o, ad_language l
    37       JOIN c_tax t ON ot.c_tax_id = t.c_tax_id, ad_language l
    33   WHERE l.isbaselanguage = 'N' AND l.issystemlanguage = 'Y')
    38      WHERE l.isbaselanguage = 'N' AND l.issystemlanguage = 'Y']]></view>
    34 UNION 
       
    35  SELECT ot.ad_client_id, ot.ad_org_id, ot.isactive, ot.created, ot.createdby, ot.updated, ot.updatedby, l.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
       
    36    FROM c_ordertax ot
       
    37    JOIN c_tax t ON ot.c_tax_id = t.c_tax_id, ad_language l
       
    38   WHERE l.isbaselanguage = 'N' AND l.issystemlanguage = 'Y']]></view>
    39   </database>
    39   </database>