Greeva.Xml 1.0.5

dotnet add package Greeva.Xml --version 1.0.5
                    
NuGet\Install-Package Greeva.Xml -Version 1.0.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Greeva.Xml" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Greeva.Xml" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Greeva.Xml" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Greeva.Xml --version 1.0.5
                    
#r "nuget: Greeva.Xml, 1.0.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Greeva.Xml@1.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Greeva.Xml&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Greeva.Xml&version=1.0.5
                    
Install as a Cake Tool

Greeva.Xml

XML generation and template engine for Greeva electronic invoicing using RazorLight templates.

Overview

Greeva.Xml provides XML document generation capabilities for all SUNAT electronic document types using RazorLight template engine with embedded CSHTML templates.

Key Features

  • RazorLight Templates: Powerful C# template engine for XML generation
  • UBL 2.1 Compliant: Generates valid UBL 2.1 XML documents
  • Embedded Templates: Pre-built templates for all document types
  • SUNAT Standards: Follows SUNAT technical specifications
  • Digital Signature Ready: XML structure prepared for digital signing

Supported Document Types

Electronic Invoices

  • Invoice 2.1: Standard electronic invoices
  • Credit Note 2.1: Credit note documents
  • Debit Note 2.1: Debit note documents

Summary Documents

  • Daily Summary: Resumen diario de documentos
  • Voided Documents: Comunicación de baja

Despatch Guides

  • Despatch Guide: Standard despatch guide
  • Despatch Guide 2022: Updated 2022 format
  • Embedded Despatch: Embedded despatch information

Other Documents

  • Perception: Perception documents
  • Retention: Retention documents

Usage

using Greeva.Xml.Builder;
using Greeva.Core.Domain.Sale;

// Create invoice builder
var invoiceBuilder = new InvoiceBuilder();

// Generate XML from invoice
var invoice = new Invoice 
{
    Serie = "F001",
    Correlativo = "123",
    // ... other properties
};

var xml = await invoiceBuilder.BuildAsync(invoice);
Console.WriteLine(xml);

Document Builders

InvoiceBuilder

var invoiceBuilder = new InvoiceBuilder();
var xml = await invoiceBuilder.BuildAsync(invoice);

NoteBuilder

var noteBuilder = new NoteBuilder();
var xml = await noteBuilder.BuildAsync(creditNote);

SummaryBuilder

var summaryBuilder = new SummaryBuilder();
var xml = await summaryBuilder.BuildAsync(summary);

DespatchBuilder

var despatchBuilder = new DespatchBuilder();
var xml = await despatchBuilder.BuildAsync(despatch);

Templates

All templates are embedded as resources and include:

  • invoice2.1.xml.cshtml: UBL 2.1 Invoice template
  • notacr2.1.xml.cshtml: UBL 2.1 Credit Note template
  • notadb2.1.xml.cshtml: UBL 2.1 Debit Note template
  • summary.xml.cshtml: Daily Summary template
  • voided.xml.cshtml: Voided Documents template
  • despatch.xml.cshtml: Standard Despatch Guide template
  • despatch2022.xml.cshtml: 2022 Despatch Guide template
  • embededDespatch.xml.cshtml: Embedded Despatch template
  • perception.xml.cshtml: Perception document template
  • retention.xml.cshtml: Retention document template

Template Engine Configuration

using RazorLight;

// Configure RazorLight for file-based templates
var engine = new RazorLightEngineBuilder()
    .UseFileSystemProject(Path.Combine(Directory.GetCurrentDirectory(), "Templates"))
    .UseMemoryCachingProvider()
    .Build();

// Configure for embedded resources
var engine = new RazorLightEngineBuilder()
    .UseEmbeddedResourcesProject(typeof(InvoiceBuilder).Assembly)
    .UseMemoryCachingProvider()
    .Build();

XML Output Example

Generated XML follows UBL 2.1 standard:

<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
         xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
         xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
    <cbc:UBLVersionID>2.1</cbc:UBLVersionID>
    <cbc:CustomizationID>2.0</cbc:CustomizationID>
    <cbc:ID>F001-123</cbc:ID>
    <cbc:IssueDate>2025-10-11</cbc:IssueDate>
    <cbc:InvoiceTypeCode listAgencyName="PE:SUNAT" listName="SUNAT:Identificador de Tipo de Documento" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo01">01</cbc:InvoiceTypeCode>
    
</Invoice>

Custom Templates

You can create custom templates by implementing the IBuilder<T> interface:

public class CustomInvoiceBuilder : IBuilder<Invoice>
{
    public async ValueTask<string> BuildAsync(Invoice invoice)
    {
        // Custom XML generation logic
        return xmlContent;
    }
}

Dependencies

  • .NET 8.0
  • RazorLight 2.3.1
  • Greeva.Core (domain models)
  • Greeva.Core: Core domain models
  • Greeva.Xml.Sign: XML digital signature functionality
  • Greeva.WebApi: Web API integration with embedded templates

License

MIT License - see LICENSE file for details.

Support

For issues and questions, please visit: https://github.com/augustoteles/greeva/issues

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Greeva.Xml:

Package Downloads
Greeva.WebApi

Greeva library optimized for Web APIs with DI support and embedded templates

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 276 11/21/2025
1.0.4 411 11/18/2025
1.0.3 292 11/13/2025
1.0.1 138 10/24/2025
1.0.0 195 10/12/2025