Example #1
0
        public ReportClass GetDetailReport(InputInvoiceInfo item, FormatConfFacturaAlbaranReport conf)
        {
            if (item == null)
            {
                return(null);
            }

            List <InputInvoiceLinePrint> conceptos = new List <InputInvoiceLinePrint>();
            List <InputInvoicePrint>     pList     = new List <InputInvoicePrint>();

            foreach (InputInvoiceLineInfo cfi in item.Conceptos)
            {
                conceptos.Add(cfi.GetPrintObject());
            }

            //Si no existen conceptos, no tiene sentido un informe detallado. Además, falla en Crystal Reports
            if (conceptos.Count <= 0)
            {
                return(null);
            }

            pList.Add(item.GetPrintObject());

            ProductList productos = ProductList.GetList(false);

            foreach (InputInvoiceLinePrint cfp in conceptos)
            {
                if (cfp.OidProducto == 0)
                {
                    continue;
                }
                ProductInfo prod = productos.GetItem(cfp.OidProducto);
                if (prod != null)
                {
                    if (prod.AyudaKilo > 0)
                    {
                        cfp.Concepto += " *";
                    }
                }
            }

            List <ImpuestoResumen> irpf_list = new List <ImpuestoResumen>();

            foreach (DictionaryEntry irpf in item.GetIRPF())
            {
                irpf_list.Add((ImpuestoResumen)irpf.Value);
            }

            ReportClass doc = null;

            try
            {
                doc = GetReportFromName("Invoice", "InputInvoiceRpt");
            }
            catch
            {
                doc = new InputInvoiceRpt();
            }

            doc.Subreports["LinesSubRpt"].SetDataSource(conceptos);
            if (doc.Subreports["IRPFSubListRpt"] != null)
            {
                doc.Subreports["IRPFSubListRpt"].SetDataSource(irpf_list);
            }

            doc.SetDataSource(pList);
            CompanyInfo company = CompanyInfo.Get(Schema.Oid, false);

            doc.SetParameterValue("nombreEmpresa", company.Name);
            doc.SetParameterValue("dirEmpresa", company.Direccion);
            doc.SetParameterValue("dir2Empresa", company.CodPostal + ". " + company.Municipio + ". " + company.Provincia);
            doc.SetParameterValue("CIFEmpresa", company.VatNumber);
            doc.SetParameterValue("nota", conf.nota);
            doc.SetParameterValue("copia", (conf.copia != null) ? conf.copia : string.Empty);
            doc.SetParameterValue("cuentaBancaria", (conf.cuenta_bancaria != string.Empty) ? conf.cuenta_bancaria : company.CuentaBancaria);

            return(doc);
        }