src-db/database/model/views/C_INVOICE_LINETAX_V.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_INVOICE_LINETAX_V">
     2   <database name="VIEW C_INVOICE_LINETAX_V">
     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, 
     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, 
     4                                         CASE
     4         CASE
     5                                             WHEN il.qtyinvoiced <> 0 OR il.m_product_id IS NOT NULL THEN il.qtyinvoiced
     5             WHEN il.qtyinvoiced <> 0 OR il.m_product_id IS NOT NULL THEN il.qtyinvoiced
     6                                             ELSE NULL
     6             ELSE NULL
     7                                         END AS qtyinvoiced, 
     7         END AS qtyinvoiced, 
     8                                         CASE
     8         CASE
     9                                             WHEN il.qtyinvoiced <> 0 OR il.m_product_id IS NOT NULL THEN uom.uomsymbol
     9             WHEN il.qtyinvoiced <> 0 OR il.m_product_id IS NOT NULL THEN uom.uomsymbol
    10                                             ELSE NULL
    10             ELSE NULL
    11                                         END AS uomsymbol, COALESCE(p.name, il.description) AS name, 
    11         END AS uomsymbol, COALESCE(p.name, il.description) AS name, 
    12                                         CASE
    12         CASE
    13                                             WHEN p.name IS NOT NULL THEN il.description
    13             WHEN p.name IS NOT NULL THEN il.description
    14                                             ELSE NULL
    14             ELSE NULL
    15                                         END AS description, p.documentnote, p.upc, p.sku, p.value AS productvalue, ra.description AS resourcedescription, 
    15         END AS description, p.documentnote, p.upc, p.sku, p.value AS productvalue, ra.description AS resourcedescription, 
    16                                         CASE
    16         CASE
    17                                             WHEN i.isdiscountprinted = 'Y' AND (il.pricelist <> 0 OR il.m_product_id IS NOT NULL) THEN il.pricelist
    17             WHEN i.isdiscountprinted = 'Y' AND (il.pricelist <> 0 OR il.m_product_id IS NOT NULL) THEN il.pricelist
    18                                             ELSE NULL
    18             ELSE NULL
    19                                         END AS pricelist, 
    19         END AS pricelist, 
    20                                         CASE
    20         CASE
    21                                             WHEN i.isdiscountprinted = 'Y' AND il.pricelist > il.priceactual THEN (il.pricelist - il.priceactual) / il.pricelist * 100
    21             WHEN i.isdiscountprinted = 'Y' AND il.pricelist > il.priceactual THEN (il.pricelist - il.priceactual) / il.pricelist * 100
    22                                             ELSE NULL
    22             ELSE NULL
    23                                         END AS discount, 
    23         END AS discount, 
    24                                         CASE
    24         CASE
    25                                             WHEN il.priceactual <> 0 OR il.m_product_id IS NOT NULL THEN il.priceactual
    25             WHEN il.priceactual <> 0 OR il.m_product_id IS NOT NULL THEN il.priceactual
    26                                             ELSE NULL
    26             ELSE NULL
    27                                         END AS priceactual, 
    27         END AS priceactual, 
    28                                         CASE
    28         CASE
    29                                             WHEN il.linenetamt <> 0 OR il.m_product_id IS NOT NULL THEN il.linenetamt
    29             WHEN il.linenetamt <> 0 OR il.m_product_id IS NOT NULL THEN il.linenetamt
    30                                             ELSE NULL
    30             ELSE NULL
    31                                         END AS linenetamt
    31         END AS linenetamt
    32                                    FROM c_invoiceline il
    32    FROM c_invoiceline il
    33                               JOIN c_uom uom ON il.c_uom_id = uom.c_uom_id
    33    JOIN c_uom uom ON il.c_uom_id = uom.c_uom_id
    34                          JOIN c_invoice i ON il.c_invoice_id = i.c_invoice_id
    34    JOIN c_invoice i ON il.c_invoice_id = i.c_invoice_id
    35                     LEFT JOIN m_product p ON il.m_product_id = p.m_product_id
    35    LEFT JOIN m_product p ON il.m_product_id = p.m_product_id
    36                LEFT JOIN s_resourceassignment ra ON il.s_resourceassignment_id = ra.s_resourceassignment_id
    36    LEFT JOIN s_resourceassignment ra ON il.s_resourceassignment_id = ra.s_resourceassignment_id
    37                         UNION 
       
    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
       
    39                                    FROM m_product_bom b
       
    40                               JOIN c_invoiceline il ON b.m_product_id = il.m_product_id
       
    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'
       
    42                     JOIN m_product p ON b.m_productbom_id = p.m_product_id
       
    43                JOIN c_uom uom ON p.c_uom_id = uom.c_uom_id)
       
    44                 UNION 
       
    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
       
    46                            FROM c_invoiceline il
       
    47                           WHERE il.c_uom_id IS NULL)
       
    48         UNION 
       
    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
       
    50                    FROM c_invoice)
       
    51 UNION 
    37 UNION 
    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
    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
    53            FROM c_invoicetax it
    39    FROM m_product_bom b
    54       JOIN c_tax t ON it.c_tax_id = t.c_tax_id]]></view>
    40    JOIN c_invoiceline il ON b.m_product_id = il.m_product_id
       
    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'
       
    42    JOIN m_product p ON b.m_productbom_id = p.m_product_id
       
    43    JOIN c_uom uom ON p.c_uom_id = uom.c_uom_id)
       
    44 UNION 
       
    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
       
    46    FROM c_invoiceline il
       
    47   WHERE il.c_uom_id IS NULL)
       
    48 UNION 
       
    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
       
    50    FROM c_invoice)
       
    51 UNION 
       
    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
       
    53    FROM c_invoicetax it
       
    54    JOIN c_tax t ON it.c_tax_id = t.c_tax_id]]></view>
    55   </database>
    55   </database>