<!-- md-source: 69c93f861c26 FactoorSharpWeb/wwwroot/de/Home/GettingStarted.md -->

# Bien démarrer avec FactoorSharp

> Version Markdown de <https://www.factoorsharp.de/fr/Home/GettingStarted> destinée aux agents IA.
> Langues : [Deutsch](https://www.factoorsharp.de/de/Home/GettingStarted.md) ·
> [English](https://www.factoorsharp.de/en/Home/GettingStarted.md) ·
> [Français](https://www.factoorsharp.de/fr/Home/GettingStarted.md)

Avec FactoorSharp, vous créez, lisez et validez des factures électroniques (ZUGFeRD,
XRechnung, EN 16931) en quelques minutes. Ce guide vous accompagne pas à pas jusqu'à
votre première facture fonctionnelle.

À l'issue de ce guide de démarrage rapide, vous saurez :

- créer une facture en C#
- l'exporter au format XML EN 16931 / ZUGFeRD
- l'intégrer, en option, dans un PDF/A-3
- valider le résultat

## Installation

Installez FactoorSharp via NuGet :

```powershell
dotnet add package FactoorSharp.FacturX
```

Ou via le Gestionnaire de package :

```powershell
Install-Package FactoorSharp.FacturX
```

La bibliothèque prend en charge .NET 6+, .NET Framework 4.6 et .NET Framework 4.8
(selon la plateforme cible).

## Obtenir une licence

Pour utiliser FactoorSharp, vous avez besoin d'une clé de licence.
[Inscrivez-vous gratuitement](https://www.factoorsharp.de/fr/Account/SignUp) – vous
recevez immédiatement après une licence d'essai de 30 jours avec toutes les
fonctionnalités, sans indiquer de moyen de paiement.

Vous retrouverez ensuite votre clé de licence dans l'espace client, sous « Ma licence »
(<https://www.factoorsharp.de/support/License/Index>). Renseignez-la une seule fois au
démarrage de votre application, comme dans l'exemple ci-dessous – d'autres méthodes
(variable d'environnement, `appsettings.json`) y sont également proposées.

## Créer votre première facture

Dans l'exemple suivant, vous créez une facture minimale conforme EN 16931.

### Données d'en-tête

Commençons par les données d'en-tête de la facture avec l'identification du vendeur et
de l'acheteur. Cela inclut également les informations de livraison.

```csharp
FacturXInvoice.SetLicense("...");

var invoice = FacturXInvoice.CreateInvoice("Invoice-01",
    new DateTime(2025,09,03),
    CurrencyCodes.EUR)
        // BG-14
        .SetSeller(name: "BikeTech GmbH",
               postcode: "10115",
               city: "Berlin",
               street: "Radweg 12",
               country: CountryCodes.DE,
               id: String.Empty,
               globalID: new GlobalID(GlobalIDSchemeIdentifiers.GLN, "4000001123452"),
               legalOrganization: new LegalOrganization(GlobalIDSchemeIdentifiers.GLN, "4000001123452", "BikeTech GmbH"))
        // BG-7
        .SetBuyer(name: "CityRider AG",
              postcode: "20457",
              city: "Hamburg",
              street: "Hafenstraße 45",
              country: CountryCodes.DE,
              id: "DE987654321");

// BT-31
invoice.AddSellerTaxRegistration("201/113/40209", TaxRegistrationSchemeID.FC);

// BT-72 - ActualDeliverySupplyChainEvent
invoice.ActualDeliveryDate = DateTime.Today;
// alternative : période de facturation (BG-14)
// invoice.SetBillingPeriod(
//     billingPeriodStart: DateTime.Today.AddDays(-7),
//     billingPeriodEnd: DateTime.Today);
```

```vbnet
FacturXInvoice.SetLicense("...")

Dim invoice = FacturXInvoice.CreateInvoice("Invoice-01",
    New DateTime(2025, 9, 3),
    CurrencyCodes.EUR) _
        .SetSeller(name:="BikeTech GmbH",
               postcode:="10115",
               city:="Berlin",
               street:="Radweg 12",
               country:=CountryCodes.DE,
               id:=String.Empty,
               globalID:=New GlobalID(GlobalIDSchemeIdentifiers.GLN, "4000001123452"),
               legalOrganization:=New LegalOrganization(GlobalIDSchemeIdentifiers.GLN, "4000001123452", "BikeTech GmbH")) _
        .SetBuyer(name:="CityRider AG",
              postcode:="20457",
              city:="Hamburg",
              street:="Hafenstraße 45",
              country:=CountryCodes.DE,
              id:="DE987654321")

' BT-31
invoice.AddSellerTaxRegistration("201/113/40209", TaxRegistrationSchemeID.FC)

' BT-72 - ActualDeliverySupplyChainEvent
invoice.ActualDeliveryDate = DateTime.Today
' alternative : période de facturation (BG-14)
' invoice.SetBillingPeriod(
'     billingPeriodStart:=DateTime.Today.AddDays(-7),
'     billingPeriodEnd:=DateTime.Today)
```

### Position

```csharp
invoice.AddTradeLineItem(name: "Vélo de randonnée",
                         netUnitPrice: 799.0m,
                         unitCode: QuantityCodes.C62,
                         grossUnitPrice: 799.0m,
                         billedQuantity: 1,
                         taxType: TaxTypes.VAT,
                         categoryCode: TaxCategoryCodes.S,
                         taxPercent: 19,
                         sellerAssignedID: "BIKE-1");
```

```vbnet
invoice.AddTradeLineItem(name:="Vélo de randonnée",
                         netUnitPrice:=799.0D,
                         unitCode:=QuantityCodes.C62,
                         grossUnitPrice:=799.0D,
                         billedQuantity:=1,
                         taxType:=TaxTypes.VAT,
                         categoryCode:=TaxCategoryCodes.S,
                         taxPercent:=19,
                         sellerAssignedID:="BIKE-1")
```

### Bloc des totaux et conditions de paiement

```csharp
decimal taxTotalAmount = 799.0m / 100m * 19m;

invoice.AddApplicableTradeTax(basisAmount: 799.0m,
                              percent: 19m,
                              taxAmount: taxTotalAmount,
                              typeCode: TaxTypes.VAT,
                              categoryCode: TaxCategoryCodes.S);

invoice.PaymentTerms.Add(new PaymentTerms() // BT-20
{
    DueDate = DateTime.Today.AddDays(14)
});

invoice.SetTotals(lineTotalAmount: 799.0m,
                  taxBasisAmount: 799.0m,
                  taxTotalAmount: taxTotalAmount,
                  grandTotalAmount: 799.0m + taxTotalAmount,
                  duePayableAmount: 799.0m + taxTotalAmount);

invoice.Save("e:\\factur-x.xml",
             version: ZUGFeRDVersion.Version25,
             profile: Profile.Extended);
```

```vbnet
Dim taxTotalAmount As Decimal = 799.0D / 100D * 19D

invoice.AddApplicableTradeTax(basisAmount:=799.0D,
                              percent:=19D,
                              taxAmount:=taxTotalAmount,
                              typeCode:=TaxTypes.VAT,
                              categoryCode:=TaxCategoryCodes.S)

invoice.PaymentTerms.Add(New PaymentTerms() With ' BT-20
{
    .DueDate = DateTime.Today.AddDays(14)
})

invoice.SetTotals(lineTotalAmount:=799.0D,
                  taxBasisAmount:=799.0D,
                  taxTotalAmount:=taxTotalAmount,
                  grandTotalAmount:=799.0D + taxTotalAmount,
                  duePayableAmount:=799.0D + taxTotalAmount)

invoice.Save("e:\factur-x.xml",
             version:=ZUGFeRDVersion.Version25,
             profile:=Profile.Extended)
```

## Export au format XML (EN 16931 / XRechnung / ZUGFeRD)

Une fois votre facture construite, vous pouvez l'exporter au format XML :

```csharp
invoice.Save("factur-x.xml",
    version: ZUGFeRDVersion.Version25,
    profile: Profile.Extended);
```

```vbnet
invoice.Save("factur-x.xml",
    version:=ZUGFeRDVersion.Version25,
    profile:=Profile.Extended)
```

Les profils habituellement utilisés pour ZUGFeRD sont :

| Profil | Signification |
|---|---|
| Comfort / EN16931 | Norme pour l'UE |
| Extended | Le profil le plus détaillé et le plus utilisé en Allemagne |

## Valider une facture

Pour vous assurer que toutes les informations nécessaires sont présentes, vous pouvez
valider votre facture avec l'outil de validation de l'espace client sur
factoorsharp.de. Cela permet aux destinataires de la facture de la traiter sans
difficulté.

## Créer un PDF/A-3 avec facture intégrée (ZUGFeRD)

Si vous disposez déjà d'un fichier PDF, par exemple issu d'un générateur de rapports ou
de votre ERP, vous pouvez intégrer directement les informations ZUGFeRD dans ce PDF :

```csharp
await FacturXInvoicePdfProcessor.SaveToPdfAsync(
    "Facture-FacturX.pdf",
    ZUGFeRDVersion.Version25,
    Profile.Extended,
    ZUGFeRDFormats.CII,
    "Facture-PDF-classique.pdf",
    invoice);
```

```vbnet
Await FacturXInvoicePdfProcessor.SaveToPdfAsync(
    "Facture-FacturX.pdf",
    ZUGFeRDVersion.Version25,
    Profile.Extended,
    ZUGFeRDFormats.CII,
    "Facture-PDF-classique.pdf",
    invoice)
```

Résultat : un PDF lisible visuellement au format PDF/A-3, contenant également le
fichier XML lisible par machine intégré au document PDF.

## Lire des factures existantes

FactoorSharp peut également analyser des factures existantes, que vous lisiez un
fichier XML ou que vous deviez extraire le fichier XML d'un fichier PDF :

```csharp
// lire le XML
var fromXml = FacturXInvoice.Load("factur-x.xml");

// extraire le XML d'un PDF
var fromPdf = await FacturXInvoicePdfProcessor.LoadFromPdfAsync("Facture-FacturX.pdf");
```

```vbnet
' lire le XML
Dim fromXml = FacturXInvoice.Load("factur-x.xml")

' extraire le XML d'un PDF
Dim fromPdf = Await FacturXInvoicePdfProcessor.LoadFromPdfAsync("Facture-FacturX.pdf")
```

## Migration depuis ZUGFeRD-csharp

FactoorSharp est le successeur de ZUGFeRD-csharp. Si vous travaillez déjà avec :

- L'API a volontairement été conservée similaire.
- Votre logique existante peut généralement être reprise telle quelle.
- Remplacez `InvoiceDescriptor` par `FacturXInvoice` et `InvoicePdfProcessor` par
  `FacturXInvoicePdfProcessor`. C'est tout.
- Nouveautés : meilleure validation, nouvelles fonctionnalités.

## Pages associées

- [Aperçu du produit](https://www.factoorsharp.de/fr/Home/Index.md) – fonctionnalités,
  tarifs, questions fréquentes
- [ZUGFeRD .NET et ZUGFeRD C#](https://www.factoorsharp.de/fr/Home/ZugferdDotNet.md)
- [Documentation ZUGFeRD](https://www.factoorsharp.de/fr/Service/Documentation) –
  référence des éléments XML, des numéros BT/BG et des classes C#
- [Versions et notes de version](https://www.factoorsharp.de/fr/Home/Versions)
