Skip to content

sendanor/node-fin-id

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Finnish Identity Number Library

Description

This library is a collection of functions dealing with Finnish specific identification numbers.

Features

  • hetu -- Finnish HETU numbers
  • ytunnus -- Finnish corporate IDs
  • refnum -- Invoice reference numbers (viitenumero)
  • pankkiviivakoodi -- Virtual bank transfer numbers (virtuaaliviivakoodi)

Installation for Node.js

Simplest way to install is to use npm, just simply npm install fin-id.

Authors

License

MIT-style license, see INSTALL.txt.

Initializing

Each feature is a property:

var hetu = require('fin-id').hetu;

See examples/ for full examples.

Hetu

The call hetu.check(hetu) returns true if the argument is valid ID:

if(hetu.check('010171-1234')) console.log("valid");
else console.log("invalid");

The call hetu.parse(hetu) returns an object with additional information:

var parsed = hetu.parse('010171-1234');
if(parsed) {
	console.log("birthday is " + parsed.date());  // Fri, 01 Jan 1971
	console.log("sex is " + parsed.sex());        // 'female'
}

Reference number (viitenumero)

var refnum = require('fin-id').refnum;

To create reference number use .create(num)

refnum.create(1234);
=> '12344'

To check reference number use .check(num)

refnum.check('12344');
=> true

To strip the number back to original use .strip(refnum)

refnum.strip('12344');
=> '1234'

To parse the reference number .parse(refnum)

refnum.parse('00001 2344');
=> '1234'

Virtual bank transfer number (virtuaaliviivakoodi)

var viivakoodi = require('fin-id').pankkiviivakoodi;

To create number use .create(...)

viivakoodi.create({
	iban: 'FI21 1234 5600 0007 85',
	cents: 1000,
	duedate: '2015-03-01',
	refnum: 13
});
=> '421123456000007850000100000000000000000000000013150301'

To check barcodes use .check(num)

viivakoodi.check('421123456000007850000100000000000000000000000013150301');
=> true

To parse barcodes use .parse(num)

viivakoodi.parse('421123456000007850000100000000000000000000000013150301');
=> { iban: 'FI2112345600000785',
  euros: 10,
  cents: 0,
  refnum: '13',
  duedate: Sun Mar 01 2015 00:00:00 GMT+0000 (UTC) }

TODO

Commercial Support

You can buy commercial support from Sendanor.

About

Finland Identity Number Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •