Skip to content

Latest commit

 

History

History
108 lines (84 loc) · 3.96 KB

README.md

File metadata and controls

108 lines (84 loc) · 3.96 KB

RNOKPP (РНОКПП)

Helper functions to work with Ukrainian registration number of the taxpayer's account card (RNOKPP).
Допоміжні функції для роботи з реєстраційним номером облікової картки платника податків (РНОКПП).

Build Status CodeCov Go Report Card License Gitter GoDoc

Demo ⚙️

You can test it with my RNOKPP Telegram Bot.

Requirements 🧐

  • GO >= 1.20

Features 🎁

  • Get details about RNOKPP
  • Get gender
  • Check gender
  • Check validity
  • Generate RNOKPP by date and gender
  • Generate random RNOKPP

Using 👨‍🎓

main.go
package main

import (
    "fmt"
    "time"

    "github.com/fre5h/rnokpp"
)

func main() {
    // Get details about RNOKPP
    details, _ := rnokpp.GetDetails("3652504575")
    fmt.Println("details:", details) // valid, male, 01.01.2000

    // Get gender from RNOKPP
    gender1, _ := rnokpp.GetGender("3652504575")
    fmt.Println("gender1:", gender1) // male
    gender2, _ := rnokpp.GetGender("3068208400")
    fmt.Println("gender2:", gender2) // female

    // Check gender
    isMale, _ := rnokpp.IsMale("3652504575")
    fmt.Println("is male:", isMale) // true
    isFemale, _ := rnokpp.IsFemale("3652504575")
    fmt.Println("is female:", isFemale) // false

    // Check valid RNOKPP
    validRnokpp := rnokpp.IsValid("3652504575")
    invalidRnokpp := rnokpp.IsValid("1234567890")
    fmt.Println("rnokpp valid:", validRnokpp, invalidRnokpp) // true, false

    // Generate RNOKPP by date and gender
    birthday, _ := time.Parse("02.01.2006", "01.01.2000")
    generatedRnokppMale, _ := rnokpp.GenerateRnokpp(birthday, rnokpp.Male)
    fmt.Println("valid RNOKPP for male with birthday on 01.01.2000:", generatedRnokppMale) // valid RNOKPP for male with birthday on 01.01.2000, e.g. 3652322032
    generatedRnokppFemale, _ := rnokpp.GenerateRnokpp(birthday, rnokpp.Female)
    fmt.Println("valid RNOKPP for female with birthday on 01.01.2000:", generatedRnokppFemale) // valid RNOKPP for female with birthday on 01.01.2000, e.g. 3652347000

    // Generate a one random RNOKPP
    generatedRandomRnokpp, _ := rnokpp.GenerateRandomRnokpp()
    fmt.Println("random rnokpp:", generatedRandomRnokpp) // e.g. random rnokpp: 3300507061
    // Or generate some number of random RNOKPPs
    generatedRandomRnokpps, _ := rnokpp.GenerateRandomRnokppN(3)
    for i, generatedRandomRnokpp := range generatedRandomRnokpps {
        fmt.Printf("random rnokpp #%d: %s\n", i, generatedRandomRnokpp)
    }
}
bash
$ go get "github.com/fre5h/rnokpp"@v1.1.2
go: downloading github.com/fre5h/rnokpp v1.1.2
go: added github.com/fre5h/rnokpp v1.1.2

$ go run main.go
details: valid, male, 01.01.2000
gender1: male
gender2: female
is male: true
is female: false
rnokpp valid: true false
valid RNOKPP for male with birthday on 01.01.2000: 3652322032
valid RNOKPP for female with birthday on 01.01.2000: 3652347000
random rnokpp: 3300507061
random rnokpp #0: 3946436021
random rnokpp #1: 2642527503
random rnokpp #2: 2620337525

Contributing 🤝

See CONTRIBUTING file.