diff --git a/Build/Build.fbl6 b/Build/Build.fbl6
index 5dbb975..69d69af 100644
Binary files a/Build/Build.fbl6 and b/Build/Build.fbl6 differ
diff --git a/Database/scripts/factuges.sql b/Database/scripts/factuges.sql
index 61c0b1a..12e592e 100644
--- a/Database/scripts/factuges.sql
+++ b/Database/scripts/factuges.sql
@@ -4185,31 +4185,65 @@ FROM
ORDER BY USERNAME;
;
-create view V_CONTRATOS_FACTURAS_PROVEEDOR (ID_CONTRATO, IMPORTE)
+CREATE VIEW V_CONTRATOS_FACTURAS_CLIENTE(
+ ID_CONTRATO,
+ IMPORTE_FACTURAS_CLIENTE)
+AS
+select ID_CONTRATO, SUM(BASE_IMPONIBLE) as IMPORTE_FACTURAS_CLIENTE
+from facturas_cliente
+where ID_CONTRATO is not null
+group by 1
+;
+
+CREATE VIEW V_CONTRATOS_FACTURAS_PROVEEDOR(
+ ID_CONTRATO,
+ IMPORTE)
AS
select ID_CONTRATO, SUM(IMPORTE) as IMPORTE_GASTOS_PROVEEDORES
from facturas_proveedor_contratos
-group by 1;
+group by 1
+;
-create view V_CONTRATOS_BENEFICIOS (ID, REFERENCIA, FECHA_CONTRATO, NOMBRE, NIF_CIF,
-IMPORTE_NETO, IMPORTE_DESCUENTO, BASE_IMPONIBLE, IMPORTE_FACTURAS_PROVEEDOR,
-IMPORTE_BENEFICIO, PORCENTAJE_BENEFICIO)
+CREATE VIEW V_CONTRATOS_BENEFICIOS(
+ ID,
+ REFERENCIA,
+ FECHA_CONTRATO,
+ NOMBRE,
+ NIF_CIF,
+ IMPORTE_NETO,
+ IMPORTE_DESCUENTO,
+ BASE_IMPONIBLE,
+ IMPORTE_FACTURAS_CLIENTE,
+ IMPORTE_FACTURAS_PROVEEDOR,
+ IMPORTE_BENEFICIO,
+ PORCENTAJE_BENEFICIO,
+ IMPORTE_BENEFICIO_REAL,
+ PORCENTAJE_BENEFICIO_REAL)
AS
select
contratos_cliente.ID,
contratos_cliente.referencia, contratos_cliente.fecha_contrato,
contratos_cliente.nombre, contratos_cliente.nif_cif,
contratos_cliente.importe_neto, contratos_cliente.importe_descuento,
-contratos_cliente.base_imponible, v_contratos_facturas_proveedor.importe as importe_facturas_proveedor,
+contratos_cliente.base_imponible,
+v_contratos_facturas_cliente.importe_facturas_cliente,
+v_contratos_facturas_proveedor.importe as importe_facturas_proveedor,
(contratos_cliente.base_imponible - coalesce(v_contratos_facturas_proveedor.importe, 0)) as importe_beneficio,
case when (contratos_cliente.base_imponible - coalesce(v_contratos_facturas_proveedor.importe, 0)) = 0 then 0
- else (((contratos_cliente.base_imponible - coalesce(v_contratos_facturas_proveedor.importe, 0))*100)/contratos_cliente.importe_neto)
-end as porcentaje_beneficio
+ else (((contratos_cliente.base_imponible - coalesce(v_contratos_facturas_proveedor.importe, 0))*100)/contratos_cliente.base_imponible)
+end as porcentaje_beneficio,
+
+(v_contratos_facturas_cliente.importe_facturas_cliente - coalesce(v_contratos_facturas_proveedor.importe, 0)) as importe_beneficio_real,
+case when (v_contratos_facturas_cliente.importe_facturas_cliente - coalesce(v_contratos_facturas_proveedor.importe, 0)) = 0 then 0
+ else (((v_contratos_facturas_cliente.importe_facturas_cliente - coalesce(v_contratos_facturas_proveedor.importe, 0))*100)/v_contratos_facturas_cliente.importe_facturas_cliente)
+end as porcentaje_beneficio_real
from contratos_cliente
left join v_contratos_facturas_proveedor
-on (v_contratos_facturas_proveedor.ID_CONTRATO = contratos_cliente.ID);
-
+on (v_contratos_facturas_proveedor.ID_CONTRATO = contratos_cliente.ID)
+left join v_contratos_facturas_cliente
+on (v_contratos_facturas_cliente.ID_CONTRATO = contratos_cliente.ID)
+;
/******************************************************************************/
diff --git a/Source/Cliente/FactuGES.dproj b/Source/Cliente/FactuGES.dproj
index fffaf00..cf7552b 100644
--- a/Source/Cliente/FactuGES.dproj
+++ b/Source/Cliente/FactuGES.dproj
@@ -51,7 +51,7 @@
Delphi.Personality
VCLApplication
-FalseTrueFalseC:\Archivos de programa\Borland\Delphi7\Bin\TrueFalse2520FalseFalseFalseFalseFalse30821252Rodax Software S.L.2.5.2.0FactuGESFactuGES2.5.2.0
+FalseTrueFalseC:\Archivos de programa\Borland\Delphi7\Bin\TrueFalse2530FalseFalseFalseFalseFalse30821252Rodax Software S.L.2.5.3.0FactuGESFactuGES2.5.3.0
File C:\Documents and Settings\All Users\Documentos\RAD Studio\5.0\Bpl\dxPScxScheduler2LnkD11.bpl not found
FactuGES.dprFalse
diff --git a/Source/Cliente/FactuGES.res b/Source/Cliente/FactuGES.res
index f2abbcb..f6fb879 100644
Binary files a/Source/Cliente/FactuGES.res and b/Source/Cliente/FactuGES.res differ
diff --git a/Source/Servidor/FactuGES_Server.dproj b/Source/Servidor/FactuGES_Server.dproj
index 11747c2..7b4b459 100644
--- a/Source/Servidor/FactuGES_Server.dproj
+++ b/Source/Servidor/FactuGES_Server.dproj
@@ -28,7 +28,7 @@
Delphi.Personality
- FalseTrueFalseTrueFalse2520FalseFalseFalseFalseFalse30821252Rodax Software S.L.2.5.2.0FactuGES (Servidor)2.5.2.0martes, 07 de febrero de 2012 17:56
+ FalseTrueFalseTrueFalse2530FalseFalseFalseFalseFalse30821252Rodax Software S.L.2.5.3.0FactuGES (Servidor)2.5.3.0miƩrcoles, 29 de febrero de 2012 16:51
File C:\Documents and Settings\All Users\Documentos\RAD Studio\5.0\Bpl\dxPScxScheduler2LnkD11.bpl not found
FactuGES_Server.dpr
diff --git a/Source/Servidor/FactuGES_Server.res b/Source/Servidor/FactuGES_Server.res
index 24d359e..e8733ba 100644
Binary files a/Source/Servidor/FactuGES_Server.res and b/Source/Servidor/FactuGES_Server.res differ