SaphetyToDDL.Lib
1.0.10
dotnet add package SaphetyToDDL.Lib --version 1.0.10
NuGet\Install-Package SaphetyToDDL.Lib -Version 1.0.10
<PackageReference Include="SaphetyToDDL.Lib" Version="1.0.10" />
<PackageVersion Include="SaphetyToDDL.Lib" Version="1.0.10" />
<PackageReference Include="SaphetyToDDL.Lib" />
paket add SaphetyToDDL.Lib --version 1.0.10
#r "nuget: SaphetyToDDL.Lib, 1.0.10"
#:package SaphetyToDDL.Lib@1.0.10
#addin nuget:?package=SaphetyToDDL.Lib&version=1.0.10
#tool nuget:?package=SaphetyToDDL.Lib&version=1.0.10
SaphetyToDDL
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/CreditNoteXML (docTypeId1/2/4) into anItemTransactionobject graph (header, party, lines, taxes, payment). - π DDL β XML serialization β maps an
ItemTransactionback to SaphetyInvoiceXML for export flows. - π§Ύ Flexible item identification β resolves the line item id from
tradeItemIdentification, falling back tosellerAssignedTradeItemIdentificationwhen 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'sdeliveryLocation/documentLineDates.deliveryDatewhen the header doesn't carry them. - π JSON serialization β the mapped
ItemTransactionserializes 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:
- Saphety XML β DDL JSON
- DDL JSON (file) β Saphety Invoice XML
- 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 | Versions 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. |
-
.NETStandard 2.0
- AutoMapper (>= 8.1.1)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.