### Install SDKSimpleFactura via NuGet Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Instructions for installing the SDKSimpleFactura package using .NET CLI, NuGet CLI, and Visual Studio Package Manager. ```bash # Usando .NET CLI dotnet add package SDKSimpleFactura # Usando NuGet CLI nuget install SDKSimpleFactura # Usando Package Manager en Visual Studio PM> Install-Package SDKSimpleFactura ``` -------------------------------- ### Install SDK SimpleFactura using NuGet CLI Source: https://github.com/lpinedozav/sdksimplefactura/blob/main/README.md This command installs the SDK SimpleFactura package using the NuGet command-line interface. Ensure NuGet is installed and configured. ```bash nuget install SDKSimpleFactura ``` -------------------------------- ### Add Products to Catalog using C# Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt This code example shows how to register new products in the SDKSimpleFactura catalog. It involves creating a request object with product details such as name, barcode, price, and unit of measure. The operation requires issuer credentials and product information. Successful execution indicates the number of products added. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; using SDKSimpleFactura.Models.Request; var client = new SimpleFacturaClient(); var request = new DatoExternoRequest { Credenciales = new Credenciales { RutEmisor = "76269769-6", NombreSucursal = "Casa Matriz" }, Productos = new List { new NuevoProductoExternoRequest { Nombre = "Servicio de Desarrollo Web", CodigoBarra = "SERVDEV001", Precio = 150000, UnidadMedida = "un", Exento = false, TieneImpuestos = false, Impuestos = new int[] { 0 } } } }; var result = await client.Productos.AgregarProductosAsync(request); if (result.Status == 200) { Console.WriteLine($"Productos agregados: {result.Data.Count}"); } ``` -------------------------------- ### Configure SDK SimpleFactura Credentials in appsettings.json Source: https://github.com/lpinedozav/sdksimplefactura/blob/main/README.md Example configuration for the SDK SimpleFactura in the appsettings.json file. This includes essential credentials like Username, Password, and the BaseUrl for API communication. ```json { "SDKSettings": { "Username": "demo@chilesystems.com", "Password": "Rv8Il4eV", "BaseUrl": "https://api.simplefactura.cl" } } ``` -------------------------------- ### Download PDF of Received Document using C# Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt This code example shows how to download the PDF of a document received from a supplier using SDKSimpleFactura. It requires issuer credentials, the document's folio, and its type. The PDF data is then saved to a local file. The operation returns the PDF content as a byte array. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; using SDKSimpleFactura.Models.Request; using static SDKSimpleFactura.Enum.TipoDTE; var client = new SimpleFacturaClient(); var request = new ListaDteRequest { Credenciales = new Credenciales { RutEmisor = "76269769-6", RutContribuyente = "76269769-6" }, Ambiente = 0, Folio = 2232, CodigoTipoDte = DTEType.FacturaElectronica }; var result = await client.Proveedores.ObtenerPDFAsync(request); if (result.Status == 200 && result.Data != null) { File.WriteAllBytes("documento_recibido.pdf", result.Data); Console.WriteLine("PDF guardado exitosamente"); } ``` -------------------------------- ### Install SDK SimpleFactura using .NET CLI Source: https://github.com/lpinedozav/sdksimplefactura/blob/main/README.md This command adds the SDK SimpleFactura package to your .NET project using the .NET CLI. It's a convenient way to manage project dependencies. ```bash dotnet add package SDKSimpleFactura ``` -------------------------------- ### GET /facturacion/consolidado-ventas Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Generates a consolidated sales report for a specific period. ```APIDOC ## GET /facturacion/consolidado-ventas ### Description Obtains a consolidated report of sales by period. ### Method GET ### Endpoint /facturacion/consolidado-ventas ### Parameters #### Request Body - **Credenciales** (object) - Required - Issuer credentials - **Desde** (date) - Required - Start date - **Hasta** (date) - Required - End date ### Response #### Success Response (200) - **Data** (array) - List of sales report objects (TipoDte, Cantidad, MontoTotal) ``` -------------------------------- ### List Received DTEs using C# Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt This example shows how to retrieve a list of received tax documents (DTEs) from suppliers using the SDKSimpleFactura. It requires issuer credentials, an environment type, and a date range. The output includes the count of received DTEs and details for each, such as folio, supplier name, and total amount. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; using SDKSimpleFactura.Models.Request; using SDKSimpleFactura.Enum; var client = new SimpleFacturaClient(); var request = new ListaDteRequest { Credenciales = new Credenciales { RutEmisor = "76269769-6" }, Ambiente = Ambiente.AmbienteEnum.Produccion, Desde = DateTime.Parse("2024-04-01"), Hasta = DateTime.Parse("2024-04-30") }; var result = await client.Proveedores.ListadoDtesRecibidosAsync(request); if (result.Status == 200) { Console.WriteLine($"DTEs recibidos: {result.Data.Count}"); foreach (var dte in result.Data) { Console.WriteLine($"Folio: {dte.Folio}, Proveedor: {dte.RazonSocialEmisor}, Total: ${dte.Total}"); } } ``` -------------------------------- ### GET /proveedores/xml Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Retrieves the XML file for a specific received document. ```APIDOC ## GET /proveedores/xml ### Description Retrieves the XML content of a received document based on the provided credentials and folio. ### Method GET ### Endpoint /proveedores/xml ### Parameters #### Request Body - **Credenciales** (object) - Required - RutEmisor and RutContribuyente. - **Folio** (int) - Required - The document folio number. - **CodigoTipoDte** (int) - Required - The DTE type code. ### Response #### Success Response (200) - **Data** (byte[]) - The XML file content. #### Response Example { "Status": 200, "Data": "[binary_data]" } ``` -------------------------------- ### GET /boletas/pdf Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Downloads the PDF version of an issued or received fee note (Boleta de Honorarios). ```APIDOC ## GET /boletas/pdf ### Description Downloads the PDF file for a specific fee note (BHE) by providing the folio and issuer credentials. ### Method GET ### Endpoint /boletas/pdf ### Parameters #### Request Body - **Credenciales** (object) - Required - Authentication details. - **Folio** (int) - Required - The fee note folio number. ### Response #### Success Response (200) - **Data** (byte[]) - The PDF file content. ``` -------------------------------- ### List Products from Catalog using C# Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt This snippet demonstrates how to retrieve a list of all registered products from the SDKSimpleFactura catalog. It requires issuer credentials and optionally a branch name. The output includes the total count of products and details for each product, such as barcode, name, and price. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; var client = new SimpleFacturaClient(); var credenciales = new Credenciales { RutEmisor = "76269769-6", NombreSucursal = "Casa Matriz" }; var result = await client.Productos.ListarProductosAsync(credenciales); if (result.Status == 200) { Console.WriteLine($"Total productos: {result.Data.Count}"); foreach (var producto in result.Data) { Console.WriteLine($"Código: {producto.CodigoBarra}, Nombre: {producto.Nombre}, Precio: ${producto.Precio}"); } } ``` -------------------------------- ### GET /facturacion/trazas Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Queries the history of states and events for a specific issued document. ```APIDOC ## GET /facturacion/trazas ### Description Retrieves the state history of a DTE. ### Method GET ### Endpoint /facturacion/trazas ### Parameters #### Request Body - **DteReferenciadoExterno** (object) - Required - Folio and TipoDte of the document ### Response #### Success Response (200) - **Data** (array) - List of event objects (Fecha, Estado) ``` -------------------------------- ### Initialize SimpleFacturaClient in C# Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Demonstrates how to initialize the SimpleFacturaClient in C# and access various service interfaces like Facturacion, Productos, Proveedores, etc. ```csharp using SDKSimpleFactura; class Program { static void Main() { var SimpleFacturaClient = new SimpleFacturaClient(); // Acceso a los servicios disponibles var facturacionService = SimpleFacturaClient.Facturacion; var productosService = SimpleFacturaClient.Productos; var proveedoresService = SimpleFacturaClient.Proveedores; var clientesService = SimpleFacturaClient.Clientes; var sucursalService = SimpleFacturaClient.Sucursal; var folioService = SimpleFacturaClient.Folio; var configuracionService = SimpleFacturaClient.Configuracion; var boletaHonorariosService = SimpleFacturaClient.BoletasHonorarios; } } ``` -------------------------------- ### Initialize SimpleFacturaClient in C# Source: https://github.com/lpinedozav/sdksimplefactura/blob/main/README.md Demonstrates how to initialize the SimpleFacturaClient in C# using the SDK. This client is the entry point for accessing various services like Facturacion, Productos, and Clientes. ```csharp using SDKSimpleFactura; class Program { static void Main() { var SimpleFacturaClient = new SimpleFacturaClient(); // Ejemplo: Uso de los servicios var facturacionService = SimpleFacturaClient.Facturacion; var productosService = SimpleFacturaClient.Productos; var proveedoresService = SimpleFacturaClient.Proveedores; var clientesService = SimpleFacturaClient.Clientes; var sucursalService = SimpleFacturaClient.Sucursal; var folioService = SimpleFacturaClient.Folio; var configuracionService = SimpleFacturaClient.Configuracion; var boletaHonorariosService = SimpleFacturaClient.BoletasHonorarios; } } ``` -------------------------------- ### Get Document Traza History Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Consults the historical status and event logs for a specific issued document. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; var client = new SimpleFacturaClient(); var request = new SolicitudDte { Credenciales = new Credenciales { RutEmisor = "76269769-6" }, DteReferenciadoExterno = new DteReferenciadoExterno { Folio = 1738, CodigoTipoDte = 61, Ambiente = 0 } }; var result = await client.Facturacion.GetTrazasEmitidosAsync(request); if (result.Status == 200) { foreach (var traza in result.Data) { Console.WriteLine($"Fecha: {traza.Fecha}, Estado: {traza.Estado}"); } } ``` -------------------------------- ### GET /facturacion/listado-dtes Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Retrieves a list of issued electronic tax documents based on date ranges and document types. ```APIDOC ## GET /facturacion/listado-dtes ### Description Retrieves a list of issued DTEs filtered by date range and type. ### Method GET ### Endpoint /facturacion/listado-dtes ### Parameters #### Request Body - **Credenciales** (object) - Required - Authentication details including RutEmisor and NombreSucursal - **Desde** (datetime) - Required - Start date for the filter - **Hasta** (datetime) - Required - End date for the filter - **CodigoTipoDte** (int) - Optional - Specific DTE type code ### Response #### Success Response (200) - **Data** (array) - List of DTE objects containing Folio, TipoDte, and Total #### Response Example { "Status": 200, "Data": [{"Folio": 123, "TipoDte": 33, "Total": 10000}] } ``` -------------------------------- ### Facturación Masiva desde CSV con SDKSimpleFactura Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Este snippet muestra cómo procesar un archivo CSV para emitir múltiples documentos tributarios de forma masiva. Se define un contenido CSV de ejemplo con los datos necesarios para la facturación y se utiliza el método FacturacionMasivaAsync del cliente SDKSimpleFactura. El archivo CSV se crea temporalmente y luego se elimina. Requiere la inicialización del cliente y la definición de credenciales. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; var client = new SimpleFacturaClient(); var credenciales = new Credenciales { RutEmisor = "76269769-6", NombreSucursal = "Casa Matriz" }; // Crear archivo CSV temporal con datos de facturación var csvContent = @"Id;TipoDte;FmaPago;FechaEmision;Vencimiento;RutRecep;GiroRecep;Contacto;CorreoRecep;DirRecep;CmnaRecep;CiudadRecep;RazonSocialRecep;DirDest;CmnaDest;CiudadDest;ReferenciaTpoDocRef;ReferenciaFolioRef;ReferenciaFchRef;ReferenciaRazonRef;ReferenciaCodigo;CodigoProducto;NombreProducto;DescripcionProducto;CantidadProducto;PrecioProducto;UnidadMedidaProducto;DescuentoProducto;RecargoProducto;IndicadorExento;TotalProducto 1;33;2;06-11-2024;06-12-2024;27808803-0;Reparación de vehículos;98765412;contacto@cliente.cl;Av. 21 de Mayo 547;Providencia;Santiago;Reparadora de vehículos SpA;Av. 21 de Mayo 547;Providencia;Santiago;;;;;;1347864355;REPUESTO DJ11-18;REPUESTO DJ11-18;61;99843;UN;0;0;0;6090423 2;33;2;06-11-2024;06-12-2024;27808803-0;Reparación de vehículos;98765412;contacto@cliente.cl;Av. 21 de Mayo 547;Providencia;Santiago;Reparadora de vehículos SpA;Av. 21 de Mayo 547;Providencia;Santiago;;;;;;1795083977;REPUESTO WB45-469;REPUESTO WB45-469;51;90843;UN;0;0;0;4632993"; var tempFilePath = Path.GetTempFileName(); File.WriteAllText(tempFilePath, csvContent); var result = await client.Facturacion.FacturacionMasivaAsync(credenciales, tempFilePath); File.Delete(tempFilePath); if (result.Status == 200 && result.Data) { Console.WriteLine($"Facturación masiva procesada: {result.Message}"); } ``` -------------------------------- ### Emitir Nota de Crédito/Débito Electrónica con SDKSimpleFactura Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Este snippet demuestra cómo emitir una nota de crédito electrónica referenciando un documento original. Se especifican los detalles del encabezado, receptor, totales y el detalle de la nota, incluyendo la referencia al documento anulado. Requiere la inicialización del cliente SDKSimpleFactura y la construcción de un objeto RequestDTE. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; using SDKSimpleFactura.Models.Request; using SDKSimpleFactura.Enum; var client = new SimpleFacturaClient(); var request = new RequestDTE { Documento = new Documento { Encabezado = new Encabezado { IdDoc = new IdentificacionDTE { TipoDTE = TipoDTE.DTEType.NotaCreditoElectronica, // Código 61 FchEmis = DateTime.Now, FmaPago = FormaPago.FormaPagoEnum.Credito, FchVenc = DateTime.Now.AddMonths(6), Folio = 5678 // Folio obtenido previamente }, Emisor = new Emisor { RUTEmisor = "76269769-6", RznSoc = "SERVICIOS INFORMATICOS CHILESYSTEMS EIRL", GiroEmis = "Desarrollo de software", Telefono = new List { "912345678" }, CorreoEmisor = "contacto@chilesystems.com", Acteco = new List { 620900 }, DirOrigen = "Chile", CmnaOrigen = "Santiago", CiudadOrigen = "Santiago" }, Receptor = new Receptor { RUTRecep = "77225200-5", RznSocRecep = "ARRENDADORA DE VEHÍCULOS S.A.", GiroRecep = "Venta de vehículos", CorreoRecep = "terceros@empresa.com", DirRecep = "Rondizzoni 2130", CmnaRecep = "SANTIAGO", CiudadRecep = "SANTIAGO" }, Totales = new Totales { MntNeto = 6930000, TasaIVA = 19, IVA = 1316700, MntTotal = 8246700 } }, Detalle = new List { new Detalle { NroLinDet = 1, NmbItem = "CERRADURA DE SEGURIDAD SATURN EVO", CdgItem = new List { new CodigoItem { TpoCodigo = "4", VlrCodigo = "EVO_2" } }, QtyItem = 42.0, UnmdItem = "unid", PrcItem = 319166.0, MontoItem = 6930000 } }, Referencia = new List { new Referencia { NroLinRef = 1, TpoDocRef = "33", // Factura electrónica FolioRef = "1268", FchRef = DateTime.Parse("2024-10-17"), CodRef = TipoReferencia.TipoReferenciaEnum.AnulaDocumentoReferencia, RazonRef = "Anulación de factura por error en datos" } } } }; var result = await client.Facturacion.EmisionNC_NDV2Async( "Casa Matriz", ReasonTypeEnum.Otros, request ); if (result.Status == 200) { Console.WriteLine($"Nota de crédito emitida: Folio {result.Data.Folio}"); } ``` -------------------------------- ### Search Client by RUT using C# Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt This snippet demonstrates how to search for a specific client using their RUT (tax identification number) with the SDKSimpleFactura client. It requires valid credentials and a RUT to perform the search. The output includes the client's name, business activity (Giro), and address if found. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; var client = new SimpleFacturaClient(); var credenciales = new Credenciales { RutEmisor = "76269769-6" }; var result = await client.Clientes.ClientXRutAsync(credenciales, "17096073-4"); if (result.Status == 200) { Console.WriteLine($"Cliente encontrado: {result.Data.RznSocRecep}"); Console.WriteLine($"Giro: {result.Data.GiroRecep}"); Console.WriteLine($"Dirección: {result.Data.DirRecep}"); } ``` -------------------------------- ### Generar factura de exportación electrónica en C# Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Este código demuestra la creación de un objeto RequestDTE configurado para exportaciones. Incluye la estructura necesaria para el encabezado, detalles del receptor extranjero, información logística de aduanas y el cálculo de totales en moneda extranjera. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; using SDKSimpleFactura.Models.Request; using SDKSimpleFactura.Enum; var client = new SimpleFacturaClient(); var exportacion = new RequestDTE { Exportaciones = new Exportaciones { Encabezado = new Encabezado { IdDoc = new IdentificacionDTE { TipoDTE = TipoDTE.DTEType.FacturaExportacionElectronica, FchEmis = DateTime.Now, FmaPago = FormaPago.FormaPagoEnum.Credito, FchVenc = DateTime.Now.AddMonths(5), Folio = 12345 }, Emisor = new Emisor { RUTEmisor = "76269769-6", RznSoc = "Chilesystems", GiroEmis = "Desarrollo de software", Telefono = new List { "912345678" }, CorreoEmisor = "exportaciones@chilesystems.com", Acteco = new List { 620200 }, DirOrigen = "Calle 7 numero 3", CmnaOrigen = "Santiago", CiudadOrigen = "Santiago" }, Receptor = new Receptor { RUTRecep = "55555555-5", RznSocRecep = "CLIENTE INTERNACIONAL EXP IMP", Extranjero = new Extranjero { NumId = "331-555555", Nacionalidad = CodigosAduana.Paises.Uruguay }, GiroRecep = "Importador Internacional", CorreoRecep = "cliente@internacional.com", DirRecep = "Dirección Internacional", CmnaRecep = "Montevideo", CiudadRecep = "Montevideo" }, Transporte = new Transporte { Aduana = new Aduana { CodModVenta = CodigosAduana.ModalidadVenta.AValoFOB, CodClauVenta = CodigosAduana.ClausulaCompraVenta.FOB, TotClauVenta = 1984.65, CodViaTransp = CodigosAduana.ViasdeTransporte.Maritima, CodPtoEmbarque = CodigosAduana.Puertos.Valparaiso, CodPtoDesemb = CodigosAduana.Puertos.Montevideo, PesoBruto = 10.65, CodUnidPesoBruto = CodigosAduana.UnidadMedida.Kilogramos, PesoNeto = 9.56, CodUnidPesoNeto = CodigosAduana.UnidadMedida.Kilogramos, TotBultos = 30, TipoBultos = new List { new TipoBulto { CodTpoBultos = CodigosAduana.TipoBultoEnum.Contenedor, CantBultos = 30, IdContainer = "CONT-001", Sello = "SELLO-001", EmisorSello = "CONTENEDOR" } }, MntFlete = 965.1, MntSeguro = 10.25, CodPaisRecep = CodigosAduana.Paises.Uruguay, CodPaisDestin = CodigosAduana.Paises.Uruguay } }, Totales = new Totales { TpoMoneda = CodigosAduana.Moneda.DolarEstadounidense, MntExe = 1000, MntTotal = 1000 }, OtraMoneda = new OtraMoneda { TpoMoneda = CodigosAduana.Moneda.PesoChileno, TpoCambio = 800.36, MntExeOtrMnda = 45454.36, MntTotOtrMnda = 45454.36 } }, Detalle = new List { new DetalleExportacion { NroLinDet = 1, CdgItem = new List { new CodigoItem { TpoCodigo = "INT1", VlrCodigo = "39" } }, IndExe = IndicadorFacturacionExencionEnum.NoAfectoOExento, NmbItem = "CHATARRA DE ALUMINIO", DscItem = "Material reciclado de alta calidad", QtyItem = 1, UnmdItem = "U", PrcItem = 1000, MontoItem = 1000 } } }, Observaciones = "Exportación a Uruguay" }; var result = await client.Facturacion.FacturacionIndividualV2ExportacionAsync("Casa Matriz", exportacion); if (result.Status == 200) { Console.WriteLine($"Factura de exportación generada: Folio {result.Data.Folio}"); } ``` -------------------------------- ### Generate Individual DTE Invoice using C# Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt This C# code snippet demonstrates how to generate an individual electronic tax document (Factura Electrónica) using the SDKSimpleFactura client. It includes setting up the request with details for the header, issuer, receiver, line items, and totals. The code also shows how to handle the response, checking for success or error messages. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; using SDKSimpleFactura.Models.Request; using static SDKSimpleFactura.Enum.TipoDTE; using static SDKSimpleFactura.Enum.FormaPago; var client = new SimpleFacturaClient(); var sucursal = "Casa_Matriz"; var request = new RequestDTE { Documento = new Documento { Encabezado = new Encabezado { IdDoc = new IdentificacionDTE { TipoDTE = DTEType.FacturaElectronica, // Código 33 FchEmis = DateTime.Now, FmaPago = FormaPagoEnum.Credito, FchVenc = DateTime.Now.AddMonths(6) }, Emisor = new Emisor { RUTEmisor = "76269769-6", RznSoc = "SERVICIOS INFORMATICOS CHILESYSTEMS EIRL", GiroEmis = "Desarrollo de software", Telefono = new List { "912345678" }, CorreoEmisor = "contacto@chilesystems.com", Acteco = new List { 620200 }, DirOrigen = "Calle 7 numero 3", CmnaOrigen = "Santiago", CiudadOrigen = "Santiago" }, Receptor = new Receptor { RUTRecep = "17096073-4", RznSocRecep = "Hotel Iquique", GiroRecep = "Hotelería", CorreoRecep = "cliente@hotel.com", DirRecep = "Calle 12", CmnaRecep = "Paine", CiudadRecep = "Santiago" }, Totales = new Totales { MntNeto = 832, TasaIVA = 19, IVA = 158, MntTotal = 990 } }, Detalle = new List { new Detalle { NroLinDet = 1, NmbItem = "Alfajor", CdgItem = new List { new CodigoItem { TpoCodigo = "ALFA", VlrCodigo = "123" } }, QtyItem = 1, UnmdItem = "un", PrcItem = 831.932773, MontoItem = 832 } } }, Observaciones = "NOTA AL PIE DE PAGINA", TipoPago = "30 dias" }; var result = await client.Facturacion.FacturacionIndividualV2DTEAsync(sucursal, request); if (result.Status == 200) { Console.WriteLine($"Factura generada exitosamente"); Console.WriteLine($"Folio: {result.Data.Folio}"); Console.WriteLine($"RUT Emisor: {result.Data.RUTEmisor}"); Console.WriteLine($"RUT Receptor: {result.Data.RUTReceptor}"); } else { Console.WriteLine($"Error: {result.Message}"); } ``` -------------------------------- ### Agregar Clientes Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Registers one or more new clients into the system. Requires detailed customer information including RUT, address, and contact emails. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; using SDKSimpleFactura.Models.Request; var client = new SimpleFacturaClient(); var request = new DatoExternoRequest { Credenciales = new Credenciales { RutEmisor = "76269769-6", NombreSucursal = "Matriz" }, Clientes = new List { new NuevoReceptorExternoRequest { Rut = "57681892-0", RazonSocial = "Cliente Ejemplo SpA", Giro = "Servicios de Consultoría", DirPart = "Av. Principal 123", DirFact = "Av. Principal 123", CorreoPar = "contacto@cliente.cl", CorreoFact = "facturacion@cliente.cl", Ciudad = "Santiago", Comuna = "Providencia" } } }; var result = await client.Clientes.AgregarClientesAsync(request); if (result.Status == 200) { Console.WriteLine($"Clientes agregados: {result.Data.Count}"); } ``` -------------------------------- ### POST /facturacion/ceder-factura Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Initiates a factoring process by assigning a document to a third party. ```APIDOC ## POST /facturacion/ceder-factura ### Description Assigns a document to a third party for factoring. ### Method POST ### Endpoint /facturacion/ceder-factura ### Parameters #### Request Body - **RutEmpresa** (string) - Required - Issuer RUT - **RutCesionario** (string) - Required - Assignee RUT - **Folio** (int) - Required - Document folio ### Response #### Success Response (200) - **Data** (string) - Assignment code ``` -------------------------------- ### Servicio de Productos API Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt APIs for managing products in the catalog. ```APIDOC ## Agregar Productos ### Description Registers new products in the catalog. ### Method POST ### Endpoint /api/productos/agregarproductos ### Parameters #### Request Body - **Credenciales** (object) - Required - Authentication credentials. - **RutEmisor** (string) - Required - The RUT of the issuer. - **NombreSucursal** (string) - Optional - The name of the branch. - **Productos** (array) - Required - A list of products to add. - **Nombre** (string) - Required - The name of the product. - **CodigoBarra** (string) - Required - The product's barcode. - **Precio** (number) - Required - The price of the product. - **UnidadMedida** (string) - Required - The unit of measure. - **Exento** (boolean) - Required - Whether the product is tax-exempt. - **TieneImpuestos** (boolean) - Required - Whether the product has taxes. - **Impuestos** (array of integers) - Required - List of tax codes. ### Request Example ```json { "credenciales": { "rutEmisor": "76269769-6", "nombreSucursal": "Casa Matriz" }, "productos": [ { "nombre": "Servicio de Desarrollo Web", "codigoBarra": "SERVDEV001", "precio": 150000, "unidadMedida": "un", "exento": false, "tieneImpuestos": false, "impuestos": [0] } ] } ``` ### Response #### Success Response (200) - **Status** (integer) - The status code of the response. - **Data** (object) - Contains information about the added products. - **Count** (integer) - The number of products added. #### Response Example ```json { "status": 200, "data": { "count": 1 } } ``` ``` ```APIDOC ## Listar Productos ### Description Retrieves all registered products. ### Method POST ### Endpoint /api/productos/listarproductos ### Parameters #### Request Body - **Credenciales** (object) - Required - Authentication credentials. - **RutEmisor** (string) - Required - The RUT of the issuer. - **NombreSucursal** (string) - Optional - The name of the branch. ### Request Example ```json { "credenciales": { "rutEmisor": "76269769-6", "nombreSucursal": "Casa Matriz" } } ``` ### Response #### Success Response (200) - **Status** (integer) - The status code of the response. - **Data** (array) - A list of products. - **CodigoBarra** (string) - The product's barcode. - **Nombre** (string) - The name of the product. - **Precio** (number) - The price of the product. #### Response Example ```json { "status": 200, "data": [ { "codigoBarra": "PROD001", "nombre": "Producto A", "precio": 10000 }, { "codigoBarra": "PROD002", "nombre": "Producto B", "precio": 20000 } ] } ``` ``` -------------------------------- ### Retrieve Company Configuration Data in C# Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Retrieves the configuration information for the issuing company, such as legal name, RUT, business line (giro), and address. This is useful for verifying company settings within the SDK. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; var client = new SimpleFacturaClient(); var credenciales = new Credenciales { RutEmisor = "76269769-6" }; var result = await client.Configuracion.DatosEmpresaAsync(credenciales); if (result.Status == 200) { Console.WriteLine($"Razón Social: {result.Data.RazonSocial}"); Console.WriteLine($"RUT: {result.Data.Rut}"); Console.WriteLine($"Giro: {result.Data.Giro}"); Console.WriteLine($"Dirección: {result.Data.Direccion}"); } ``` -------------------------------- ### Obtener PDF de DTE en C# Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Downloads a tax document (DTE) in PDF format, ready for printing or sending. It requires the client to be initialized and a SolicitudDte object with necessary credentials and DTE information. The output is a byte array representing the PDF file. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; var client = new SimpleFacturaClient(); var solicitud = new SolicitudDte { Credenciales = new Credenciales { RutEmisor = "76269769-6", NombreSucursal = "Casa Matriz" }, DteReferenciadoExterno = new DteReferenciadoExterno { Folio = 4117, CodigoTipoDte = 33, // Factura Electrónica Ambiente = 0 // 0 = Certificación, 1 = Producción } }; var result = await client.Facturacion.ObtenerPdfDteAsync(solicitud); if (result.Status == 200 && result.Data != null) { File.WriteAllBytes("factura_4117.pdf", result.Data); Console.WriteLine("PDF guardado exitosamente"); } ``` -------------------------------- ### Consultar DTE en C# Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Retrieves comprehensive information about an issued tax document. It utilizes the SimpleFacturaClient and a SolicitudDte object to specify the document. The response includes details such as folio, environment, recipient's name and RUT, total amount, and line item details. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; var client = new SimpleFacturaClient(); var solicitud = new SolicitudDte { Credenciales = new Credenciales { RutEmisor = "76269769-6", NombreSucursal = "Casa Matriz" }, DteReferenciadoExterno = new DteReferenciadoExterno { Folio = 12553, CodigoTipoDte = 39, Ambiente = 0 } }; var result = await client.Facturacion.ObtenerDteAsync(solicitud); if (result.Status == 200) { Console.WriteLine($"Folio: {result.Data.Folio}"); Console.WriteLine($"Ambiente: {result.Data.Ambiente}"); Console.WriteLine($"Receptor: {result.Data.RazonSocialReceptor}"); Console.WriteLine($"RUT Receptor: {result.Data.RutReceptor}"); Console.WriteLine($"Total: {result.Data.Total}"); foreach (var detalle in result.Data.Detalles) { Console.WriteLine($" - {detalle.Nombre}: ${detalle.Total}"); } } ``` -------------------------------- ### Obtener Timbre del DTE en C# Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Fetches the electronic seal (PDF417 barcode) of a tax document for verification purposes. It uses the SimpleFacturaClient and a SolicitudDte object. The result contains the seal data and a message, typically indicating the DTE's details. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; var client = new SimpleFacturaClient(); var solicitud = new SolicitudDte { Credenciales = new Credenciales { RutEmisor = "76269769-6", NombreSucursal = "Casa Matriz" }, DteReferenciadoExterno = new DteReferenciadoExterno { Folio = 4117, CodigoTipoDte = 33, Ambiente = 0 } }; var result = await client.Facturacion.ObtenerTimbreDteAsync(solicitud); if (result.Status == 200) { Console.WriteLine($"Timbre: {result.Data}"); Console.WriteLine($"Mensaje: {result.Message}"); // Output: "Timbre del DTE tipo FacturaElectronica con folio 4117 de la empresa 76269769-6" } ``` -------------------------------- ### Obtener Sobre XML para Envío Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Generates the XML envelope for sending to the SII or the document recipient. ```APIDOC ## Obtener Sobre XML para Envío ### Description Generates the XML envelope for sending to the SII or the document recipient. ### Method POST ### Endpoint /api/facturacion/obtenerSobreXmlDte ### Parameters #### Path Parameters - **tipoSobreEnvio** (TipoSobreEnvio) - Required - Specifies the recipient of the envelope ('AlSII' or 'AlReceptor'). #### Request Body - **Credenciales** (object) - Required - Credentials for authentication. - **RutEmisor** (string) - Required - RUT of the issuer. - **DteReferenciadoExterno** (object) - Required - Information about the referenced tax document. - **Folio** (integer) - Required - The folio number of the DTE. - **CodigoTipoDte** (integer) - Required - The type code of the DTE. - **Ambiente** (integer) - Required - The environment (0 for Certification, 1 for Production). ### Request Example ```json { "Credenciales": { "RutEmisor": "76269769-6" }, "DteReferenciadoExterno": { "Folio": 2393, "CodigoTipoDte": 33, "Ambiente": 0 } } ``` ### Response #### Success Response (200) - **Data** (string) - The XML content of the envelope. #### Response Example ```xml ... ``` ``` -------------------------------- ### Listar Clientes Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Retrieves a list of all clients registered for a specific issuer. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; var client = new SimpleFacturaClient(); var credenciales = new Credenciales { RutEmisor = "76269769-6" }; var result = await client.Clientes.ListarClientesAsync(credenciales); if (result.Status == 200) { Console.WriteLine($"Total clientes: {result.Data.Count}"); foreach (var cliente in result.Data) { Console.WriteLine($"RUT: {cliente.Rut}, Razón Social: {cliente.RazonSocial}"); } } ``` -------------------------------- ### POST /facturacion/masiva Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Processes multiple electronic tax documents from a provided CSV file. ```APIDOC ## POST /facturacion/masiva ### Description Allows issuing multiple tax documents from a CSV file with a predefined format. ### Method POST ### Endpoint /facturacion/masiva ### Parameters #### Request Body - **Credenciales** (object) - Required - Authentication and branch details. - **FilePath** (string) - Required - Path to the local CSV file containing invoice data. ### Request Example { "RutEmisor": "76269769-6", "NombreSucursal": "Casa Matriz", "FilePath": "/tmp/invoices.csv" } ### Response #### Success Response (200) - **Success** (boolean) - Indicates if the process was successful. - **Message** (string) - Status message regarding the bulk operation. #### Response Example { "Status": 200, "Data": true, "Message": "Facturación masiva procesada" } ``` -------------------------------- ### Obtener Sobre XML para Envío en C# Source: https://context7.com/lpinedozav/sdksimplefactura/llms.txt Generates the XML envelope required for submitting a tax document to the SII or the recipient. This function requires the SDK client, a SolicitudDte object, and specifies the type of envelope (to SII or to Recipient). The output is an XML file. ```csharp using SDKSimpleFactura; using SDKSimpleFactura.Models.Facturacion; using SDKSimpleFactura.Enum; var client = new SimpleFacturaClient(); var solicitud = new SolicitudDte { Credenciales = new Credenciales { RutEmisor = "76269769-6" }, DteReferenciadoExterno = new DteReferenciadoExterno { Folio = 2393, CodigoTipoDte = 33, Ambiente = 0 } }; // Opciones: TipoSobreEnvio.AlSII o TipoSobreEnvio.AlReceptor var result = await client.Facturacion.ObtenerSobreXmlDteAsync(solicitud, TipoSobreEnvio.AlSII); if (result.Status == 200 && result.Data != null) { File.WriteAllBytes("sobre_envio_sii.xml", result.Data); Console.WriteLine("Sobre XML guardado exitosamente"); } ```