示例#1
0
        private void GuardarCobranza()
        {
            facturas                  oFacturas                  = new facturas();
            socios                    oSocio                     = new socios();
            SocioImplement            oSocioImplement            = new SocioImplement();
            FacturasImplement         oFacturasImplement         = new FacturasImplement();
            PeriodosImplement         oPeriodosImplement         = new PeriodosImplement();
            FacturasDetallesImplement oFacturasDetallesImplement = new FacturasDetallesImplement();

            oFacturas = oFacturasImplement.Get(int.Parse(txtNroFactura.Text));
            oFacturas.id_estadoPago = 3;
            oFacturasImplement.Update(oFacturas);

            cobranzas oCobranza = new cobranzas();

            oCobranza.id_caja                = int.Parse(cmbCaja.SelectedValue.ToString());
            oCobranza.id_factura             = _idFactura;
            oCobranza.id_recibo              = 0;
            oCobranza.id_socio               = _idSocio;
            oCobranza.importe                = decimal.Parse(txtTotalCobrado.Text);
            oCobranza.descuento_convenio     = 0;
            oCobranza.iva_descuento_convenio = 0;
            oCobranza.fecha_cobro            = dtpFechaCaja.Value;
            oCobranza.id_terminal            = 0;//VER
            oCobranza.fecha_registro         = DateTime.Now;
            CobranzasImplement oCobranzasImplement = new CobranzasImplement();

            oCobranzasImplement.Save(oCobranza);
        }
示例#2
0
        public int ObtenerLecturaAnterior(int idFactura)
        {
            int _LectAnt = 0;

            using (cooperativaEntities bd = new cooperativaEntities())
            {
                Commons oCommons = new Commons();

                FacturasImplement oFacturasImplement = new FacturasImplement();
                facturas          oFactura           = new facturas();

                oFactura = oFacturasImplement.Get(idFactura);


                var facturaAnterior = (from f in bd.facturas
                                       join m in bd.socios_mediciones on f.id_medicion equals m.id_medicion
                                       where f.id_factura < idFactura && f.id_socio == oFactura.id_socio
                                       orderby f.id_factura descending
                                       select new
                {
                    f.id_factura,
                    m.lectura
                }).Take(1).ToList();

                if (facturaAnterior.Count > 0)
                {
                    _LectAnt = (int)facturaAnterior[0].lectura;
                }
            }
            return(_LectAnt);
        }
        private void CargarDatos()
        {
            FacturasImplement oFacturasImplement = new FacturasImplement();
            CalculosConvenio  oCalculosConvenio  = new CalculosConvenio();

            foreach (int i in _ListaFacturas)
            {
                _totalCobrado = _totalCobrado + (decimal)oFacturasImplement.Get(i).cobrado;
            }
            txtFacNoCanceladas.Text = (_FacturasNoCanceladas - _totalCobrado).ToString(); //Preguntar
            _ConveniosNoCancelados  = oCalculosConvenio.ObtenerImporteConvenioAdeudado(_idSocio);

            txtConvNoCancelados.Text = _ConveniosNoCancelados.ToString();
            Decimal _conveniosNoVolcados = 0;

            txtConvNoVolcados.Text = _conveniosNoVolcados.ToString();
            Decimal _costoFinanciero = 0;

            txtCostoFinanciero.Text = _costoFinanciero.ToString();
            Decimal _gastosAdministrativos = 0;

            txtGastosAdministrativos.Text = _gastosAdministrativos.ToString();
            Decimal _reconexion = 0;

            txtReconexion.Text = _reconexion.ToString();

            txtCanonMunicipal.Text = _CanonMunicipal.ToString();
            _ImporteDeuda          = (_FacturasNoCanceladas + _ConveniosNoCancelados + _conveniosNoVolcados + _gastosAdministrativos + _reconexion
                                      - _totalCobrado - _CanonMunicipal);
            txtImporteTotal.Text = _ImporteDeuda.ToString();
            nudCuotas.Value      = 1;
            _CantidadCuotas      = (int)nudCuotas.Value;
            _ImporteCuota        = _ImporteDeuda / nudCuotas.Value;
            txtValorCuotas.Text  = Math.Round(_ImporteCuota, 2).ToString();
        }
        public void Delete(int idConvenio)
        {
            using (cooperativaEntities bd = new cooperativaEntities())
            {
                DataTable         dtFacturas         = new DataTable();
                FacturasImplement oFacturasImplement = new FacturasImplement();
                var listar = (from f in bd.facturas
                              where f.id_convenio == idConvenio
                              select f).ToList();
                Commons oCommons = new Commons();
                dtFacturas = oCommons.convertToTable(listar);

                foreach (DataRow dr in dtFacturas.Rows)
                {
                    int      idFactura = int.Parse(dr["id_factura"].ToString());
                    facturas oFacturas = new facturas();
                    oFacturas             = oFacturasImplement.Get(idFactura);
                    oFacturas.id_convenio = 0;
                    oFacturasImplement.Update(oFacturas);
                }

                var regis = (from p in bd.convenios
                             where p.id_convenio == idConvenio
                             select p).Single();

                bd.DeleteObject(regis);
                bd.SaveChanges();
            }
        }
        private void AbrirFacturasSeleccion()
        {
            frmFacturasSeleccion f = new frmFacturasSeleccion(_idSocio);
            FacturasImplement    oFacturasImplement = new FacturasImplement();

            f.Text = "Facturas Seleccion";
            CalculosConvenio oCalculosConvenio = new CalculosConvenio();

            if (f.ShowDialog() == DialogResult.OK)
            {
                _ListaFacturas = f.rowSeleccion; //lee la propiedad
                _ImporteFacturasSeleccionadasTotal = f.TotalFacturasImporte;
                _CanonMunicipal        = f.CanonMunicipal;
                _ConveniosNoCancelados = oCalculosConvenio.ObtenerImporteConvenioAdeudado(_idSocio);
                _ImporteSinInteres     = f.ImporteSinInteres;
                _ImporteRecargos       = f.ImporteRecargos;
                _FacturasNoCanceladas  = _ImporteFacturasSeleccionadasTotal;

                lbFacturas.Items.Clear();
                foreach (int i in _ListaFacturas)
                {
                    lbFacturas.Items.Add(i.ToString());
                    _totalCobrado = _totalCobrado + (decimal)oFacturasImplement.Get(i).cobrado;
                }

                CargarDatos();
            }
            //f.Show();
        }
        private void Inicializar()
        {
            FacturasImplement oFacturasImplement = new FacturasImplement();
            facturas          oFacturas          = new facturas();

            oFacturas               = oFacturasImplement.Get(_idFactura);
            txtFactura.Text         = oFacturas.id_factura.ToString();
            txtPeriodo.Text         = oFacturas.id_periodo.ToString().Substring(4, 2) + "/" + oFacturas.id_periodo.ToString().Substring(0, 4);
            txtFehaFacturacion.Text = "";

            txtFechaVencimiento.Text = "";
            EstadosPagoImplement oEstadosPagoImplement = new EstadosPagoImplement();
            cod_estados_pago     oCod_Estados_Pago     = new cod_estados_pago();
            int idEstado = (int)oFacturas.id_estadoPago;

            oCod_Estados_Pago = oEstadosPagoImplement.Get(idEstado);
            txtEstado.Text    = oCod_Estados_Pago.estado_pago;
            txtFechaPago.Text = oFacturas.fechaPago.ToString();
            socios_mediciones      oSociosMediciones       = new socios_mediciones();
            SocioMedicionImplement oSocioMedicionImplement = new SocioMedicionImplement();

            oSociosMediciones    = oSocioMedicionImplement.Get((int)oFacturas.id_medicion);
            txtM3Consumidos.Text = oSociosMediciones.consumo.ToString();

            cargarGrillaConceptos();

            txtImporteTotal.Text = oFacturas.importeTotal.ToString();
            txtCobrado.Text      = oFacturas.cobrado.ToString();
        }
示例#7
0
        private void CargarFacturas()
        {
            this.pDetalles.Visible    = true;
            this.gbRefacturar.Visible = true;
            facturas          oFactura          = new facturas();
            FacturasImplement oFacturaImplement = new FacturasImplement();
            socios            oSocio            = new socios();
            SocioImplement    oSocioImplement   = new SocioImplement();

            oSocio = oSocioImplement.Get(_idSocio);
            tarifas           oTarifa            = new tarifas();
            TarifaImplement   oTarifaImplement   = new TarifaImplement();
            cod_impuestos     oCodImpuesto       = new cod_impuestos();
            ImpuestoImplement oImpuestoImplement = new ImpuestoImplement();

            oCodImpuesto = oImpuestoImplement.Get(oSocio.iva.Value);
            oFactura     = oFacturaImplement.Get(_idFactura);
            oTarifa      = oTarifaImplement.Get(oSocio.tarifa.Value);
            this.txtNroFacturaAct.Text = oFactura.id_factura.ToString();
            _periodo = oFactura.id_factura.ToString();
            this.txtFechaAct.Text = oFactura.id_periodo.ToString();
            CargarFactura(_idFactura);
            this.txtTotalAct.Text = sumarFilas(ref this.dgDetalleAct, "colAImporte").ToString();
            CargarFacturaFutura(_periodo, _idSocio);
            this.txtTotalFut.Text = sumarFilas(ref this.dgDetalleFut, "colFImporte").ToString();
        }
示例#8
0
 private void dtpFechaCaja_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         FacturasImplement oFacturasImplement = new FacturasImplement();
         if (oFacturasImplement.ExisteFactura(_idFactura))
         {
             if (dtpFechaCobro.Visible && dtpFechaCobro.Enabled)
             {
                 dtpFechaCobro.Focus();
             }
             else
             {
                 DialogResult result = MessageBox.Show("Se completará el proceso de cobranza", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                 if (result.Equals(DialogResult.OK))
                 {
                     GuardarCobranza();
                     LimpiarCampos();
                 }
                 else
                 {
                     //nada
                 }
             }
         }
     }
 }
示例#9
0
        private void InicializarTablaExt()
        {
            FacturasImplement oFacturasImplement = new FacturasImplement();

            _facturasAct      = oFacturasImplement.GetByIdSocioDT(_idSocio, 0, 1);
            _facturasNoActImp = oFacturasImplement.GetByIdSocioDT(_idSocio, 1, 0);
            _facturasActImp   = oFacturasImplement.GetByIdSocioDT(_idSocio, 1, 1);
        }
示例#10
0
        private void CargarTotales()
        {
            FacturasImplement oFacturasImplement = new FacturasImplement();

            txtFactListadas.Text = this.dgvFacturas.Rows.Count.ToString();//oFacturasImplement.GetCountFacturasBySocio(_idSocio, _mostrarImpagas).ToString();
            //txtTotal.Text = Math.Round((decimal)oFacturasImplement.GetTotalFacturasBySocio(_idSocio, _mostrarImpagas),2).ToString();
            //txtRecargo.Text = Math.Round((decimal)oFacturasImplement.GetTotalRecargoBySocio(_idSocio, _mostrarImpagas), 2).ToString();
        }
示例#11
0
        public DateTime?ObtenerFechaVenc(int idFactura)
        {
            periodos          oPeriodo           = new periodos();
            PeriodosImplement oPeriososImplement = new PeriodosImplement();


            FacturasImplement oFacturasImplement = new FacturasImplement();

            oPeriodo = oPeriososImplement.Get(oFacturasImplement.Get(idFactura).id_periodo.ToString());
            return(oPeriodo.fecha_primer_venc);
        }
示例#12
0
        private void ObtenerFacturasSocio()
        {
            socios         oSocio          = new socios();
            SocioImplement oSocioImplement = new SocioImplement();

            oSocio = oSocioImplement.Get(_idSocio);
            this.mtxtNumero.Text = oSocio.codigo_socio + oSocio.subcodigo_socio;
            this.txtNombre.Text  = oSocio.nombre;
            FacturasImplement oFacturaImplement = new FacturasImplement();

            this.dgFacturar.DataSource = oFacturaImplement.GetByIdSocio(_idSocio);
        }
示例#13
0
        private void CargarSeleccionFactura()
        {
            facturas          oFacturas          = new facturas();
            FacturasImplement oFacturasImplement = new FacturasImplement();
            DataGridViewRow   row = this.dgvFacturas.CurrentRow;

            if (row != null)
            {
                _idFactura = Convert.ToInt32(row.Cells[1].Value);
                this.dgvConceptos.DataSource = oFacturasImplement.GetConceptosByIdFactDT(_idFactura);
            }
        }
示例#14
0
        public decimal CalcularIVA(int idFactura)
        {
            using (cooperativaEntities bd = new cooperativaEntities())
            {
                Commons oCommons       = new Commons();
                var     detallesByFact = (from d in bd.facturas_detalles
                                          join c in bd.cod_conceptos on d.id_concepto equals c.id_concepto
                                          where d.id_factura == idFactura
                                          select new
                {
                    d.id_factura,
                    d.id_detalle,
                    d.id_concepto,
                    d.idOrden,
                    d.idTipo,
                    d.importe,
                    c.id_formula,
                    c.orden_concepto,
                    c.tipo_signo,
                    c.variable,
                    c.activo,
                    c.aplicar_descuento,
                    c.aplicar_iva,
                    c.aplicar_recargo,
                    c.concepto
                }).ToList();
                DataTable detallesCalc = oCommons.convertToTable(detallesByFact);
                decimal   IVA          = 0;
                foreach (DataRow rowDet in detallesCalc.Rows)
                {
                    if (bool.Parse(rowDet["aplicar_iva"].ToString()))
                    {
                        IVA = IVA + decimal.Parse(rowDet["importe"].ToString());
                    }
                }
                int idSocio = 0;
                FacturasImplement oFacturasImplement = new FacturasImplement();
                idSocio = (int)oFacturasImplement.Get(idFactura).id_socio;
                socios         oSocio          = new socios();
                SocioImplement oSocioImplement = new SocioImplement();
                oSocio = oSocioImplement.Get(idSocio);
                IVA    = IVA * (decimal.Parse(oSocio.iva.ToString()) / 100);

                return(IVA);
            }
        }
示例#15
0
        private void btnCambiar_Click(object sender, EventArgs e)
        {
            FacturasImplement  oFacturasImplement  = new FacturasImplement();
            cobranzas          oCobranza           = new cobranzas();
            CobranzasImplement oCobranzasImplement = new CobranzasImplement();

            if (oFacturasImplement.ExisteCobranza(_idFactura))
            {
                oCobranza = oCobranzasImplement.GetByIdFactura(_idFactura);
                if (oCobranza != null)
                {
                    oCobranza.id_caja = int.Parse(cmbCajaNueva.SelectedValue.ToString());
                    oCobranzasImplement.Update(oCobranza);
                    this.Close();
                }
            }
        }
示例#16
0
        private void ImprimirTarifas()
        {
            FacturasImplement  oFacturaImplement   = new FacturasImplement();
            SysConfigImplement oSysConfigImplement = new SysConfigImplement();

            view.Reportes.frmReportes frmRpt           = new view.Reportes.frmReportes();
            Facturacion.Reportes.rptResumenXTarifa rpt = new Reportes.rptResumenXTarifa();
            //Cargo el Data Set
            DataSet ds = new DataSet("dsResumen");

            ds.Tables.Add(oSysConfigImplement.GetEncabezadoDT("Encabezado"));
            ds.Tables[0].TableName = "dtEncabezado";
            ds.Tables.Add(oFacturaImplement.GetResumenFacturacionPorTarifas(this.cmbAnio.SelectedValue.ToString() + this.cmbMes.SelectedValue.ToString(), 108000));
            ds.Tables[1].TableName = "dtXTarifas";
            rpt.SetDataSource(ds);
            frmRpt.crvGenerico.ReportSource = rpt;
            frmRpt.Show();
        }
示例#17
0
        private void ImprimirFacturacionZB()
        {
            FacturasImplement  oFacturaImplement   = new FacturasImplement();
            SysConfigImplement oSysConfigImplement = new SysConfigImplement();

            view.Reportes.frmReportes frmRpt = new view.Reportes.frmReportes();
            Facturacion.Reportes.rptResumenFacturacionXzonaXBarrio rpt = new Reportes.rptResumenFacturacionXzonaXBarrio();
            //Cargo el Data Set
            DataSet ds = new DataSet("dsResumen");

            ds.Tables.Add(oSysConfigImplement.GetEncabezadoDT("Encabezado"));
            ds.Tables[0].TableName = "dtEncabezado";
            ds.Tables.Add(oFacturaImplement.GetResumenFacturacionPorBarriosPorZonas(this.cmbAnio.SelectedValue.ToString() + this.cmbMes.SelectedValue.ToString(), int.Parse(this.cmbBarrios.SelectedValue.ToString()), int.Parse(this.cmbZonas.SelectedValue.ToString())));
            ds.Tables[1].TableName = "dtResumenFacturacionXBXC";
            rpt.SetDataSource(ds);
            frmRpt.crvGenerico.ReportSource = rpt;
            frmRpt.Show();
        }
示例#18
0
        public int ObtenerDiasDeVencimiento(int idFactura)
        {
            periodos          oPeriodo           = new periodos();
            PeriodosImplement oPeriososImplement = new PeriodosImplement();
            FacturasImplement oFacturasImplement = new FacturasImplement();

            oPeriodo = oPeriososImplement.Get(oFacturasImplement.Get(idFactura).id_periodo.ToString());
            TimeSpan diferencia;

            if (oPeriodo.fecha_primer_venc < DateTime.Today)
            {
                diferencia = DateTime.Today - DateTime.Parse(oPeriodo.fecha_primer_venc.ToString());
            }
            else
            {
                diferencia = DateTime.Today - DateTime.Today;
            }

            return(diferencia.Days);
        }
示例#19
0
        private void GuardarNuevoConvenio()
        {
            convenios         oConvenio          = new convenios();
            ConvenioImplement oConvenioImplement = new ConvenioImplement();

            //Cancelo el adeudado
            oConvenioImplement.CancelarAdeudado(_idSocio);

            oConvenio.id_socio                     = _idSocio;
            oConvenio.fecha_convenio               = dtpFechaConvenio.Value;
            oConvenio.importe_total                = _ImporteDeuda;
            oConvenio.valor_cuota                  = _ImporteCuota;
            oConvenio.cuotas                       = _CantidadCuotas;
            oConvenio.facturadas                   = _CantidadCuotasCanceladas;
            oConvenio.pendientes                   = _CantidadCuotas - _CantidadCuotasCanceladas;
            oConvenio.finalizado                   = (_CantidadCuotas == _CantidadCuotasCanceladas);
            oConvenio.iva_facturas                 = 0; //VER
            oConvenio.cuota_iva                    = 0; //VER
            oConvenio.convenio_judicial            = (chkConvenioAbogado.Checked);
            oConvenio.porcentaje_descuento_recargo = 0; //VER
            oConvenio.importe_descuento_recargo    = 0; //VER
            oConvenio.tipo_descuento_recargo       = -1;
            oConvenio.id_usuario                   = null;
            oConvenio.id_terminal                  = null;
            oConvenio.fecha_registro               = DateTime.Today;
            oConvenio.moratoria                    = _convenioMora;
            int idConvenio = oConvenioImplement.Save(oConvenio);

            FacturasImplement oFacturasImplement = new FacturasImplement();
            facturas          oFacturas          = new facturas();

            foreach (int i in _ListaFacturas)
            {
                oFacturas             = oFacturasImplement.Get(i);
                oFacturas.id_convenio = idConvenio;
                oFacturasImplement.Update(oFacturas);
            }

            DialogResult = DialogResult.OK;
            this.Close();
        }
示例#20
0
        private void Refacturar()
        {
            facturas          oFactura      = new facturas();
            FacturasImplement oFacImplement = new FacturasImplement();

            oFactura = oFacImplement.Get(_idFactura);
            facturas          oFacturaNew      = new facturas();
            FacturasImplement oFacImplementNew = new FacturasImplement();

            // oFacturaNew.
            foreach (DataRow row in _TablaGrilla.Rows)
            {
                //registro["id_detalle"] = oFacturaDetalle.id_detalle;
                //registro["id_concepto"] = oFacturaDetalle.id_concepto;
                //registro["id_factura"] = oFacturaDetalle.id_factura;
                //registro["id_orden"] = oFacturaDetalle.idOrden;
                //registro["id_Tipo"] = oFacturaDetalle.idTipo;
                //registro["concepto"] = oConcepto.concepto;
                //registro["importe"] = Math.Round(oFacturaDetalle.importe, 2);
            }
        }
示例#21
0
        private void CargarTotales()
        {
            int mostrarImpagas = 1;
            FacturasImplement oFacturasImplement = new FacturasImplement();

            decimal _recargo  = 0;
            decimal _srecargo = 0;

            CalculosFactura oCalculosFactura = new CalculosFactura();
            facturas        oFacturas        = new facturas();

            foreach (DataGridViewRow dr in dgvFacturas.Rows)
            {
                if (dr.Selected)
                {
                    int     id_factura  = (int)dr.Cells[1].Value;
                    decimal recargoTemp = oCalculosFactura.CalcularRecargo(id_factura);
                    decimal ivaRecTemp  = oCalculosFactura.CalcularIVARecargoNuevo(recargoTemp, _idSocio);
                    _recargo       = _recargo + recargoTemp + ivaRecTemp;
                    _srecargo      = _srecargo + (decimal)oFacturasImplement.Get(id_factura).importeTotal;
                    CanonMunicipal = CanonMunicipal + oCalculosFactura.ObtenerCanonMunicipal(id_factura);
                }
            }

            ImporteRecargos   = Math.Round(_recargo, 2);
            txtRecargo.Text   = ImporteRecargos.ToString();
            ImporteSinInteres = Math.Round(_srecargo, 2);
            txtSRecargo.Text  = ImporteSinInteres.ToString();

            TotalFacturasImporte = (decimal.Parse(txtSRecargo.Text) + decimal.Parse(txtRecargo.Text));
            txtTotalImporte.Text = TotalFacturasImporte.ToString();

            txtTotalFacturas.Text = oFacturasImplement.GetCountFacturasBySocio(_idSocio, mostrarImpagas).ToString();

            ConceptoImplement oConceptoImplement = new ConceptoImplement();

            txtRecargoDiario.Text = oConceptoImplement.Get(18).variable.ToString();

            txtSelec.Text = ObtenerCantSeleccionadas().ToString();
        }
示例#22
0
        private void CargarFacturaFutura(string periodo, int idSocio)
        {
            decimal           NetoConIVA        = 0;
            decimal           NetoSinIVA        = 0;
            int               idMedidor         = 0;
            facturas          oFactura          = new facturas();
            FacturasImplement oFacturaImplement = new FacturasImplement();

            oFactura           = oFacturaImplement.Get(_idFactura);
            _oFactura          = new facturas();
            _oFactura.id_socio = _idSocio;
            //oFactura.id_medicion Ver como soluciono el idMedicion
            _oFactura.id_estadoPago = 1; //Impaga
            _oFactura.id_tarifa     = 0; //aun no se carga
            _oFactura.id_convenio   = 0; //Aun no se carga
            _oFactura.fechaPago     = null;
            _oFactura.cobrado       = 0;
            _oFactura.neto1         = 0;
            _oFactura.neto2         = 0;
            _oFactura.importeNeto   = 0;
            _oFactura.importeTotal  = 0;
            _oFactura.id_medicion   = 0;

            // obtengo solo los conceptos activos
            IList listaConceptos = new ConceptoImplement().GetActivosAll();
            SocioConexionImplement oSocioConexionImpl = new SocioConexionImplement();
            DataTable DTUsuariosAFacturar             = oSocioConexionImpl.GetSociosAFacturar(periodo, idSocio);

            if (DTUsuariosAFacturar.Rows[0]["medidor"].ToString() != "")
            {
                socios_mediciones      oSocioMedicionActual    = new socios_mediciones();
                SocioMedicionImplement oSocioMedicionImplement = new SocioMedicionImplement();
                oSocioMedicionActual = oSocioMedicionImplement.ultimaMedicion(int.Parse(DTUsuariosAFacturar.Rows[0]["id_socio"].ToString()));
                socios_mediciones oSocioMedicionNew = new socios_mediciones();
                oSocioMedicionNew.fecha_lectura = null;
                oSocioMedicionNew.id_socio      = _idSocio;
                decimal consumo = 0;
                if (oSocioMedicionActual != null)
                {
                    consumo = (decimal)decimal.Parse((oSocioMedicionActual.consumo * 0.75).ToString());
                    oSocioMedicionNew.consumo = (int)Math.Truncate(consumo);
                    oSocioMedicionNew.lectura = oSocioMedicionActual.lectura + oSocioMedicionNew.consumo;
                }
                else
                {
                    oSocioMedicionNew.consumo = 0;
                    oSocioMedicionNew.lectura = 0;
                }
                idMedidor = oSocioMedicionImplement.Save(oSocioMedicionNew);
            }

            _oFactura.id_medicion = idMedidor;//Cargo 0 si no tiene medidor
            // recorre toda la base de conceptos

            foreach (cod_conceptos oConcepto in listaConceptos)
            {
                bool CorrespondeFacturar = false;

                if (_oFactura.id_medicion.Value != 0)
                {
                    //SocioMedicionImplement oSosioMedicionImpl = new SocioMedicionImplement();
                    //socios_mediciones oSocioMedicion = new socios_mediciones();
                    //oSocioMedicion = oSosioMedicionImpl.Get(oFactura.id_medicion.Value);
                }
                acciones oAccion = new acciones();
                conceptos_particulares         oConceptoParticular          = new conceptos_particulares();
                conceptosParticularesImplement oConceptoParticularImplement = new conceptosParticularesImplement();
                AccionImplement oAccionesImplement = new AccionImplement();

                if (oConcepto.aplicacion == 2)
                { // si concepto Particular
                    oConceptoParticular = oConceptoParticularImplement.GetByFilter(idSocio, oConcepto.id_concepto, _oFactura.id_periodo);
                    if (oConceptoParticular != null)
                    {
                        CorrespondeFacturar = true;
                    }
                    else
                    {
                        // No encontrado entonces no corresponde facturar
                        CorrespondeFacturar = false;
                    }
                }
                else
                {
                    //Concepto Activo y no particular entonces corresponde facturar
                    CorrespondeFacturar = true;
                }

                if (CorrespondeFacturar)
                {
                    facturas_detalles         oDetalle = new facturas_detalles();
                    FacturasDetallesImplement oFacturasDetallesImplement = new FacturasDetallesImplement();
                    //ConvenioImplement oConvenioImplement = new ConvenioImplement();
                    CalculosFacturacionFormulas oCalculosFacturacionFormulas = new CalculosFacturacionFormulas();
                    oDetalle = oCalculosFacturacionFormulas.getDetalle(idSocio, decimal.Parse(DTUsuariosAFacturar.Rows[0]["cargo_fijo"].ToString()), decimal.Parse(DTUsuariosAFacturar.Rows[0]["abono"].ToString()), decimal.Parse(DTUsuariosAFacturar.Rows[0]["valor_m3"].ToString()), oConcepto, _oFactura, oConceptoParticular);
                    if (oDetalle.importe != 0)
                    {
                        AgregarDetalle(oDetalle);
                    }
                    // Calcula los subtotales separados para los conceptos con y sin IVA
                    if (oConcepto.aplicar_iva.Value)
                    {
                        NetoConIVA = NetoConIVA + oDetalle.importe;
                    }
                    else
                    {
                        NetoSinIVA = NetoSinIVA + oDetalle.importe;
                    }
                    // Calcula los campos Neto1 y Neto2 utilizados en los
                    // cálculos de intereses
                    if (oConcepto.aplicar_recargo.Value)
                    {
                        oFactura.neto1 = oFactura.neto1.Value + Convert.ToSingle(oDetalle.importe);
                    }
                    else
                    {
                        oFactura.neto2 = oFactura.neto2.Value + Convert.ToSingle(oDetalle.importe);
                    }
                }
            }
            cod_conceptos     oConceptoIVA       = new cod_conceptos();
            ConceptoImplement oConceptoImplement = new ConceptoImplement();
            facturas_detalles oDetalleFac        = new facturas_detalles();

            oConceptoIVA            = oConceptoImplement.Get(23);//concepto IVA es el 23
            oDetalleFac.id_concepto = oConceptoIVA.id_concepto;
            oDetalleFac.id_factura  = 0;
            oDetalleFac.idOrden     = oConceptoIVA.orden_concepto;
            oDetalleFac.idTipo      = 0;
            oDetalleFac.importe     = decimal.Round(NetoConIVA * decimal.Parse(DTUsuariosAFacturar.Rows[0]["iva"].ToString()) / 100, 2);
            AgregarDetalle(oDetalleFac);
        }
示例#23
0
        private void CargarGrilla()
        {
            FacturasImplement oFacturasImplement = new FacturasImplement();
            DataTable         dtFacturas         = new DataTable();

            if (_mostrarValoresActualizados == 0)
            {
                if (_mostrarImpagas == 0)
                {
                    if (_facturasNoAct == null)
                    {
                        _facturasNoAct = oFacturasImplement.GetByIdSocioDT(_idSocio, _mostrarImpagas, _mostrarValoresActualizados);
                    }
                    dtFacturas = _facturasNoAct;
                }
                else
                {
                    dtFacturas = _facturasNoActImp;
                }
            }
            else
            {
                if (_mostrarImpagas == 0)
                {
                    dtFacturas = _facturasAct;
                }
                else
                {
                    dtFacturas = _facturasActImp;
                }
            }

            if (dtFacturas == null)
            {
                MessageBox.Show("Se estan calculando los datos... espere");
                if (valor == 1)//se clickeo imp
                {
                    chkMostrarImpagas.Checked = !chkMostrarImpagas.Checked;
                }
                else
                {
                    chkValoresAct.Checked = !chkValoresAct.Checked;
                }
            }
            else
            {
                /*if (_mostrarValoresActualizados == 1)
                 * {*/
                Decimal valorTotal   = 0;
                Decimal valorRecargo = 0;
                foreach (DataRow dr in dtFacturas.Rows)
                {
                    #region <Control Valores Vacios>
                    decimal Neto       = 0;
                    decimal IVA        = 0;
                    decimal Cobrado    = 0;
                    decimal Recargo    = 0;
                    decimal IVARecargo = 0;
                    if (dr["Neto"] == null | dr["Neto"].ToString() == "")
                    {
                        Neto = 0;
                    }
                    else
                    {
                        Neto = decimal.Parse(dr["Neto"].ToString());
                    }
                    if (dr["IVA"] == null | dr["IVA"].ToString() == "")
                    {
                        IVA = 0;
                    }
                    else
                    {
                        IVA = decimal.Parse(dr["IVA"].ToString());
                    }
                    if (dr["Cobrado"] == null | dr["Cobrado"].ToString() == "")
                    {
                        Cobrado = 0;
                    }
                    else
                    {
                        Cobrado = decimal.Parse(dr["Cobrado"].ToString());
                    }
                    if (dr["Recargo"] == null | dr["Recargo"].ToString() == "")
                    {
                        Recargo = 0;
                    }
                    else
                    {
                        Recargo = decimal.Parse(dr["Recargo"].ToString());
                    }
                    if (dr["IVARecargo"] == null | dr["IVARecargo"].ToString() == "")
                    {
                        IVARecargo = 0;
                    }
                    else
                    {
                        IVARecargo = decimal.Parse(dr["IVARecargo"].ToString());
                    }
                    #endregion

                    valorTotal = valorTotal + (Neto + IVA - Cobrado)
                                 + Recargo + IVARecargo;

                    valorRecargo = valorRecargo + Recargo;
                }
                txtTotal.Text   = Math.Round(valorTotal, 2).ToString();
                txtRecargo.Text = Math.Round(valorRecargo, 2).ToString();
                /*}*/

                this.dgvFacturas.DataSource = dtFacturas;
            }
        }
示例#24
0
        private void Imprimir()
        {
            SysConfigImplement oSysConfigImplement = new SysConfigImplement();

            Reportes.frmReportes frmRpt             = new Reportes.frmReportes();
            Reportes.rptFacturas rpt                = new Reportes.rptFacturas();
            FacturasImplement    oFacturasImplement = new FacturasImplement();
            //DataTable dtFacturas=new DataTable();
            //if(_mostrarImpagas ==0)
            //{
            //    if(_mostrarValoresActualizados==0)
            //    {
            //        dtFacturas=_facturasNoAct;
            //    }
            //    else
            //    {
            //        dtFacturas=_facturasAct;
            //    }
            //}
            //else
            //{
            //    if(_mostrarValoresActualizados==0)
            //    {
            //        dtFacturas=_facturasNoActImp;
            //    }
            //    else
            //    {
            //        dtFacturas=_facturasActImp;
            //    }
            //}


            DataTable dtFacturas     = oFacturasImplement.GetByIdSocioDT(_idSocio, _mostrarImpagas, _mostrarValoresActualizados);
            decimal   totalfacturado = 0;
            decimal   totalrecargo   = 0;
            decimal   totalcobrado   = 0;
            decimal   totaldeuda     = 0;

            foreach (DataRow dr in dtFacturas.Rows)
            {
                dr["Total"]   = (decimal.Parse(dr["Recargo"].ToString()) + decimal.Parse(dr["IVARecargo"].ToString())) + (decimal.Parse(dr["Neto"].ToString()) + decimal.Parse(dr["IVA"].ToString())) - decimal.Parse(dr["Cobrado"].ToString());
                dr["Neto"]    = (decimal.Parse(dr["Neto"].ToString()) + decimal.Parse(dr["IVA"].ToString()));
                dr["Recargo"] = (decimal.Parse(dr["Recargo"].ToString()) + decimal.Parse(dr["IVARecargo"].ToString()));

                totalfacturado = totalfacturado + (decimal.Parse(dr["Neto"].ToString()) + decimal.Parse(dr["IVA"].ToString()));
                totalrecargo   = totalrecargo + (decimal.Parse(dr["Recargo"].ToString()) + decimal.Parse(dr["IVARecargo"].ToString()));
                totalcobrado   = totalcobrado + decimal.Parse(dr["Cobrado"].ToString());
                totaldeuda     = totaldeuda + decimal.Parse(dr["Total"].ToString());
            }

            socios             oSocio               = new socios();
            SocioImplement     oSocioImplement      = new SocioImplement();
            socios_lote        oSocio_lote          = new socios_lote();
            SocioLoteImplement oSocio_loteImplement = new SocioLoteImplement();
            tarifas            oTarifas             = new tarifas();
            TarifaImplement    oTarifaImplement     = new TarifaImplement();
            cod_barrios        oCod_Barrios         = new cod_barrios();
            BarrioImplement    oBarrioImplement     = new BarrioImplement();
            cod_calles         oCod_Calles          = new  cod_calles();
            CalleImplement     oCalleImplement      = new CalleImplement();

            oSocio      = oSocioImplement.Get(_idSocio);
            oSocio_lote = oSocio_loteImplement.Get(_idSocio);
            string calleAltura = "";
            string manzana     = "";
            string lote        = "";
            string tarifa      = "";
            string barrio      = "";

            if (oSocio.tarifa > 0)
            {
                tarifa = oTarifaImplement.Get((int)oSocio.tarifa).tarifa;
            }
            if (oSocio_lote != null)
            {
                if (oSocio_lote.barrio > 0)
                {
                    barrio = oBarrioImplement.Get((int)oSocio_lote.barrio).barrio;
                }
                if (oSocio_lote.calle_altura.Length > 0)
                {
                    calleAltura = oSocio_lote.calle_altura;
                }
                if (oSocio_lote.manzana.Length > 0)
                {
                    manzana = oSocio_lote.manzana;
                }
                if (oSocio_lote.lote.Length > 0)
                {
                    lote = oSocio_lote.lote;
                }
            }
            string calle = "";

            if (oSocio_lote.calle != null && oSocio_lote.calle > 0)
            {
                calle = oCalleImplement.Get((int)oSocio_lote.calle).calle;
            }

            //Cargo el Data Set


            DataSet ds = new DataSet("Generico");

            ds.Tables.Add(oSysConfigImplement.GetEncabezadoDT("Encabezado"));
            ds.Tables[0].TableName = "dtEncabezado";
            ds.Tables.Add(dtFacturas);
            ds.Tables[1].TableName = "dtFacturas";
            rpt.SetDataSource(ds);
            rpt.SetParameterValue("socio", oSocio.codigo_socio + "/" + oSocio.subcodigo_socio + "  " + oSocio.nombre);
            rpt.SetParameterValue("tarifa", tarifa);
            rpt.SetParameterValue("barrio", barrio);
            rpt.SetParameterValue("calle", calle);
            rpt.SetParameterValue("numero", calleAltura);
            rpt.SetParameterValue("manzana", manzana);
            rpt.SetParameterValue("lote", lote);
            rpt.SetParameterValue("totalfacturado", Math.Round(totalfacturado, 2).ToString());
            rpt.SetParameterValue("totalrecargo", Math.Round(totalrecargo, 2).ToString());
            rpt.SetParameterValue("totalcobrado", Math.Round(totalcobrado, 2).ToString());
            rpt.SetParameterValue("totaldeuda", Math.Round(totaldeuda, 2).ToString());
            frmRpt.crvGenerico.ReportSource = rpt;
            frmRpt.Show();
        }
示例#25
0
        private void CargarDatosMoratoria()
        {
            FacturasImplement oFacturasImplement = new FacturasImplement();
            CalculosConvenio  oCalculosConvenio  = new CalculosConvenio();

            _ConveniosNoCancelados = oCalculosConvenio.ObtenerImporteConvenioAdeudado(_idSocio);

            DataTable dtFacturas = oFacturasImplement.GetByIdSocioSinConvenioDT(_idSocio, 1, 1);

            txtFactAdeudadasMora.Text = dtFacturas.Rows.Count.ToString();
            Decimal valorTotalSinInteres = 0;
            Decimal valorInteresesMora   = 0;

            foreach (DataRow dr in dtFacturas.Rows)
            {
                #region <Control Valores Vacios>
                decimal Neto       = 0;
                decimal IVA        = 0;
                decimal Cobrado    = 0;
                decimal Recargo    = 0;
                decimal IVARecargo = 0;

                if (dr["Neto"] == null | dr["Neto"].ToString() == "")
                {
                    Neto = 0;
                }
                else
                {
                    Neto = decimal.Parse(dr["Neto"].ToString());
                }
                if (dr["IVA"] == null | dr["IVA"].ToString() == "")
                {
                    IVA = 0;
                }
                else
                {
                    IVA = decimal.Parse(dr["IVA"].ToString());
                }
                if (dr["Cobrado"] == null | dr["Cobrado"].ToString() == "")
                {
                    Cobrado = 0;
                }
                else
                {
                    Cobrado = decimal.Parse(dr["Cobrado"].ToString());
                }

                if (dr["Recargo"] == null | dr["Recargo"].ToString() == "")
                {
                    Recargo = 0;
                }
                else
                {
                    Recargo = decimal.Parse(dr["Recargo"].ToString());
                }
                if (dr["IVARecargo"] == null | dr["IVARecargo"].ToString() == "")
                {
                    IVARecargo = 0;
                }
                else
                {
                    IVARecargo = decimal.Parse(dr["IVARecargo"].ToString());
                }

                #endregion

                valorTotalSinInteres = valorTotalSinInteres + (Neto + IVA - Cobrado);
                valorInteresesMora   = valorInteresesMora + (Recargo + IVARecargo);
            }

            Decimal ImporteTotalSinInteresMora = valorTotalSinInteres + _ConveniosNoCancelados;
            txtTotalSinInteresMora.Text = ImporteTotalSinInteresMora.ToString();
            Decimal ImporteInteresesMora = valorInteresesMora;
            txtImporteInteresesMora.Text = ImporteInteresesMora.ToString();
            txtTotalMoratoria.Text       = (ImporteTotalSinInteresMora + ImporteInteresesMora).ToString();
            txtCuotasAbonadasMora.Text   = "1";
            txtDescPagoContadoMora.Text  = "5%";
            txtCantMaxCuotasMora.Text    = "-";

            facturas oFacturas = new facturas();
            oFacturas = oFacturasImplement.GetUltimaFactura(_idSocio);
            DataTable oFacturasDetallesDT = new DataTable();
            FacturasDetallesImplement oFacturasDetallesImplements = new FacturasDetallesImplement();
            oFacturasDetallesDT = oFacturasDetallesImplements.GetAllByIdFacturaDT(oFacturas.id_factura);
            decimal valorUltimaFactura = 0;
            foreach (DataRow dr in oFacturasDetallesDT.Rows)
            {
                int _idConcepto = int.Parse(dr["id_concepto"].ToString());
                if (_idConcepto == 1 | _idConcepto == 2 | _idConcepto == 3 | _idConcepto == 8)
                {
                    valorUltimaFactura = valorUltimaFactura + decimal.Parse(dr["importe"].ToString());
                }
            }

            decimal valorMinimoCuota = Math.Round((valorUltimaFactura / 2), 2);
            txtValorMinimoCuotaMora.Text = valorMinimoCuota.ToString();

            int maxCantCuotas = (int)((ImporteTotalSinInteresMora + ImporteInteresesMora) / valorMinimoCuota);
            //Pregunto por si la moratoria tiene limitacion, si no la tiene cambio la cant max de cuotas por minimo monto
            //por la max cant de cuotas por moratoria directamente

            MoratoriasImplement oMoratoriasImplement = new MoratoriasImplement();
            DataTable           cuotasDT             = new DataTable();
            DateTime            fechaConv            = dtpFechaConvenio.Value;

            cuotasDT = oMoratoriasImplement.GetTablaCuotasConvenioMoratoria(maxCantCuotas, fechaConv, ImporteTotalSinInteresMora, ImporteInteresesMora);
            txtCantMaxCuotasMora.Text = cuotasDT.Rows.Count.ToString();//esta tabla trae la cantidad de cuotas previendo limitacion con valor minimo

            dgvCuotasMora.DataSource = cuotasDT;
        }
示例#26
0
        private void CargarGrilla()
        {
            FacturasImplement oFacturasImplement = new FacturasImplement();
            DataTable         dtFacturas         = oFacturasImplement.GetByIdSocioSinConvenioDT(_idSocio, 1, 1);

            Decimal valorTotal = 0;

            foreach (DataRow dr in dtFacturas.Rows)
            {
                #region <Control Valores Vacios>
                decimal Neto       = 0;
                decimal IVA        = 0;
                decimal Cobrado    = 0;
                decimal Recargo    = 0;
                decimal IVARecargo = 0;
                if (dr["Neto"] == null | dr["Neto"].ToString() == "")
                {
                    Neto = 0;
                }
                else
                {
                    Neto = decimal.Parse(dr["Neto"].ToString());
                }
                if (dr["IVA"] == null | dr["IVA"].ToString() == "")
                {
                    IVA = 0;
                }
                else
                {
                    IVA = decimal.Parse(dr["IVA"].ToString());
                }
                if (dr["Cobrado"] == null | dr["Cobrado"].ToString() == "")
                {
                    Cobrado = 0;
                }
                else
                {
                    Cobrado = decimal.Parse(dr["Cobrado"].ToString());
                }
                if (dr["Recargo"] == null | dr["Recargo"].ToString() == "")
                {
                    Recargo = 0;
                }
                else
                {
                    Recargo = decimal.Parse(dr["Recargo"].ToString());
                }
                if (dr["IVARecargo"] == null | dr["IVARecargo"].ToString() == "")
                {
                    IVARecargo = 0;
                }
                else
                {
                    IVARecargo = decimal.Parse(dr["IVARecargo"].ToString());
                }
                #endregion

                valorTotal = valorTotal + (Neto + IVA - Cobrado)
                             + Recargo + IVARecargo;
            }

            this.dgvFacturas.DataSource = dtFacturas;
        }
示例#27
0
        private void Iniciar()
        {
            sys_configuracion  oSysConfig          = new sys_configuracion();
            SysConfigImplement oSysConfigImplement = new SysConfigImplement();

            oSysConfig = oSysConfigImplement.GetByNombre("CantVencimientos");
            int     CantUsuarios = 0;
            decimal NetoConIVA   = 0;
            decimal NetoSinIVA   = 0;
            decimal SubTotal     = 0;

            switch (int.Parse(oSysConfig.valor))
            {
            case 1:
                //No hace nada porque el primer se establece por defecto
                break;

            case 2:
                for (int i = 1; i <= (int.Parse(this.nudCantidad.Value.ToString()) - 1); i++)
                {
                    DateTimePicker fecha1 = (DateTimePicker)tcPeriodos.Controls.Find("dtpPrimerVencimiento" + i, true)[0];
                    DateTimePicker fecha2 = (DateTimePicker)tcPeriodos.Controls.Find("dtpSegundoVencimiento" + i, true)[0];
                    if (fecha2.Value <= fecha1.Value)
                    {
                        string msg = "Debe establecer las fechas para los 2 vencimientos y éstas " +
                                     "no pueden ser iguales, controlar fechas indicadas en  el periodo " + (i - 1).ToString();
                        MessageBox.Show(msg);
                    }
                }

                break;

            case 3:
                for (int i = 1; i <= (int.Parse(this.nudCantidad.Value.ToString()) + 1); i++)
                {
                    DateTimePicker fecha1 = (DateTimePicker)tcPeriodos.Controls.Find("dtpPrimerVencimiento" + i, true)[0];
                    DateTimePicker fecha2 = (DateTimePicker)tcPeriodos.Controls.Find("dtpSegundoVencimiento" + i, true)[0];
                    if (fecha2.Value <= fecha1.Value)
                    {
                        string msg = "Debe establecer las fechas para los 2 vencimientos y éstas " +
                                     "no pueden ser iguales, controlar fechas indicadas en  el periodo " + (i - 1).ToString();
                        MessageBox.Show(msg);
                    }
                }

                break;
            }


            // Verificar que se hayan cargado los estados de los medidores

            SocioConexionImplement oSocioConexionImplement = new SocioConexionImplement();
            DataTable DTMedidores = oSocioConexionImplement.GetEstadosMedidores();

            if (DTMedidores.Rows.Count > 0)
            {
                string msg2 = "No se puede efectuar el proceso de facturación porque existen " +
                              "socios de servicio medido que no tienen informado el estado del " +
                              "medidor. \n El estado del medidor debe ser " +
                              "informado siempre, si por algún motivo no se efectuó la lectura, " +
                              "coloque un valor estimado en el campo 'Lectura' pero no informe " +
                              "la fecha de lectura en el campo 'Fecha Lectura', en la factura " +
                              "se informará al socio que el valor de M3 consumidos fué estimado /n" +
                              "El proceso de facturación no puede continuar.";
                MessageBox.Show(msg2);
            }

            // Pide confirmar el proceso de facturación
            string msj2 = "";

            if (int.Parse(this.nudCantidad.Value.ToString()) > 1)
            {
                msj2 = "Está Ud. realmente seguro de querer comenzar el proceso de " +
                       "facturación ?. \nEste proceso no puede ser " +
                       "cancelado y al facturarse más de un período sólo puede " +
                       "anularse la facturación del último período pero no de los " +
                       "períodos anteriores";
            }
            else
            {
                msj2 = "Está Ud. realmente seguro de querer comenzar el proceso de " +
                       "facturación ?. \nEste proceso no puede ser " +
                       "cancelado, aunque sí es reversible, es decir que una vez " +
                       "finalizado el proceso se puede anular \n toda la facturación " +
                       "y volver a efectuarla";
            }
            DialogResult dialogResult = MessageBox.Show(msj2, "Confirmar facturación", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                // Hay que inhabilitar los forms porque el proceso no puede detenerse
                DeshabilitarControles();
                // Guarda la cantidad de usuarios para utilizar la misma cantidad en
                // todos los períodos a facturar


                // obtengo solo los conceptos activos
                IList listaConceptos = new ConceptoImplement().GetActivosAll();
                for (int i = 0; i < (int.Parse(this.nudCantidad.Value.ToString())); i++)
                {
                    TextBox   textPeriodo         = (TextBox)this.Controls.Find("txtPeriodo" + i, true)[0];
                    string    idPeriodo           = textPeriodo.Text.Substring(3, 4) + textPeriodo.Text.Substring(0, 2);
                    DataTable DTUsuariosAFacturar = oSocioConexionImplement.GetSociosAFacturar(idPeriodo);
                    //Repetir el proceso de facturación para todas las solapas (periodos) seleccionados
                    CantUsuarios = DTUsuariosAFacturar.Rows.Count;
                    this.txtUsuariosAFacturar.Text  = CantUsuarios.ToString();
                    this.txtUsuariosFacturados.Text = "0";
                    this.txtUsuariosFaltantes.Text  = CantUsuarios.ToString();
                    this.pbEstado.Value             = 0;
                    // Cartel indicativo del proceso que se está efectuando
                    this.tcPeriodos.TabIndex = i;

                    // Guarda el número 'ProxFactura' del proceso anterior por si se desea
                    // anular la facturación en curso (obviamente luego que termine)

                    //sys_configuracion oSysProxFacturaAnterior = new sys_configuracion();
                    //oSysProxFacturaAnterior = oSysConfigImplement.GetByNombre("ProxFacturaAnt");
                    //sys_configuracion oSysProxFactura = new sys_configuracion();
                    //oSysProxFactura = oSysConfigImplement.GetByNombre("ProxFactura");
                    //oSysProxFacturaAnterior.valor = oSysProxFactura.valor;
                    //oSysConfigImplement.Update(oSysProxFacturaAnterior);



                    // Guardo las fechas de vencimiento en la tabla periodos
                    periodos          oPeriodo           = new periodos();
                    PeriodosImplement oPeriodosImplement = new PeriodosImplement();
                    oPeriodo                = oPeriodosImplement.Get(idPeriodo);
                    this.txtProceso.Text    = "Se esta procesando el periodo " + idPeriodo;
                    this.txtProceso.Visible = true;
                    Application.DoEvents();
                    oPeriodo.fecha_facturacion = this.dtpFecha.Value;
                    DateTimePicker dtpPrimerVenc = (DateTimePicker)this.Controls.Find("dtpPrimerVencimiento" + i, true)[0];
                    oPeriodo.fecha_primer_venc = dtpPrimerVenc.Value;
                    DateTimePicker dtpSegundoVenc = (DateTimePicker)this.Controls.Find("dtpSegundoVencimiento" + i, true)[0];
                    if (dtpSegundoVenc.Value.ToString() != "")
                    {
                        oPeriodo.fecha_segundo_venc = dtpSegundoVenc.Value;
                    }
                    oPeriodo.fecha_tercer_venc = null;
                    oPeriodo.facturado         = true;
                    FacturasImplement oFacturasImplement = new FacturasImplement();
                    int cantUsuario = DTUsuariosAFacturar.Rows.Count;
                    this.pbEstado.Maximum = cantUsuario;
                    for (int j = 0; j < cantUsuario; j++)
                    {
                        this.pbEstado.Value = j;

                        facturas          oFactura          = new facturas();
                        FacturasImplement oFacturaImplement = new FacturasImplement();
                        oFactura.id_periodo = idPeriodo;
                        oFactura.id_socio   = int.Parse(DTUsuariosAFacturar.Rows[j]["id_socio"].ToString());
                        //oFactura.id_medicion Ver como soluciono el idMedicion
                        oFactura.id_estadoPago = 1; //Impaga
                        oFactura.id_tarifa     = 0; //aun no se carga
                        oFactura.id_convenio   = 0; //Aun no se carga
                        oFactura.fechaPago     = null;
                        oFactura.cobrado       = 0;
                        oFactura.neto1         = 0;
                        oFactura.neto2         = 0;
                        oFactura.importeNeto   = 0;
                        oFactura.importeTotal  = 0;
                        int idFactura = 0;
                        idFactura = oFacturasImplement.Save(oFactura);

                        /* Si corresponde calcula los consumos estimados, además transfiere
                         * los valores de los campos de datos actuales a los campos de
                         * los datos anteriores*/
                        int idMedidor = 0;
                        if (DTUsuariosAFacturar.Rows[j]["medidor"].ToString() != "")
                        {
                            socios_mediciones      oSocioMedicionActual    = new socios_mediciones();
                            SocioMedicionImplement oSocioMedicionImplement = new SocioMedicionImplement();
                            oSocioMedicionActual = oSocioMedicionImplement.ultimaMedicion(int.Parse(DTUsuariosAFacturar.Rows[j]["id_socio"].ToString()));
                            socios_mediciones oSocioMedicionNew = new socios_mediciones();
                            oSocioMedicionNew.fecha_lectura = null;
                            oSocioMedicionNew.id_socio      = int.Parse(DTUsuariosAFacturar.Rows[j]["id_socio"].ToString());

                            if (i <= (int.Parse(this.nudCantidad.Value.ToString()) - 1))
                            {
                                decimal consumo = 0;
                                if (oSocioMedicionActual != null)
                                {
                                    consumo = (decimal)decimal.Parse((oSocioMedicionActual.consumo * 0.75).ToString());
                                    oSocioMedicionNew.consumo = (int)Math.Truncate(consumo);
                                    oSocioMedicionNew.lectura = oSocioMedicionActual.lectura + oSocioMedicionNew.consumo;
                                }
                                else
                                {
                                    oSocioMedicionNew.consumo = 0;
                                    oSocioMedicionNew.lectura = 0;
                                }
                            }
                            else
                            {
                                oSocioMedicionNew.consumo = 0;
                                oSocioMedicionNew.lectura = 0;
                            }
                            idMedidor = oSocioMedicionImplement.Save(oSocioMedicionNew);
                        }
                        oFactura.id_medicion = idMedidor;    //Cargo 0 si no tiene medidor

                        // Limpia las variables de subtotales con y sin IVA
                        NetoConIVA = 0;
                        NetoSinIVA = 0;

                        //Para cada socio, recorre toda la base de conceptos
                        foreach (cod_conceptos oConcepto in listaConceptos)
                        {
                            bool CorrespondeFacturar = false;

                            if (oFactura.id_medicion.Value != 0)
                            {
                                //SocioMedicionImplement oSosioMedicionImpl = new SocioMedicionImplement();
                                //socios_mediciones oSocioMedicion = new socios_mediciones();
                                //oSocioMedicion = oSosioMedicionImpl.Get(oFactura.id_medicion.Value);
                            }
                            acciones oAccion = new acciones();
                            conceptos_particulares         oConceptoParticular          = new conceptos_particulares();
                            conceptosParticularesImplement oConceptoParticularImplement = new conceptosParticularesImplement();
                            AccionImplement oAccionesImplement = new AccionImplement();

                            if (oConcepto.aplicacion == 2)
                            {     // si concepto Particular
                                oConceptoParticular = oConceptoParticularImplement.GetByFilter(int.Parse(DTUsuariosAFacturar.Rows[j]["id_socio"].ToString()), oConcepto.id_concepto, oFactura.id_periodo);
                                if (oConceptoParticular != null)
                                {
                                    CorrespondeFacturar = true;
                                }
                                else
                                {
                                    // No encontrado entonces no corresponde facturar
                                    CorrespondeFacturar = false;
                                }
                            }
                            else
                            {
                                //Concepto Activo y no particular entonces corresponde facturar
                                CorrespondeFacturar = true;
                            }

                            if (CorrespondeFacturar)
                            {
                                facturas_detalles         oDetalle = new facturas_detalles();
                                FacturasDetallesImplement oFacturasDetallesImplement = new FacturasDetallesImplement();
                                //ConvenioImplement oConvenioImplement = new ConvenioImplement();
                                CalculosFacturacionFormulas oCalculosFacturacionFormulas = new CalculosFacturacionFormulas();
                                oDetalle = oCalculosFacturacionFormulas.getDetalle(int.Parse(DTUsuariosAFacturar.Rows[j]["id_socio"].ToString()), decimal.Parse(DTUsuariosAFacturar.Rows[j]["cargo_fijo"].ToString()), decimal.Parse(DTUsuariosAFacturar.Rows[j]["abono"].ToString()), decimal.Parse(DTUsuariosAFacturar.Rows[j]["valor_m3"].ToString()), oConcepto, oFactura, oConceptoParticular);
                                if (oDetalle.importe != 0)
                                {
                                    oFacturasDetallesImplement.Save(oDetalle);
                                }

                                this.txtUsuariosFacturados.Text = j.ToString();
                                this.txtUsuariosFaltantes.Text  = (int.Parse(this.txtUsuariosAFacturar.Text) - j).ToString();
                                Application.DoEvents();
                                // Calcula los subtotales separados para los conceptos con y sin IVA
                                if (oConcepto.aplicar_iva.Value)
                                {
                                    NetoConIVA = NetoConIVA + oDetalle.importe;
                                }
                                else
                                {
                                    NetoSinIVA = NetoSinIVA + oDetalle.importe;
                                }
                                // Calcula los campos Neto1 y Neto2 utilizados en los
                                // cálculos de intereses
                                if (oConcepto.aplicar_recargo.Value)
                                {
                                    oFactura.neto1 = oFactura.neto1.Value + Convert.ToSingle(oDetalle.importe);
                                }
                                else
                                {
                                    oFactura.neto2 = oFactura.neto2.Value + Convert.ToSingle(oDetalle.importe);
                                }
                            }
                        }

                        // Obtiene el subtotal general como suma de los
                        // subtotales parciales con y sin IVA
                        SubTotal = NetoConIVA + NetoSinIVA;
                        // Redondea el subtotal a dos dígitos
                        SubTotal = decimal.Round(SubTotal, 2);
                        // Registra el subtotal general
                        oFactura.importeNeto = Convert.ToSingle(SubTotal);
                        // Calcula IVA (sólo para los conceptos que corresponde)
                        facturas_detalles         oFacDetalle          = new facturas_detalles();
                        FacturasDetallesImplement oFacDetalleImplement = new FacturasDetallesImplement();

                        cod_conceptos     oConceptoIVA       = new cod_conceptos();
                        ConceptoImplement oConceptoImplement = new ConceptoImplement();

                        oConceptoIVA            = oConceptoImplement.Get(23);//concepto IVA es el 23
                        oFacDetalle.id_concepto = oConceptoIVA.id_concepto;
                        oFacDetalle.id_factura  = oFactura.id_factura;
                        oFacDetalle.idOrden     = oConceptoIVA.orden_concepto;
                        oFacDetalle.idTipo      = 0;
                        oFacDetalle.importe     = decimal.Round(NetoConIVA * decimal.Parse(DTUsuariosAFacturar.Rows[j]["iva"].ToString()) / 100, 2);
                        oFacDetalleImplement.Save(oFacDetalle);
                        // Calcula Total
                        oFactura.importeTotal = oFactura.importeNeto.Value + Convert.ToSingle(oFacDetalle.importe);      //este ahi que ver el tipo de dato
                        oFactura.id_factura   = idFactura;
                        oFacturaImplement.Update(oFactura);
                        // Generar entradas en la base de CuentasCorrientes
                        CuentaCorrienteImplement oCuentaCorrienteImplement = new CuentaCorrienteImplement();
                        cuentas_corrientes       oCuentaCorriente          = new cuentas_corrientes();
                        oCuentaCorriente.fecha           = DateTime.Now;
                        oCuentaCorriente.id_factura      = idFactura;
                        oCuentaCorriente.id_movimiento   = 1;
                        oCuentaCorriente.id_socio        = int.Parse(DTUsuariosAFacturar.Rows[j]["id_socio"].ToString());
                        oCuentaCorriente.importe_credito = 0;
                        oCuentaCorriente.importe_saldo   = 0;
                        oCuentaCorriente.importe_debito  = Convert.ToDecimal(oFactura.importeTotal);
                        oCuentaCorriente.id_cobranza     = 0;
                        oCuentaCorrienteImplement.Save(oCuentaCorriente);

                        // }
                    }
                }
            }
        }
示例#28
0
        public decimal CalcularIVARecargo(int idFactura)
        {
            #region

            /*
             * using (cooperativaEntities bd = new cooperativaEntities())
             * {
             *  Commons oCommons = new Commons();
             *  var detallesByFact = (from d in bd.facturas_detalles
             *                        join c in bd.cod_conceptos on d.id_concepto equals c.id_concepto
             *                        where d.id_factura == idFactura
             *                        select new
             *                        {
             *                            d.id_factura,
             *                            d.id_detalle,
             *                            d.id_concepto,
             *                            d.idOrden,
             *                            d.idTipo,
             *                            d.importe,
             *                            c.id_formula,
             *                            c.orden_concepto,
             *                            c.tipo_signo,
             *                            c.variable,
             *                            c.activo,
             *                            c.aplicar_descuento,
             *                            c.aplicar_iva,
             *                            c.aplicar_recargo,
             *                            c.concepto
             *                        }).ToList();
             *  DataTable detallesCalc = oCommons.convertToTable(detallesByFact);
             *  decimal IVARecargo = 0;
             *  foreach (DataRow rowDet in detallesCalc.Rows)
             *  {
             *      if (bool.Parse(rowDet["aplicar_iva"].ToString()) && bool.Parse(rowDet["aplicar_recargo"].ToString()))
             *          IVARecargo = IVARecargo + decimal.Parse(rowDet["importe"].ToString());
             *  }
             *  int idSocio = 0;
             *  FacturasImplement oFacturasImplement = new FacturasImplement();
             *  idSocio = (int)oFacturasImplement.Get(idFactura).id_socio;
             *  socios oSocio = new socios();
             *  SocioImplement oSocioImplement = new SocioImplement();
             *  oSocio = oSocioImplement.Get(idSocio);
             *
             *  IVARecargo = IVARecargo * (decimal.Parse(oSocio.iva.ToString()) / 100);
             *
             *  return IVARecargo;
             * }
             */
            #endregion
            decimal _IvaRecargo = 0;
            decimal _recargo    = 0;
            _recargo = CalcularRecargo(idFactura);
            int idSocio = 0;
            FacturasImplement oFacturasImplement = new FacturasImplement();
            idSocio = (int)oFacturasImplement.Get(idFactura).id_socio;
            socios         oSocio          = new socios();
            SocioImplement oSocioImplement = new SocioImplement();
            oSocio      = oSocioImplement.Get(idSocio);
            _IvaRecargo = _recargo * (decimal.Parse(oSocio.iva.ToString()) / 100);
            return(_IvaRecargo);
        }
示例#29
0
        private void Inicializar()
        {
            socios         oSocios          = new socios();
            SocioImplement oSociosImplement = new SocioImplement();

            socios_lote        oSocioLote          = new socios_lote();
            SocioLoteImplement oSocioLoteImplement = new SocioLoteImplement();

            oSocioLote = oSocioLoteImplement.Get(_idSocio);

            socios_conexion        oSocioConexion          = new socios_conexion();
            SocioConexionImplement oSocioConexionImplement = new SocioConexionImplement();

            oSocioConexion = oSocioConexionImplement.Get(_idSocio);

            socios_varios        oSocioVarios          = new socios_varios();
            SocioVariosImplement oSocioVariosImplement = new SocioVariosImplement();

            oSocioVarios = oSocioVariosImplement.Get(_idSocio);


            oSocios               = oSociosImplement.Get(_idSocio);
            txtCodigo.Text        = oSocios.codigo_socio;
            txtFechaConvenio.Text = _FechaConvenio.ToShortDateString();
            txtNombre.Text        = oSocios.nombre;
            cod_documentos     oCodDocumentos       = new cod_documentos();
            DocumentoImplement oDocumentosImplement = new DocumentoImplement();

            if (oSocios.tipo_documento != null)
            {
                txtTipoDocumento.Text = oDocumentosImplement.Get((int)oSocios.tipo_documento).documento;
            }
            txtDocumento.Text = oSocios.documento.ToString();

            CalleImplement oCalleImplement = new CalleImplement();

            BarrioImplement    oBarrioImplement    = new BarrioImplement();
            LocalidadImplement oLocalidadImplement = new LocalidadImplement();

            if (oSocioConexion.calle != null & (int)oSocioConexion.calle != 0)
            {
                txtDomicilioReal.Text = oCalleImplement.Get((int)oSocioConexion.calle).calle + " " + oSocioConexion.calle_altura;
            }
            if (oSocioLote.localidad != null & (int)oSocioLote.localidad != 0)
            {
                txtCiudadReal.Text = oLocalidadImplement.Get((int)oSocioLote.localidad).localidad;
            }
            if (oSocioLote.calle != null & (int)oSocioLote.calle != 0)
            {
                txtDomicilioLegal.Text = oCalleImplement.Get((int)oSocioLote.calle).calle + " " + oSocioLote.calle_altura;
            }
            if (oSocioLote.localidad != null & (int)oSocioLote.localidad != 0)
            {
                txtCiudadLegal.Text = oLocalidadImplement.Get((int)oSocioLote.localidad).localidad;
            }
            txtLote.Text    = oSocioLote.lote;
            txtManzana.Text = oSocioLote.manzana;
            if (oSocioLote.barrio != null & (int)oSocioLote.barrio != 0)
            {
                txtBarrio.Text = oBarrioImplement.Get((int)oSocioLote.barrio).barrio;
            }

            txtImporteDeuda.Text          = _ImporteDeuda.ToString();
            txtValorCuotas.Text           = _ImporteCuota.ToString();
            txtCantidadCuotas.Text        = _CantidadCuotas.ToString();
            txtImporteCanonMunicipal.Text = _CanonMunicipal.ToString();


            FacturasImplement oFacturasImplement = new FacturasImplement();
            string            sPeriodo           = oFacturasImplement.GetUltimoPeriodoFacturadoBySocio(_idSocio);
            int      anio         = int.Parse(sPeriodo.Substring(0, 3));
            int      mes          = int.Parse(sPeriodo.Substring(4, 5));
            DateTime fechaPeriodo = new DateTime(anio, mes, 1);
            DateTime fechaDesde   = fechaPeriodo.AddMonths(1);
            DateTime fechaHasta   = fechaPeriodo.AddMonths(_CantidadCuotas);
            Meses    mesDesde     = (Meses)fechaDesde.Month;
            Meses    mesHasta     = (Meses)fechaHasta.Month;

            txtDesdeMes.Text  = mesDesde.ToString();
            txtMesHasta.Text  = mesHasta.ToString();
            txtDesdeAnio.Text = fechaDesde.Year.ToString();
            txtAnioHasta.Text = fechaHasta.Year.ToString();
        }
示例#30
0
        private void CargarDatos()
        {
            if (txtNroFactura.Text.Length > 0)
            {
                facturas                  oFacturas                  = new facturas();
                socios                    oSocio                     = new socios();
                SocioImplement            oSocioImplement            = new SocioImplement();
                FacturasImplement         oFacturasImplement         = new FacturasImplement();
                PeriodosImplement         oPeriodosImplement         = new PeriodosImplement();
                FacturasDetallesImplement oFacturasDetallesImplement = new FacturasDetallesImplement();
                _idFactura = int.Parse(txtNroFactura.Text);
                if (oFacturasImplement.ExisteFactura(_idFactura))
                {
                    oFacturas = oFacturasImplement.Get(int.Parse(txtNroFactura.Text));
                    oSocio    = oSocioImplement.Get((int)oFacturas.id_socio);
                    _idSocio  = oSocio.id_socio;
                    txtCodigoSubCodSocio.Text = oSocio.codigo_socio + "/" + oSocio.subcodigo_socio;
                    txtNombreSocio.Text       = oSocio.nombre;
                    txtVencimiento.Text       = ((DateTime)oPeriodosImplement.Get(oFacturas.id_periodo).fecha_primer_venc).ToShortDateString();
                    //facturado = neto + iva
                    DataTable detallesFacturaDT = oFacturasImplement.GetByIdFacturaDT(oFacturas.id_factura);
                    decimal   _totalFacturado   = 0;
                    decimal   _importeTotal     = 0;
                    decimal   _convenio         = 0;
                    decimal   _acciones         = 0;
                    foreach (DataRow dr in detallesFacturaDT.Rows)
                    {
                        //IVA = decimal.Parse(dr["IVA"].ToString());
                        _totalFacturado = _totalFacturado + decimal.Parse(dr["Neto"].ToString()) + decimal.Parse(dr["IVA"].ToString());
                        _importeTotal   = _importeTotal + decimal.Parse(dr["Total"].ToString());
                        _convenio       = _convenio + decimal.Parse(dr["Convenio"].ToString());
                        _acciones       = _acciones + decimal.Parse(dr["Acciones"].ToString());
                    }

                    txtFacturado.Text = _totalFacturado.ToString();
                    txtCobrado.Text   = oFacturas.cobrado.ToString();
                    txtResto.Text     = (_totalFacturado - (decimal.Parse(oFacturas.cobrado.ToString()))).ToString();
                    txtDescuento.Text = "0";
                    CalculosFactura oCalculosFacturas = new CalculosFactura();
                    txtRecargo.Text  = (oCalculosFacturas.CalcularRecargo(oFacturas.id_factura) + oCalculosFacturas.CalcularIVARecargo(oFacturas.id_factura)).ToString();
                    txtTotal.Text    = (_importeTotal - (decimal)oFacturas.cobrado - decimal.Parse(txtDescuento.Text)).ToString();
                    txtConvenio.Text = _convenio.ToString();
                    txtAcciones.Text = _acciones.ToString();


                    CobranzasImplement oCobranzasImplement = new CobranzasImplement();

                    txtFactIngresadas.Text = oCobranzasImplement.GetFacturas(dtpFechaCaja.Value).ToString();

                    txtTotalCobrado.Text = _importeTotal.ToString();
                    txtTotalFactura.Text = _importeTotal.ToString();;
                    txtDiferencia.Text   = (decimal.Parse(txtTotalFactura.Text) - decimal.Parse(txtTotalCobrado.Text)).ToString();
                }
                else
                {
                    //si esta con cobranza entonces seria para cambiar la caja
                    if (oFacturasImplement.ExisteCobranza(_idFactura))
                    {
                        _existeCobranza = true;
                    }
                    else
                    {
                        _existeCobranza = false;
                    }
                }
            }
        }