Lytrax.AFM 1.0.1

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 and Polyglot Notebooks. 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 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. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.0 is compatible.  netstandard1.1 was computed.  netstandard1.2 was computed.  netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 is compatible.  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 tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Windows Phone wp8 was computed.  wp81 was computed.  wpa81 was computed. 
Windows Store netcore was computed.  netcore45 was computed.  netcore451 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.1 563 1/2/2020
1.0.0 400 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