SaphetyToDDL.Lib 1.0.10

dotnet add package SaphetyToDDL.Lib --version 1.0.10
                    
NuGet\Install-Package SaphetyToDDL.Lib -Version 1.0.10
                    
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="SaphetyToDDL.Lib" Version="1.0.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SaphetyToDDL.Lib" Version="1.0.10" />
                    
Directory.Packages.props
<PackageReference Include="SaphetyToDDL.Lib" />
                    
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 SaphetyToDDL.Lib --version 1.0.10
                    
#r "nuget: SaphetyToDDL.Lib, 1.0.10"
                    
#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 SaphetyToDDL.Lib@1.0.10
                    
#: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=SaphetyToDDL.Lib&version=1.0.10
                    
Install as a Cake Addin
#tool nuget:?package=SaphetyToDDL.Lib&version=1.0.10
                    
Install as a Cake Tool

SaphetyToDDL

NuGet Version NuGet Downloads

A .NET Standard 2.0 library that parses Saphety electronic documents (Invoices, Orders, Credit Notes) from XML and maps them to a common accounting domain-driven model (DDL), with round-trip JSON/XML serialization.


🎯 Purpose

Saphety is a Portuguese EDI platform. Systems integrating with it (e.g. ERP extensions) receive documents as provider-specific XML that needs to be turned into a neutral transaction shape before it can be imported, and turned back into Saphety XML when exporting. SaphetyToDDL owns that mapping so consuming applications never touch the Saphety schema directly.

✨ Features

  • πŸ“„ XML β†’ DDL parsing β€” deserializes Saphety Invoice/Order/CreditNote XML (docTypeId 1/2/4) into an ItemTransaction object graph (header, party, lines, taxes, payment).
  • πŸ” DDL β†’ XML serialization β€” maps an ItemTransaction back to Saphety Invoice XML for export flows.
  • 🧾 Flexible item identification β€” resolves the line item id from tradeItemIdentification, falling back to sellerAssignedTradeItemIdentification when the source system omits it (common on real-world Order documents).
  • 🚚 Flexible ship-to/unload data β€” resolves the unload address and unload date from the document header (shipTo / documentDates.deliveryDate), falling back to the first line item's deliveryLocation / documentLineDates.deliveryDate when the header doesn't carry them.
  • πŸ”„ JSON serialization β€” the mapped ItemTransaction serializes cleanly to/from JSON via Newtonsoft.Json for storage or transport.

πŸ—οΈ Architecture

Project Role
SaphetyToDDL.Lib Core library β€” models, mapping (SaphetyToDDL class + AutoMapper profiles), XML (de)serialization
SaphetyToDDL.Console Interactive console harness for exercising parse/serialize flows against sample files

Key types (SaphetyToDDL.Lib):

Type Purpose
SaphetyToDDL Entry point β€” Parse / ParseFromFile (XML β†’ ItemTransaction), MapFromDdl / MapFromDdlString (ItemTransaction β†’ XML)
Models.Saphety.Invoice Root XML model for Saphety Invoice/Order/CreditNote documents (Models/Saphety/)
Models.ItemTransaction Neutral DDL transaction model consumed by callers (Models/)
Models.Detail A mapped transaction line (item id, quantity, price, taxes)
Converters.SettingsConverter-style mapping lives in SaphetyToDDL.MapConfig() AutoMapper configuration for both mapping directions

πŸ› οΈ Tech Stack

  • .NET Standard 2.0
  • AutoMapper 10.1.1 β€” object-to-object mapping between Saphety XML models and DDL models
  • Newtonsoft.Json 13.0.3 β€” JSON serialization of the DDL model
  • System.Xml.Serialization β€” XML (de)serialization of Saphety documents

πŸš€ Quick Start

Prerequisites

  • .NET Standard 2.0–compatible SDK / Visual Studio 2022

Setup

nuget restore SaphetyToDDL.sln
msbuild SaphetyToDDL.sln /p:Configuration=Release /p:Platform=AnyCPU

Usage

using Newtonsoft.Json;

var parser = new SaphetyToDDL.Lib.SaphetyToDDL();

// Parse a Saphety XML file (Invoice, Order or CreditNote) into the DDL model
var itemTransaction = parser.ParseFromFile(@"C:\path\to\document.xml");

var serializeOptions = new JsonSerializerSettings
{
    NullValueHandling = NullValueHandling.Ignore,
};

var json = JsonConvert.SerializeObject(itemTransaction, Formatting.Indented, serializeOptions);
Console.WriteLine(json);

// Reverse mapping: DDL -> Saphety Invoice XML
var invoiceXml = SaphetyToDDL.Lib.SaphetyToDDL.SerializeInvoiceToXml(
    SaphetyToDDL.Lib.SaphetyToDDL.MapFromDdl(itemTransaction));

πŸ“‹ Configuration

There is no runtime configuration β€” behavior is controlled entirely by the input XML's docTypeId attribute (1 = Invoice, 2 = Order, 4 = CreditNote) and by which elements are present in the source document (see the fallback behavior under Features).

πŸ§ͺ Testing

Run SaphetyToDDL.Console and use its interactive menu against the embedded sample resources (SaphetyToDDL.Console/Properties/Resources.resx) to exercise:

  1. Saphety XML β†’ DDL JSON
  2. DDL JSON (file) β†’ Saphety Invoice XML
  3. DDL JSON (inline sample string) β†’ Saphety Invoice XML

πŸ“¦ Distribution

Packaged and published as the SaphetyToDDL.Lib NuGet package via SaphetyToDDL.Lib/nugetPackagePush.cmd, which bumps the version in the .csproj/.nuspec, builds Release, commits/tags (vX.Y.Z), pushes to main, and publishes to nuget.org using SaphetyToDDL.Lib.nuspec.

πŸ“š Documentation

See inline XML doc comments on SaphetyToDDL.Lib.SaphetyToDDL for method-level details on parsing and mapping.

πŸ“ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


Issues and suggestions: GitHub repository.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.10 94 9/11/2026
1.0.9 152 1/14/2026
1.0.8 133 1/13/2026
1.0.7 239 11/6/2025
1.0.6 312 8/7/2025
1.0.5 566 7/24/2025
1.0.4 216 7/9/2025
1.0.3 235 5/6/2025
1.0.2 232 4/30/2025
1.0.1 230 4/29/2025