//Cuenta por Cobrar public CuentaPorCobrar AgregarNuevaCuentaPorCobrar(double pReferencia, DateTime pFechaVencimiento, decimal pPagoDocumentoNacional, decimal pPagoDocumentoExtranjera, decimal pSaldoDocumentoNacional, decimal pSaldoDocumentoExtranjera, int pDiasDeGracia, decimal pNumeroVale, string pCodigoEstadoDocumento, string pCodigoDiaDePago, string pCodigoTipoDocumentoReferencia) { if (string.IsNullOrEmpty(pCodigoEstadoDocumento.Trim()) || string.IsNullOrEmpty(pCodigoDiaDePago.Trim()) || pReferencia <= 0) { throw new ArgumentException(Mensajes.excepcion_DatosNoValidosParaLineaCuentaPorCobrar); } var nuevaLineaCuentaPorCobrar = new CuentaPorCobrar(this.NumeroDocumento, this.CodigoMoneda, this.CodigoClaseTipoCambio, pCodigoEstadoDocumento.Trim(), pCodigoDiaDePago.Trim(), this.CodigoAlmacen, this.CodigoUsuarioDeSistema, this.CodigoTipoDocumento, this.CodigoCliente, pCodigoTipoDocumentoReferencia, pReferencia, DateTime.Now, this.FechaProceso, pFechaVencimiento, this.TotalNacional, this.TotalExtranjera, pPagoDocumentoNacional, pPagoDocumentoExtranjera, pSaldoDocumentoNacional, pSaldoDocumentoExtranjera, this.RucCliente, this.TipoCambio, pDiasDeGracia, pNumeroVale); nuevaLineaCuentaPorCobrar.GenerarNuevaIdentidad(); this.CuentasPorCobrar.Add(nuevaLineaCuentaPorCobrar); return(nuevaLineaCuentaPorCobrar); }
public Entidad consultarCuenta(int idCuenta) { String cadenaConexion = ConfigurationManager.ConnectionStrings["ConnUricao"].ToString(); SqlConnection conexion = new SqlConnection(); SqlCommand cmd = new SqlCommand(); SqlDataReader dr; Entidad objetoCuenta = FabricaEntidad.NuevaCuentaPorCobrar(); // List<CuentaPorCobrar> lalista = new List<CuentaPorCobrar>(); try { conexion = new SqlConnection(cadenaConexion); conexion.Open(); cmd = new SqlCommand("dbo.ConsultarCuenta", conexion); cmd.CommandType = CommandType.StoredProcedure; SqlParameter param = new SqlParameter("@idCuenta", idCuenta); cmd.Parameters.Add(param); // cmd.Parameters.AddWithValue("@cedula", "v-19293743"); dr = cmd.ExecuteReader(); while (dr.Read()) { objetoCuenta = new CuentaPorCobrar(); (objetoCuenta as CuentaPorCobrar).Id = (Convert.ToInt32(dr.GetValue(0))); (objetoCuenta as CuentaPorCobrar).Estado = dr.GetValue(1).ToString(); } db.CerrarConexion(); } catch (Exception e) { } finally { db.CerrarConexion(); } return(objetoCuenta); }
public CuadrarCuentaCobrarModal(FactoryManager factoryManager, CuentaPorCobrar cuentaPorCobrar) { InitializeComponent(); _factoryManager = factoryManager; _cuentaCobrarManager = factoryManager.CrearCuentaPorCobrarManager; _cuentaPorCobrar = cuentaPorCobrar; _montosPagos = cuentaPorCobrar.Pagos; dtgMontosPagos.ItemsSource = _montosPagos; txtNombreProveedor.Text = cuentaPorCobrar.Venta.NombreProveedor ?? ""; txtRazonSocialProveedor.Text = cuentaPorCobrar.Venta.RazonSocialProveedor ?? ""; txtDniProveedor.Text = cuentaPorCobrar.Venta.Dni ?? ""; txtRucProveedor.Text = cuentaPorCobrar.Venta.Ruc ?? ""; var nfi = new NumberFormatInfo { NumberDecimalSeparator = ".", NumberGroupSeparator = "," }; _amount = cuentaPorCobrar.Venta.Productos.Sum(x => x.Total); txtTotalDeuda.Text = _amount.ToString("#,##0.00", nfi); UpdateTotal(); }
private async void btnSave_Click(object sender, RoutedEventArgs e) { btnSave.IsEnabled = false; btnClose.IsEnabled = false; if (Productos.Count < 1 || string.IsNullOrWhiteSpace(txtNombreApellidoProveedor.Text) && string.IsNullOrWhiteSpace(txtRazonSocialProveedor.Text)) { DialogResult result = CustomMessageBox.Show("Todos los cambios son obligatorios", CustomMessageBox.CMessageBoxTitle.Advertencia, CustomMessageBox.CMessageBoxButton.Aceptar, CustomMessageBox.CMessageBoxButton.Cancelar); btnSave.IsEnabled = true; btnClose.IsEnabled = true; return; } Venta venta = new Venta { IdCliente = StaticParameters.ClienteSelected.Id, TipoCliente = StaticParameters.ClienteSelected.TipoCliente, NombreProveedor = txtNombreApellidoProveedor.Text, RazonSocialProveedor = txtRazonSocialProveedor.Text, Dni = txtDniProveedor.Text, Ruc = txtRucProveedor.Text, SerieDocumento = txtSerieDocumento.Text, NumeroDocumento = txtNumeroDocumento.Text, Productos = Productos, TipoVenta = (TipoVenta)cmbTipo.SelectedItem, Credito = (bool)chkCredito.IsChecked }; if (venta.TipoVenta == TipoVenta.NotaDeVenta) { if (_ventaManager.Insertar(venta) != null && venta.Credito) { CuentaPorCobrar cuentaPorCobrar = new CuentaPorCobrar { Venta = venta, TipoCliente = venta.TipoCliente, TotalCobrar = venta.Productos.Sum(x => x.Total), Balance = venta.Productos.Sum(x => x.Total), }; _cuentaPorCobrarManager.Insertar(cuentaPorCobrar); } } else if (venta.TipoVenta == TipoVenta.Boleta) { BoletaResponse response = await ConsultaEmitirRecibo.Envio_seguro_boleta(venta); if (response.success) { venta.ExternalId = response.data.external_id; venta.Hash = response.data.hash; venta.Qr = response.data.qr; venta.linkPdf = response.links.pdf; venta.linkXml = response.links.xml; venta.linkCdr = response.links.cdr; if (_ventaManager.Insertar(venta) != null && venta.Credito) { CuentaPorCobrar cuentaPorCobrar = new CuentaPorCobrar { Venta = venta, TipoCliente = venta.TipoCliente, TotalCobrar = venta.Productos.Sum(x => x.Total), Balance = venta.Productos.Sum(x => x.Total), }; _cuentaPorCobrarManager.Insertar(cuentaPorCobrar); } } else { DialogResult result = CustomMessageBox.Show(response.message, CustomMessageBox.CMessageBoxTitle.Advertencia, CustomMessageBox.CMessageBoxButton.Aceptar, CustomMessageBox.CMessageBoxButton.Cancelar); btnSave.IsEnabled = true; btnClose.IsEnabled = true; return; } } else if (venta.TipoVenta == TipoVenta.Factura) { FacturaReponse response = await ConsultaEmitirRecibo.Envio_seguro_factura(venta); if (response.success) { venta.ExternalId = response.data.external_id; venta.Hash = response.data.hash; venta.Qr = response.data.qr; venta.linkPdf = response.links.pdf; venta.linkXml = response.links.xml; venta.linkCdr = response.links.cdr; if (_ventaManager.Insertar(venta) != null && venta.Credito) { CuentaPorCobrar cuentaPorCobrar = new CuentaPorCobrar { Venta = venta, TipoCliente = venta.TipoCliente, TotalCobrar = venta.Productos.Sum(x => x.Total), Balance = venta.Productos.Sum(x => x.Total), }; _cuentaPorCobrarManager.Insertar(cuentaPorCobrar); } } else { DialogResult result = CustomMessageBox.Show(response.message, CustomMessageBox.CMessageBoxTitle.Advertencia, CustomMessageBox.CMessageBoxButton.Aceptar, CustomMessageBox.CMessageBoxButton.Cancelar); btnSave.IsEnabled = true; btnClose.IsEnabled = true; return; } } DialogResult = true; Close(); if (venta.TipoVenta != TipoVenta.NotaDeVenta) { Process.Start(venta?.linkPdf); } }