예제 #1
0
        private void btnModificarConvenio_Click(object sender, EventArgs e)
        {
            convenios         oConvenios         = new convenios();
            ConvenioImplement oConvenioImplement = new ConvenioImplement();
            DataGridViewRow   row = this.dgvConvenio.CurrentRow;

            if (btnModificarConvenio.Text == "&Modificar Convenio")
            {
                if (row != null)
                {
                    row.ReadOnly              = false;
                    row.Cells[0].ReadOnly     = true;
                    row.Cells[1].ReadOnly     = true;
                    row.Cells[2].ReadOnly     = true;
                    row.Cells[3].ReadOnly     = true;
                    row.Cells[4].ReadOnly     = true;
                    row.Cells[5].ReadOnly     = true;
                    row.Cells[7].ReadOnly     = true;
                    _facturadasOriginal       = Convert.ToInt32(row.Cells[6].Value);
                    _idConvenio               = Convert.ToInt32(row.Cells[1].Value);
                    oConvenios                = oConvenioImplement.Get(_idConvenio);
                    btnModificarConvenio.Text = "&Terminar Modificacion";
                }
            }
            else
            {
                if (row != null)
                {
                    int _facturadasNuevas = Convert.ToInt32(row.Cells[6].Value);
                    int _cuotas           = Convert.ToInt32(row.Cells[5].Value);
                    if (_facturadasNuevas >= _facturadasOriginal && _facturadasNuevas <= _cuotas)
                    {
                        _idConvenio = Convert.ToInt32(row.Cells[1].Value);
                        oConvenios  = oConvenioImplement.Get(_idConvenio);
                        oConvenios.fecha_convenio = Convert.ToDateTime(row.Cells[2].Value);
                        oConvenios.importe_total  = Convert.ToDecimal(row.Cells[3].Value);
                        oConvenios.cuotas         = Convert.ToInt32(row.Cells[5].Value);
                        oConvenios.valor_cuota    = Convert.ToDecimal(row.Cells[4].Value);
                        oConvenios.facturadas     = Convert.ToInt32(row.Cells[6].Value);
                        if (oConvenios.cuotas == oConvenios.facturadas)
                        {
                            //if (row.Cells[7].Value == "Si")
                            oConvenios.finalizado = true;
                        }
                        else
                        {
                            oConvenios.finalizado = false;
                        }
                        oConvenioImplement.Update(oConvenios);
                        btnModificarConvenio.Text = "&Modificar Convenio";
                        frmConvenios_Load(sender, e);
                    }
                    else
                    {
                        frmVentanaInformativa f = new frmVentanaInformativa("Cantidad facturadas incorrecta.");
                        f.ShowDialog();
                    }
                }
            }
        }
예제 #2
0
        private void CargarConveniosBySocio()
        {
            ConvenioImplement oConvenioImplement = new ConvenioImplement();
            DataTable         dtConvenios        = oConvenioImplement.GetConveniosBySocioDT(_idSocio);

            this.dgvConvenio.DataSource = dtConvenios;
        }
예제 #3
0
        private void btnTransferir_Click(object sender, EventArgs e)
        {
            convenios         oConvenios         = new convenios();
            ConvenioImplement oConvenioImplement = new ConvenioImplement();
            DataGridViewRow   row = this.dgvConvenio.CurrentRow;

            if (row != null)
            {
                int _idConvenio             = Convert.ToInt32(row.Cells[1].Value);
                Buscadores.frmBuscarSocio f = new Buscadores.frmBuscarSocio();
                f.Text = "Facturas Seleccion";
                int _idSocioATransferir = 0;
                if (f.ShowDialog() == DialogResult.OK)
                {
                    _idSocioATransferir = f.ValorIdRetorno;
                    if (_idSocioATransferir > 0)
                    {
                        oConvenios          = oConvenioImplement.Get(_idConvenio);
                        oConvenios.id_socio = _idSocioATransferir;
                        oConvenioImplement.Update(oConvenios);
                        CargarConveniosBySocio();
                    }
                    else
                    {
                        frmVentanaInformativa frmInfo = new frmVentanaInformativa("No se selecciono ningun socio.");
                        frmInfo.ShowDialog();
                    }
                }
            }
        }
예제 #4
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();
        }
예제 #5
0
        private void btnEliminarConvenio_Click(object sender, EventArgs e)
        {
            convenios         oConvenios         = new convenios();
            ConvenioImplement oConvenioImplement = new ConvenioImplement();
            DataGridViewRow   row = this.dgvConvenio.CurrentRow;

            if (row != null)
            {
                int _facturadas = Convert.ToInt32(row.Cells[6].Value);
                if (_facturadas == 0)
                {
                    _idConvenio = Convert.ToInt32(row.Cells[1].Value);
                    //limpio facturas
                    oConvenioImplement.Delete(_idConvenio);
                    CargarConveniosBySocio();
                }
                else
                {
                    frmVentanaInformativa f = new frmVentanaInformativa("No se puede eliminar convenio si hay cuotas facturadas.");
                    f.ShowDialog();
                }
            }
        }
        public facturas_detalles getDetalle(int idSocio, decimal cargoFijo, decimal abono, decimal valorM3, cod_conceptos oConcepto, facturas oFactura, conceptos_particulares oConceptoParticular)
        {
            SocioMedicionImplement oSocioMedicionImpl = new SocioMedicionImplement();
                                    socios_mediciones oSocioMedicion = new socios_mediciones();
                                    if (oFactura.id_medicion.Value!=0)
                                        oSocioMedicion = oSocioMedicionImpl.Get(oFactura.id_medicion.Value);
                                    acciones oAccion = new acciones();
                                    AccionImplement oAccionesImplement = new AccionImplement();

                                    facturas_detalles oDetalle = new facturas_detalles();
                                    oDetalle.idOrden = oConcepto.orden_concepto;
                                    oDetalle.id_concepto = oConcepto.id_concepto;
                                    oDetalle.idTipo = 0;
                                    oDetalle.id_factura = oFactura.id_factura;

                                    ConvenioImplement oConvenioImplement = new ConvenioImplement();
                                    switch (oConcepto.id_formula)
                                    {
                                        case 0:

                                            oDetalle.importe = cargoFijo;

                                            break;
                                        case 1:

                                            if (cargoFijo> 0)
                                            {
                                                oDetalle.importe = cargoFijo * oConcepto.variable.Value;
                                            }
                                            else
                                            {
                                                if (oFactura.id_medicion.Value != 0)
                                                {//revisar
                                                    if ((oSocioMedicion.consumo - abono) <= 0)
                                                    {
                                                        // Si no hubo consumo excedente ...
                                                        oDetalle.importe = abono * valorM3 * oConcepto.variable.Value;
                                                    }
                                                    else
                                                    {
                                                        //  Si hubo consumo excedente ...
                                                        decimal uno = (abono * valorM3);
                                                        decimal dos = ((oSocioMedicion.consumo.Value - abono) * valorM3);
                                                        oDetalle.importe = (uno + dos) * oConcepto.variable.Value;
                                                    }
                                                }
                                                else
                                                {
                                                    //Por que no tiene medidor usa el abono
                                                    oDetalle.importe = abono * valorM3 * oConcepto.variable.Value;
                                                }
                                            }
                                            break;
                                        case 2:
                                            // Consumo excedente por ValorM3
                                            // (Facturas.Consumo - Socios.Tarifa->Abono) *
                                            // Socios.Tarifa->ValorM3

                                              if (oFactura.id_medicion.Value != 0)
                                                {
                                                    oSocioMedicion = oSocioMedicionImpl.Get(oFactura.id_medicion.Value);
                                                if ((oSocioMedicion.consumo.Value - abono) > 0)
                                                {
                                                    //        ' Calcula sólo sobre el consumo excedente
                                                    oDetalle.importe = (oSocioMedicion.consumo.Value - abono) * valorM3;

                                                }
                                                else
                                                {
                                                    //  No hubo consumo excedente
                                                    oDetalle.importe = 0;
                                                }
                                                }else
                                                  oDetalle.importe = 0;

                                            break;
                                        case 3:
                                            //  ' Abono por ValorM3
                                            //' Socios.Tarifa->Abono * Socios.Tarifa->ValorM3
                                            oDetalle.importe = abono * valorM3;
                                            break;
                                        case 4:

                                            //' Consumo por ValorM3 por Variable
                                            //' Facturas.Consumo * Socios.Tarifa->ValorM3 * Conceptos.Variable
                                            if (oFactura.id_medicion.Value != 0)
                                            oDetalle.importe = oSocioMedicion.consumo.Value * valorM3 * oConcepto.variable.Value;
                                            else
                                                oDetalle.importe = 0;
                                            break;

                                        case 5:

                                            oAccion = oAccionesImplement.GetByIdSocio(idSocio);
                                            if (oAccion != null)
                                            {
                                                if (oAccion.cuotas > oAccion.facturadas)
                                                {
                                                    oAccion.facturadas = oAccion.facturadas + 1;
                                                    oAccionesImplement.Update(oAccion);
                                                    oDetalle.importe = oAccion.valor_cuota;
                                                }
                                                else { oDetalle.importe = 0; }
                                            }
                                            else { oDetalle.importe = 0; }

                                            break;
                                        case 6:
                                            // Variable por Cuota Acciones
                                            // Acciones.ValorCuota * Conceptos.Variable
                                            // Buscar Acciones
                                            oAccion = oAccionesImplement.GetByIdSocio(idSocio);
                                            // Si encuentra un registro
                                            if (oAccion != null)
                                            {
                                                // Pregunta si no está finalizado
                                                if (oAccion.cuotas > oAccion.facturadas)
                                                {
                                                    //Si no ha finalizado se factura una cuota más
                                                    oAccion.facturadas = oAccion.facturadas + 1;
                                                    oAccionesImplement.Update(oAccion);
                                                    oDetalle.importe = oAccion.valor_cuota * oConcepto.variable.Value;
                                                }
                                                else { oDetalle.importe = 0; }
                                            }
                                            else { oDetalle.importe = 0; }
                                            break;
                                        case 7:

                                            // Cuota Convenio de pago
                                            // Convenios.ValorCuota
                                            decimal ImporteConvenios = 0;
                                            // Inicializa el campo en cero
                                            oDetalle.importe = 0;
                                            // Buscar Convenio
                                            IList ListConvenios = oConvenioImplement.GetAllBySocio(idSocio);
                                            foreach (convenios oConvenio in ListConvenios)
                                            {
                                                //  Verifica que no se trate de un convenio judicial
                                                if (!oConvenio.convenio_judicial.Value)
                                                {
                                                    //Pregunta si no está finalizado
                                                    if (oConvenio.cuotas > oConvenio.facturadas)
                                                    {
                                                        //Si no ha finalizado se factura una cuota más
                                                        oConvenio.facturadas = oConvenio.facturadas + 1;
                                                        if (oConvenio.cuotas == oConvenio.facturadas) { oConvenio.finalizado = true; }
                                                        oConvenioImplement.Update(oConvenio);
                                                        ImporteConvenios = ImporteConvenios + oConvenio.valor_cuota;
                                                    }
                                                }
                                            }
                                            oDetalle.importe = ImporteConvenios;
                                            break;
                                        case 8:
                                            // Variable por Cuota Convenio
                                            // Convenios.ValorCuota * Conceptos.Variable
                                            // Buscar Convenio
                                            IList ListaConvenios = oConvenioImplement.GetAllBySocio(idSocio);
                                            //Si encuentra un registro
                                            oDetalle.importe = 0;
                                            foreach (convenios oConvenio in ListaConvenios)
                                            {
                                                //  Verifica que no se trate de un convenio judicial
                                                if (!oConvenio.convenio_judicial.Value)
                                                {
                                                    //Pregunta si no está finalizado
                                                    if (oConvenio.cuotas > oConvenio.facturadas)
                                                    {
                                                        oConvenio.facturadas = oConvenio.facturadas + 1;
                                                        oConvenioImplement.Update(oConvenio);
                                                        oDetalle.importe = oConvenio.valor_cuota * oConcepto.variable.Value;
                                                    }
                                                    else
                                                    {
                                                        oDetalle.importe = 0;
                                                    }
                                                }
                                                else { oDetalle.importe = 0; }
                                            }

                                            break;
                                        case 9:
                                            //Importe fijo según concepto
                                            // Conceptos.Variable
                                            oDetalle.importe = oConcepto.variable.Value;
                                            break;
                                        case 10:
                                            // Importe variable que se calcula en el momento
                                            // (NO IMPLEMENTADO)
                                            break;
                                        case 11:
                                            // Importe fijo según Conceptos Particulares
                                            // ConceptosPartic.Importe
                                            oDetalle.importe = oConceptoParticular.importe;
                                            break;
                                    }

                                    return oDetalle;
        }
        public facturas_detalles getDetalle(int idSocio, decimal cargoFijo, decimal abono, decimal valorM3, cod_conceptos oConcepto, facturas oFactura, conceptos_particulares oConceptoParticular)
        {
            SocioMedicionImplement oSocioMedicionImpl = new SocioMedicionImplement();
            socios_mediciones      oSocioMedicion     = new socios_mediciones();

            if (oFactura.id_medicion.Value != 0)
            {
                oSocioMedicion = oSocioMedicionImpl.Get(oFactura.id_medicion.Value);
            }
            acciones        oAccion            = new acciones();
            AccionImplement oAccionesImplement = new AccionImplement();

            facturas_detalles oDetalle = new facturas_detalles();

            oDetalle.idOrden     = oConcepto.orden_concepto;
            oDetalle.id_concepto = oConcepto.id_concepto;
            oDetalle.idTipo      = 0;
            oDetalle.id_factura  = oFactura.id_factura;


            ConvenioImplement oConvenioImplement = new ConvenioImplement();

            switch (oConcepto.id_formula)
            {
            case 0:

                oDetalle.importe = cargoFijo;

                break;

            case 1:

                if (cargoFijo > 0)
                {
                    oDetalle.importe = cargoFijo * oConcepto.variable.Value;
                }
                else
                {
                    if (oFactura.id_medicion.Value != 0)
                    {                            //revisar
                        if ((oSocioMedicion.consumo - abono) <= 0)
                        {
                            // Si no hubo consumo excedente ...
                            oDetalle.importe = abono * valorM3 * oConcepto.variable.Value;
                        }
                        else
                        {
                            //  Si hubo consumo excedente ...
                            decimal uno = (abono * valorM3);
                            decimal dos = ((oSocioMedicion.consumo.Value - abono) * valorM3);
                            oDetalle.importe = (uno + dos) * oConcepto.variable.Value;
                        }
                    }
                    else
                    {
                        //Por que no tiene medidor usa el abono
                        oDetalle.importe = abono * valorM3 * oConcepto.variable.Value;
                    }
                }
                break;

            case 2:
                // Consumo excedente por ValorM3
                // (Facturas.Consumo - Socios.Tarifa->Abono) *
                // Socios.Tarifa->ValorM3


                if (oFactura.id_medicion.Value != 0)
                {
                    oSocioMedicion = oSocioMedicionImpl.Get(oFactura.id_medicion.Value);
                    if ((oSocioMedicion.consumo.Value - abono) > 0)
                    {
                        //        ' Calcula sólo sobre el consumo excedente
                        oDetalle.importe = (oSocioMedicion.consumo.Value - abono) * valorM3;
                    }
                    else
                    {
                        //  No hubo consumo excedente
                        oDetalle.importe = 0;
                    }
                }
                else
                {
                    oDetalle.importe = 0;
                }

                break;

            case 3:
                //  ' Abono por ValorM3
                //' Socios.Tarifa->Abono * Socios.Tarifa->ValorM3
                oDetalle.importe = abono * valorM3;
                break;

            case 4:

                //' Consumo por ValorM3 por Variable
                //' Facturas.Consumo * Socios.Tarifa->ValorM3 * Conceptos.Variable
                if (oFactura.id_medicion.Value != 0)
                {
                    oDetalle.importe = oSocioMedicion.consumo.Value * valorM3 * oConcepto.variable.Value;
                }
                else
                {
                    oDetalle.importe = 0;
                }
                break;

            case 5:

                oAccion = oAccionesImplement.GetByIdSocio(idSocio);
                if (oAccion != null)
                {
                    if (oAccion.cuotas > oAccion.facturadas)
                    {
                        oAccion.facturadas = oAccion.facturadas + 1;
                        oAccionesImplement.Update(oAccion);
                        oDetalle.importe = oAccion.valor_cuota;
                    }
                    else
                    {
                        oDetalle.importe = 0;
                    }
                }
                else
                {
                    oDetalle.importe = 0;
                }

                break;

            case 6:
                // Variable por Cuota Acciones
                // Acciones.ValorCuota * Conceptos.Variable
                // Buscar Acciones
                oAccion = oAccionesImplement.GetByIdSocio(idSocio);
                // Si encuentra un registro
                if (oAccion != null)
                {
                    // Pregunta si no está finalizado
                    if (oAccion.cuotas > oAccion.facturadas)
                    {
                        //Si no ha finalizado se factura una cuota más
                        oAccion.facturadas = oAccion.facturadas + 1;
                        oAccionesImplement.Update(oAccion);
                        oDetalle.importe = oAccion.valor_cuota * oConcepto.variable.Value;
                    }
                    else
                    {
                        oDetalle.importe = 0;
                    }
                }
                else
                {
                    oDetalle.importe = 0;
                }
                break;

            case 7:

                // Cuota Convenio de pago
                // Convenios.ValorCuota
                decimal ImporteConvenios = 0;
                // Inicializa el campo en cero
                oDetalle.importe = 0;
                // Buscar Convenio
                IList ListConvenios = oConvenioImplement.GetAllBySocio(idSocio);
                foreach (convenios oConvenio in ListConvenios)
                {
                    //  Verifica que no se trate de un convenio judicial
                    if (!oConvenio.convenio_judicial.Value)
                    {
                        //Pregunta si no está finalizado
                        if (oConvenio.cuotas > oConvenio.facturadas)
                        {
                            //Si no ha finalizado se factura una cuota más
                            oConvenio.facturadas = oConvenio.facturadas + 1;
                            if (oConvenio.cuotas == oConvenio.facturadas)
                            {
                                oConvenio.finalizado = true;
                            }
                            oConvenioImplement.Update(oConvenio);
                            ImporteConvenios = ImporteConvenios + oConvenio.valor_cuota;
                        }
                    }
                }
                oDetalle.importe = ImporteConvenios;
                break;

            case 8:
                // Variable por Cuota Convenio
                // Convenios.ValorCuota * Conceptos.Variable
                // Buscar Convenio
                IList ListaConvenios = oConvenioImplement.GetAllBySocio(idSocio);
                //Si encuentra un registro
                oDetalle.importe = 0;
                foreach (convenios oConvenio in ListaConvenios)
                {
                    //  Verifica que no se trate de un convenio judicial
                    if (!oConvenio.convenio_judicial.Value)
                    {
                        //Pregunta si no está finalizado
                        if (oConvenio.cuotas > oConvenio.facturadas)
                        {
                            oConvenio.facturadas = oConvenio.facturadas + 1;
                            oConvenioImplement.Update(oConvenio);
                            oDetalle.importe = oConvenio.valor_cuota * oConcepto.variable.Value;
                        }
                        else
                        {
                            oDetalle.importe = 0;
                        }
                    }
                    else
                    {
                        oDetalle.importe = 0;
                    }
                }

                break;

            case 9:
                //Importe fijo según concepto
                // Conceptos.Variable
                oDetalle.importe = oConcepto.variable.Value;
                break;

            case 10:
                // Importe variable que se calcula en el momento
                // (NO IMPLEMENTADO)
                break;

            case 11:
                // Importe fijo según Conceptos Particulares
                // ConceptosPartic.Importe
                oDetalle.importe = oConceptoParticular.importe;
                break;
            }

            return(oDetalle);
        }