public FrmDetalleDocumento(DetalleDocumento detalle, DocumentoElectronico documento)
        {
            InitializeComponent();
            _detalle   = detalle;
            _documento = documento;

            detalleDocumentoBindingSource.DataSource = detalle;
            detalleDocumentoBindingSource.ResetBindings(false);

            Load += (s, e) =>
            {
                using (var ctx = new OpenInvoicePeruDb())
                {
                    tipoImpuestoBindingSource.DataSource = ctx.TipoImpuestos.ToList();
                    tipoImpuestoBindingSource.ResetBindings(false);

                    tipoPrecioBindingSource.DataSource = ctx.TipoPrecios.ToList();
                    tipoPrecioBindingSource.ResetBindings(false);
                }
            };
            decimal sumar = 0;

            sumar = documento.Items.Count() + 1;
            idNumericUpDown.Value = (sumar);
        }
Example #2
0
 public FrmDocumento(DocumentoElectronico documento)
 {
     InitializeComponent();
     _documento     = documento;
     txtSerie.Text  = "B002";
     txtCorrel.Text = "1";
     CargaNumDocBaja();
     Inicializar();
 }
Example #3
0
        private void btnGenerar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (_frmDocumento == null)
                {
                    if (string.IsNullOrEmpty(txtNroRuc.Text))
                    {
                        _frmDocumento = new FrmDocumento();
                    }
                    else
                    {
                        var documento = new DocumentoElectronico
                        {
                            Emisor = { NroDocumento = txtNroRuc.Text, NombreLegal = "Empresa de Servicios Turísticos S.R.L.",      NombreComercial = "PLAYA COLAN LODGE",
                                       Ubigeo       = "200101",       Direccion   = "Calle Arequipa Nº 978 Piura - Piura - Piura",
                                       Departamento = "PIURA",        Provincia   = "PIURA",                                       Distrito        = "PIURA" },
                            FechaEmision = DateTime.Today.ToShortDateString()
                        };
                        _frmDocumento = new FrmDocumento(documento);
                    }
                }
                var rpta = _frmDocumento.ShowDialog(this);

                if (rpta != DialogResult.OK)
                {
                    return;
                }

                txtSource.Text           = _frmDocumento.RutaArchivo;
                txtSerieCorrelativo.Text = _frmDocumento.IdDocumento;
                _documento = _frmDocumento._documento2;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Example #4
0
        public FrmDocumento()
        {
            InitializeComponent();
            Numera = AdmNumera.BuscaNumeracionFac();
            string str = Convert.ToString(Numera.Numeracion);
            char   pad = '0';

            _documento = new DocumentoElectronico
            {
                FechaEmision = DateTime.Today.ToShortDateString(),
                //IdDocumento = Numera.Serie+ "-" + str.PadLeft(8, pad)
            };
            Inicializar();
            if (_documento.Receptor != null)
            {
                txtNroDocRec.Text      = _documento.Receptor.NroDocumento;
                txtNombreLegalRec.Text = _documento.Receptor.NombreLegal;
                txtDirRec.Text         = _documento.Receptor.Direccion;
            }
        }
Example #5
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            try {
                if (dgreten.Rows.Count > 0)
                {
                    _documento.DocumentoRetencion.Receptor.NroDocumento  = txtNroCliente.Text;
                    _documento.DocumentoRetencion.Receptor.TipoDocumento = cboTipoDocRec2.SelectedValue.ToString();
                    _documento.DocumentoRetencion.Receptor.NombreLegal   = txtNomCliente.Text;
                    _documento.DocumentoRetencion.IdDocumento            = txtCorrelativo3.Text;
                    _documento.DocumentoRetencion.FechaEmision           = DateTime.Today.ToString(FormatoFecha);
                    _documento.DocumentoRetencion.Moneda           = cboMoneda2.SelectedValue.ToString();
                    _documento.DocumentoRetencion.RegimenRetencion = "01";
                    _documento.DocumentoRetencion.TasaRetencion    = 3;


                    Decimal ImporteRetenido = 0, ImportePagado = 0;
                    foreach (DataGridViewRow row in dgreten.Rows)
                    {
                        ItemRetencion retencion = new ItemRetencion();
                        retencion.NroDocumento  = row.Cells[1].Value.ToString();
                        retencion.TipoDocumento = "01";
                        retencion.MonedaDocumentoRelacionado = row.Cells[3].Value.ToString();
                        retencion.FechaEmision        = DateTime.Today.ToString(FormatoFecha);
                        retencion.ImporteTotal        = Convert.ToDecimal(row.Cells[4].Value);
                        retencion.FechaPago           = row.Cells[2].Value.ToString();
                        retencion.NumeroPago          = Convert.ToInt32(row.Cells[0].Value);
                        retencion.ImporteSinRetencion = Convert.ToDecimal(row.Cells[4].Value) - Convert.ToDecimal(row.Cells[5].Value);
                        retencion.ImporteRetenido     = Convert.ToDecimal(row.Cells[5].Value);
                        retencion.FechaRetencion      = row.Cells[2].Value.ToString();
                        retencion.ImporteTotalNeto    = Convert.ToDecimal(row.Cells[4].Value);;
                        // retencion.TipoCambio = 3.41m;
                        //retencion.FechaTipoCambio = DateTime.Today.ToString(FormatoFecha);
                        ImporteRetenido += Convert.ToDecimal(row.Cells[5].Value);
                        ImportePagado    = Convert.ToDecimal(row.Cells[4].Value);
                        _documento.DocumentoRetencion.DocumentosRelacionados.Add(retencion);


                        //documentoReten.DocumentosRelacionados.Add(retencion);
                    }
                    _documento.DocumentoRetencion.ImporteTotalPagado   = ImportePagado;
                    _documento.DocumentoRetencion.ImporteTotalRetenido = ImporteRetenido;
                    _documento.DocumentoRetencion.Emisor = CrearEmisor();
                    _documento.MontoEnLetras             = ConvertLetras.enletras(_documento.DocumentoRetencion.ImporteTotalRetenido.ToString());

                    var RetenDoc      = GeneradorXML.GenerarRetention(_documento.DocumentoRetencion);
                    var serializador4 = new Serializador();
                    TramaXmlSinFirma = serializador4.GenerarXml(RetenDoc);
                    RutaArchivo      = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Documentos\\" +
                                                    $"{_documento.DocumentoRetencion.IdDocumento}.xml");
                    File.WriteAllBytes(RutaArchivo, Convert.FromBase64String(TramaXmlSinFirma));
                    IdDocumento  = _documento.DocumentoRetencion.IdDocumento;
                    _documento2  = _documento;
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("No hay Registros para Generar Documento");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Example #6
0
        private void toolGenerar_Click(object sender, EventArgs e)
        {
            try
            {
                if (cboTipoDoc.SelectedIndex == -1)
                {
                    MessageBox.Show("Seleccione un tipo de Documento Factura/Boleta");
                    return;
                }
                if (cboTipoDocRec.SelectedIndex == -1)
                {
                    MessageBox.Show("Seleccione un tipo de Documento para el Cliente..!");
                    return;
                }

                if (txtNroDocRec.Text == "")
                {
                    MessageBox.Show("Ingrese Tipo Documento Cliente");
                    txtNroDocRec.Focus();
                    return;
                }
                if (txtNombreLegalRec.Text == "")
                {
                    MessageBox.Show("Ingrese Nombre Legal Cliente");
                    txtNombreLegalRec.Focus();
                    return;
                }
                if (cboTipoDocRec.SelectedValue.ToString() == "1")
                {
                    cboTipoDocRec.MaxLength = 8;
                    if ((txtNroDocRec.Text.Length) < 8)
                    {
                        MessageBox.Show("Ingrese DNI Correcto");
                        txtNroDocRec.Focus();
                        return;
                    }
                }
                if (cboTipoDocRec.SelectedValue.ToString() == "6")
                {
                    cboTipoDocRec.MaxLength = 11;
                    if ((txtNroDocRec.Text.Length) < 11)
                    {
                        MessageBox.Show("Ingrese RUC Correcto");
                        txtNroDocRec.Focus();
                        return;
                    }
                }

                if (txtDirRec.Text == "")
                {
                    MessageBox.Show("Ingrese Dirección de Cliente..!");
                    txtDirRec.Focus();
                    return;
                }
                if (textBox17.Text == "")
                {
                    MessageBox.Show("Ingrese Correlativo del Documento..!");
                    textBox17.Focus();
                    return;
                }

                Cursor.Current = Cursors.WaitCursor;

                documentoElectronicoBindingSource.EndEdit();
                totalVentaTextBox.Focus();

                switch (_documento.TipoDocumento)
                {
                case "07":
                    //NotaCredito
                    var notaCredito   = GeneradorXML.GenerarCreditNote(_documento);
                    var serializador1 = new Serializador();
                    TramaXmlSinFirma = serializador1.GenerarXml(notaCredito);
                    break;

                case "08":
                    //GenerarNotaDebito
                    var notaDebito    = GeneradorXML.GenerarDebitNote(_documento);
                    var serializador2 = new Serializador();
                    TramaXmlSinFirma = serializador2.GenerarXml(notaDebito);
                    break;

                default:
                    var invoice       = GeneradorXML.GenerarInvoice(_documento);
                    var serializador3 = new Serializador();
                    TramaXmlSinFirma = serializador3.GenerarXml(invoice);
                    break;
                }



                RutaArchivo = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Documentos\\" +
                                           $"{_documento.IdDocumento}.xml");
                File.WriteAllBytes(RutaArchivo, Convert.FromBase64String(TramaXmlSinFirma));



                IdDocumento = _documento.IdDocumento;

                _documento2  = _documento;
                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }