src-db/database/model/views/C_INVOICE_CUSTOMERVENDQTR.xml
author Antonio Moreno <antonio.moreno@openbravo.com>
Mon, 04 Feb 2013 09:27:53 +0100
changeset 9910 6767429386d8
parent 7031 2aac4501bbd5
child 9911 444911e2b851
permissions -rw-r--r--
Changes required to support PostgreSQL 9.2
<?xml version="1.0"?>
  <database name="VIEW C_INVOICE_CUSTOMERVENDQTR">
    <view name="C_INVOICE_CUSTOMERVENDQTR"><![CDATA[SELECT il.ad_client_id, il.ad_org_id, il.c_bpartner_id,  po.c_bpartner_id AS vendor_id,  TRUNC(il.dateinvoiced, 'Q') AS dateinvoiced,  sum(il.linenetamt) AS linenetamt, sum(il.linelistamt) AS linelistamt,  sum(il.linelimitamt) AS linelimitamt,  sum(il.linediscountamt) AS linediscountamt,  CASE sum(il.linelistamt) WHEN 0 THEN 0 ELSE round((sum(il.linelistamt) - sum(il.linenetamt)) / sum(il.linelistamt) * 100, 2) END AS linediscount,  sum(il.lineoverlimitamt) AS lineoverlimitamt,  CASE sum(il.linenetamt) WHEN 0 THEN 0 ELSE 100 - round((sum(il.linenetamt) - sum(il.lineoverlimitamt)) / sum(il.linenetamt) * 100, 2) END AS lineoverlimit,  sum(il.qtyinvoiced) AS qtyinvoiced FROM c_invoiceline_v2 il, m_product_po po WHERE il.m_product_id = po.m_product_id GROUP BY il.ad_client_id, il.ad_org_id, il.c_bpartner_id, po.c_bpartner_id, TRUNC(il.dateinvoiced, 'Q')]]></view>
  </database>