Greeva.Xml
1.0.5
dotnet add package Greeva.Xml --version 1.0.5
NuGet\Install-Package Greeva.Xml -Version 1.0.5
<PackageReference Include="Greeva.Xml" Version="1.0.5" />
<PackageVersion Include="Greeva.Xml" Version="1.0.5" />
<PackageReference Include="Greeva.Xml" />
paket add Greeva.Xml --version 1.0.5
#r "nuget: Greeva.Xml, 1.0.5"
#:package Greeva.Xml@1.0.5
#addin nuget:?package=Greeva.Xml&version=1.0.5
#tool nuget:?package=Greeva.Xml&version=1.0.5
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)
Related Packages
- 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 | Versions 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. |
-
net8.0
- Greeva.Core (>= 1.0.5)
- RazorLight (>= 2.3.1)
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.