@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
exports . bulgaria = {
4
4
name : 'Bulgaria' ,
5
5
codes : [ 'BG' , 'BGR' , '100' ] ,
6
- calcFn : ( vat ) => {
6
+ calcFn : function ( vat ) {
7
7
if ( vat . length === 9 )
8
8
return _checkNineLengthVat ( vat ) ;
9
- const { multipliers } = exports . bulgaria . rules ;
9
+ var multipliers = exports . bulgaria . rules . multipliers ;
10
10
return _isPhysicalPerson ( vat , multipliers . physical ) || _isForeigner ( vat , multipliers ) || _miscellaneousVAT ( vat , multipliers ) ;
11
11
} ,
12
12
rules : {
@@ -19,23 +19,23 @@ exports.bulgaria = {
19
19
}
20
20
} ;
21
21
function _increase ( value , vat , from , to , incr ) {
22
- let result = value ;
23
- for ( let i = from ; i < to ; i ++ ) {
22
+ var result = value ;
23
+ for ( var i = from ; i < to ; i ++ ) {
24
24
result += Number ( vat . charAt ( i ) ) * ( i + incr ) ;
25
25
}
26
26
return result ;
27
27
}
28
28
function _increase2 ( value , vat , from , to , multipliers ) {
29
- let result = value ;
30
- for ( let i = from ; i < to ; i ++ ) {
29
+ var result = value ;
30
+ for ( var i = from ; i < to ; i ++ ) {
31
31
result += Number ( vat . charAt ( i ) ) * multipliers [ i ] ;
32
32
}
33
33
return result ;
34
34
}
35
35
function _checkNineLengthVat ( vat ) {
36
- let total ;
37
- let temp = _increase ( 0 , vat , 0 , 8 , 1 ) ;
38
- const expect = Number ( vat . slice ( 8 ) ) ;
36
+ var total ;
37
+ var temp = _increase ( 0 , vat , 0 , 8 , 1 ) ;
38
+ var expect = Number ( vat . slice ( 8 ) ) ;
39
39
total = temp % 11 ;
40
40
if ( total !== 10 )
41
41
return total === expect ;
@@ -49,9 +49,9 @@ function _isPhysicalPerson(vat, physicalMultipliers) {
49
49
// 10 digit VAT code - see if it relates to a standard physical person
50
50
if ( ( / ^ \d \d [ 0 - 5 ] \d [ 0 - 3 ] \d \d { 4 } $ / ) . test ( vat ) ) {
51
51
// Check month
52
- const month = Number ( vat . slice ( 2 , 4 ) ) ;
52
+ var month = Number ( vat . slice ( 2 , 4 ) ) ;
53
53
if ( ( month > 0 && month < 13 ) || ( month > 20 && month < 33 ) || ( month > 40 && month < 53 ) ) {
54
- let total = _increase2 ( 0 , vat , 0 , 9 , physicalMultipliers ) ;
54
+ var total = _increase2 ( 0 , vat , 0 , 9 , physicalMultipliers ) ;
55
55
// Establish check digit.
56
56
total = total % 11 ;
57
57
if ( total === 10 )
@@ -65,20 +65,20 @@ function _isPhysicalPerson(vat, physicalMultipliers) {
65
65
}
66
66
function _isForeigner ( vat , multipliers ) {
67
67
// Extract the next digit and multiply by the counter.
68
- const total = _increase2 ( 0 , vat , 0 , 9 , multipliers . foreigner ) ;
68
+ var total = _increase2 ( 0 , vat , 0 , 9 , multipliers . foreigner ) ;
69
69
// Check to see if the check digit given is correct, If not, try next type of person
70
70
return total % 10 === Number ( vat . substr ( 9 , 1 ) ) ;
71
71
}
72
72
function _miscellaneousVAT ( vat , multipliers ) {
73
73
// Finally, if not yet identified, see if it conforms to a miscellaneous VAT number
74
- let total = _increase2 ( 0 , vat , 0 , 9 , multipliers . miscellaneous ) ;
74
+ var total = _increase2 ( 0 , vat , 0 , 9 , multipliers . miscellaneous ) ;
75
75
// Establish check digit.
76
76
total = 11 - total % 11 ;
77
77
if ( total === 10 )
78
78
return false ;
79
79
if ( total === 11 )
80
80
total = 0 ;
81
81
// Check to see if the check digit given is correct, If not, we have an error with the VAT number
82
- const expect = Number ( vat . substr ( 9 , 1 ) ) ;
82
+ var expect = Number ( vat . substr ( 9 , 1 ) ) ;
83
83
return total === expect ;
84
84
}
0 commit comments