Mews.Fiscalizations.Spain
10.0.1
Prefix Reserved
See the version list below for details.
dotnet add package Mews.Fiscalizations.Spain --version 10.0.1
NuGet\Install-Package Mews.Fiscalizations.Spain -Version 10.0.1
<PackageReference Include="Mews.Fiscalizations.Spain" Version="10.0.1" />
paket add Mews.Fiscalizations.Spain --version 10.0.1
#r "nuget: Mews.Fiscalizations.Spain, 10.0.1"
// Install Mews.Fiscalizations.Spain as a Cake Addin #addin nuget:?package=Mews.Fiscalizations.Spain&version=10.0.1 // Install Mews.Fiscalizations.Spain as a Cake Tool #tool nuget:?package=Mews.Fiscalizations.Spain&version=10.0.1
<p align="center"> <a href="https://mews.com"> <img alt="Mews" src="https://user-images.githubusercontent.com/51375082/120493257-16938780-c3bb-11eb-8cb5-0b56fd08240d.png"> </a> <br><br> <b>Mews.Fiscalizations.Spain</b> is a .NET library that was built to help reporting of e-invoices to the Spanish authorities (SII - Suministro Inmediato de Información del IVA). <b>Current supported version is 1.1.</b> <br><br> <a href="https://www.nuget.org/packages/Mews.Fiscalizations.Spain/"> <img src="https://img.shields.io/nuget/v/Mews.Fiscalizations.Spain"> </a> <a href="https://github.com/MewsSystems/fiscalizations/blob/master/LICENSE"> <img src="https://img.shields.io/github/license/MewsSystems/fiscalizations"> </a> <a href="https://github.com/MewsSystems/fiscalizations/actions/workflows/publish-spain.yml"> <img src="https://img.shields.io/github/actions/workflow/status/MewsSystems/fiscalizations/publish-spain.yml?branch=master&label=publish"> </a> <a href="https://www.agenciatributaria.es/AEAT.internet/en_gb/SII.html"> <img src="https://img.shields.io/badge/v1.1-SII-lightgrey"> </a> </p>
📃 Description
This library uses the SII to report e-invoices, please check their Documentation.
SII stands for Suministro Inmediato de Información del IVA, which translates to Immediate Supply of Information on VAT. It's an online API provided by Spanish authorities in a form of a SOAP Web Service.
⚙️ Installation
The library can be installed through NuGet packages or the command line as mentioned below:
Install-Package Mews.Fiscalizations.Spain
🎯 Features
- Functional approach via FuncSharp.
- No Spanish abbreviations.
- Early data validation.
- Asynchronous I/O.
- All endpoints are covered with tests.
- Intuitive immutable DTOs.
- Pipelines that run on both Windows and Linux operating systems.
- Cross platform (uses .NET 6).
- Logging support.
❗ Known issues
- We didn't implement deleting or modifying already existing records.
📦 NuGet
We have published the library as Mews.Fiscalizations.Spain.
👀 Code Examples
Listed below are some of the common examples. If you want to see more code examples, please check the Tests.
Creating the client
There are 3 required properties that need to be provided when creating the client
- Certificate: the certificate can be obtained from the SII website
- Environment: production/test.
- HttpTimeout: the timespan to wait before the request times out.
var certificate = new X509Certificate2(.....);
var client = new Client(certificate, Environment.Test, httpTimeout: TimeSpan.FromSeconds(30));
Creating the IssuingCompany (supplier/issuer)
First step is to create the tax payer object:
var taxpayerIdentificationNumber = TaxpayerIdentificationNumber.Create(Countries.Spain, "INSERT_ISSUER_TAX_NUMBER").Success.Get();
and to create the IssuingCompany object:
var issuingCompany = new LocalCompany(
name: Name.CreateUnsafe("Name of the issuing company"),
taxpayerIdentificationNumber: taxpayerIdentificationNumber
);
Creating the invoice
var issueDateUtc = nowUtc.Date;
var vat = 21m;
var baseValue = 42.07m;
var taxRateSummaries = new[]
{
new TaxRateSummary(
taxRatePercentage: Percentage.Create(vat).Success.Get(),
taxBaseAmount: Amount.Create(baseValue).Success.Get(),
taxAmount: Amount.Create(Math.Round(baseValue * vat / 100, 2)).Success.Get()
)
};
var taxExemptItems = new[] { new TaxExemptItem(Amount.Create(20m).Success.Get(), CauseOfExemption.OtherGrounds) };
var invoice = new SimplifiedInvoice(
taxPeriod: new TaxPeriod(Year.Create(issueDateUtc.Year).Success.Get(), (Month)(issueDateUtc.Month - 1)),
id: new InvoiceId(issuingCompany.TaxpayerIdentificationNumber, String1To60.CreateUnsafe("Invoice_number"), issueDateUtc),
taxMode: TaxMode.GeneralTaxRegimeActivity,
description: String0To500.CreateUnsafe("Invoice description."),
taxBreakdown: new TaxBreakdown(TaxSummary.Create(taxExempt: taxExemptItems, taxed: taxRateSummaries).Success.Get()),
issuedByThirdParty: true
);
Submitting the invoice
var model = SimplifiedInvoicesToSubmit.Create(
header: new Header(IssuingCompany, CommunicationType.Registration),
invoices: new[] { invoice }
).Success.Get();
var response = await client.SubmitSimplifiedInvoiceAsync(model);
Handling response result
Client will return a coproduct of successful soap response and potential soap fault. You could read more about algebraic types here. Specifically, samples of handling Try coproduct are here. Below is a reference of basic scenarios:
Get result or throw an exception in a case service returned soap fault response.
var receivedInvoices = response.MapError(e => new Exception($"code {e.Code} message {e.Message}")).Get();
Conditionally access successful response
if (response.IsSuccess)
{
var soapSuccessResult = response.Success.Get();
}
Conditionally access fault response
if (response.IsError)
{
var soapFaultResult = response.Error.Get();
}
🧑 Authors
Development: @PavelKalandra, @MiroslavVeith
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. |
-
net6.0
- Mews.Fiscalizations.Core (>= 6.0.1)
- Mews.FuncSharp (>= 5.0.2 && < 6.0.0)
- System.Net.Http (>= 4.3.4)
- System.ServiceModel.Primitives (>= 6.0.0)
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 |
---|---|---|
12.0.2 | 117 | 7/3/2024 |
12.0.1 | 316 | 1/30/2024 |
12.0.0 | 281 | 1/29/2024 |
11.0.0 | 613 | 8/27/2023 |
10.0.2 | 690 | 8/2/2023 |
10.0.1 | 682 | 7/26/2023 |
10.0.0 | 657 | 7/24/2023 |
9.0.5 | 917 | 10/24/2022 |
9.0.4 | 918 | 10/21/2022 |
9.0.2 | 887 | 10/17/2022 |
9.0.1 | 945 | 9/15/2022 |
9.0.0 | 913 | 9/6/2022 |
8.0.3 | 960 | 7/4/2022 |
8.0.2 | 948 | 5/24/2022 |
8.0.1 | 988 | 4/25/2022 |
8.0.0 | 943 | 4/21/2022 |
7.0.4 | 972 | 4/14/2022 |
7.0.3 | 971 | 4/14/2022 |
7.0.2 | 996 | 1/12/2022 |
7.0.1 | 1,936 | 11/26/2021 |
7.0.0 | 813 | 11/23/2021 |
6.0.0 | 872 | 11/8/2021 |
5.0.1 | 841 | 11/5/2021 |
5.0.0 | 898 | 7/21/2021 |
4.0.0 | 1,422 | 5/24/2021 |