1 package Algorithm::CheckDigits::M97_001;
 
   8 use version; our $VERSION = 'v1.3.2';
 
  10 our @ISA = qw(Algorithm::CheckDigits);
 
  15         my $class = ref($proto) || $proto;
 
  16         my $self  = bless({}, $class);
 
  17         $self->{type} = lc($type);
 
  22         my ($self,$number) = @_;
 
  23         if ($number =~ /^(\d{7,8})?(\d\d)$/i) {
 
  24                 return $2 eq $self->_compute_checkdigit($1);
 
  30         my ($self,$number) = @_;
 
  31         if ($number =~ /^(\d{7,8})$/i) {
 
  32                 return sprintf('%08d', $number) . $self->_compute_checkdigit($1);
 
  38         my ($self,$number) = @_;
 
  39         if ($number =~ /^(\d{7,8})(\d\d)$/i) {
 
  40                 return sprintf('%08d', $1) if ($2 eq $self->_compute_checkdigit($1));
 
  46         my ($self,$number) = @_;
 
  47         if ($number =~ /^(\d{7,8})(\d\d)$/i) {
 
  48                 return $2 if (uc($2) eq $self->_compute_checkdigit($1));
 
  53 sub _compute_checkdigit {
 
  57         if ($number =~ /^\d{7,8}$/i) {
 
  58                 return sprintf("%2.2d",97 - ($number % 97));
 
  61 } # _compute_checkdigit()
 
  63 # Preloaded methods go here.
 
  70 CheckDigits::M97_001 - compute check digits for VAT Registration Number (BE)
 
  74   use Algorithm::CheckDigits;
 
  76   $ustid = CheckDigits('ustid_be');
 
  78   if ($ustid->is_valid('136695962')) {
 
  82   $cn = $ustid->complete('1366959');
 
  85   $cd = $ustid->checkdigit('136695962');
 
  88   $bn = $ustid->basenumber('136695962');
 
  99 The whole number (without checksum) is taken modulo 97.
 
 103 The checksum is difference of the remainder from step 1 to 97.
 
 111 =item is_valid($number)
 
 113 Returns true only if C<$number> consists solely of numbers and the last digit
 
 114 is a valid check digit according to the algorithm given above.
 
 116 Returns false otherwise,
 
 118 =item complete($number)
 
 120 The check digit for C<$number> is computed and concatenated to the end
 
 123 Returns the complete number with check digit or '' if C<$number>
 
 124 does not consist solely of digits and spaces.
 
 126 =item basenumber($number)
 
 128 Returns the basenumber of C<$number> if C<$number> has a valid check
 
 133 =item checkdigit($number)
 
 135 Returns the checkdigits of C<$number> if C<$number> has a valid check
 
 148 Mathias Weidner, C<< <mamawe@cpan.org> >>
 
 154 F<www.pruefziffernberechnung.de>.