first time posting here.
I've read a lot and couldn't find an answer to my problem.
I'm creating a report to display a bill using Crystal Report and using Visual Studio Code. I'm doing it by creating a XSD from a XML file and then using CR to create the report.
I have created 2 querys that display all the info I need but I couldn't find how to achieve using one of the reports as a subreport.
When I insert one report as a subreport in CR, VSC throws an exception in the subreport:
Excepción no controlada: System.NotSupportedException: No se admite dentro de subinformes.
en CrystalDecisions.CrystalReports.Engine.ReportDocument.get_ParameterFields()
en Idea.GesComWeb.Reports.Model.CrystalReport.LogInfo(Action`1 log) en C:\Development\GesComWeb\gcw-backend\Reports\src\Model\Reports\Crystal\CrystalReport.cs:línea 294
en Idea.GesComWeb.Utils.ReportsTool.Program.LogReportInfo()
en Idea.GesComWeb.Utils.ReportsTool.Program.RenderReport()
en Idea.GesComWeb.Utils.ReportsTool.Program.Main(String[] args)
The terminal process terminated with exit code: 1
I assume the problem is in the subreport and after hours of trying to solve this by my own (and searching and asking to people) I couldn't get it working.
My 2 Codes are the following:
This is the header of the bill:
<Report xsi:type="crystalReport" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation="../sqi.xsd">
<Id>61837efa-414c-4330-807a-b8101e6bb48a</Id>
<Name>Factura</Name>
<Category>ventas</Category>
<Module>ventas</Module>
<Description>Muestra la factura</Description>
<Resources>
<Resource repository="Local" location="/ventas" name="factura.rpt"/>
</Resources>
<PreVariables>
</PreVariables>
<ParametersGroups>
<ParametersGroup name="comprobante" title="Comprobante" layout="column">
<Parameter name="ventaComprobanteId" title="Comprobante ID" required="true" type="int">
<Default xsi:type="int">1</Default>
</Parameter>
</ParametersGroup>
</ParametersGroups>
<Variables/>
<DatasourceFilters>
</DatasourceFilters>
<Datasources>
<Datasource xsi:type="sql" name="Cabecera" connection="gcw" skipCount="0">
<Query xsi:type="script" valueType="string" lang="tpl"><![CDATA[
SELECT
TC.LetraComprobante AS 'Letra',
TC.CodigoFe AS 'CodigoFE',
TC.Codigo AS 'TipoComprobante',
VC.NumeroComprobante AS 'NumeroComprobante',
VC.PuntoVentaID AS 'PuntodeVenta',
date(VC.FechaCreacion) as 'FechaFactura',
EM.InicioActividad AS 'InicioActividad',
EF.EntidadID 'CodigoCliente',
EF.RazonSocial AS 'RazonSocial',
ED.CalleStr AS 'Direccion',
EF.Documento 'Documento',
CI.Descripcion 'CondicionIVA',
E.Telefono 'Telefono',
ED.CodigoPostal AS 'CodigoPostal',
L.Nombre AS 'Localidad',
CP.Descripcion AS 'CondicionPago',
EMP.Codigo as 'CodigoVendedor',
RP.Codigo as 'CodigoZona',
RP.Descripcion AS 'Zona',
V.FechaEntrega 'FechaEntrega',
VC.FechaVencimientoCAE 'VencimientoCAE',
VC.CAE 'NumeroCAE',
VC.Id 'ventaComprobanteId',
(select Nombre from Entidad where Entidad.Id = EMP.EntidadID) as 'Vendedor',
(SELECT EntidadFiscal.NroIngresosBrutos FROM Venta INNER JOIN Empresa ON Empresa.Id = Venta.EmpresaID INNER JOIN Entidad ON Entidad.Id = Empresa.Id INNER JOIN EntidadFiscal ON EntidadFiscal.EntidadID = Entidad.Id INNER JOIN EntidadDireccion ON EntidadDireccion.Id = Empresa.Id WHERE Empresa.Id =EM.Id AND Venta.Id = V.Id) as 'NroIngresosBrutos',
(SELECT EntidadFiscal.Documento FROM Venta INNER JOIN Empresa ON Empresa.Id = Venta.EmpresaID INNER JOIN Entidad ON Entidad.Id = Empresa.Id INNER JOIN EntidadFiscal ON EntidadFiscal.EntidadID = Entidad.Id INNER JOIN EntidadDireccion ON EntidadDireccion.Id = Empresa.Id WHERE Empresa.Id =EM.Id AND Venta.Id = V.Id) as 'CUIT',
(SELECT Nombre FROM Entidad INNER JOIN Empresa ON Empresa.Id = Entidad.Id INNER JOIN Venta ON Venta.EmpresaId = Empresa.Id WHERE Empresa.Id = EM.Id AND Venta.Id = V.Id) as 'EmpresaNombre',
(SELECT Telefono FROM Entidad INNER JOIN Empresa ON Empresa.Id = Entidad.Id INNER JOIN Venta ON Venta.EmpresaId = Empresa.Id WHERE Empresa.Id = EM.Id AND Venta.Id = V.Id) AS 'EmpresaTelefono',
(SELECT Email FROM Entidad INNER JOIN Empresa ON Empresa.Id = Entidad.Id INNER JOIN Venta ON Venta.EmpresaId = Empresa.Id WHERE Empresa.Id = EM.Id AND Venta.Id = V.Id) as 'EmpresaMail',
(SELECT Provincia.Descripcion FROM Venta INNER JOIN Empresa ON Empresa.Id = Venta.EmpresaID INNER JOIN Entidad ON Entidad.Id = Empresa.Id INNER JOIN EntidadDireccion ON EntidadDireccion.Id = Empresa.Id inner JOIN Localidad ON Localidad.Id = EntidadDireccion.LocalidadId INNER JOIN Departamento ON Departamento.Id = EntidadDireccion.DepartamentoID INNER JOIN Provincia ON Provincia.Id = Departamento.ProvinciaID WHERE Empresa.Id =EM.Id AND Venta.Id = V.Id) as 'EmpresaProvincia',
(CONCAT((SELECT CalleStr FROM Venta INNER JOIN Empresa ON Empresa.Id = Venta.EmpresaID INNER JOIN Entidad ON Entidad.Id = Empresa.Id INNER JOIN EntidadDireccion ON EntidadDireccion.Id = Empresa.Id WHERE Empresa.Id =EM.Id AND Venta.Id = V.Id), '', (SELECT Altura FROM Venta INNER JOIN Empresa ON Empresa.Id = Venta.EmpresaID INNER JOIN Entidad ON Entidad.Id = Empresa.Id INNER JOIN EntidadDireccion ON EntidadDireccion.Id = Empresa.Id WHERE Empresa.Id =EM.Id AND Venta.Id = V.Id))) as 'EmpresaDomicilio',
(SELECT Localidad.Nombre FROM Venta INNER JOIN Empresa ON Empresa.Id = Venta.EmpresaID INNER JOIN Entidad ON Entidad.Id = Empresa.Id INNER JOIN EntidadDireccion ON EntidadDireccion.Id = Empresa.Id INNER JOIN Localidad ON Localidad.Id = EntidadDireccion.LocalidadID WHERE Empresa.Id =EM.Id AND Venta.Id = V.Id) as 'EmpresaLocalidad',
(SELECT CodigoPostal FROM Venta INNER JOIN Empresa ON Empresa.Id = Venta.EmpresaID INNER JOIN Entidad ON Entidad.Id = Empresa.Id INNER JOIN EntidadDireccion ON EntidadDireccion.Id = Empresa.Id WHERE Empresa.Id =EM.Id AND Venta.Id = V.Id) as 'EmpresaCP',
VI.PrecioNetoUnitarioOriginal,
VI.PrecioNetoUnitario,
VI.ImpuestoInternoUnitario,
VI.Cantidad,
VI.AlicuotaIvaTotal,
I.Codigo,
I.Descripcion,
AI.Porcentaje,
U.Nombre
FROM VentaComprobante VC
INNER JOIN TipoComprobante TC ON TC.Id = VC.TipoComprobanteID
INNER JOIN Venta V ON V.Id = VC.VentaID
INNER JOIN EntidadFiscal EF ON EF.EntidadID = V.EntidadFiscalID
INNER JOIN Empresa EM ON EM.Id = V.EmpresaID
INNER JOIN Entidad E ON E.Id=EF.EntidadID
INNER JOIN EntidadDireccion ED ON ED.EntidadID = E.Id
LEFT join Localidad L on L.Id = ED.LocalidadID
inner join Cliente Cli on Cli.Id = V.ClienteID
inner join CondicionPago CP on CP.Id = Cli.CondicionPagoID
inner join Empleado EMP on EMP.Id = V.VendedorID
inner join RutaPreventa RP on RP.Id = V.RutaID
INNER JOIN CondicionIva CI ON CI.Id = EF.CondicionIvaID
inner JOIN VentaComprobanteItem VCI ON VC.ID=VCI.VentaComprobanteID
inner join VentaItem VI ON VCI.VentaItemID=VI.Id
INNER JOIN AlicuotaIva AI ON AI.Id = VI.AlicuotaIvaID
INNER JOIN Item I ON I.Id = VI.ItemID
INNER JOIN Unidad U ON U.Id = VI.UnidadID
where
VC.Id = $ventaComprobanteId
$!Debug
]]>
</Query>
</Datasource>
</Datasources>
<DatasourceMappings/>
</Report>
And this is the bottom of the bill that sums and group by tax type (one item can be affected by multiple taxes):
<Report xsi:type="crystalReport" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation="../sqi.xsd">
<Id>f5ea4698-5b0c-44d5-a6ad-df048f220091</Id>
<Name>SubtotalFactura</Name>
<Category>ventas</Category>
<Module>ventas</Module>
<Description>Muestra los Importe totales</Description>
<Resources>
<Resource repository="Local" location="/ventas" name="Subtotalfactura.rpt"/>
</Resources>
<PreVariables>
</PreVariables>
<ParametersGroups>
<ParametersGroup name="comprobante" title="Comprobante" layout="column">
<Parameter name="ventaComprobanteId" title="Comprobante ID" required="true" type="int">
<Default xsi:type="int">1</Default>
</Parameter>
</ParametersGroup>
</ParametersGroups>
<Variables/>
<DatasourceFilters>
</DatasourceFilters>
<Datasources>
<Datasource xsi:type="sql" name="Totales" connection="gcw" skipCount="0">
<Query xsi:type="script" valueType="string" lang="tpl"><![CDATA[
SELECT
IV.Codigo,
IV.Descripcion,
VII.Alicuota,
VC.Id 'ventaComprobanteId',
sum(VII.Importe) 'Importe'
FROM VentaComprobante VC inner JOIN VentaComprobanteItem VCI ON VC.ID=VCI.VentaComprobanteID
inner join VentaItem VI ON VCI.VentaItemID=VI.Id
INNER JOIN AlicuotaIva AI ON AI.Id = VI.AlicuotaIvaID
INNER JOIN Item I ON I.Id = VI.ItemID
INNER JOIN Unidad U ON U.Id = VI.UnidadID
INNER JOIN VentaItemImpuesto VII ON VII.VentaItemID = VI.Id
INNER JOIN ImpuestoVenta IV ON VII.ImpuestoID=IV.Id
where VC.Id = $ventaComprobanteId
GROUP BY IV.Descripcion,VII.Alicuota,IV.Codigo, VC.Id
UNION
SELECT
-2 Codigo,
'IVA',
AI.Porcentaje,
VC.Id 'ventaComprobanteId',
sum(VI.AlicuotaIvaTotal) 'Importe'
FROM VentaComprobante VC inner JOIN VentaComprobanteItem VCI ON VC.ID=VCI.VentaComprobanteID
inner join VentaItem VI ON VCI.VentaItemID=VI.Id
INNER JOIN AlicuotaIva AI ON AI.Id = VI.AlicuotaIvaID
INNER JOIN Item I ON I.Id = VI.ItemID
INNER JOIN Unidad U ON U.Id = VI.UnidadID
where VC.Id = $ventaComprobanteId
GROUP BY AI.Porcentaje, VC.Id
UNION
SELECT
-1 Codigo,
'NETO',
AI.Porcentaje,
VC.Id 'ventaComprobanteId',
sum(VI.PrecioNetoUnitario*VI.Cantidad) 'Importe'
FROM VentaComprobante VC inner JOIN VentaComprobanteItem VCI ON VC.ID=VCI.VentaComprobanteID
inner join VentaItem VI ON VCI.VentaItemID=VI.Id
INNER JOIN AlicuotaIva AI ON AI.Id = VI.AlicuotaIvaID
INNER JOIN Item I ON I.Id = VI.ItemID
INNER JOIN Unidad U ON U.Id = VI.UnidadID
where VC.Id = $ventaComprobanteId
GROUP BY AI.Porcentaje, VC.Id
ORDER BY 1
$!Debug
]]>
</Query>
</Datasource>
</Datasources>
<DatasourceMappings/>
</Report>
My question here is:
How can I pass the Parameter to the subreport so when I send the Id of the bill both reports (Main and sub) shows the info of the same document?
I tried with Crystal Report editing the subreport and changing the link, creating new parameters and using them in both main and subreport but nothing worked. I know I'm missing something but I don't know what it is.
Hope I was clear enough and someone can share some info with me.
Regards