Business-DK-CVR
view release on metacpan or search on metacpan
lib/Business/DK/CVR.pm view on Meta::CPAN
=encoding utf8
=begin markdown
[](http://badge.fury.io/pl/Business-DK-CVR)
[](https://travis-ci.org/jonasbn/bdkcvr)
[](https://coveralls.io/r/jonasbn/bdkcvr)
=end markdown
=head1 NAME
Business::DK::CVR - Danish CVR (VAT Registration) number generator/validator
=head1 VERSION
This documentation describes version 0.12 of Business::DK::CVR
=head1 SYNOPSIS
use Business::DK::CVR qw(validate);
my $rv;
eval { $rv = validate(27355021); };
if ($@) {
die "Code is not of the expected format - $@";
}
if ($rv) {
print "Code is valid";
} else {
print "Code is not valid";
}
#Using with Params::Validate
#See also examples/
use Params::Validate qw(:all);
use Business::DK::CVR qw(validateCVR);
eval {
check_cvr(cvr => 27355021);
};
if ($@) {
print "CVR is not valid - $@\n";
}
eval {
check_cvr(cvr => 27355020);
};
if ($@) {
print "CVR is not valid - $@\n";
}
sub check_cvr {
validate( @_,
{ cvr =>
{ callbacks =>
{ 'validate_cvr' => sub { validateCVR($_[0]); } } } } );
print "$_[0] is a valid CVR\n";
}
=head1 DESCRIPTION
CVR is a company registration number used in conjuction with VAT handling in
Denmark.
If you want to use this module with L<Data::FormValidator> please check:
L<Data::FormValidator::Constraints::Business::DK::CVR>
=head1 SUBROUTINES AND METHODS
=head2 validate
The function takes a single argument, a 10 digit CVR number.
The function returns 1 (true) in case of a valid CVR number argument and 0
(false) in case of an invalid CVR number argument.
If the argument is a valid argument the sum is calculated by B<_calculate_sum>
based on the argument and the controlcifers array.
The sum returned is checked using a modulus caluculation and based on its
validity either 1 or 0 is returned.
=head2 validateCVR
Better name for export. This is just a wrapper for L</validate>
=head2 generate
Generate is a function which generates valid CVR numbers, it is by no means
an authority, since CVRs are generated and distributed by danish tax
authorities, but it can be used to generate example CVRs for testing and so on.
=head1 PRIVATE FUNCTIONS
=head2 _calculate_sum
This function takes an integer and calculates the sum bases on the the
controlcifer array.
=head1 EXPORTS
Business::DK::CVR exports on request:
=over
=item L</validate>
=item L</generate>
=item L</_calculate_sum>
=back
( run in 0.756 second using v1.01-cache-2.11-cpan-97f6503c9c8 )