viernes, 2 de marzo de 2012
Facturas contabilizadas del proveedor
-- select fc.* from vw_facturas_contabilizadas fc;
-- drop view vw_facturas_contabilizadas;
create view vw_facturas_contabilizadas as
(
select
f.record_id,
o.ad_org_id cod_organizacion,
o.name organizacion,
ev.value cod_cuenta,
evt.name cuenta_contable,
f.amtacctdr debito,
f.amtacctcr credito,
coalesce(p.m_product_id, 0) id_producto,
coalesce(p.value, '') cod_producto,
coalesce(pt.name, '') producto,
bp.c_bpartner_id cod_tercero,
bp.name tercero,
f.dateacct fecha_contable,
pp.c_period_id cod_periodo,
pp.name periodo,
cast('Actual' as character varying) tipo_aplicacion, -- ad_ref_list
f.record_id cod_factura
from fact_acct f
join ad_org o
on f.ad_org_id = o.ad_org_id
join c_elementvalue ev
on f.account_id = ev.c_elementvalue_id
join c_elementvalue_trl evt
on (ev.c_elementvalue_id = evt.c_elementvalue_id
and evt.ad_language = 'es_CO')
left outer join m_product p
on f.m_product_id = p.m_product_id
left outer join m_product_trl pt
on (p.m_product_id = pt.m_product_id
and pt.ad_language = 'es_CO')
join c_bpartner bp
on f.c_bpartner_id = bp.c_bpartner_id
join c_period pp
on f.c_period_id = pp.c_period_id
where f.ad_client_id = 1000000
and f.postingtype = 'A'
and f.c_acctschema_id = 1000000
and f.ad_table_id = 318 -- AP Invoice
and f.fact_acct_id not in
(select
pa.record_id
from ad_private_access pa
where pa.ad_table_id = 270 -- GLJournal
and pa.ad_user_id <> 0
and pa.isactive = 'Y')
order by
f.fact_acct_id
);
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario