壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1534|回复: 1

adempiere视图

[复制链接]
发表于 2009/11/2 10:01:13 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622  。

您需要 登录 才可以下载或查看,没有帐号?注册

x
大家好,我想重新定义发票的格式,但是不知道如何在对应的试图中添加字段。

下面就是发票行的试图,对应的表为:c_invoice_linetax_v, 现在,我想添加taxbaseamt字段(in c_linetax table)到该表中,请高手们帮帮忙。

-- View: c_invoice_linetax_v

-- DROP VIEW c_invoice_linetax_v;

CREATE OR REPLACE VIEW c_invoice_linetax_v AS
((( 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.taxamt, il.linetotalamt, t.taxindicator, il.line, p.m_product_id,
        CASE
            WHEN il.qtyinvoiced <> 0::numeric OR il.m_product_id IS NOT NULL THEN il.qtyinvoiced
            ELSE NULL::numeric
        END AS qtyinvoiced,
        CASE
            WHEN il.qtyentered <> 0::numeric OR il.m_product_id IS NOT NULL THEN il.qtyentered
            ELSE NULL::numeric
        END AS qtyentered,
        CASE
            WHEN il.qtyentered <> 0::numeric OR il.m_product_id IS NOT NULL THEN uom.uomsymbol
            ELSE NULL::character varying
        END AS uomsymbol, COALESCE(c.name, (p.name::text || productattribute(il.m_attributesetinstance_id)::text)::character varying, il.description) AS name,
        CASE
            WHEN COALESCE(c.name, p.name) IS NOT NULL THEN il.description
            ELSE NULL::character varying
        END AS description, p.documentnote, p.upc, p.sku, COALESCE(pp.vendorproductno, p.value) AS productvalue, ra.description AS resourcedescription,
        CASE
            WHEN i.isdiscountprinted = 'Y'::bpchar AND il.pricelist <> 0::numeric THEN il.pricelist
            ELSE NULL::numeric
        END AS pricelist,
        CASE
            WHEN i.isdiscountprinted = 'Y'::bpchar AND il.pricelist <> 0::numeric AND il.qtyentered <> 0::numeric THEN il.pricelist * il.qtyinvoiced / il.qtyentered
            ELSE NULL::numeric
        END AS priceenteredlist,
        CASE
            WHEN i.isdiscountprinted = 'Y'::bpchar AND il.pricelist > il.priceactual AND il.pricelist <> 0::numeric THEN (il.pricelist - il.priceactual) / il.pricelist * 100::numeric
            ELSE NULL::numeric
        END AS discount,
        CASE
            WHEN il.priceactual <> 0::numeric OR il.m_product_id IS NOT NULL THEN il.priceactual
            ELSE NULL::numeric
        END AS priceactual,
        CASE
            WHEN il.priceentered <> 0::numeric OR il.m_product_id IS NOT NULL THEN il.priceentered
            ELSE NULL::numeric
        END AS priceentered,
        CASE
            WHEN il.linenetamt <> 0::numeric OR il.m_product_id IS NOT NULL THEN il.linenetamt
            ELSE NULL::numeric
        END AS linenetamt, il.m_attributesetinstance_id, asi.m_attributeset_id, asi.serno, asi.lot, asi.m_lot_id, asi.guaranteedate, p.description AS productdescription, p.imageurl, il.c_campaign_id, il.c_project_id, il.c_activity_id, il.c_projectphase_id, il.c_projecttask_id
   FROM c_invoiceline il
   JOIN c_uom uom ON il.c_uom_id = uom.c_uom_id
   JOIN c_invoice i ON il.c_invoice_id = i.c_invoice_id
   LEFT JOIN c_tax t ON il.c_tax_id = t.c_tax_id
   LEFT JOIN m_product p ON il.m_product_id = p.m_product_id
   LEFT JOIN c_charge c ON il.c_charge_id = c.c_charge_id
   LEFT JOIN c_bpartner_product pp ON il.m_product_id = pp.m_product_id AND i.c_bpartner_id = pp.c_bpartner_id
   LEFT JOIN s_resourceassignment ra ON il.s_resourceassignment_id = ra.s_resourceassignment_id
   LEFT JOIN m_attributesetinstance asi ON il.m_attributesetinstance_id = asi.m_attributesetinstance_id
UNION
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.taxamt, il.linetotalamt, t.taxindicator, il.line + bl.line / 100::numeric AS line, p.m_product_id,
        CASE
            WHEN bl.isqtypercentage = 'N'::bpchar THEN il.qtyinvoiced * bl.qtybom
            ELSE il.qtyinvoiced * (bl.qtybatch / 100::numeric)
        END AS qtyinvoiced,
        CASE
            WHEN bl.isqtypercentage = 'N'::bpchar THEN il.qtyentered * bl.qtybom
            ELSE il.qtyentered * (bl.qtybatch / 100::numeric)
        END AS qtyentered, uom.uomsymbol, p.name, b.description, p.documentnote, p.upc, p.sku, p.value AS productvalue, NULL::unknown AS resourcedescription, NULL::unknown AS pricelist, NULL::unknown AS priceenteredlist, NULL::unknown AS discount, NULL::unknown AS priceactual, NULL::unknown AS priceentered, NULL::unknown AS linenetamt, il.m_attributesetinstance_id, asi.m_attributeset_id, asi.serno, asi.lot, asi.m_lot_id, asi.guaranteedate, p.description AS productdescription, p.imageurl, il.c_campaign_id, il.c_project_id, il.c_activity_id, il.c_projectphase_id, il.c_projecttask_id
   FROM pp_product_bom b
   JOIN c_invoiceline il ON b.m_product_id = il.m_product_id
   JOIN m_product bp ON bp.m_product_id = il.m_product_id AND bp.isbom = 'Y'::bpchar AND bp.isverified = 'Y'::bpchar AND bp.isinvoiceprintdetails = 'Y'::bpchar
   JOIN pp_product_bomline bl ON bl.pp_product_bom_id = b.pp_product_bom_id
   JOIN m_product p ON bl.m_product_id = p.m_product_id
   JOIN c_uom uom ON p.c_uom_id = uom.c_uom_id
   LEFT JOIN c_tax t ON il.c_tax_id = t.c_tax_id
   LEFT JOIN m_attributesetinstance asi ON il.m_attributesetinstance_id = asi.m_attributesetinstance_id)
UNION
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, NULL::unknown AS c_tax_id, NULL::unknown AS taxamt, NULL::unknown AS linetotalamt, NULL::unknown AS taxindicator, il.line, NULL::unknown AS m_product_id, NULL::unknown AS qtyinvoiced, NULL::unknown AS qtyentered, NULL::unknown AS uomsymbol, il.description AS name, NULL::unknown AS description, NULL::unknown AS documentnote, NULL::unknown AS upc, NULL::unknown AS sku, NULL::unknown AS productvalue, NULL::unknown AS resourcedescription, NULL::unknown AS pricelist, NULL::unknown AS priceenteredlist, NULL::unknown AS discount, NULL::unknown AS priceactual, NULL::unknown AS priceentered, NULL::unknown AS linenetamt, NULL::unknown AS m_attributesetinstance_id, NULL::unknown AS m_attributeset_id, NULL::unknown AS serno, NULL::unknown AS lot, NULL::unknown AS m_lot_id, NULL::unknown AS guaranteedate, NULL::unknown AS productdescription, NULL::unknown AS imageurl, NULL::unknown AS c_campaign_id, NULL::unknown AS c_project_id, NULL::unknown AS c_activity_id, NULL::unknown AS c_projectphase_id, NULL::unknown AS c_projecttask_id
   FROM c_invoiceline il
  WHERE il.c_uom_id IS NULL)
UNION
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::unknown AS c_invoiceline_id, NULL::unknown AS c_tax_id, NULL::unknown AS taxamt, NULL::unknown AS linetotalamt, NULL::unknown AS taxindicator, 9998 AS line, NULL::unknown AS m_product_id, NULL::unknown AS qtyinvoiced, NULL::unknown AS qtyentered, NULL::unknown AS uomsymbol, NULL::unknown AS name, NULL::unknown AS description, NULL::unknown AS documentnote, NULL::unknown AS upc, NULL::unknown AS sku, NULL::unknown AS productvalue, NULL::unknown AS resourcedescription, NULL::unknown AS pricelist, NULL::unknown AS priceenteredlist, NULL::unknown AS discount, NULL::unknown AS priceactual, NULL::unknown AS priceentered, NULL::unknown AS linenetamt, NULL::unknown AS m_attributesetinstance_id, NULL::unknown AS m_attributeset_id, NULL::unknown AS serno, NULL::unknown AS lot, NULL::unknown AS m_lot_id, NULL::unknown AS guaranteedate, NULL::unknown AS productdescription, NULL::unknown AS imageurl, NULL::unknown AS c_campaign_id, NULL::unknown AS c_project_id, NULL::unknown AS c_activity_id, NULL::unknown AS c_projectphase_id, NULL::unknown AS c_projecttask_id
   FROM c_invoice)
UNION
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::unknown AS c_invoiceline_id, it.c_tax_id, NULL::unknown AS taxamt, NULL::unknown AS linetotalamt, t.taxindicator, 9999 AS line, NULL::unknown AS m_product_id, NULL::unknown AS qtyinvoiced, NULL::unknown AS qtyentered, NULL::unknown AS uomsymbol, t.name, NULL::unknown AS description, NULL::unknown AS documentnote, NULL::unknown AS upc, NULL::unknown AS sku, NULL::unknown AS productvalue, NULL::unknown AS resourcedescription, NULL::unknown AS pricelist, NULL::unknown AS priceenteredlist, NULL::unknown AS discount,
        CASE
            WHEN it.istaxincluded = 'Y'::bpchar THEN it.taxamt
            ELSE it.taxbaseamt
        END AS priceactual,
        CASE
            WHEN it.istaxincluded = 'Y'::bpchar THEN it.taxamt
            ELSE it.taxbaseamt
        END AS priceentered,
        CASE
            WHEN it.istaxincluded = 'Y'::bpchar THEN NULL::numeric
            ELSE it.taxamt
        END AS linenetamt, NULL::unknown AS m_attributesetinstance_id, NULL::unknown AS m_attributeset_id, NULL::unknown AS serno, NULL::unknown AS lot, NULL::unknown AS m_lot_id, NULL::unknown AS guaranteedate, NULL::unknown AS productdescription, NULL::unknown AS imageurl, NULL::unknown AS c_campaign_id, NULL::unknown AS c_project_id, NULL::unknown AS c_activity_id, NULL::unknown AS c_projectphase_id, NULL::unknown AS c_projecttask_id
   FROM c_invoicetax it
   JOIN c_tax t ON it.c_tax_id = t.c_tax_id;

ALTER TABLE c_invoice_linetax_v OWNER TO adempiere;
发表于 2010/5/27 10:38:36 | 显示全部楼层
为什么要在代码中该呢,窗口里可以加字段啊。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/30 04:59 , Processed in 0.013559 second(s), 14 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表