Ejemplo n.º 1
0
        public DocumentoElectronico()
        {
            Exportacion        = new Exportacion {
            };
            DocumentoRetencion = new DocumentoRetencion {
            };
            ItemRetencion      = new ItemRetencion {
            };

            Emisor = new Contribuyente
            {
                TipoDocumento = "6" // RUC.
            };

            Receptor = new Contribuyente
            {
                TipoDocumento = "6" // RUC.   //REG. UNICO DE CONTRIBUYENTES - VER CATALAGO Nº 6 TABLA 2
            };
            CalculoIgv        = 0.18m;
            CalculoIsc        = 0.10m;
            CalculoDetraccion = 0.04m;
            Items             = new List <DetalleDocumento>();
            DatoAdicionales   = new List <DatoAdicional>();
            Relacionados      = new List <DocumentoRelacionado>();
            Discrepancias     = new List <Discrepancia>();
            //TipoDocumento = "01"; // Factura - 03 Boleta. - 07 NC - 08 ND
            TipoOperacion = "01";  // Venta Interna.
            Moneda        = "PEN"; // Soles.
        }
Ejemplo n.º 2
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;
            }
        }