private void validarDatosFactura() { if (string.IsNullOrWhiteSpace(textBoxNumeroFactura.Text)) { throw new CampoVacioException("Numero Factura"); } if (string.IsNullOrWhiteSpace(textBoxImporte.Text)) { throw new CampoVacioException("Importe"); } if (string.IsNullOrWhiteSpace(comboBoxEmpresa.Text)) { throw new CampoVacioException("Empresa"); } if (dateTimePickerFechaVencimiento == null) { throw new CampoVacioException("Fecha de Vencimiento"); } if (Importe <= 0) { throw new ValorNegativoException("Importe"); } if (esFacturaYaAgregada(NumeroFactura)) { throw new FacturaYaAgregadaException(NumeroFactura.ToString()); } if (!Factura.esFacturaExistente(NumeroFactura)) { throw new FacturaInexistenteException(NumeroFactura.ToString()); } if (!Factura.esFacturaHabilitada(NumeroFactura)) { throw new FacturaInhabilitadaException(NumeroFactura.ToString()); } if (Factura.estaCobrada(NumeroFactura)) { throw new FacturaYaCobradaException(NumeroFactura.ToString()); } if (!Factura.esFacturaDeLaEmpresa(NumeroFactura, empresaSeleccionada.id)) { throw new EmpresaFacturaException(NumeroFactura.ToString(), empresaSeleccionada.nombre); } if (!Factura.verificaFechaVencimiento(NumeroFactura, FechaVencimiento)) { throw new FacturaFechaVencimientoException(NumeroFactura.ToString(), FechaVencimiento.ToString()); } if (!Factura.esImporteCorrecto(NumeroFactura, Importe)) { throw new ImporteFacturaException(NumeroFactura.ToString()); } ComparadorFechas comparar = new ComparadorFechas(); if (comparar.esMenor(FechaVencimiento, FechaCobro)) { throw new ExpireDateBeforeException("Factura vencida controle las fechas"); } }
public static bool verificaFechaVencimiento(String numero_factura, DateTime fecha_vencimiento_ingresada) { Factura factura = getFactura(Convert.ToInt32(numero_factura)); ComparadorFechas comparadorFechas = new ComparadorFechas(); return(comparadorFechas.esIgual(fecha_vencimiento_ingresada, factura.fecha_vencimiento)); }
public void CompararFechaActual_FechaEventoInvalida_LanzaExcepcion() { //Arrange DateTime fechaEvento = new DateTime(); Mock <ICreadorMensajeTiempo> creadorMensajetiempoMock = new Mock <ICreadorMensajeTiempo>(); ComparadorFechas comparadorFechas = new ComparadorFechas(creadorMensajetiempoMock.Object); //Act //Assert Assert.ThrowsException <ArgumentException>(() => comparadorFechas.CompararFechaActual(fechaEvento)); }
private void validarFiltroBusqueda() { if (DNICliente < 0) { throw new ValorNegativoException("DNI Cliente"); } ComparadorFechas comparador = new ComparadorFechas(); if (comparador.esMenor(FechaHasta, FechaDesde)) { throw new rangoFechasException("Fecha Hasta/Desde"); } }
public void CompararFechaActual_FechaEventoInvalida_DevuelveMensajeEnExcepcion() { //Arrange string expected = "El formato de fecha es inválido"; DateTime fechaEvento = new DateTime(); Mock <ICreadorMensajeTiempo> creadorMensajetiempoMock = new Mock <ICreadorMensajeTiempo>(); ComparadorFechas comparadorFechas = new ComparadorFechas(creadorMensajetiempoMock.Object); //Act //Assert ArgumentException exception = Assert.ThrowsException <ArgumentException>(() => comparadorFechas.CompararFechaActual(fechaEvento)); Assert.AreEqual(expected, exception.Message); }
private bool verificaValidacionesFactura() { epProvider.Clear(); if (!formularioFacturaCompleto()) { return(false); } if (!facturaVerificaTiposDeDatos()) { return(false); } if (FacturasRepositorio.esFacturaExistente(tx_numero_factura.Text)) { MessageBox.Show("Ya existe una factura con el numero ingresado", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (tabla_items.Rows.Count == 0) { MessageBox.Show("No se han registrado items para la factura", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } DateTime fecha_alta = date_fecha_alta_factura.Value; DateTime fecha_vencimiento = date_vencimiento_factura.Value; ComparadorFechas comparadorFechas = new ComparadorFechas(); if (comparadorFechas.esMenor(fecha_vencimiento, fecha_alta)) { MessageBox.Show("La fecha de vencimiento no puede ser menor a la fecha de alta", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (comparadorFechas.esMenor(fecha_vencimiento, DateTime.Now)) { MessageBox.Show("La fecha de vencimiento no puede ser menor al dia de hoy", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (comparadorFechas.esMenor(DateTime.Now, fecha_alta)) { MessageBox.Show("La fecha de alta no puede ser mayor al dia de hoy", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }
public void CompararFechaActual_FechaEventoMayorActual_DevulveMensajeOcurrira() { //Arrange string mensaje = "mensajeTiempo"; string expected = "ocurrirá en " + mensaje; Mock <ICreadorMensajeTiempo> creadorMensajetiempoMock = new Mock <ICreadorMensajeTiempo>(); creadorMensajetiempoMock.Setup(m => m.CrearMensajeTiempo(It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(mensaje); ComparadorFechas comparadorFechas = new ComparadorFechas(creadorMensajetiempoMock.Object); DateTime fechaEvento = DateTime.Now.AddDays(+1); //Act string act = comparadorFechas.CompararFechaActual(fechaEvento); //Assert Assert.AreEqual(expected, act); }
private void validar() { if (string.IsNullOrWhiteSpace(textBoxDNICliente.Text)) { throw new CampoVacioException("DNI Cliente"); } if (!Cliente.esClienteExistente(Convert.ToDecimal(textBoxDNICliente.Text))) { throw new ClienteInexistenteException(textBoxDNICliente.Text); } if (string.IsNullOrWhiteSpace(textBoxNumeroFactura.Text)) { throw new CampoVacioException("Numero de Factura"); } if (Empresa == null) { throw new EmpresaNoSeleccionadaException(); // valido los datos ingresados } if (dateTimePickerFechaAlta == null) { throw new CampoVacioException("Fecha de Alta"); } if (dateTimePickerFechaVencimiento == null) { throw new CampoVacioException("Fecha de Vencimiento"); } if (DataGridViewDetalleFactura.RowCount < 1) { throw new CampoVacioException("Items facturas (debe ingresar al menos 1 Item)"); } ComparadorFechas comparar = new ComparadorFechas(); if (comparar.esMenor(FechaVencimiento, FechaAlta)) { throw new ExpireDateBeforeException("Corrija las fechas de alta con las de vencimiento. Fecha de alta debe ser anterior al vencimiento."); } if (comparar.esMenor(FechaVencimiento, Program.FechaEjecucion)) { throw new ExpireDateBeforeException("Corrija la fecha de vencimiento para que sea posterior a la fecha actual"); } }
public bool verificaValidacionesFactura() { bool error = true; errorProvider1.Clear(); if (!verificaFormularioCompleto()) { return(error); } if (!verificaTiposDatosFactura()) { return(error); } DateTime fecha_vencimiento = date_fecha_vencimiento.Value; DateTime fecha_actual = DateTime.Now; if (!clienteDefinido()) { inicializarCliente(); } else { if (this.cliente != Convert.ToInt32(combo_clientes.Text)) { MessageBox.Show("El pago solo puede realizarse para un unico cliente", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(error); } } if (esFacturaYaAgregadaParaPagar(tx_numero_factura.Text)) { MessageBox.Show("La factura ya fue ingresada para pagar", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(error); } if (!FacturasRepositorio.esFacturaExistente(tx_numero_factura.Text)) { MessageBox.Show("La factura no existe", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(error); } if (FacturasRepositorio.esFacturaPagada(tx_numero_factura.Text)) { MessageBox.Show("La factura ya fue pagada", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(error); } if (!FacturasRepositorio.esFacturaHabilitada(tx_numero_factura.Text)) { MessageBox.Show("La factura no esta habilitada para pagar", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(error); } if (!EmpresasRepositorio.esEmpresaHabilitada(((Empresa)(combo_empresas.SelectedItem)).cuit)) { MessageBox.Show("La empresa no esta habilitada", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(error); } if (!FacturasRepositorio.esFacturaDelCliente(tx_numero_factura.Text, combo_clientes.Text)) { MessageBox.Show("La factura no le corresponde al cliente", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(error); } if (!FacturasRepositorio.esFacturaDeLaEmpresa(tx_numero_factura.Text, ((Empresa)combo_empresas.SelectedItem).cuit)) { MessageBox.Show("La factura no le corresponde a la empresa", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(error); } if (Convert.ToDouble(tx_importe.Text) <= 0) { MessageBox.Show("El importe ingresado no puede ser menor o igual a 0", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(error); } if (!FacturasRepositorio.verificaFechaVencimiento(tx_numero_factura.Text, fecha_vencimiento)) { MessageBox.Show("La fecha de vencimiento ingresada no coincide con la fecha de vencimiento de la factura", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(error); } ComparadorFechas comparadorFechas = new ComparadorFechas(); if (comparadorFechas.esMenor(fecha_vencimiento, fecha_actual)) { MessageBox.Show("La fecha de vencimiento ha expirado, el cliente debera regularizar su situacion con su proveedor del servicio", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(error); } if (!FacturasRepositorio.esImporteCorrecto(tx_numero_factura.Text, tx_importe.Text)) { MessageBox.Show("El importe ingresado no coincide con el importe de la factura", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(error); } error = false; return(error); }