src-db/database/model/views/C_INVOICE_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_INVOICE_LINETAX_V">
eduardo@6917
     3
    <view name="C_INVOICE_LINETAX_V"><![CDATA[((( SELECT il.ad_client_id, il.ad_org_id, il.isactive, il.created, il.createdby, il.updated, il.updatedby, 'en_US' AS ad_language, il.c_invoice_id, il.c_invoiceline_id, il.c_tax_id, il.line, 
eduardo@6917
     4
        CASE
eduardo@6917
     5
            WHEN il.qtyinvoiced <> 0 OR il.m_product_id IS NOT NULL THEN il.qtyinvoiced
eduardo@6917
     6
            ELSE NULL
eduardo@6917
     7
        END AS qtyinvoiced, 
eduardo@6917
     8
        CASE
eduardo@6917
     9
            WHEN il.qtyinvoiced <> 0 OR il.m_product_id IS NOT NULL THEN uom.uomsymbol
eduardo@6917
    10
            ELSE NULL
eduardo@6917
    11
        END AS uomsymbol, COALESCE(p.name, il.description) AS name, 
eduardo@6917
    12
        CASE
eduardo@6917
    13
            WHEN p.name IS NOT NULL THEN il.description
eduardo@6917
    14
            ELSE NULL
eduardo@6917
    15
        END AS description, p.documentnote, p.upc, p.sku, p.value AS productvalue, ra.description AS resourcedescription, 
eduardo@6917
    16
        CASE
eduardo@6917
    17
            WHEN i.isdiscountprinted = 'Y' AND (il.pricelist <> 0 OR il.m_product_id IS NOT NULL) THEN il.pricelist
eduardo@6917
    18
            ELSE NULL
eduardo@6917
    19
        END AS pricelist, 
eduardo@6917
    20
        CASE
eduardo@6917
    21
            WHEN i.isdiscountprinted = 'Y' AND il.pricelist > il.priceactual THEN (il.pricelist - il.priceactual) / il.pricelist * 100
eduardo@6917
    22
            ELSE NULL
eduardo@6917
    23
        END AS discount, 
eduardo@6917
    24
        CASE
eduardo@6917
    25
            WHEN il.priceactual <> 0 OR il.m_product_id IS NOT NULL THEN il.priceactual
eduardo@6917
    26
            ELSE NULL
eduardo@6917
    27
        END AS priceactual, 
eduardo@6917
    28
        CASE
eduardo@6917
    29
            WHEN il.linenetamt <> 0 OR il.m_product_id IS NOT NULL THEN il.linenetamt
eduardo@6917
    30
            ELSE NULL
eduardo@6917
    31
        END AS linenetamt
eduardo@6917
    32
   FROM c_invoiceline il
eduardo@6917
    33
   JOIN c_uom uom ON il.c_uom_id = uom.c_uom_id
eduardo@6917
    34
   JOIN c_invoice i ON il.c_invoice_id = i.c_invoice_id
eduardo@6917
    35
   LEFT JOIN m_product p ON il.m_product_id = p.m_product_id
eduardo@6917
    36
   LEFT JOIN s_resourceassignment ra ON il.s_resourceassignment_id = ra.s_resourceassignment_id
antonio@776
    37
UNION 
eduardo@6917
    38
 SELECT il.ad_client_id, il.ad_org_id, il.isactive, il.created, il.createdby, il.updated, il.updatedby, 'en_US' AS ad_language, il.c_invoice_id, il.c_invoiceline_id, il.c_tax_id, il.line + b.line / 100 AS line, il.qtyinvoiced * b.bomqty AS qtyinvoiced, 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
    39
   FROM m_product_bom b
eduardo@6917
    40
   JOIN c_invoiceline il ON b.m_product_id = il.m_product_id
eduardo@6917
    41
   JOIN m_product bp ON bp.m_product_id = il.m_product_id AND bp.isbom = 'Y' AND bp.isverified = 'Y' AND bp.isinvoiceprintdetails = 'Y'
eduardo@6917
    42
   JOIN m_product p ON b.m_productbom_id = p.m_product_id
eduardo@6917
    43
   JOIN c_uom uom ON p.c_uom_id = uom.c_uom_id)
eduardo@6917
    44
UNION 
eduardo@6917
    45
 SELECT il.ad_client_id, il.ad_org_id, il.isactive, il.created, il.createdby, il.updated, il.updatedby, 'en_US' AS ad_language, il.c_invoice_id, il.c_invoiceline_id, il.c_tax_id, il.line, NULL AS qtyinvoiced, NULL AS uomsymbol, il.description 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
    46
   FROM c_invoiceline il
eduardo@6917
    47
  WHERE il.c_uom_id IS NULL)
eduardo@6917
    48
UNION 
eduardo@6917
    49
 SELECT c_invoice.ad_client_id, c_invoice.ad_org_id, c_invoice.isactive, c_invoice.created, c_invoice.createdby, c_invoice.updated, c_invoice.updatedby, 'en_US' AS ad_language, c_invoice.c_invoice_id, NULL AS c_invoiceline_id, NULL AS c_tax_id, 9998 AS line, NULL AS qtyinvoiced, 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
    50
   FROM c_invoice)
eduardo@6917
    51
UNION 
eduardo@6917
    52
 SELECT it.ad_client_id, it.ad_org_id, it.isactive, it.created, it.createdby, it.updated, it.updatedby, 'en_US' AS ad_language, it.c_invoice_id, NULL AS c_invoiceline_id, it.c_tax_id, 9999 AS line, NULL AS qtyinvoiced, 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, it.taxbaseamt AS priceactual, it.taxamt AS linenetamt
eduardo@6917
    53
   FROM c_invoicetax it
eduardo@6917
    54
   JOIN c_tax t ON it.c_tax_id = t.c_tax_id]]></view>
adrian@94
    55
  </database>