public static void eliminarUnidad(edificio Edificio, unidad Unidad)
 {
     unidad u = new unidad();
     u.dir_edificio = Edificio.direccion;
     u.id_unidad = Unidad.id_unidad;
     CatalogoUnidades.removeUnidad(u);
 }
 public static void eliminarUnidad(string Edificio, string Unidad)
 {
     unidad u = new unidad();
     u.dir_edificio = Edificio;
     u.id_unidad = Unidad;
     CatalogoUnidades.removeUnidad(u);
 }
 public static bool agregarFacturaExtraordinaria(edificio edificio, unidad unidad, string ID, DateTime fecha, object Provedor, object TipoGasto, object Sector)
 {
     factura fact = new factura();
     fact.dir_edificio = edificio.direccion;
     fact.id_unidad = unidad.id_unidad;
     fact.numero_factura = ID;
     fact.fecha = fecha;
     fact.razon_provedor = ((provedor)Provedor).razon_social;
     fact.id_tipogasto = ((tipo_gasto)TipoGasto).idtipo_gasto;
     fact.id_sector = ((sector)Sector).idsector;
     CatalogoFacturas.addFactura(fact);
     return true;
 }
        public static expensas getExpensaEdificioUnidad(unidad unidad, DateTime periodo)
        {
            try
            {
                admEntities db = Datos.getDB();
                return db.expensas.Where(x => x.fecha.Month == periodo.Month && x.fecha.Year == periodo.Year && x.dir_edificio == unidad.dir_edificio && x.id_unidad == unidad.id_unidad).SingleOrDefault();

            }
            catch (Exception e)
            {
                Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message);
                throw e;
            }
        }
 public static void addUnidad(unidad u)
 {
     try
     {
         admEntities db = Datos.getDB();
         //String query = @"INSERT INTO `unidad` (`id_unidad`, `tipo`, `parcela`, `dir_edificio`, `id_titular`) VALUES ('" + u.id_unidad + "', '" + u.tipo + "',  '" + u.parcela + "', '" + u.dir_edificio + "', " + getNullValue(u.id_titular) + ");";
         //db.Database.ExecuteSqlCommand(query);
         db.unidad.Add(u); // WTF??? Me actualiza los registros anteriores dando titulares inquilinos y inmobiliarias.
         db.SaveChanges();
     }
     catch (Exception e)
     {
         Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message);
         throw e;
     }
 }
        public static bool actualizarUnidad(object edificio, string id_unidad, string tipo, string parcela, string titular, object inmobiliaria, object inquilino)
        {
            unidad u = new unidad();
            u.dir_edificio = ((edificio)edificio).direccion;
            u.id_unidad = id_unidad;
            u.tipo = tipo;
            u.parcela = parcela;

            if ((inmobiliaria != null) && (((inmobiliaria)inmobiliaria).nombre != "Ninguno"))
                u.nombre_inmobiliaria = ((inmobiliaria)inmobiliaria).nombre;
            if ((inquilino != null) && (((inquilino)inquilino).nombre != "Ninguno"))
                u.id_inquilino = ((inquilino)inquilino).idinquilino;

            if (titular != null && titular != "Ninguno")
                u.id_titular = CatalogoTitulares.getOrAddTitular(titular).idtitular;

            CatalogoUnidades.updateUnidad(u);
            return true;
        }
 public static void addGasto(unidad unidad, DateTime fecha, string concepto, string importe, string tipo)
 {
     switch (tipo)
     {
         case "exclusivo":
             {
                 recargo_exclusivo r = new recargo_exclusivo();
                 r.concepto = concepto;
                 r.dir_edificio = unidad.dir_edificio;
                 r.fecha = fecha;
                 r.id_unidad = unidad.id_unidad;
                 r.pagado = 0;
                 r.importe = double.Parse(importe);
                 CatalogoGastosExclusivos.addRecargoExclusivo(r);
                 break;
             }
         case "legales":
             {
                 recargo_legal r = new recargo_legal();
                 r.concepto = concepto;
                 r.dir_edificio = unidad.dir_edificio;
                 r.fecha = fecha;
                 r.id_unidad = unidad.id_unidad;
                 r.pagado = 0;
                 r.importe = double.Parse(importe);
                 CatalogoGastosExclusivos.addRecargoLegal(r);
                 break;
             }
         case "varios":
             {
                 recargo_vario r = new recargo_vario();
                 r.concepto = concepto;
                 r.dir_edificio = unidad.dir_edificio;
                 r.fecha = fecha;
                 r.id_unidad = unidad.id_unidad;
                 r.importe = double.Parse(importe);
                 r.pagado = 0;
                 CatalogoGastosExclusivos.addRecargoVarios(r);
                 break;
             }
     }
 }
 public static expensas getLastExpensaUnidad(unidad u)
 {
     try
     {
         admEntities db = Datos.getDB();
         return db.expensas.Where(x => x.dir_edificio == u.dir_edificio && x.id_unidad == u.id_unidad).OrderByDescending(x => x.fecha).First();
     }
     catch (Exception e)
     {
         Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message);
         throw e;
     }
 }
        public static ExpensasEdificio getExpensasUnidad(edificio edificio, DateTime periodo, unidad unidad)
        {
            try
            {
                ExpensasEdificio expensasEdificio = new ExpensasEdificio();
                using (admEntities db = new admEntities())
                {

                    List<provedor> proveedores = db.edificio.Where(x => x.direccion == edificio.direccion).SingleOrDefault().provedor.ToList();
                    expensasEdificio.Proveedores = new List<Proveedor>();
                    foreach (var p in proveedores)
                    {
                        Proveedor prov = new Proveedor();
                        prov.cargo = p.cargo;
                        prov.nombre = p.razon_social;
                        prov.telefono = p.telefono1;
                        expensasEdificio.Proveedores.Add(prov);
                    }

                    expensasEdificio.Periodo = periodo;
                    expensasEdificio.Edificio = edificio = db.edificio.Where(x => x.direccion == edificio.direccion).SingleOrDefault();
                    List<unidad> unidades = db.unidad.Where(x => x.dir_edificio == edificio.direccion && x.id_unidad == unidad.id_unidad).ToList();
                    expensasEdificio.Sectores = (from es in db.edificios_sectores join e in db.edificio on es.dir_edificio equals e.direccion join s in db.sector on es.id_sector equals s.idsector where e.direccion == edificio.direccion select s).ToList();
                    expensasEdificio.Conceptos = db.Database.SqlQuery<Conceptos>(@"select  s.descripcion 'Sector', f.numero_factura 'NumeroFactura', p.razon_social 'Proveedor', concat(tg.descripcion, ' ', f.detalle) 'concepto', f.importe from factura f                                                     left join provedor p                            on p.razon_social = f.razon_provedor   join sector s on id_sector = s.idsector      join tipo_gasto tg  on f.id_tipogasto = tg.idtipo_gasto                    where dir_edificio = '" + edificio.direccion + "' and month(f.fecha) = " + periodo.Month + " and year(f.fecha) = " + periodo.Year).ToList();
                    expensasEdificio.TotalUnidad = new List<TotalUnidad>();
                    expensasEdificio.EstadoDeCaja = new EstadoCaja();
                    expensasEdificio.EstadoDeCaja.MovimientosDeCaja = db.Database.SqlQuery<MovimientosCaja>("select * from movimiento_caja mc where dir_edificio = '" + edificio.direccion + @"' and month(periodo)=" + periodo.Month + " and year(periodo)=" + periodo.Year).ToList();
                    int tasaRecargoVto = CatalogoTasas.getTasaVto();
                    expensasEdificio.Tasa2Vto = tasaRecargoVto;
                    DateTime fechaActual = DateTime.Parse(1 + "/" + periodo.Month + "/" + periodo.Year);
                    DateTime fechaAnterior = fechaActual.AddMonths(-1);
                    expensasEdificio.EstadoDeCaja.FechaActual = fechaActual.ToShortDateString();
                    expensasEdificio.EstadoDeCaja.FechaAnterior = fechaAnterior.ToShortDateString();
                    expensasEdificio.Deudores = CatalogoDeudores.getDeudoresFromEdificioRegenerarUnidad(edificio, periodo);

                    Double saldoCajaMesAnterior = CatalogoCajaEdificio.getSaldoCajaMes(edificio, fechaAnterior.AddMonths(1).AddDays(-1));
                    Double saldoCajaMesActual = CatalogoCajaEdificio.getSaldoCajaMes(edificio, fechaActual.AddMonths(1).AddDays(-1));

                    expensasEdificio.EstadoDeCaja.ImporteAnterior = saldoCajaMesAnterior;
                    expensasEdificio.EstadoDeCaja.ImporteActual = saldoCajaMesActual;

                    DateTime asd = DateTime.Parse("1 /" + periodo.Month + "/" + periodo.Year);

                    expensas expensaExistente = db.expensas.Where(x => x.dir_edificio == edificio.direccion && x.fecha == asd && x.id_unidad == unidad.id_unidad).SingleOrDefault();

                    foreach (unidad u in unidades)
                    {
                        unidad tempUni = new unidad();
                        if (u.titular == null)
                        {
                            tempUni.titular = new titular();
                            tempUni.titular.nombre = "<<ninguno>>";
                        }
                        else
                            tempUni.titular = u.titular;

                        TotalUnidad totalUnidad = new TotalUnidad();
                        totalUnidad.Unidad = tempUni;
                        string idUnidad = u.id_unidad;
                        tempUni.id_unidad = idUnidad;

                        totalUnidad.Exclusivos = db.recargo_exclusivo.Where(x => x.dir_edificio == u.dir_edificio && x.id_unidad == u.id_unidad && x.fecha.Month == periodo.Month && x.fecha.Year == periodo.Year && x.pagado != 1).Sum(x => (double?)x.importe) ?? 0; ;
                        totalUnidad.Legales = db.recargo_legal.Where(x => x.dir_edificio == u.dir_edificio && x.id_unidad == u.id_unidad && x.fecha.Month == periodo.Month && x.fecha.Year == periodo.Year && x.pagado != 1).Sum(x => (double?)x.importe) ?? 0; ;
                        totalUnidad.Varios = db.recargo_vario.Where(x => x.dir_edificio == u.dir_edificio && x.id_unidad == u.id_unidad && x.fecha.Month == periodo.Month && x.fecha.Year == periodo.Year && x.pagado != 1).Sum(x => (double?)x.importe) ?? 0; ;

                        totalUnidad.TotalSector = db.Database.SqlQuery<Totales>(@"DROP TEMPORARY TABLE IF EXISTS asd;                        CREATE TEMPORARY TABLE IF NOT EXISTS asd AS (                        select id_sector,porcentaje from unidades_sectores us                        where us.dir_edificio = '" + edificio.direccion + @"' and us.id_unidad = '" + u.id_unidad + @"');                        SELECT descripcion 'sector', sum(importe)'importe', porcentaje 'distribucion', (sum(importe) / 100 * porcentaje) 'corresponde' FROM factura f                        join sector s                        on s.idsector = f.id_sector                        join asd r1                        on r1.id_sector = s.idsector                        where month(f.fecha) = " + periodo.Month + @" and year(f.fecha) = " + periodo.Year + @" and f.dir_edificio = '" + edificio.direccion + @"'                        group by  descripcion                        order by r1.id_sector                        ").ToList();

                        double deuda = 0;
                        double recargo = 0;

                        foreach (CatalogoDeudores.Deudor d in expensasEdificio.Deudores)
                        {
                            if (u.id_unidad == d.Unidad)
                            {
                                deuda += d.Importe;
                                recargo += d.Recargo;
                            }
                        }
                        totalUnidad.Deuda = deuda;
                        totalUnidad.Recargo = recargo;
                        totalUnidad.NroFactura = expensaExistente.nro_factura;
                        expensasEdificio.TotalUnidad.Add(totalUnidad);

                        expensasEdificio.ImporteVto1 = (Double)expensaExistente.importeVto1;
                        expensasEdificio.ImporteVto2 = (Double)expensaExistente.importeVto2;

                        expensasEdificio.Vto1 = (DateTime)expensaExistente.fechaVto1;
                        expensasEdificio.Vto2 = (DateTime)expensaExistente.fechaVto2;
                    }

                }
                return expensasEdificio;
            }
            catch (Exception ex)
            {
                Logger.Log.write(ex.InnerException == null ? ex.Message : ex.InnerException.Message);
                throw ex;
            }
        }
        static void addEncabezado(Document doc, ExpensasEdificio expensaEdificio, unidad u, string Tipo, string nroComprobante, System.Drawing.Image qr)
        {
            Image img = iTextSharp.text.Image.GetInstance(qr, System.Drawing.Imaging.ImageFormat.Png);
            img.SetAbsolutePosition(milimetroToPoint(12), doc.PageSize.Height - milimetroToPoint(19) - milimetroToPoint(7));
            img.ScaleToFit(milimetroToPoint(19), milimetroToPoint(19));

            PdfPTable t = new PdfPTable(4);

            float[] widths = new float[] { 25f, 40f, 85f, 25f };
            t.SetWidths(widths);

            PdfPCell c = new PdfPCell();
            Paragraph p;

            c.PaddingTop = -2;
            c.PaddingLeft = 0;
            c.Border = 0;
            c.BorderWidthBottom = 0.5f;
            c.AddElement(img);
            t.WidthPercentage = 100;
            t.AddCell(c);

            int leading = 9;
            c = new PdfPCell();
            c.PaddingTop = -2;
            c.Border = 0;
            c.BorderWidthBottom = 0.5f;
            p = new Paragraph(leading, "CALVAGNA CONSORCIOS", calibri8N);
            c.AddElement(p);

            p = new Paragraph(leading, "Maipú 1148 Piso 10º Of. 04", calibri8N);
            c.AddElement(p);

            p = new Paragraph(leading, "S2000CGN Rosario ", calibri8N);
            c.AddElement(p);

            p = new Paragraph(leading, "+54 341 4260298", calibri8N);
            c.AddElement(p);

            p = new Paragraph(leading, "+54 341 6415393", calibri8N);
            c.AddElement(p);

            p = new Paragraph(leading, "*****@*****.**", calibri8N);
            c.AddElement(p);

            t.AddCell(c);

            c = new PdfPCell();
            c.PaddingTop = -2;
            c.Border = 0;
            c.BorderWidthBottom = 0.5f;
            p = new Paragraph(leading, "CONSORCIO EDIFICIO: " + expensaEdificio.Edificio.direccion.ToUpper(), calibri8B);
            c.AddElement(p);

            p = new Paragraph(leading, "LIQUIDACION EXPENSAS COMUNES PERIODO: " + expensaEdificio.Periodo.Month + "/" + expensaEdificio.Periodo.Year, calibri8N);
            c.AddElement(p);

            p = new Paragraph(leading, "TIPO: " + Tipo, calibri8N);
            c.AddElement(p);

            p = new Paragraph(leading, "UNIDAD: " + u.id_unidad, calibri8B);
            c.AddElement(p);
            if (u.titular == null)
            {
                u.titular = new titular();
                u.titular.nombre = "<<ninguno>>";
            }
            p = new Paragraph(leading, "TITULAR: " + u.titular.nombre, calibri8B);
            c.AddElement(p);

            p = new Paragraph(leading, "Comprobante número: " + nroComprobante, calibri8N);
            c.AddElement(p);

            t.AddCell(c);

            c = new PdfPCell();

            p = new Paragraph(leading, "Rosario, " + DateTime.Today.ToShortDateString(), calibri8N);
            c.PaddingTop = -2;
            c.Border = 0;
            c.BorderWidthBottom = 0.5f;
            c.AddElement(p);
            t.AddCell(c);
            doc.Add(t);
        }
 public static List<ExpensaConsultaRapida> getLastExpensas(edificio e, unidad u)
 {
     return CatalogoDeudores.getLastExpensas(e, u);
 }
Beispiel #12
0
        static void Main(string[] args)
        {
            calibri = BaseFont.CreateFont("calibri.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
            calibri8N = new Font(calibri, 8, Font.NORMAL);
            calibri8I = new Font(calibri, 8, Font.ITALIC);
            calibri8B = new Font(calibri, 8, Font.BOLD);
            calibri9N = new Font(calibri, 9, Font.NORMAL);
            calibri9B = new Font(calibri, 9, Font.BOLD);
            calibri12N = new Font(calibri, 10, Font.NORMAL);
            calibri12B = new Font(calibri, 10, Font.BOLD);
            calibri11N = new Font(calibri, 10, Font.NORMAL);
            calibri11B = new Font(calibri, 10, Font.BOLD);

            titular t = new titular();
            unidad u = new unidad();
            expensas e = new expensas();
            u.dir_edificio = "9 de Julio 566";
            u.id_unidad = "02-02";
            t.nombre = "Ramon Fernandez";
            u.titular = t;
            u.parcela = "10";

            e.nro_factura = "159";
            e.nro_referencia = "534023492342";
            e.fechaVto2 = DateTime.Now;
            e.importeVto2 = 3150.32;

            GenerarIntimacionAdministrativa(u, e);
        }
Beispiel #13
0
        private static void agregarIntimacionAdministrativaTitulo(Document doc, unidad u)
        {
            PdfPTable t = new PdfPTable(1);
            float[] widths = new float[] { 500f };
            t.WidthPercentage = 85;
            t.SetWidths(widths);
            t.HorizontalAlignment = Element.ALIGN_CENTER;

            int leading = 14;
            Paragraph p;
            PdfPCell c = new PdfPCell();

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthTop = 1;
            c.BorderWidthBottom = 1;
            p = new Paragraph(leading, u.titular.nombre + " y/o Propietario y/o Responsable", calibri12B);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            c.PaddingBottom = 10;
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthBottom = 1;
            p = new Paragraph(leading, u.dir_edificio + " " + u.id_unidad, calibri12B);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            c.PaddingBottom = 10;
            c.BackgroundColor = BaseColor.LIGHT_GRAY;
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthBottom = 1;
            p = new Paragraph(leading, "2000 ROSARIO", calibri12B);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            c.PaddingBottom = 10;
            t.AddCell(c);

            doc.Add(t);
        }
        static void addConceptos(Document doc, List<CatalogoDeudores.DetalleDeuda> detalles, unidad uni, titular tit, double descuento = 0)
        {
            PdfPTable t = new PdfPTable(6);
            t.WidthPercentage = 100;
            float[] widths = new float[] { 35f, 35f, 35f, 35f, 35f, 35f };
            t.SetWidths(widths);

            Paragraph p;
            p = new Paragraph(15, "Consorcio: " + uni.dir_edificio, calibri9N);
            doc.Add(p);

            p = new Paragraph(15, "Unidad: " + uni.id_unidad, calibri9N);
            doc.Add(p);

            p = new Paragraph(15, "Titular: " + (uni.titular != null ? uni.titular.nombre : "Ninguno"), calibri9N);
            doc.Add(p);

            p = new Paragraph(15, " ", calibri9N);
            doc.Add(p);

            int leading = 9;

            PdfPCell c;

            c = new PdfPCell();

            c.Border = 0;
            c.BorderWidthBottom = 0.1f;
            c.BorderWidthTop = 0.1f;
            p = new Paragraph(leading, "Periodo", calibri9N);
            p.Alignment = Element.ALIGN_CENTER;
            c.FixedHeight = 16;
            c.AddElement(p);

            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthBottom = 0.1f;
            c.BorderWidthTop = 0.1f;
            p = new Paragraph(leading, "Concepto", calibri9N);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthBottom = 0.1f;
            c.BorderWidthTop = 0.1f;
            p = new Paragraph(leading, "Comprobante", calibri9N);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthBottom = 0.1f;
            c.BorderWidthTop = 0.1f;
            p = new Paragraph(leading, "Importe       ", calibri9N);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthBottom = 0.1f;
            c.BorderWidthTop = 0.1f;
            p = new Paragraph(leading, "Recargo       ", calibri9N);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthBottom = 0.1f;
            c.BorderWidthTop = 0.1f;
            p = new Paragraph(leading, "Deuda       ", calibri9N);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            //Poner cobros

            double total = 0;
            double totalRecargos = 0;
            foreach (var d in detalles)
            {
                c = new PdfPCell();

                c.Border = 0;

                p = new Paragraph(leading, d.Periodo.Month + "/" + d.Periodo.Year, calibri9N);
                p.Alignment = Element.ALIGN_CENTER;
                c.FixedHeight = 16;
                c.AddElement(p);

                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;
                p = new Paragraph(leading, d.Tipo == "Ordinaria" ? "Expensas" : d.Tipo, calibri9N);
                p.Alignment = Element.ALIGN_CENTER;
                c.AddElement(p);
                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;
                if (d.NroFactura == "000000000000000")
                    d.NroFactura = " - ";
                p = new Paragraph(leading, d.Tipo == "Ordinaria" ? d.NroFactura : " - ", calibri9N);
                p.Alignment = Element.ALIGN_CENTER;
                c.AddElement(p);
                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;
                p = new Paragraph(leading, d.Importe.ToString("n2") + "       ", calibri9N);
                p.Alignment = Element.ALIGN_RIGHT;
                c.AddElement(p);
                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;

                p = new Paragraph(leading, d.Recargo.ToString("n2") + "       ", calibri9N);
                p.Alignment = Element.ALIGN_RIGHT;
                c.AddElement(p);
                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;

                p = new Paragraph(leading, (d.Importe + d.Recargo).ToString("n2") + "       ", calibri9N);
                p.Alignment = Element.ALIGN_RIGHT;
                c.AddElement(p);
                t.AddCell(c);
                total += d.Importe + d.Recargo;
                totalRecargos += d.Recargo;
            }

            if (descuento > 0)
            {
                c = new PdfPCell();

                c.Border = 0;

                p = new Paragraph(leading, DateTime.Now.Month + "/" + DateTime.Now.Year, calibri9N);
                p.Alignment = Element.ALIGN_CENTER;
                c.FixedHeight = 16;
                c.AddElement(p);

                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;
                p = new Paragraph(leading, "Bonificacion: " + descuento + "%", calibri9N);
                p.Alignment = Element.ALIGN_CENTER;
                c.AddElement(p);
                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;
                p = new Paragraph(leading, " ", calibri9N);
                p.Alignment = Element.ALIGN_CENTER;
                c.AddElement(p);
                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;
                p = new Paragraph(leading, " ", calibri9N);
                p.Alignment = Element.ALIGN_RIGHT;
                c.AddElement(p);
                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;

                p = new Paragraph(leading, "-" + ((descuento / 100) * totalRecargos).ToString("n2"), calibri9N);
                p.Alignment = Element.ALIGN_RIGHT;
                c.AddElement(p);
                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;

                p = new Paragraph(leading, " ", calibri9N);
                p.Alignment = Element.ALIGN_RIGHT;
                c.AddElement(p);
                t.AddCell(c);
            }

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthBottom = 0.1f;
            c.BorderWidthTop = 0.1f;
            p = new Paragraph(leading, "TOTAL ", calibri9B);
            p.Alignment = Element.ALIGN_CENTER;
            c.FixedHeight = 16;
            c.AddElement(p);

            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthBottom = 0.1f;
            c.BorderWidthTop = 0.1f;
            p = new Paragraph(leading, " ", calibri9N);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthBottom = 0.1f;
            c.BorderWidthTop = 0.1f;
            p = new Paragraph(leading, " ", calibri9N);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthBottom = 0.1f;
            c.BorderWidthTop = 0.1f;
            p = new Paragraph(leading, " ", calibri9N);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthBottom = 0.1f;
            c.BorderWidthTop = 0.1f;
            p = new Paragraph(leading, " ", calibri9N);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.BorderWidthBottom = 0.1f;
            c.BorderWidthTop = 0.1f;
            p = new Paragraph(leading, (total - ((descuento / 100) * totalRecargos)).ToString("n2"), calibri9B);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            doc.Add(t);
        }
        public static String GenerarResumenDeCuenta(edificio e, unidad u)
        {
            calibri = BaseFont.CreateFont(IncludesPath + "calibri.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);

            calibri8N = new Font(calibri, 8, Font.NORMAL);
            calibri8B = new Font(calibri, 8, Font.BOLD);

            calibri9N = new Font(calibri, 9, Font.NORMAL);
            calibri9B = new Font(calibri, 9, Font.BOLD);

            calibri12N = new Font(calibri, 10, Font.NORMAL);
            calibri12B = new Font(calibri, 10, Font.BOLD);

            calibri11N = new Font(calibri, 10, Font.NORMAL);
            calibri11B = new Font(calibri, 10, Font.BOLD);

            Document doc = new Document(PageSize.A4, milimetroToPoint(12), milimetroToPoint(12), milimetroToPoint(12), milimetroToPoint(12));
            Directory.CreateDirectory(Ruta + "Resumen de Cuenta");
            var output = new FileStream(Ruta + @"Resumen de Cuenta\\Resumen de Cuenta " + e.direccion + " " + u.id_unidad + " " + DateTime.Now.Month + " del " + DateTime.Now.Year + ".pdf", FileMode.Create);
            var writer = PdfWriter.GetInstance(doc, output);

            u.dir_edificio = e.direccion;
            u = CatalogoUnidades.getUnidad(u);

            var detalles = Business.ControladorExpensas.getDetalleDeudaUnidad(u);

            doc.Open();
            addEncabezadoSinQRResumenCuenta(doc, e.direccion, u.id_unidad, u.titular.nombre);
            if (detalles.Count > 0)
                addDetallesDeResumenDeCuenta(doc, e, u, detalles);
            else
                doc.Add(new Paragraph(40, "La unidad no tiene deudas a la fecha."));
            doc.Close();

            return Ruta + @"Resumen de Cuenta\\Resumen de Cuenta " + e.direccion + " " + u.id_unidad + " " + DateTime.Now.Month + " del " + DateTime.Now.Year + ".pdf";
        }
        public static string generarRecibo(System.Drawing.Image qr, List<CatalogoDeudores.DetalleDeuda> detalles, unidad uni, titular tit, double descuento = 0)
        {
            calibri = BaseFont.CreateFont(IncludesPath + "calibri.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
            calibri8N = new iTextSharp.text.Font(calibri, 8, iTextSharp.text.Font.NORMAL);
            calibri8B = new iTextSharp.text.Font(calibri, 8, iTextSharp.text.Font.BOLD);
            calibri9N = new iTextSharp.text.Font(calibri, 9, iTextSharp.text.Font.NORMAL);
            calibri9B = new iTextSharp.text.Font(calibri, 9, iTextSharp.text.Font.BOLD);
            calibri12N = new iTextSharp.text.Font(calibri, 10, iTextSharp.text.Font.NORMAL);
            calibri12B = new iTextSharp.text.Font(calibri, 10, iTextSharp.text.Font.BOLD);
            calibri11N = new iTextSharp.text.Font(calibri, 10, iTextSharp.text.Font.NORMAL);
            calibri11B = new iTextSharp.text.Font(calibri, 10, iTextSharp.text.Font.BOLD);

            Document doc = new Document(PageSize.A4, milimetroToPoint(12), milimetroToPoint(12), milimetroToPoint(7), 0f);
            bool exists = System.IO.Directory.Exists(Ruta + "Recibos");

            if (!exists)
                System.IO.Directory.CreateDirectory(Ruta + "Recibos");

            string nombre = detalles.First().Edificio + " " + detalles.First().Unidad + " " + DateTime.Now.ToShortDateString().Replace("/", "-");

            var output = new FileStream(Ruta + @"Recibos\" + nombre + ".pdf", FileMode.Create);
            var writer = PdfWriter.GetInstance(doc, output);

            doc.Open();
            addEncabezado(doc, qr);
            addConceptos(doc, detalles, uni, tit, descuento);
            doc.Add(new Paragraph(10, " "));
            addFirmaSello(doc);
            doc.Close();
            return Ruta + @"Recibos\" + nombre + ".pdf";
        }
        public static string generarLiquidacionesUnidadWeb(edificio edificio, DateTime p, unidad unidad, System.Drawing.Image _24, System.Drawing.Image qr, System.Drawing.Image tijera)
        {
            calibri = BaseFont.CreateFont(IncludesPath + "calibri.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);

            calibri8N = new Font(calibri, 8, Font.NORMAL);
            calibri8B = new Font(calibri, 8, Font.BOLD);

            calibri9N = new Font(calibri, 9, Font.NORMAL);
            calibri9B = new Font(calibri, 9, Font.BOLD);

            calibri12N = new Font(calibri, 10, Font.NORMAL);
            calibri12B = new Font(calibri, 10, Font.BOLD);

            calibri11N = new Font(calibri, 10, Font.NORMAL);
            calibri11B = new Font(calibri, 10, Font.BOLD);

            ExpensasEdificio expensasEdificio = CatalogoExpensas.getExpensasUnidad(edificio, p, unidad);

            Document doc = new Document(PageSize.A4, milimetroToPoint(12), milimetroToPoint(12), milimetroToPoint(7), 0f);
            bool exists = System.IO.Directory.Exists(Ruta + "Liquidaciones/" + p.Month + " del " + p.Year);

            if (!exists)
                System.IO.Directory.CreateDirectory(Ruta + "Liquidaciones/" + p.Month + " del " + p.Year);
            var output = new FileStream(Ruta + "Liquidaciones/" + p.Month + " del " + p.Year + "/" + expensasEdificio.Edificio.direccion + " " + unidad.id_unidad + ".pdf", FileMode.Create);
            var writer = PdfWriter.GetInstance(doc, output);

            doc.Open();
            PDFFooter footer = new PDFFooter();
            footer.texto = "";
            writer.PageEvent = footer;
            foreach (TotalUnidad totalesUnidad in expensasEdificio.TotalUnidad)
            {
                if (totalesUnidad.Unidad.id_unidad == unidad.id_unidad)
                {
                    addEncabezado(doc, expensasEdificio, totalesUnidad.Unidad, "Ordinaria", totalesUnidad.NroFactura, qr);
                    addGastos(doc, expensasEdificio);
                    doc.Add(new Paragraph(3, " "));
                    addTotales(doc, expensasEdificio, totalesUnidad);
                    addResumen(doc, expensasEdificio, totalesUnidad);
                    addEstadoCaja(doc, expensasEdificio);
                    addDeudores(doc, expensasEdificio);
                    doc.Add(new Paragraph(8, " "));
                    addUrgencias(doc, writer, expensasEdificio, _24, tijera);
                    doc.Add(new Paragraph(8, " "));
                    addCuponDePago(doc, writer, expensasEdificio, totalesUnidad, expensasEdificio.Vto1, expensasEdificio.Vto2);//, strWriter);
                    doc.NewPage();
                }
            }
            doc.Close();
            return Ruta + "Liquidaciones/" + p.Month + " del " + p.Year + "/" + expensasEdificio.Edificio.direccion + " " + unidad.id_unidad + ".pdf";
        }
        public static string GenerarIntimacionAdministrativa(unidad u)
        {
            u = Business.ControladorUnidades.getUnidad(u.dir_edificio, u.id_unidad);
            expensas e = CatalogoExpensas.getLastExpensaUnidad(u);

            calibri = BaseFont.CreateFont(IncludesPath + "calibri.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
            calibri8N = new Font(calibri, 8, Font.NORMAL);
            calibri8I = new Font(calibri, 8, Font.ITALIC);
            calibri8B = new Font(calibri, 8, Font.BOLD);
            calibri9N = new Font(calibri, 9, Font.NORMAL);
            calibri9B = new Font(calibri, 9, Font.BOLD);
            calibri12N = new Font(calibri, 10, Font.NORMAL);
            calibri12B = new Font(calibri, 10, Font.BOLD);
            calibri11N = new Font(calibri, 10, Font.NORMAL);
            calibri11B = new Font(calibri, 10, Font.BOLD);

            String salida = Ruta + @"Intimaciones Administrativas\\" + u.dir_edificio + " " + u.id_unidad + " " + DateTime.Now.ToShortDateString().Replace("/", "-") + ".pdf";
            Document doc = new Document(PageSize.A4, milimetroToPoint(12), milimetroToPoint(12), milimetroToPoint(7), 0f);
            Directory.CreateDirectory(Ruta + "Intimaciones Administrativas");
            var output = new FileStream(salida, FileMode.Create);
            var writer = PdfWriter.GetInstance(doc, output);

            doc.Open();

            doc.Add(new Paragraph(40, " "));
            agregarIntimacionAdministrativaEncabezado(doc);
            doc.Add(new Paragraph(15, " "));
            agregarIntimacionAdministrativaTitulo(doc, u);
            doc.Add(new Paragraph(120, " "));
            agregarIntimacionAdministrativaTexto(doc, u, e);
            doc.Add(new Paragraph(80, " "));
            agregarIntimacionAdministrativaFirma(doc);
            doc.Close();

            return salida;
        }
 private static void hacerLiquidacionThread(ExpensasEdificio expensasEdificio, DateTime p, DateTime vto1, DateTime vto2, string textoPie, System.Drawing.Image _24, System.Drawing.Image qr, System.Drawing.Image tijera)
 {
     Document doc = new Document(PageSize.A4, milimetroToPoint(12), milimetroToPoint(12), milimetroToPoint(7), 0f);
     bool exists = System.IO.Directory.Exists(Ruta + "Liquidaciones\\" + p.Month + " del " + p.Year);
     if (!exists)
         System.IO.Directory.CreateDirectory(Ruta + "Liquidaciones\\" + p.Month + " del " + p.Year);
     var output = new FileStream(Ruta + @"Liquidaciones\\" + p.Month + " del " + p.Year + "\\" + expensasEdificio.Edificio.direccion + ".pdf", FileMode.Create);
     var writer = PdfWriter.GetInstance(doc, output);
     doc.Open();
     PDFFooter footer = new PDFFooter();
     footer.texto = textoPie;
     writer.PageEvent = footer;
     foreach (TotalUnidad totalesUnidad in expensasEdificio.TotalUnidad)
     {
         addEncabezado(doc, expensasEdificio, totalesUnidad.Unidad, "Ordinaria", totalesUnidad.NroFactura, qr);
         addGastos(doc, expensasEdificio);
         doc.Add(new Paragraph(3, " "));
         addTotales(doc, expensasEdificio, totalesUnidad);
         addResumen(doc, expensasEdificio, totalesUnidad);
         addEstadoCaja(doc, expensasEdificio);
         addDeudores(doc, expensasEdificio);
         doc.Add(new Paragraph(8, " "));
         addUrgencias(doc, writer, expensasEdificio, _24, tijera);
         doc.Add(new Paragraph(8, " "));
         addCuponDePago(doc, writer, expensasEdificio, totalesUnidad, vto1, vto2);//, strWriter);
         doc.NewPage();
     }
     unidad uniAdm = new unidad();
     titular titAdm = new titular();
     titAdm.nombre = "Administración";
     uniAdm.id_unidad = "Archivo";
     uniAdm.titular = titAdm;
     addEncabezado(doc, expensasEdificio, uniAdm, "Ordinaria", "000000000000000", qr);
     addGastos(doc, expensasEdificio);
     doc.Add(new Paragraph(3, " "));
     addEstadoCaja(doc, expensasEdificio);
     addDeudores(doc, expensasEdificio);
     doc.Add(new Paragraph(8, " "));
     addUrgencias(doc, writer, expensasEdificio, _24, tijera);
     doc.Close();
 }
        public static List<expensas> registrarPagos(DateTime periodo, List<Pagos> pagos, unidad unidad)
        {
            try
            {
                admEntities db = new admEntities();
                List<expensas> expensas = db.expensas.Where(x => x.fecha.Month == periodo.Month && x.fecha.Year == periodo.Year && x.dir_edificio == unidad.dir_edificio && x.id_unidad == unidad.id_unidad).ToList();
                List<expensas> expensasPagadas = new List<Data.expensas>();
                foreach (Pagos p in pagos)
                {
                    foreach (expensas e in expensas)
                    {
                        if (p.nroReferencia == e.nro_referencia && p.nroFactura == e.nro_factura)
                        {
                            e.pagado = 1;
                            db.Entry(e).State = System.Data.EntityState.Modified;
                            expensasPagadas.Add(e);
                        }

                    }
                }
                db.SaveChanges();
                return expensas;
            }
            catch (Exception e)
            {
                Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message);
                throw e;
            }
        }
        public static List<CatalogoExpensas.Pagos> registrarPagosAutomaticos(DateTime periodo, List<Pagos> pagos)
        {
            try
            {
                admEntities db = new admEntities();

                //Si alguien paga por automatico, queda totalmente al dia. Sumar recargos cobrados de meses anteriores o si pago en 2 vto
                List<expensas> expensas = new List<expensas>();
                List<Recargo> gastosExclusivos = new List<Recargo>();
                List<recargos> recargos = new List<recargos>();

                foreach (var p in pagos)
                {
                    var exp = db.expensas.Where(x => x.nro_referencia == p.nroReferencia).OrderByDescending(x => x.fecha).First();
                    var uni = new unidad();
                    uni.dir_edificio = exp.dir_edificio;
                    uni.id_unidad = exp.id_unidad;
                    p.Edificio = uni.dir_edificio;
                    p.Unidad = uni.id_unidad;
                    p.Periodo = exp.fecha.Month + "/" + exp.fecha.Year;

                    var expensasMismaUnidad = db.expensas.Where(x => x.dir_edificio == uni.dir_edificio && x.id_unidad == uni.id_unidad && x.pagado == 0).ToList();
                    var exclusivosMismaUnidad = CatalogoGastosExclusivos.getAllRecargos(uni);

                    expensas.AddRange(expensasMismaUnidad);
                    gastosExclusivos.AddRange(exclusivosMismaUnidad);
                }

                var expGrouped = expensas.GroupBy(x => new { x.dir_edificio, x.id_unidad })
                                        .Select(x => new expensas { dir_edificio = x.Key.dir_edificio, id_unidad = x.Key.id_unidad })
                                        .Cast<expensas>()
                                        .ToList();

                foreach (expensas e in expensas)
                {
                    e.pagado = 1;
                    db.Entry(e).State = System.Data.EntityState.Modified;
                }

                foreach (expensas e in expGrouped)
                {
                    recargos r = new recargos();
                    var uni = new unidad();
                    uni.dir_edificio = e.dir_edificio;
                    uni.id_unidad = e.id_unidad;
                    r.dir_edificio = e.dir_edificio;
                    r.periodo = DateTime.Parse("1/" + DateTime.Now.Month + "/" + DateTime.Now.Year);
                    var detalles = CatalogoDeudores.getDetalleDeudaUnidad(uni);
                    r.importe = detalles.Sum(x => x.Recargo);

                    var rExistente = recargos.Where(x => x.dir_edificio == r.dir_edificio && x.periodo == r.periodo).SingleOrDefault();

                    if (rExistente != null)
                        rExistente.importe += r.importe;
                    else
                        recargos.Add(r);
                }

                db.SaveChanges();

                foreach (var excl in gastosExclusivos)
                {
                    switch (excl.Tipo)
                    {
                        case "Exclusivos":
                            CatalogoGastosExclusivos.pagarRecargoExclusivo(excl.Edificio, excl.Unidad, excl.Concepto, excl.Fecha);
                            break;
                        case "Legales":
                            CatalogoGastosExclusivos.pagarRecargoLegales(excl.Edificio, excl.Unidad, excl.Concepto, excl.Fecha);
                            break;
                        case "Varios":
                            CatalogoGastosExclusivos.pagarRecargoVarios(excl.Edificio, excl.Unidad, excl.Concepto, excl.Fecha);
                            break;
                    }
                }

                CatalogoRecargos.addRecargos(recargos);

                return pagos;

            }
            catch (Exception e)
            {
                Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message);
                var str = "";
                str = e.InnerException?.InnerException?.Message;
                Logger.Log.write("Otro error: " + str);
                throw e;
            }
        }
 public static void removeUnidad(unidad u)
 {
     try {
         admEntities db = Datos.getDB();
         var unidad = db.unidad.SingleOrDefault(x => x.id_unidad == u.id_unidad && x.dir_edificio == u.dir_edificio);
         if (unidad != null)
         {
             db.unidad.Remove(unidad);
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message);
         throw e;
     }
 }
Beispiel #23
0
        private static void agregarIntimacionAdministrativaTexto(Document doc, unidad u, expensas e)
        {
            PdfPTable t = new PdfPTable(1);
            float[] widths = new float[] { 500f };
            t.WidthPercentage = 85;
            t.SetWidths(widths);
            t.HorizontalAlignment = Element.ALIGN_CENTER;

            int leading = 14;
            Paragraph p;
            PdfPCell c = new PdfPCell();

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, "Rosario, 25 de Enero de 2016", calibri11N);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, " ", calibri11N);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, "En mi carácter de Administrador del Consorcio de Propietarios del Edificio "+u.dir_edificio+ ", sito en calle " + u.dir_edificio + " de esta ciudad, por las facultades que me otorga el Reglamento de Copropiedad y Administración, procedo a notificarlo que su propiedad ubicada en la parcela " + u.parcela + ", unidad " + u.id_unidad + ", registra en nuestro sistema contable una deuda de expensas comunes de $ " + e.importeVto2?.ToString("n2") + " calculada al " + e.fechaVto2?.ToShortDateString() + ".", calibri12N);
            p.Alignment = Element.ALIGN_LEFT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, " ", calibri11N);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, "Por lo expuesto intimo a Ud. a la cancelación total de la acreencia dentro del plazo de 72 horas contadas desde la recepción de la presente. Para tal fin se le ha remitido en la última liquidación n°: " + e.nro_factura + ", que adjunta el volante de pago, cuyo codigo eléctronico es: " +e.nro_referencia+" para abonar a través de los canales habilitados de la red Banelco, que los puede consultar en: www.pagomiscuentas.com.ar, además podrá comunicarse con esta administración para recibir más instrucciones o constituir un posible plan de pagos mensuales.", calibri12N);
            p.Alignment = Element.ALIGN_LEFT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, " ", calibri11N);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, "Si la obligación ya fue cancelada, ruego desestimar esta nota.", calibri12N);
            p.Alignment = Element.ALIGN_LEFT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, " ", calibri11N);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, "En caso de incumplimiento se pasarán  las acciones el departamento legal, generando mayores costos y perjuicios.", calibri12N);
            p.Alignment = Element.ALIGN_LEFT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, " ", calibri11N);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, "Sin otro particular, saludo a Ud. Atte.", calibri12N);
            p.Alignment = Element.ALIGN_LEFT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, " ", calibri11N);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            doc.Add(t);
        }
 public static void updateUnidad(unidad u)
 {
     try
     {
         unidad uni;
         admEntities db = Datos.getDB();
         uni = db.unidad.Where(x => x.dir_edificio == u.dir_edificio && x.id_unidad == u.id_unidad).First();
         uni.id_inquilino = u.id_inquilino;
         uni.nombre_inmobiliaria = u.nombre_inmobiliaria;
         uni.id_titular = u.id_titular;
         uni.parcela = u.parcela;
         uni.tipo = u.tipo;
         db.Entry(uni).State = System.Data.EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception e)
     {
         Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message);
         throw e;
     }
 }
Beispiel #25
0
        private static void GenerarIntimacionAdministrativa(unidad u, expensas e)
        {
            Document doc = new Document(PageSize.A4, milimetroToPoint(12), milimetroToPoint(12), milimetroToPoint(7), 0f);
            calibri8I = new Font(calibri, 8, Font.ITALIC);
            Directory.CreateDirectory(Ruta + "Intimaciones Administrativas");
            var output = new FileStream(Ruta + @"Intimaciones Administrativas\\" + u.dir_edificio + " " + u.id_unidad + " " + DateTime.Now.ToShortDateString().Replace("/", "-") + ".pdf", FileMode.Create);
            var writer = PdfWriter.GetInstance(doc, output);

            doc.Open();
            doc.Add(new Paragraph(40, " "));
            agregarIntimacionAdministrativaEncabezado(doc);
            doc.Add(new Paragraph(15, " "));
            agregarIntimacionAdministrativaTitulo(doc, u);
            doc.Add(new Paragraph(120, " "));
            agregarIntimacionAdministrativaTexto(doc, u, e);
            doc.Add(new Paragraph(80, " "));
            agregarIntimacionAdministrativaFirma(doc);
            doc.Close();
        }
        public static String generarAllVistaPreviaLiquidaciones(List<edificio> edificios, DateTime p, DateTime vto1, DateTime vto2, string textoPie, System.Drawing.Image _24, System.Drawing.Image qr, System.Drawing.Image tijera)
        {
            List<ExpensasEdificio> expensas = CatalogoExpensas.getAllExpensasVistaPrevia(edificios, p, vto1, vto2);
            calibri = BaseFont.CreateFont(IncludesPath + "calibri.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
            calibri8N = new Font(calibri, 8, Font.NORMAL);
            calibri8B = new Font(calibri, 8, Font.BOLD);
            calibri9N = new Font(calibri, 9, Font.NORMAL);
            calibri9B = new Font(calibri, 9, Font.BOLD);
            calibri12N = new Font(calibri, 10, Font.NORMAL);
            calibri12B = new Font(calibri, 10, Font.BOLD);
            calibri11N = new Font(calibri, 10, Font.NORMAL);
            calibri11B = new Font(calibri, 10, Font.BOLD);

            Document doc = new Document(PageSize.A4, milimetroToPoint(12), milimetroToPoint(12), milimetroToPoint(7), 0f);
            bool exists = System.IO.Directory.Exists(Ruta + "VistaPrevia\\" + p.Month + " del " + p.Year);
            if (!exists)
                System.IO.Directory.CreateDirectory(Ruta + "VistaPrevia\\" + p.Month + " del " + p.Year);

            String salida = Ruta + @"VistaPrevia\\" + p.Month + " del " + p.Year + "\\VistaPrevia.pdf";
            var output = new FileStream(salida, FileMode.Create);
            var writer = PdfWriter.GetInstance(doc, output);
            doc.Open();
            PDFFooter footer = new PDFFooter();
            footer.texto = "Vista Previa " + (textoPie.Count() > 0 ? "- " + textoPie : "");
            writer.PageEvent = footer;

            foreach (var expensasEdificio in expensas)
            {
                unidad uniAdm = new unidad();
                titular titAdm = new titular();
                titAdm.nombre = "Administración";
                uniAdm.id_unidad = "Archivo";
                uniAdm.titular = titAdm;
                addEncabezado(doc, expensasEdificio, uniAdm, "Ordinaria", "000000000000000", qr);
                addGastos(doc, expensasEdificio);
                doc.Add(new Paragraph(3, " "));
                addEstadoCaja(doc, expensasEdificio);
                addDeudores(doc, expensasEdificio);
                doc.Add(new Paragraph(8, " "));
                addUrgencias(doc, writer, expensasEdificio, _24, tijera);
                doc.NewPage();
            }
            doc.Close();
            return salida;
        }
 public static List<CatalogoDeudores.Deudor> getDeudores(edificio e, unidad u)
 {
     return CatalogoDeudores.getDeudoresFromEdificio(e,u);
 }
 public static unidad getUnidad(unidad unidad)
 {
     try
     {
         admEntities db = Datos.getDB();
         return db.unidad.Where(x => x.dir_edificio == unidad.dir_edificio && x.id_unidad == unidad.id_unidad).SingleOrDefault();
     }
     catch (Exception e)
     {
         Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message);
         throw e;
     }
 }
        public static ExpensasEdificio getExpensasEdificio(edificio edificio, DateTime periodo, DateTime vto1, DateTime vto2, ref int correlativo, admEntities db, List<expensas> allExpensasExistentes)
        {
            try
            {
                ExpensasEdificio expensasEdificio = new ExpensasEdificio();
                {

                    expensasEdificio.Periodo = periodo;
                    expensasEdificio.Edificio = edificio;//db.edificio.Where(x => x.direccion == edificio.direccion).SingleOrDefault();
                    List<unidad> unidades = CatalogoUnidades.getAllUnidades(edificio);
                    // expensasEdificio.Sectores = (from es in db.edificios_sectores join e in db.edificio on es.dir_edificio equals e.direccion join s in db.sector on es.id_sector equals s.idsector where e.direccion == edificio.direccion select s).ToList();
                    expensasEdificio.Conceptos = db.Database.SqlQuery<Conceptos>(@"select  s.descripcion 'Sector', f.numero_factura 'NumeroFactura', p.razon_social 'Proveedor', concat(tg.descripcion, ' ', f.detalle) 'concepto', f.importe from factura f                                                     left join provedor p                            on p.razon_social = f.razon_provedor   join sector s on id_sector = s.idsector      join tipo_gasto tg  on f.id_tipogasto = tg.idtipo_gasto                    where dir_edificio = '" + edificio.direccion + "' and month(f.fecha) = " + periodo.Month + " and year(f.fecha) = " + periodo.Year).ToList();
                    expensasEdificio.TotalUnidad = new List<TotalUnidad>();
                    expensasEdificio.EstadoDeCaja = new EstadoCaja();
                    expensasEdificio.EstadoDeCaja.MovimientosDeCaja = db.Database.SqlQuery<MovimientosCaja>("select * from movimiento_caja mc where dir_edificio = '" + edificio.direccion + @"' and month(periodo)=" + periodo.Month + " and year(periodo)=" + periodo.Year).ToList();

                    List<provedor> proveedores = db.edificio.Where(x => x.direccion == edificio.direccion).SingleOrDefault().provedor.ToList();
                    expensasEdificio.Proveedores = new List<Proveedor>();
                    foreach (var pr in proveedores)
                    {
                        Proveedor prov = new Proveedor();
                        prov.cargo = pr.cargo;
                        prov.nombre = pr.razon_social;
                        prov.telefono = pr.telefono1;
                        expensasEdificio.Proveedores.Add(prov);
                    }

                    DateTime fechaActual = DateTime.Parse(1 + "/" + periodo.Month + "/" + periodo.Year);
                    DateTime fechaAnterior = fechaActual.AddMonths(-1);
                    expensasEdificio.EstadoDeCaja.FechaActual = fechaActual.ToShortDateString();
                    expensasEdificio.EstadoDeCaja.FechaAnterior = fechaAnterior.ToShortDateString();
                    expensasEdificio.Deudores = CatalogoDeudores.getDeudoresFromEdificio(edificio, periodo);
                    int tasaRecargoVto = CatalogoTasas.getTasaVto();
                    expensasEdificio.Tasa2Vto = tasaRecargoVto;

                    Double saldoCajaMesAnterior = CatalogoCajaEdificio.getSaldoCajaMes(edificio, fechaAnterior.AddMonths(1).AddDays(-1));
                    Double saldoCajaMesActual = CatalogoCajaEdificio.getSaldoCajaMes(edificio, fechaActual.AddMonths(1).AddDays(-1));

                    expensasEdificio.EstadoDeCaja.ImporteAnterior = saldoCajaMesAnterior;
                    expensasEdificio.EstadoDeCaja.ImporteActual = saldoCajaMesActual;

                    DateTime asd = DateTime.Parse("1 /" + periodo.Month + "/" + periodo.Year);

                    List<expensas> expensasExistentes = allExpensasExistentes.Where(x => x.dir_edificio == edificio.direccion).ToList();

                    foreach (unidad u in unidades)
                    {
                        unidad tempUni = new unidad();
                        if (u.titular == null)
                        {
                            tempUni.titular = new titular();
                            tempUni.titular.nombre = "<<ninguno>>";
                        }
                        else
                            tempUni.titular = u.titular;

                        TotalUnidad totalUnidad = new TotalUnidad();
                        totalUnidad.Unidad = tempUni;
                        string idUnidad = u.id_unidad;
                        tempUni.id_unidad = idUnidad;

                        totalUnidad.Exclusivos = db.recargo_exclusivo.Where(x => x.dir_edificio == u.dir_edificio && x.id_unidad == u.id_unidad && x.fecha.Month == periodo.Month && x.fecha.Year == periodo.Year && x.pagado != 1).Sum(x => (double?)x.importe) ?? 0; ;
                        totalUnidad.Legales = db.recargo_legal.Where(x => x.dir_edificio == u.dir_edificio && x.id_unidad == u.id_unidad && x.fecha.Month == periodo.Month && x.fecha.Year == periodo.Year && x.pagado != 1).Sum(x => (double?)x.importe) ?? 0; ;
                        totalUnidad.Varios = db.recargo_vario.Where(x => x.dir_edificio == u.dir_edificio && x.id_unidad == u.id_unidad && x.fecha.Month == periodo.Month && x.fecha.Year == periodo.Year && x.pagado != 1).Sum(x => (double?)x.importe) ?? 0; ;

                        totalUnidad.TotalSector = db.Database.SqlQuery<Totales>(@"DROP TEMPORARY TABLE IF EXISTS asd;                        CREATE TEMPORARY TABLE IF NOT EXISTS asd AS (                        select id_sector,porcentaje from unidades_sectores us                        where us.dir_edificio = '" + edificio.direccion + @"' and us.id_unidad = '" + u.id_unidad + @"');                        SELECT descripcion 'sector', sum(importe)'importe', porcentaje 'distribucion', (sum(importe) / 100 * porcentaje) 'corresponde' FROM factura f                        join sector s                        on s.idsector = f.id_sector                        join asd r1                        on r1.id_sector = s.idsector                        where month(f.fecha) = " + periodo.Month + @" and year(f.fecha) = " + periodo.Year + @" and f.dir_edificio = '" + edificio.direccion + @"'                        group by  descripcion                        order by r1.id_sector                        ").ToList();

                        double deuda = 0;
                        double recargo = 0;

                        foreach (CatalogoDeudores.Deudor d in expensasEdificio.Deudores)
                        {
                            if (u.id_unidad == d.Unidad)
                            {
                                deuda += d.Importe;
                                recargo += d.Recargo;
                            }
                        }
                        totalUnidad.Deuda = deuda;
                        totalUnidad.Recargo = recargo;
                        totalUnidad.NroFactura = (correlativo++).ToString();
                        expensasEdificio.TotalUnidad.Add(totalUnidad);

                        double importe1 = 0;
                        double importe2 = 0;
                        double mesEnEmision = 0;
                        foreach (Totales total in totalUnidad.TotalSector) //CatalogoExpensas.getTotales(edificio, unidad, periodo))
                        {
                            mesEnEmision += total.corresponde;
                        }

                        importe1 = mesEnEmision + totalUnidad.Deuda + totalUnidad.Recargo;
                        Double importeSinExclusivos = importe1;

                        importe1 += totalUnidad.Exclusivos;
                        importe1 += totalUnidad.Varios;
                        importe1 += totalUnidad.Legales;

                        importe2 = importe1 * (1 + (Double)tasaRecargoVto / 100);

                        expensas expensa = new expensas();
                        expensa.dir_edificio = edificio.direccion;
                        expensa.fecha = DateTime.Parse("1 /" + periodo.Month + "/" + periodo.Year);
                        expensa.id_unidad = u.id_unidad;
                        expensa.importeVto1 = double.Parse(importe1.ToString("n2"));
                        expensa.importeVto2 = double.Parse(importe2.ToString("n2"));
                        expensa.nro_factura = totalUnidad.NroFactura;
                        expensa.fechaVto1 = vto1;
                        expensa.fechaVto2 = vto2;
                        expensa.importeSinExclusivos = importeSinExclusivos;
                        expensa.nro_referencia = completarCadena(Math.Abs((expensa.dir_edificio.ToLower() + u.id_unidad.Replace("-", "")).GetHashCode()).ToString(), 12, "0");
                        expensa.pagado = 0;
                        expensa.mesEnEmision = mesEnEmision;
                        expensa.importeVto1 = importe1;
                        expensa.importeVto2 = importe2;

                        bool update = false;

                        foreach (expensas exp in expensasExistentes)
                        {

                            if (exp.id_unidad == expensa.id_unidad)
                            {
                                {
                                    exp.importeVto1 = expensa.importeVto1;
                                    exp.importeVto2 = expensa.importeVto2;
                                    exp.nro_factura = expensa.nro_factura;
                                    exp.fechaVto1 = vto1;
                                    exp.fechaVto2 = vto2;
                                    expensa.mesEnEmision = mesEnEmision;
                                    exp.importeSinExclusivos = importeSinExclusivos;
                                    exp.nro_referencia = completarCadena(Math.Abs((expensa.dir_edificio.ToLower() + u.id_unidad.Replace("-", "")).GetHashCode()).ToString(), 12, "0");
                                    db.Entry(exp).State = System.Data.EntityState.Modified;
                                    update = true;
                                    break;
                                }
                            }
                        }

                        if (update == false)
                            db.expensas.Add(expensa);

                        //db.Database.ExecuteSqlCommand("delete from expensas where dir_edificio={0} and fecha = {1} and id_unidad ={2}", expensa.dir_edificio, expensa.fecha, expensa.id_unidad);

                    }
                    db.SaveChanges();
                }

                return expensasEdificio;
            }
            catch (Exception ex)
            {
                Logger.Log.write(ex.InnerException == null ? ex.Message : ex.InnerException.Message);
                throw ex;
            }
        }
        private static void addDetallesDeResumenDeCuenta(Document doc, edificio e, unidad u, List<CatalogoDeudores.DetalleDeuda> detalles)
        {
            PdfPTable t = new PdfPTable(7);
            t.WidthPercentage = 85;
            float[] widths = new float[] { 25f, 25f, 25f, 25f, 25f, 25f, 25f };
            t.SetWidths(widths);

            Paragraph p;

            p = new Paragraph(10, " ", calibri9B);
            doc.Add(p);

            int leading = 9;

            PdfPCell c = new PdfPCell();

            c = new PdfPCell();
            c.Border = 0;
            c.PaddingBottom = 5;
            c.BorderWidthBottom = 0.1f;
            p = new Paragraph(leading, "Periodo", calibri8B);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.PaddingBottom = 5;
            c.BorderWidthBottom = 0.1f;
            p = new Paragraph(leading, "Concepto", calibri8B);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.PaddingBottom = 5;
            c.BorderWidthBottom = 0.1f;
            p = new Paragraph(leading, "Liquidacion", calibri8B);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.PaddingBottom = 5;
            c.BorderWidthBottom = 0.1f;
            p = new Paragraph(leading, "Importe", calibri8B);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.PaddingBottom = 5;
            c.BorderWidthBottom = 0.1f;
            p = new Paragraph(leading, "Recargo", calibri8B);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.PaddingBottom = 5;
            c.BorderWidthBottom = 0.1f;
            p = new Paragraph(leading, "Parcial", calibri8B);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.PaddingBottom = 5;
            c.BorderWidthBottom = 0.1f;
            p = new Paragraph(leading, "Acumulado", calibri8B);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            Double acumulado = 0;
            foreach (var d in detalles)
            {

                c = new PdfPCell();
                c.Border = 0;
                p = new Paragraph(leading, d.Periodo.Month + "/" + d.Periodo.Year, calibri8N);
                p.Alignment = Element.ALIGN_CENTER;
                c.AddElement(p);
                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;
                p = new Paragraph(leading, d.Tipo.Replace("Ordinaria", "Expensas"), calibri8N);
                p.Alignment = Element.ALIGN_CENTER;
                c.AddElement(p);
                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;
                p = new Paragraph(leading, d.NroFactura == "000000000000000" ? "-" : d.NroFactura, calibri8N);
                p.Alignment = Element.ALIGN_CENTER;
                c.AddElement(p);
                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;
                p = new Paragraph(leading, d.Importe.ToString("n2"), calibri8N);
                p.Alignment = Element.ALIGN_RIGHT;
                c.AddElement(p);
                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;
                p = new Paragraph(leading, d.Recargo.ToString("n2"), calibri8N);
                p.Alignment = Element.ALIGN_RIGHT;
                c.AddElement(p);
                t.AddCell(c);

                c = new PdfPCell();
                c.Border = 0;
                p = new Paragraph(leading, (d.Importe + d.Recargo).ToString("n2"), calibri8N);
                p.Alignment = Element.ALIGN_RIGHT;
                c.AddElement(p);
                t.AddCell(c);

                acumulado += d.Importe + d.Recargo;

                c = new PdfPCell();
                c.Border = 0;
                p = new Paragraph(leading, acumulado.ToString("n2"), calibri8N);
                p.Alignment = Element.ALIGN_RIGHT;
                c.AddElement(p);
                t.AddCell(c);

            }

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(1, " ", calibri8B);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            t.AddCell(c);
            t.AddCell(c);
            t.AddCell(c);
            t.AddCell(c);
            t.AddCell(c);
            t.AddCell(c);
            t.AddCell(c);
            leading = 7;

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, "TOTALES", calibri8B);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, " ", calibri8B);
            p.Alignment = Element.ALIGN_LEFT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, " ", calibri8B);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, detalles.Sum(x => x.Importe).ToString("n2"), calibri8B);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, detalles.Sum(x => x.Recargo).ToString("n2"), calibri8B);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, " ", calibri8B);
            p.Alignment = Element.ALIGN_CENTER;
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            p = new Paragraph(leading, acumulado.ToString("n2"), calibri8B);
            p.Alignment = Element.ALIGN_RIGHT;
            c.AddElement(p);
            t.AddCell(c);

            doc.Add(t);
        }