###Elimnar producto de maxicomercio
#####Quitar existencias
~~~
delete existencias from producto inner join existencias on producto.sys_pk=existencias.FK_Producto_IExistencias where producto.iclase=999;
~~~
#####Quitar maxmin
~~~
delete ut_maxmin from producto inner join ut_maxmin on producto.sys_pk=ut_maxmin.Iproducto where producto.iclase=999;
~~~
#####Quitar de dcardex y dcapa  
~~~
delete dca,dc from producto p inner join dcardex dc on p.sys_pk=dc.iproducto left join dcapa dca on dc.sys_pk=dca.FK_DCardex_Capas where p.IClase=999;
~~~
#####Quitar dventa 
~~~
delete dventa from producto inner join dventa on producto.sys_pk=dventa.iproducto where producto.iclase=999;
~~~
#####Quitar dcompra
~~~
delete dcompra from producto inner join dcompra on producto.sys_pk=dcompra.iproducto where producto.iclase=999;
~~~
#####Quitar producto 
~~~
delete from producto where producto.iclase=999;
~~~
MZ2045500 Y MZ114400

LLANTA 18 300 METZELER C REINFTL 52P ME22 BR

LLANTA 18 350 METZELER REINF 62P ME22 BR

060248
Costo de Venta:
qryRepCostoVentas

45 -45  
18 - 0  
20 -38  
40 - 35 dif 5  
25  

9 oct 2018 empiezan las salidas con entradas en compras

12 nov 2018 comienza salidas or inve

DCardex.RVenta debe ser igual a la pk de dventa

DCardex.RVenta=DVenta.sys_pk - En Dcardex rventa esta null en muchos casos
#####AL facturar
A00000429
~~~
update dcardex set RVenta=sys_pkDventa where fk_Venta_Detalle=sys_pkVenta

update dcardex set RVenta=sys_pkDventa where fk_Venta_Detalle=sys_pkVenta
~~~
#####Obtiene las facturas globales:
~~~
select venta.sys_pk,venta.Documento,venta.notas,venta.referencia,venta.aplicadoA from venta where notas like '%Factura Global%';
~~~
#####Obtiene 
~~~
select v1.sys_pk AS PKFact,v2.sys_pk As PKTick,v1.notas,v1.referencia AS Fact,V2.referencia as Tickt,v2.aplicadoA from venta as v1 inner join venta as v2 on v1.sys_pk=v2.aplicadoA  where v1.notas like '%Factura Global%';
~~~
######De la mayor parte
~~~
select v1.sys_pk AS PKFact,v2.sys_pk As PKTick,v1.notas,v1.referencia AS Fact,Producto.descripcion,producto.sys_pk as PKProducto,V2.referencia as Tickt,v2.aplicadoA from venta as v1 inner join venta as v2 on v1.sys_pk=v2.aplicadoA inner join dventa on v1.sys_pk=dventa.fk_venta_detalle inner join producto on dventa.iproducto=producto.sys_pk where v1.notas like '%Factura Global%';

select v1.sys_pk AS PKFact,v2.sys_pk As PKTick,v1.notas,v1.referencia AS Fact,p.descripcion,p.sys_pk as PKProducto,V2.referencia as Tickt,v2.aplicadoA,dcardex.RVenta from venta as v1 inner join venta as v2 on v1.sys_pk=v2.aplicadoA inner join dventa as dv on v1.sys_pk=dv.fk_venta_detalle inner join producto as p on dv.iproducto=p.sys_pk inner join dcardex on p.sys_pk=dcardex.Iproducto where v1.notas like '%Factura Global%' and dcardex.rventa is not null;

select dventa.sys_pk As PKDVenta,dventa.fk_venta_Detalle,venta.sys_pk As PKVenta,producto.descripcion from venta inner join dventa on venta.sys_pk=dventa.fk_venta_detalle inner join producto on dventa.iproducto=producto.sys_pk where venta.notas like '%Factura Global%';
~~~