From f1aed83aa528620ff58686fc26440053cc8d6dd0 Mon Sep 17 00:00:00 2001 From: Nick Stakenburg Date: Thu, 20 Aug 2015 19:41:23 +0200 Subject: [PATCH] LU VAT increased. Added CZ reduced & BE parking --- .gitignore | 1 + Gruntfile.js | 30 ++++ bower.json | 6 +- package.json | 12 +- src/vatrates.js | 329 ++++++++++++++++++++++++++++++++++++++ src/vatrates.json | 305 +++++++++++++++++++++++++++++++++++ src/vatrates.php | 312 ++++++++++++++++++++++++++++++++++++ tests/css/github_mark.png | Bin 0 -> 367 bytes tests/css/github_mark.svg | 15 ++ tests/css/reset.css | 8 + tests/css/style.css | 164 +++++++++++++++++++ tests/index.php | 125 +++++++++++++++ tests/js/table-js.js | 45 ++++++ tests/js/tests.js | 70 ++++++++ vatrates.js | 11 +- vatrates.json | 10 +- vatrates.php | 11 +- 17 files changed, 1433 insertions(+), 21 deletions(-) create mode 100644 Gruntfile.js create mode 100644 src/vatrates.js create mode 100644 src/vatrates.json create mode 100644 src/vatrates.php create mode 100644 tests/css/github_mark.png create mode 100644 tests/css/github_mark.svg create mode 100644 tests/css/reset.css create mode 100644 tests/css/style.css create mode 100644 tests/index.php create mode 100644 tests/js/table-js.js create mode 100644 tests/js/tests.js diff --git a/.gitignore b/.gitignore index e69de29..c2658d7 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..f2062b3 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,30 @@ +module.exports = function(grunt) { + + // Config + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + + /* TODO: Move towards having only vatrates.json in 'src' and build + all other files from it, much easier to maintain */ + copy: { + main: { + options: { + processContent: function (content, srcpath) { + return grunt.template.process(content); + } + }, + files: [ + {expand: true, cwd: 'src/', src: ['**'], dest: './'} + ] + } + } + }); + + // Load plugins + grunt.loadNpmTasks('grunt-contrib-copy'); + + // Tasks + grunt.registerTask('default', [ + 'copy' + ]); +}; diff --git a/bower.json b/bower.json index 82b1ed7..88917ac 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "vatrates", "description": "Up-to-date European VAT Rates", - "version": "1.1.0", + "version": "1.2.0", "keywords": [ "VAT", "rates", @@ -10,11 +10,13 @@ ], "homepage": "http://github.com/staaky/vatrates", "main": [ - "vatrates.js" + "./vatrates.js" ], "ignore": [ "node_modules", "bower_components", + "src", + "tests", "/.*", "bower.json", "Gruntfile.js", diff --git a/package.json b/package.json index fa5187e..a0f893c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vatrates", "title": "VATRates", - "version": "1.1.0", + "version": "1.2.0", "description": "Up-to-date European VAT Rates", "keywords": [ "VAT", @@ -13,8 +13,8 @@ "bugs": "http://github.com/staaky/vatrates/issues", "main": "./vatrates.js", "repository": { - "type" : "git", - "url" : "http://github.com/staaky/vatrates.git" + "type": "git", + "url": "http://github.com/staaky/vatrates.git" }, "author": { "name": "Nick Stakenburg", @@ -25,5 +25,9 @@ "type": "MIT", "url": "http://choosealicense.com/licenses/mit/" } - ] + ], + "devDependencies": { + "grunt": "^0.4.5", + "grunt-contrib-copy": "^0.8.1" + } } diff --git a/src/vatrates.js b/src/vatrates.js new file mode 100644 index 0000000..c7d93da --- /dev/null +++ b/src/vatrates.js @@ -0,0 +1,329 @@ +/*! + * VATRates - v<%= pkg.version %> + * Last update: <%= grunt.template.today("isoDateTime") %> + * MIT License + */ + +// UMD wrapper +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD + define([], factory); + } else if (typeof module === 'object' && module.exports) { + // Node/CommonJS + module.exports = factory(); + } else { + // Browser global + root.VATRates = factory(); + } +}(this, function() { + +var VATRates = { + "AT": { + "country": "Austria", + "rates": { + "superReduced": false, + "reduced": [10], + "standard": 20, + "parking": 12 + } + }, + + "BE": { + "country": "Belgium", + "rates": { + "superReduced": false, + "reduced": [6, 12], + "standard": 21, + "parking": 12 + } + }, + + "BG": { + "country": "Bulgaria", + "rates": { + "superReduced": false, + "reduced": [9], + "standard": 20, + "parking": false + } + }, + + "CY": { + "country": "Cyprus", + "rates": { + "superReduced": false, + "reduced": [5, 9], + "standard": 19, + "parking": false + } + }, + + "CZ": { + "country": "Czech Republic", + "rates": { + "superReduced": false, + "reduced": [10, 15], + "standard": 21, + "parking": false + } + }, + + "DE": { + "country": "Germany", + "rates": { + "superReduced": false, + "reduced": [7], + "standard": 19, + "parking": false + } + }, + + "DK": { + "country": "Denmark", + "rates": { + "superReduced": false, + "reduced": false, + "standard": 25, + "parking": false + } + }, + + "EE": { + "country": "Estonia", + "rates": { + "superReduced": false, + "reduced": [9], + "standard": 20, + "parking": false + } + }, + + "EL": { + "hasISODuplicate": "GR", + "country": "Greece", + "rates": { + "superReduced": false, + "reduced": [6.5, 13], + "standard": 23, + "parking": false + } + }, + + "GR": { + "isISODuplicateOf": "EL", + "country": "Greece", + "rates": { + "superReduced": false, + "reduced": [6.5, 13], + "standard": 23, + "parking": false + } + }, + + "ES": { + "country": "Spain", + "rates": { + "superReduced": 4, + "reduced": [10], + "standard": 21, + "parking": false + } + }, + + "FI": { + "country": "Finland", + "rates": { + "superReduced": false, + "reduced": [10, 14], + "standard": 24, + "parking": false + } + }, + + "FR": { + "country": "France", + "rates": { + "superReduced": 2.1, + "reduced": [5.5, 10], + "standard": 20, + "parking": false + } + }, + + "HR": { + "country": "Croatia", + "rates": { + "superReduced": false, + "reduced": [5,13], + "standard": 25, + "parking": false + } + }, + + "HU": { + "country": "Hungary", + "rates": { + "superReduced": false, + "reduced": [5, 18], + "standard": 27, + "parking": false + } + }, + + "IE": { + "country": "Ireland", + "rates": { + "superReduced": 4.8, + "reduced": [9, 13.5], + "standard": 23, + "parking": 13.5 + } + }, + + "IT": { + "country": "Italy", + "rates": { + "superReduced": 4, + "reduced": [10], + "standard": 22, + "parking": false + } + }, + + "LT": { + "country": "Lithuania", + "rates": { + "superReduced": false, + "reduced": [5, 9], + "standard": 21, + "parking": false + } + }, + + "LU": { + "country": "Luxembourg", + "rates": { + "superReduced": 3, + "reduced": [8], + "standard": 17, + "parking": 14 + } + }, + + "LV": { + "country": "Latvia", + "rates": { + "superReduced": false, + "reduced": [12], + "standard": 21, + "parking": false + } + }, + + "MT": { + "country": "Malta", + "rates": { + "superReduced": false, + "reduced": [5, 7], + "standard": 18, + "parking": false + } + }, + + "NL": { + "country": "Netherlands", + "rates": { + "superReduced": false, + "reduced": [6], + "standard": 21, + "parking": false + } + }, + + "PL": { + "country": "Poland", + "rates": { + "superReduced": false, + "reduced": [5, 8], + "standard": 23, + "parking": false + } + }, + + "PT": { + "country": "Portugal", + "rates": { + "superReduced": false, + "reduced": [6, 13], + "standard": 23, + "parking": 13 + } + }, + + "RO": { + "country": "Romania", + "rates": { + "superReduced": false, + "reduced": [5, 9], + "standard": 24, + "parking": false + } + }, + + "SE": { + "country": "Sweden", + "rates": { + "superReduced": false, + "reduced": [6, 12], + "standard": 25, + "parking": false + } + }, + + "SI": { + "country": "Slovenia", + "rates": { + "superReduced": false, + "reduced": [9.5], + "standard": 22, + "parking": false + } + }, + + "SK": { + "country": "Slovakia", + "rates": { + "superReduced": false, + "reduced": [10], + "standard": 20, + "parking": false + } + }, + + "UK": { + "hasISODuplicate": "GB", + "country": "United Kingdom", + "rates": { + "superReduced": false, + "reduced": [5], + "standard": 20, + "parking": false + } + }, + + "GB": { + "isISODuplicateOf": "UK", + "country": "United Kingdom", + "rates": { + "superReduced": false, + "reduced": [5], + "standard": 20, + "parking": false + } + } +}; + +return VATRates; + +})); diff --git a/src/vatrates.json b/src/vatrates.json new file mode 100644 index 0000000..49d6039 --- /dev/null +++ b/src/vatrates.json @@ -0,0 +1,305 @@ +{ + "AT": { + "country": "Austria", + "rates": { + "superReduced": false, + "reduced": [10], + "standard": 20, + "parking": 12 + } + }, + + "BE": { + "country": "Belgium", + "rates": { + "superReduced": false, + "reduced": [6, 12], + "standard": 21, + "parking": 12 + } + }, + + "BG": { + "country": "Bulgaria", + "rates": { + "superReduced": false, + "reduced": [9], + "standard": 20, + "parking": false + } + }, + + "CY": { + "country": "Cyprus", + "rates": { + "superReduced": false, + "reduced": [5, 9], + "standard": 19, + "parking": false + } + }, + + "CZ": { + "country": "Czech Republic", + "rates": { + "superReduced": false, + "reduced": [10, 15], + "standard": 21, + "parking": false + } + }, + + "DE": { + "country": "Germany", + "rates": { + "superReduced": false, + "reduced": [7], + "standard": 19, + "parking": false + } + }, + + "DK": { + "country": "Denmark", + "rates": { + "superReduced": false, + "reduced": false, + "standard": 25, + "parking": false + } + }, + + "EE": { + "country": "Estonia", + "rates": { + "superReduced": false, + "reduced": [9], + "standard": 20, + "parking": false + } + }, + + "EL": { + "hasISODuplicate": "GR", + "country": "Greece", + "rates": { + "superReduced": false, + "reduced": [6.5, 13], + "standard": 23, + "parking": false + } + }, + + "GR": { + "isISODuplicateOf": "EL", + "country": "Greece", + "rates": { + "superReduced": false, + "reduced": [6.5, 13], + "standard": 23, + "parking": false + } + }, + + "ES": { + "country": "Spain", + "rates": { + "superReduced": 4, + "reduced": [10], + "standard": 21, + "parking": false + } + }, + + "FI": { + "country": "Finland", + "rates": { + "superReduced": false, + "reduced": [10, 14], + "standard": 24, + "parking": false + } + }, + + "FR": { + "country": "France", + "rates": { + "superReduced": 2.1, + "reduced": [5.5, 10], + "standard": 20, + "parking": false + } + }, + + "HR": { + "country": "Croatia", + "rates": { + "superReduced": false, + "reduced": [5,13], + "standard": 25, + "parking": false + } + }, + + "HU": { + "country": "Hungary", + "rates": { + "superReduced": false, + "reduced": [5, 18], + "standard": 27, + "parking": false + } + }, + + "IE": { + "country": "Ireland", + "rates": { + "superReduced": 4.8, + "reduced": [9, 13.5], + "standard": 23, + "parking": 13.5 + } + }, + + "IT": { + "country": "Italy", + "rates": { + "superReduced": 4, + "reduced": [10], + "standard": 22, + "parking": false + } + }, + + "LT": { + "country": "Lithuania", + "rates": { + "superReduced": false, + "reduced": [5, 9], + "standard": 21, + "parking": false + } + }, + + "LU": { + "country": "Luxembourg", + "rates": { + "superReduced": 3, + "reduced": [8], + "standard": 17, + "parking": 14 + } + }, + + "LV": { + "country": "Latvia", + "rates": { + "superReduced": false, + "reduced": [12], + "standard": 21, + "parking": false + } + }, + + "MT": { + "country": "Malta", + "rates": { + "superReduced": false, + "reduced": [5, 7], + "standard": 18, + "parking": false + } + }, + + "NL": { + "country": "Netherlands", + "rates": { + "superReduced": false, + "reduced": [6], + "standard": 21, + "parking": false + } + }, + + "PL": { + "country": "Poland", + "rates": { + "superReduced": false, + "reduced": [5, 8], + "standard": 23, + "parking": false + } + }, + + "PT": { + "country": "Portugal", + "rates": { + "superReduced": false, + "reduced": [6, 13], + "standard": 23, + "parking": 13 + } + }, + + "RO": { + "country": "Romania", + "rates": { + "superReduced": false, + "reduced": [5, 9], + "standard": 24, + "parking": false + } + }, + + "SE": { + "country": "Sweden", + "rates": { + "superReduced": false, + "reduced": [6, 12], + "standard": 25, + "parking": false + } + }, + + "SI": { + "country": "Slovenia", + "rates": { + "superReduced": false, + "reduced": [9.5], + "standard": 22, + "parking": false + } + }, + + "SK": { + "country": "Slovakia", + "rates": { + "superReduced": false, + "reduced": [10], + "standard": 20, + "parking": false + } + }, + + "UK": { + "hasISODuplicate": "GB", + "country": "United Kingdom", + "rates": { + "superReduced": false, + "reduced": [5], + "standard": 20, + "parking": false + } + }, + + "GB": { + "isISODuplicateOf": "UK", + "country": "United Kingdom", + "rates": { + "superReduced": false, + "reduced": [5], + "standard": 20, + "parking": false + } + } +} \ No newline at end of file diff --git a/src/vatrates.php b/src/vatrates.php new file mode 100644 index 0000000..b18d95f --- /dev/null +++ b/src/vatrates.php @@ -0,0 +1,312 @@ + + * Last update: <%= grunt.template.today("isoDateTime") %> + * MIT License + */ + +$VATRates = array( + "AT" => array( + "country" => "Austria", + "rates" => array( + "superReduced" => false, + "reduced" => array(10), + "standard" => 20, + "parking" => 12 + ) + ), + + "BE" => array( + "country" => "Belgium", + "rates" => array( + "superReduced" => false, + "reduced" => array(6, 12), + "standard" => 21, + "parking" => 12 + ) + ), + + "BG" => array( + "country" => "Bulgaria", + "rates" => array( + "superReduced" => false, + "reduced" => array(9), + "standard" => 20, + "parking" => false + ) + ), + + "CY" => array( + "country" => "Cyprus", + "rates" => array( + "superReduced" => false, + "reduced" => array(5, 9), + "standard" => 19, + "parking" => false + ) + ), + + "CZ" => array( + "country" => "Czech Republic", + "rates" => array( + "superReduced" => false, + "reduced" => array(10, 15), + "standard" => 21, + "parking" => false + ) + ), + + "DE" => array( + "country" => "Germany", + "rates" => array( + "superReduced" => false, + "reduced" => array(7), + "standard" => 19, + "parking" => false + ) + ), + + "DK" => array( + "country" => "Denmark", + "rates" => array( + "superReduced" => false, + "reduced" => false, + "standard" => 25, + "parking" => false + ) + ), + + "EE" => array( + "country" => "Estonia", + "rates" => array( + "superReduced" => false, + "reduced" => array(9), + "standard" => 20, + "parking" => false + ) + ), + + "EL" => array( + "hasISODuplicate" => "GR", + "country" => "Greece", + "rates" => array( + "superReduced" => false, + "reduced" => array(6.5, 13), + "standard" => 23, + "parking" => false + ) + ), + + "GR" => array( + "isISODuplicateOf" => "EL", + "country" => "Greece", + "rates" => array( + "superReduced" => false, + "reduced" => array(6.5, 13), + "standard" => 23, + "parking" => false + ) + ), + + "ES" => array( + "country" => "Spain", + "rates" => array( + "superReduced" => 4, + "reduced" => array(10), + "standard" => 21, + "parking" => false + ) + ), + + "FI" => array( + "country" => "Finland", + "rates" => array( + "superReduced" => false, + "reduced" => array(10, 14), + "standard" => 24, + "parking" => false + ) + ), + + "FR" => array( + "country" => "France", + "rates" => array( + "superReduced" => 2.1, + "reduced" => array(5.5, 10), + "standard" => 20, + "parking" => false + ) + ), + + "HR" => array( + "country" => "Croatia", + "rates" => array( + "superReduced" => false, + "reduced" => array(5,13), + "standard" => 25, + "parking" => false + ) + ), + + "HU" => array( + "country" => "Hungary", + "rates" => array( + "superReduced" => false, + "reduced" => array(5, 18), + "standard" => 27, + "parking" => false + ) + ), + + "IE" => array( + "country" => "Ireland", + "rates" => array( + "superReduced" => 4.8, + "reduced" => array(9, 13.5), + "standard" => 23, + "parking" => 13.5 + ) + ), + + "IT" => array( + "country" => "Italy", + "rates" => array( + "superReduced" => 4, + "reduced" => array(10), + "standard" => 22, + "parking" => false + ) + ), + + "LT" => array( + "country" => "Lithuania", + "rates" => array( + "superReduced" => false, + "reduced" => array(5, 9), + "standard" => 21, + "parking" => false + ) + ), + + "LU" => array( + "country" => "Luxembourg", + "rates" => array( + "superReduced" => 3, + "reduced" => array(8), + "standard" => 17, + "parking" => 14 + ) + ), + + "LV" => array( + "country" => "Latvia", + "rates" => array( + "superReduced" => false, + "reduced" => array(12), + "standard" => 21, + "parking" => false + ) + ), + + "MT" => array( + "country" => "Malta", + "rates" => array( + "superReduced" => false, + "reduced" => array(5, 7), + "standard" => 18, + "parking" => false + ) + ), + + "NL" => array( + "country" => "Netherlands", + "rates" => array( + "superReduced" => false, + "reduced" => array(6), + "standard" => 21, + "parking" => false + ) + ), + + "PL" => array( + "country" => "Poland", + "rates" => array( + "superReduced" => false, + "reduced" => array(5, 8), + "standard" => 23, + "parking" => false + ) + ), + + "PT" => array( + "country" => "Portugal", + "rates" => array( + "superReduced" => false, + "reduced" => array(6, 13), + "standard" => 23, + "parking" => 13 + ) + ), + + "RO" => array( + "country" => "Romania", + "rates" => array( + "superReduced" => false, + "reduced" => array(5, 9), + "standard" => 24, + "parking" => false + ) + ), + + "SE" => array( + "country" => "Sweden", + "rates" => array( + "superReduced" => false, + "reduced" => array(6, 12), + "standard" => 25, + "parking" => false + ) + ), + + "SI" => array( + "country" => "Slovenia", + "rates" => array( + "superReduced" => false, + "reduced" => array(9.5), + "standard" => 22, + "parking" => false + ) + ), + + "SK" => array( + "country" => "Slovakia", + "rates" => array( + "superReduced" => false, + "reduced" => array(10), + "standard" => 20, + "parking" => false + ) + ), + + "UK" => array( + "hasISODuplicate" => "GB", + "country" => "United Kingdom", + "rates" => array( + "superReduced" => false, + "reduced" => array(5), + "standard" => 20, + "parking" => false + ) + ), + + "GB" => array( + "isISODuplicateOf" => "UK", + "country" => "United Kingdom", + "rates" => array( + "superReduced" => false, + "reduced" => array(5), + "standard" => 20, + "parking" => false + ) + ) +); diff --git a/tests/css/github_mark.png b/tests/css/github_mark.png new file mode 100644 index 0000000000000000000000000000000000000000..b4c86ead8c2fe30fd24612eb0ed54779863d350c GIT binary patch literal 367 zcmV-#0g(QQP)#X3mrt@D`)^NzT!68G@1D&9Q{%cK z|C&0Nnk+z7=@#;xivub|Y)Q8|JOW_Kx=fePsnd8ws&ZwUnORHjx)L>i N002ovPDHLkV1f(gl1Kmm literal 0 HcmV?d00001 diff --git a/tests/css/github_mark.svg b/tests/css/github_mark.svg new file mode 100644 index 0000000..f871505 --- /dev/null +++ b/tests/css/github_mark.svg @@ -0,0 +1,15 @@ + + + + + + diff --git a/tests/css/reset.css b/tests/css/reset.css new file mode 100644 index 0000000..621c018 --- /dev/null +++ b/tests/css/reset.css @@ -0,0 +1,8 @@ +/* RESET */ +html,body,div,ul,ol,li,dl,dt,dd,h1,h2,h3,h4,h5,h6,pre,form,p,blockquote,fieldset,input { margin: 0; padding: 0; } +h1,h2,h3,h4,h5,h6,pre,code,address,caption,cite,code,th { font-size: 1em; font-weight: normal; font-style: normal; } +ul,ol { list-style: none; } +fieldset,img { border: none; } +caption,th { text-align: left; } +table { border-collapse: collapse; border-spacing: 0; } + diff --git a/tests/css/style.css b/tests/css/style.css new file mode 100644 index 0000000..8f2bcf1 --- /dev/null +++ b/tests/css/style.css @@ -0,0 +1,164 @@ +html { + background: #fff; + font-size: 100%; + min-height: 100%; + width: 100%; + margin-bottom: 1px; + overflow: -moz-scrollbars-vertical !important; + overflow-y: scroll; + box-sizing: border-box; +} +*, *:before, *:after { + box-sizing: inherit; +} + +body, input, textarea, select { + font: 18px/32px Georgia, Times, "Times New Roman", serif; + background-color: transparent; + color: #333; + -webkit-font-smoothing: antialiased; +} + +body { + background-color: #fff; + height: 100%; + width: 100%; + position: relative; + padding: 0; + margin: 0; + float: left; + padding: 30px; +} + +p, section { + float: left; + clear: both; + width: 100%; + margin-bottom: 32px; +} +strong { font-weight: bold; } + +h1, h2, h3, h4, h5, h6 { + margin-bottom: 0; + font-weight: bold; + float: left; + clear: both; + width: 100%; + color: #333; +} + +h1 { font-size: 28px; line-height: 34px; margin-bottom: 34px; font-family: Georgia, Times, "Times New Roman", serif; font-style: italic; font-weight: normal; } +h2 { font-size: 26px; line-height: 32px; margin-bottom: 32px; font-family: Georgia, Times, "Times New Roman", serif; font-style: italic; font-weight: normal; color: #333; } + +.ic { + padding: 5px 7px; + font-size: 13px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + margin: 0 1px; + border-radius: 4px; + color: #555; + border: 1px solid #ccc; + background-color: #ececec; + box-shadow: inset 0 1px 2px rgba(0,0,0,.1);/*inset 0 1px 0 rgba(255,255,255,.5), inset 0 -1px 0 rgba(255,255,255,.2), 0 1px 0 rgba(0,0,0,.05);*/ + text-shadow: 0 1px 0 rgba(255,255,255,.8); + font-family: "Lucida Console", "Droid Sans Mono", "Courier New", "Lucida Sans Unicode", monospace, sans-serif; +} +.ic a { background: none; padding: 0; margin: 0; } + + +/* Tests */ +#lists { + float: left; + clear: both; +} + +.list { + float: left; + margin: 0 20px 20px 0; +} + +.list table { + float: left; + clear: both; + font-family: Menlo, Monaco, "Andale Mono", "lucida console", "Courier New", monospace; + font-size: 13px; + line-height: 20px; + padding: 0; + margin: 0 0 32px 0; +} + +.list table td { + padding: 3px 6px; + border: 1px solid #ccc; +} + +.list table tr:nth-child(even) {background: #f9f9f9; } +.list table .legenda { font-weight: bold; background: #fff; color: #333; } +.list table .rate { text-align: center; max-width: 100px; } + +#results { + padding: 4px 12px; + border-radius: 8px; + float: left; + margin-bottom: 40px; + font-size: 15px; + font-family: Arial, Helvetica, sans-serif; + font-weight: bold; + text-shadow: 0 1px 0 rgba(0,0,0,.4); +} +.error { background: #ee1111 !important; color: #fff !important; } +.success { background: #44ab44 !important; color: #fff !important; } + +.github { + position: absolute; + top: 0; + right: 0; + width: 40px; + height: 40px; + background-color: transparent; + overflow: hidden; +} + +.github .ribbon { + position: absolute; + top: 0; + right: 0; + width: 40px; + height: 40px; + background: #e8341a; + margin: 0; +} +.github:hover .ribbon { + background: #1492e2; +} + +.github i { + position: absolute; + top: 0; + right: 0; + width: 40px; + height: 40px; + background: url('github_mark.png') 50% 50% no-repeat; + cursor: pointer; +} +.svg .github i { + background: url('github_mark.svg') 50% 50% no-repeat; +} + +@supports (transform:rotate(45deg)) { + .github { + width: 90px; + height: 90px; + } + .github .ribbon { + margin: 0; + margin-right: -60px; + width: 200px; + height: 40px; + transform:rotate(45deg); + } + .github i { + margin: 10px 10px 0 0; + } +} \ No newline at end of file diff --git a/tests/index.php b/tests/index.php new file mode 100644 index 0000000..0108a5f --- /dev/null +++ b/tests/index.php @@ -0,0 +1,125 @@ + + + + +VATRates - Tests + + + + + + + + + + + + + + + + +

VATRates - Tests

+ +

This page tests all files in production (.js, .json & .php) + and helps make sure VAT rates are identical across files.

+ +
+ +
+ + +
+

vatrates.js

+ +
+ + + + + +
+

vatrates.json

+ + + + + + + + + + + + + $data) : ?> + + + + + + + + + + + + +
CountryCodeSuper reducedReducedStandardParking
+ + +
+
+ + + +
+

vatrates.php

+ + + + + + + + + + + + + $data) : ?> + + + + + + + + + + + + +
CountryCodeSuper reducedReducedStandardParking
+ + +
+
+ +
+ + + \ No newline at end of file diff --git a/tests/js/table-js.js b/tests/js/table-js.js new file mode 100644 index 0000000..ba91c31 --- /dev/null +++ b/tests/js/table-js.js @@ -0,0 +1,45 @@ +(function($, VATRates) { + var Table = { + create: function() { + var results = $('#list-js'), + tbody; + + results.append($('') + .append(tbody = $('')) + ); + + tbody.append($('').addClass('legenda') + .append($('') + .append($('
').addClass('country').html('Country')) + .append($('').addClass('country-code').html('Code')) + .append($('').addClass('rate rate-super-reduced').html('Super reduced')) + .append($('').addClass('rate rate-reduced').html('Reduced')) + .append($('').addClass('rate rate-standard').html('Standard')) + .append($('').addClass('rate rate-parking').html('Parking')) + ); + + $.each(VATRates, function(country_code, data) { + var tr; + + tbody.append(tr = $('
').addClass('country').append(data.country)) + .append($('').addClass('country-code').append(country_code)) + .append($('').addClass('rate rate-super-reduced').append(data.rates.superReduced || '-' )) + ); + + // reduced rates + var reduced = '-'; + if (data.rates.reduced) { + reduced = data.rates.reduced.join(' / '); + } + tr.append($('').addClass('rate rate-reduced').append(reduced)); + + tr.append($('').addClass('rate rate-standard').append(data.rates.standard || '-' )) + .append($('').addClass('rate rate-parking').append(data.rates.parking || '-' )); + }); + } + }; + + $(function() { + Table.create(); + }); +})(jQuery, VATRates); \ No newline at end of file diff --git a/tests/js/tests.js b/tests/js/tests.js new file mode 100644 index 0000000..8531364 --- /dev/null +++ b/tests/js/tests.js @@ -0,0 +1,70 @@ +// Tests +(function($) { + var Tests = { + run: function() { + var lists = $('.list'), + errors = []; + + // check if all files load + var loaded = 0; + lists.each(function(i, list) { + var type = $(list).attr('id').replace(/^list-/, ''); + if ($(list).find('table tr:not(.legenda)').length < 0 || + $(list).html().indexOf('Netherlands') < 0) { + errors.push('Error: vatrates.' + type + " won't load, it might have a syntax error"); + $(list).find('h1').addClass('error'); + } else { + loaded++; + } + }); + + if (loaded != lists.length) { + // exit here + this.error(errors); + return; + } + + // check for differences + var differences = 0; + // go over the first table, check that all others match + var jsTable = $('#list-js table'); + + $('table:not(#list-js table)').each(function(i, table) { + $(table).find('tr').each(function(y, tr) { + $(tr).find('td').each(function(x, td) { + var value = $.trim($(td).html()); + // find matching js value + var compareWith = $($(jsTable.find('tr')[y]).find('td')[x]); + + if (value != $.trim(compareWith.html())) { + compareWith.add(td).addClass('error'); + differences++; + } + }); + }); + }); + + if (differences) { + errors.push("Error: Found some differences, fix the incorrect values"); + this.error(errors); + return; + } + + this.success("Success! No issues detected") + }, + + error: function(errors) { + $('#results').append(errors.join('
')) + .addClass('error'); + }, + + success: function(msg) { + if (msg) $('#results').append(msg); + $("#results").addClass('success'); + } + }; + + $(document).ready(function() { + Tests.run(); + }); +})(jQuery); \ No newline at end of file diff --git a/vatrates.js b/vatrates.js index 9042309..7bb0ce7 100644 --- a/vatrates.js +++ b/vatrates.js @@ -1,5 +1,6 @@ /*! - * VATRates - v1.1.0 + * VATRates - v1.2.0 + * Last update: 2015-08-20T19:37:53 * MIT License */ @@ -34,7 +35,7 @@ var VATRates = { "superReduced": false, "reduced": [6, 12], "standard": 21, - "parking": false + "parking": 12 } }, @@ -62,7 +63,7 @@ var VATRates = { "country": "Czech Republic", "rates": { "superReduced": false, - "reduced": [15], + "reduced": [10, 15], "standard": 21, "parking": false } @@ -204,9 +205,9 @@ var VATRates = { "country": "Luxembourg", "rates": { "superReduced": 3, - "reduced": [6, 12], + "reduced": [8], "standard": 17, - "parking": 12 + "parking": 14 } }, diff --git a/vatrates.json b/vatrates.json index 8c23a1f..49d6039 100644 --- a/vatrates.json +++ b/vatrates.json @@ -15,7 +15,7 @@ "superReduced": false, "reduced": [6, 12], "standard": 21, - "parking": false + "parking": 12 } }, @@ -43,7 +43,7 @@ "country": "Czech Republic", "rates": { "superReduced": false, - "reduced": [15], + "reduced": [10, 15], "standard": 21, "parking": false } @@ -185,9 +185,9 @@ "country": "Luxembourg", "rates": { "superReduced": 3, - "reduced": [6, 12], + "reduced": [8], "standard": 17, - "parking": 12 + "parking": 14 } }, @@ -302,4 +302,4 @@ "parking": false } } -}; +} \ No newline at end of file diff --git a/vatrates.php b/vatrates.php index 1929a45..005f9bf 100644 --- a/vatrates.php +++ b/vatrates.php @@ -1,6 +1,7 @@ false, "reduced" => array(6, 12), "standard" => 21, - "parking" => false + "parking" => 12 ) ), @@ -49,7 +50,7 @@ "country" => "Czech Republic", "rates" => array( "superReduced" => false, - "reduced" => array(15), + "reduced" => array(10, 15), "standard" => 21, "parking" => false ) @@ -191,9 +192,9 @@ "country" => "Luxembourg", "rates" => array( "superReduced" => 3, - "reduced" => array(6, 12), + "reduced" => array(8), "standard" => 17, - "parking" => 12 + "parking" => 14 ) ),