private void AgregarConceptoComoParticular() { cod_conceptos oCod_Conceptos = new cod_conceptos(); ConceptoImplement oConceptoImplement = new ConceptoImplement(); conceptos_particulares oConceptosParticulares = new conceptos_particulares(); conceptosParticularesImplement oConceptosParticularesimplement = new conceptosParticularesImplement(); PeriodosImplement oPeriodosImplement = new PeriodosImplement(); string nuevoPeriodo = oPeriodosImplement.GetUltimoPeriodo(); if (nuevoPeriodo != "") { DataGridViewRow rowconcepto = this.dgvConceptos.CurrentRow; int idConcepto = Convert.ToInt32(rowconcepto.Cells[0].Value); oCod_Conceptos = oConceptoImplement.Get(idConcepto); oConceptosParticulares.id_concepto = idConcepto; oConceptosParticulares.id_socio = _idSocio; //oConceptosParticulares.id_factura = oCod_Conceptos.; oConceptosParticulares.id_periodo = nuevoPeriodo; oConceptosParticulares.importe = decimal.Parse(oCod_Conceptos.variable.ToString()); oConceptosParticulares.detalles = oCod_Conceptos.concepto; oConceptosParticulares.facturado = false; oConceptosParticularesimplement.Save(oConceptosParticulares); this.txtImporte.Text = oConceptosParticulares.importe.ToString(); this.cmbPeriodo.SelectedValue = oConceptosParticulares.id_periodo; } CargarGrillaConceptosParticulares(); btnActualizar.Visible = false; }
private void ActualizarConceptoParticular() { conceptos_particulares oConceptosParticulares = new conceptos_particulares(); conceptosParticularesImplement oConceptosParticularesimplement = new conceptosParticularesImplement(); DataGridViewRow row = this.dgvConceptosPart.CurrentRow; int id = Convert.ToInt32(row.Cells[0].Value); oConceptosParticulares = oConceptosParticularesimplement.Get(id); oConceptosParticulares.id_periodo = this.cmbPeriodo.SelectedValue.ToString(); oConceptosParticulares.importe = Decimal.Parse(this.txtImporte.Text); oConceptosParticularesimplement.Update(oConceptosParticulares); btnActualizar.Visible = false; }
private void Refacturar1() { decimal NetoConIVA = 0; decimal NetoSinIVA = 0; decimal SubTotal = 0; SocioConexionImplement oSocioConexionImplement = new SocioConexionImplement(); DataTable DTMedidores = oSocioConexionImplement.GetEstadosMedidores(); IList listaConceptos = new ConceptoImplement().GetActivosAll(); DataTable DTUsuariosAFacturar = oSocioConexionImplement.GetSociosAFacturar(_periodo, _idSocio); _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; if (DTUsuariosAFacturar.Rows[0]["medidor"].ToString() != "") { //preguntar como hago con la medicion? //socios_mediciones oSocioMedicionActual = new socios_mediciones(); //SocioMedicionImplement oSocioMedicionImplement = new SocioMedicionImplement(); //oSocioMedicionActual = oSocioMedicionImplement.ultimaMedicion(_idSocio); //socios_mediciones oSocioMedicionNew = new socios_mediciones(); //oSocioMedicionNew.fecha_lectura = null; //oSocioMedicionNew.id_socio =_idSocio; NetoConIVA = 0; NetoSinIVA = 0; foreach (cod_conceptos oConcepto in listaConceptos) { bool CorrespondeFacturar = false; if (DTUsuariosAFacturar.Rows[0]["medidor"].ToString() != "") { //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, _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); } } // 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 = 0; oFacDetalle.idOrden = oConceptoIVA.orden_concepto; oFacDetalle.idTipo = 0; oFacDetalle.importe = decimal.Round(NetoConIVA * decimal.Parse(DTUsuariosAFacturar.Rows[0]["iva"].ToString()) / 100, 2); AgregarDetalle(oFacDetalle); // Calcula Total _oFactura.importeTotal = _oFactura.importeNeto.Value + Convert.ToSingle(oFacDetalle.importe); //este ahi que ver el tipo de dato //// 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 = _idSocio; //oCuentaCorriente.importe_credito = 0; //oCuentaCorriente.importe_saldo = 0; //oCuentaCorriente.importe_debito = Convert.ToDecimal(oFactura.importeTotal); //oCuentaCorriente.id_cobranza = 0; //oCuentaCorrienteImplement.Save(oCuentaCorriente); } }
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); }
private void CargarGrillaConceptosParticulares() { conceptosParticularesImplement oConceptosParticularesImplement = new conceptosParticularesImplement(); this.dgvConceptosPart.DataSource = oConceptosParticularesImplement.GetByIdSocioDT(_idSocio); this.dgvConceptosPart.Enabled = true; btnActualizar.Visible = false; _eliminoCP = false; }
private void CargarDatosConceptoParticular() { if (!_eliminoCP) { conceptos_particulares oConceptosParticulares = new conceptos_particulares(); conceptosParticularesImplement oConceptosParticularesimplement = new conceptosParticularesImplement(); DataGridViewRow row = this.dgvConceptosPart.CurrentRow; int id = Convert.ToInt32(row.Cells[0].Value); oConceptosParticulares = oConceptosParticularesimplement.Get(id); this.txtImporte.Text = oConceptosParticulares.importe.ToString(); this.cmbPeriodo.SelectedValue = oConceptosParticulares.id_periodo; } }
private void btnQuitar_Click(object sender, EventArgs e) { _eliminoCP = true; conceptos_particulares oConceptosParticulares = new conceptos_particulares(); conceptosParticularesImplement oConceptosParticularesimplement = new conceptosParticularesImplement(); DataGridViewRow row = this.dgvConceptosPart.CurrentRow; if (row != null) { int id = Convert.ToInt32(row.Cells[0].Value); oConceptosParticularesimplement.Delete(id); } CargarGrillaConceptosParticulares(); }