Skip to content

OGM, "overschrijving met gestructureerde mededeling", is a structured message often added to belgian bank transfers to enable automatic processing. This package enables the generation and validation of these structured messages

Notifications You must be signed in to change notification settings

stefanpante/Node-Belgian-VCS-OGM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Belgian-VCS-OGM (Belgium)

OGM, 'overschrijving met gestructureerde mededeling', is a structured message often added to belgian bank transfers to enable automatic processing. This Node package enables the generation and validation of these structured messages.

Installation

npm install belgian-vcs-ogm

Usage

var ogm = require('belgian-vcs-ogm');

Available Methods

isValidOGM(structuredMessage)

Checks whether the given structured message is a valid ogm. Validates the format and the check digits.

Parameters

  1. structuredMessage (String): structured message to check.

Return

Boolean: true if the structuredMessage is a valid ogm, false otherwise.

Example

ogm.isValidOGM('+++123/1234/12328+++');
// returns true

ogm.isValidOGM('++700/8000/90602+++');
// returns false, wrong structure

ogm.isValidOGM('++++700/8000/90607+++');
// returns false, wrong check digits

ogm.isValidOGM('+++70/0800/10029+++');
// returns false, wrong length



generateOGM(numbers)

Generates a valid OGM based on the given numbers.

Parameters

  1. numbers (String|Number): Numbers to be used to generate ogm. Length should be equal to or less than 10. only positive values are allowed.

Return

String: A valid ogm based on the given numbers. If the length of the numbers is less than 10, leading zeros are added. Two checkdigits are also added.

Example

var structuredMessage = ogm.generateOGM('0008000906');
// structuredMessage === '+++000/8000/90655+++'

var structuredMessage = ogm.generateOGM(8000906);
// structuredMessage === '+++000/8000/90655+++'

var structuredMessage = ogm.generateOGM(7008000933);
//structuredMessage === '+++700/8000/93329+++'



calculateCheckDigits(numbers)

Generates check digits for a given number. The check digits are equal to remainder of the division of the numeric value of the given numbers by 97. If the check digits are smaller than 10, a leading zero is added. If the check digit is equal to 0, 97 is used instead.

Parameters

  1. numbers (String|Number): Numbers to be used to generate checkdigits. Length should be equal to or less than 10. only positive values are allowed.

Return

String: The generated check digits

Example

var checkDigits = ogm.calculateControl(1115532822);
// checkDigits === '36'

var checkDigits = ogm.calculateControl('1115532786');
 // checkDigits === '97'



generateRandomOGM()

Generates a random structured message.

DOES NOT PREVENT COLLISION WITH PREVIOUSLY GENERATED VALUES

Parameters

none

Return

String: A randomly generated structured message, conforming to the ogm standard.

Example

var structuredMessage = ogm.generateRandomOGM();
// output is a valid structuredMessage.
getStrippedOGM(ogm)

strips +'s and /'s from the ogm. returns only the digits.

Parameters

  1. ogm (String): ogm to strip.

Return

String: Stripped ogm

Example

var stripped = ogm.getStrippedOGM('+++000/8000/90655+++');
// stripped === '000800090655'



About

OGM, "overschrijving met gestructureerde mededeling", is a structured message often added to belgian bank transfers to enable automatic processing. This package enables the generation and validation of these structured messages

Resources

Stars

Watchers

Forks

Packages

No packages published