"VER1.0","Representantes","Comisiones por representante y cliente"
;Versio, Categoria, Descripcion

;--- Comisiones por representante, desglosadas por cliente. Moderno A4 vertical.
;--- Color de acento = ColorIndex 2. Busca ",2,#TRUE#" para cambiarlo (1-9).
;---
;--- La comision NO se calcula: se suma VenFacturas.TComision, que ya viene
;--- guardada factura a factura. El % del representante solo se muestra.
;--- TComision es NULL en muchas facturas, por eso va envuelto en IIf.
;--- La columna "S/com." cuenta las facturas sin comision grabada.

;Ampla, Llarg, [EspaiCos]
;MargenX,MargenY, EtiLin, EtiPag
[DOCUM]
"V", 9, 0
0, 0, 0, 0

;=========================================================================
; CABECERA - banda de titulo con los datos de la empresa
;=========================================================================
[GRUP]
1,"CABECERA", #FALSE#
"SELECT * , CodigoPostal & ' - ' & Poblacion as Direc, 'Tel : ' & Telefono1 as Tel "
"FROM Configuracion"
""
[CAPSALERA]
0, 0, #FALSE#, 0, #FALSE#, #TRUE#, 0
; RAp(n), Alt(n), SMin(b), Salto(D), GA(b), All(b), Rel(D)
[CAMPS] 4
1,"cajaTitulo", 3,2,197,16, 1,2,#TRUE#
3,"CABECERA","NombreComercial", 6,4,"ARIAL", 15,0,0,"1000",""
3,"CABECERA","Nif", 6,11,"ARIAL", 8,0,0,"1000",""
0,"Comisiones por representante", 120,6,"ARIAL",11,0,0,"1000"
[FICAP]

[FIGRUP]

;=========================================================================
; GENERAL - filtros, pagina, fecha, cabecera de columnas y total general
;=========================================================================
[GRUP]
0, "GENERAL", #FALSE#
""
""
""
[CAPSALERA]
10, 34, #TRUE#, 0, #TRUE#, #TRUE#, 0
; RAp(n), Alt(n), SMin(b), Salto(D), GA(b), All(b), Rel(D)
[CAMPS] 13
0,"Condiciones : ", 6,19,"ARIAL",8,0,0,"1000"
6,"Condiciones", 30,19,"ARIAL",8,0,0,"1000",""
0,"Pagina :", 150,19,"ARIAL",8,0,0,"1000"
6,"Pagina", 194,19,"ARIAL",8,0,1,"1000",""
0,"Fecha :", 150,23,"ARIAL",8,0,0,"1000"
6,"Fecha", 194,23,"ARIAL",8,0,1,"1000",""
1,"bandaColumnas", 3,27,197,33, 8,2,#TRUE#
0,"Cliente", 10,28,"ARIAL",8,0,0,"1000"
0,"Nombre", 24,28,"ARIAL",8,0,0,"1000"
0,"Facturas", 105,28,"ARIAL",8,0,0,"1000"
0,"S/com.", 125,28,"ARIAL",8,0,0,"1000"
0,"Base", 150,28,"ARIAL",8,0,0,"1000"
0,"Comision", 175,28,"ARIAL",8,0,0,"1000"
[FICAP]

[PEU]
0, 16, #TRUE#, 0, #FALSE#, #FALSE#, 0
; RAp(n), Alt(n), SMin(b), Salto(D), GA(b), All(b), Rel(D)
[CAMPS] 4
1,"cajaTotal", 3,2,197,12, 1,2,#TRUE#
0,"TOTAL GENERAL :", 6,5,"ARIAL",11,0,0,"1000"
5,0,"T1", 165,5,"ARIAL",10,0,1,"1000","Total"
5,0,"T2", 194,5,"ARIAL",10,0,1,"1000","Total"
[FIPEU]

[FIGRUP]

;=========================================================================
; REPRE - un grupo por representante, con SELECT propio.
;         Los clientes cuelgan de aqui por el parametro Rel del grupo COS.
;=========================================================================
[GRUP]
3,"REPRE", #FALSE#
"SELECT Representantes.CodRepresentante AS CodRepre, Representantes.Nombre AS NombreRepre, Representantes.Comision AS PorcenComision "
"FROM Representantes"
""

[ORDENACIONS] 2
"Representantes.CodRepresentante", "Codigo de representante", 3
"Representantes.Nombre", "Nombre de representante", 3

[CAPSALERA]
0, 9, #TRUE#, 0, #TRUE#, #FALSE#, 0
; RAp(n), Alt(n), SMin(b), Salto(D), GA(b), All(b), Rel(D)
[CAMPS] 5
1,"bandaRepre", 3,1,197,7, 1,2,#TRUE#
3,"REPRE","CodRepre", 6,2,"ARIAL", 9,0,0,"0000",""
3,"REPRE","NombreRepre", 20,2,"ARIAL", 10,0,0,"0000",""
0,"% Comision :", 150,3,"ARIAL",8,0,0,"1000"
3,"REPRE","PorcenComision", 194,2,"ARIAL", 9,0,1,"0000",""
[FICAP]

[PEU]
0, 8, #TRUE#, 0, #FALSE#, #FALSE#, 0
; RAp(n), Alt(n), SMin(b), Salto(D), GA(b), All(b), Rel(D)
[CAMPS] 4
1,"lineaSubtotal", 3,1,197,1,,,
0,"Subtotal representante", 88,2,"ARIAL",9,0,0,"1000"
5,0,"S1", 165,2,"ARIAL", 9,0,1,"1000","Total"
5,0,"S2", 194,2,"ARIAL", 9,0,1,"1000","Total"
[FIPEU]

[FIGRUP]

;=========================================================================
; COS - una linea por cliente, colgando del representante activo
;=========================================================================
[GRUP]
3,"COS", #FALSE#
"SELECT VenFacturas.CodRepresentante AS CodRepre, VenFacturas.CodCliente AS CodCli, VenFacturas.NombreFiscal AS NombreCliente, Count(VenFacturas.NumFactura) AS NumFacturas, Sum(IIf([TComision] Is Null,1,0)) AS SinComision, Sum(IIf([BaseImponible1] Is Null,0,[BaseImponible1])+IIf([BaseImponible2] Is Null,0,[BaseImponible2])+IIf([BaseImponible3] Is Null,0,[BaseImponible3])) AS TotalBase, Sum(IIf([TComision] Is Null,0,[TComision])) AS TotalComision "
"FROM VenFacturas"
"GROUP BY VenFacturas.CodRepresentante, VenFacturas.CodCliente, VenFacturas.NombreFiscal"

[CONDICIONS] 4
"VenFacturas.CodCliente","Cliente",0,1
"NombreFiscal","Nombre del cliente",0,1
"Seccion","Seccion",0,1
"FechaFactura","Fecha de factura",0,2

[CAPSALERA]
0, 5, #TRUE#, 0, #TRUE#, #FALSE#, "CodRepre"
; RAp(n), Alt(n), SMin(b), Salto(D), GA(b), All(b), Rel(D)
[CAMPS] 6
3,"COS","CodCli", 10,0,"ARIAL", 8,0,0,"0000",""
3,"COS","NombreCliente", 24,0,"ARIAL", 8,0,0,"0000",""
3,"COS","NumFacturas", 118,0,"ARIAL", 8,0,1,"0000",""
3,"COS","SinComision", 140,0,"ARIAL", 8,0,1,"0000",""
3,"COS","TotalBase", 165,0,"ARIAL", 8,0,1,"0000","Total"
3,"COS","TotalComision", 194,0,"ARIAL", 8,0,1,"0000","Total"
[FICAP]

[FIGRUP]

;=========================================================================
; S1/S2 = subtotales por representante. T1/T2 = totales del listado.
;=========================================================================
[CALCULS] 4
"S1", "COS", "TotalBase", "REPRE"
"S2", "COS", "TotalComision", "REPRE"
"T1", "COS", "TotalBase", "GENERAL"
"T2", "COS", "TotalComision", "GENERAL"

[FIDOCUM]
