Lytrax.AFM 1.0.1

.NET Standard 1.0 .NET Framework 4.5
dotnet add package Lytrax.AFM --version 1.0.1
NuGet\Install-Package Lytrax.AFM -Version 1.0.1
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="Lytrax.AFM" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Lytrax.AFM --version 1.0.1
#r "nuget: Lytrax.AFM, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Lytrax.AFM as a Cake Addin
#addin nuget:?package=Lytrax.AFM&version=1.0.1

// Install Lytrax.AFM as a Cake Tool
#tool nuget:?package=Lytrax.AFM&version=1.0.1

Greek TIN/AFM Validator and Generator

Linux Build Status Linux Build Status

Validate and generate Greek TIN (Tax Identification Number) / AFM (Αριθμός Φορολογικού Μητρώου). Generation function can create valid or invalid numbers including parameters for old format, individuals, legal entities and repet tolerance digits control.

Online demo and presentation

https://lytrax.io/blog/projects/greek-tin-validator-generator

Installation

Using NuGet Package Manager Console:

# Add the Lytrax.AFM package to the default project as specified in the console's project selector
Install-Package Lytrax.AFM

# Add the Lytrax.AFM package to a project named <MyProject> that is not the default
Install-Package Lytrax.AFM -ProjectName <MyProject>

Usage

Import:

using Lytrax.AFM;

Validate a number:

> ValidateAFM.Validate("090000045")
true

> ValidateAFM.Validate("123456789")
false

Generate a valid number:

> GenerateAFM.GenerateValid()
"731385437"

Generate an invalid number:

> GenerateAFM.GenerateInvalid()
"853003357"

API

Class ValidateAFM

  • Validate static boolean function
    • afm: string - A number to be checked
    • Returns: bool - A boolean result indicating the validation of the number
  • ValidateExtended static ValidateAFMExtendedResult function
    • afm: string - A number to be checked
    • Returns: ValidateAFMExtendedResult - Result indicating the validation of the number
  • constructor instantiates a new ValidateAFM object
    • afm: string - A number to be checked
  • Number string property - The current AFM number the class object contains
  • Valid bool property - A boolean result indicating the validation of the current number the class object contains
  • Error string property - A string result indicating the error if the current number the class object is invalid.<br/> It can be empty or "length" or "nan" or "zero" or "invalid"

Class ValidateAFMExtendedResult

  • constructor instantiates a new ValidateAFMExtendedResult object
    • valid: bool - Boolean indicates whether a number is valid or not
    • error: string - A string indicating the error if the number is invalid.<br/> It can be "length" or "nan" or "zero" or "invalid"
  • Valid boolean property - Whether a number is valid or not
  • Error string property - Empty or "length" or "nan" or "zero" or "invalid"

Example:

> ValidateAFM.ValidateExtended("ab1234")
ValidateAFMExtendedResult { Error="length", Valid=false }

Class GenerateAFM

  • Generate static string function
    • forceFirstDigit: int? = null - If specified, overrides all pre99, legalEntity and individual
    • pre99: bool = false - Για ΑΦΜ πριν από 1/1/1999 (ξεκινάει με 0),<br/> (if true, overrides both legalEntity and individual)
    • individual: bool = false - Φυσικά πρόσωπα, (ξεκινάει με 1-4)
    • legalEntity: bool = false - Νομικές οντότητες (ξεκινάει με 7-9)
    • repeatTolerance: int? = null - Number for max repeat tolerance (0 for no repeats, unspecified for no check)
    • valid: bool = true - Generate valid or invalid AFM
    • Returns: string - A valid or invalid 9 digit AFM number

Example:

> GenerateAFM.Generate(forceFirstDigit: 3, repeatTolerance: 1, valid: true)
"335151580"
  • GenerateValid static string function - Same as Generate with valid force and override to true
    • Returns: string - A valid 9 digit AFM number

Example:

> GenerateAFM.GenerateValid(pre99: true)
"070825250"
  • GenerateInvalid static string function - Same as Generate with valid force and override to false
    • Returns: string - An invalid 9 digit AFM number

Example:

> GenerateAFM.GenerateInvalid(legalEntity: true)
"877577341"

Test

Clone this repository:

git clone https://github.com/clytras/afm-dotnet.git && cd afm-dotnet

Open Src\Lytrax.AFM\Lytrax.AFM.sln using Visual Strudio and run tests.

Changelog

See CHANGELOG

License

MIT License - see the LICENSE file for details

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard1.0 netstandard1.1 netstandard1.2 netstandard1.3 netstandard1.4 netstandard1.5 netstandard1.6 netstandard2.0 netstandard2.1
.NET Framework net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen30 tizen40 tizen60
Universal Windows Platform uap uap10.0
Windows Phone wp8 wp81 wpa81
Windows Store netcore netcore45 netcore451
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
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.1 398 1/2/2020
1.0.0 321 1/2/2020

Validate and generate Greek TIN (Tax Identification Number) / AFM (Αριθμός Φορολογικού Μητρώου). Generation function can create valid or invalid numbers including parameters for old format, individuals, legal entities and repet tolerance digits control.

v1.0.1: FIX: Seed random int generator with a random GUID hash code