Sha256: 4ce404341272073f4b233b7f83a02ccb05557aef2f4ee37503c0ad6ae18fbe8f
Contents?: true
Size: 1001 Bytes
Versions: 37
Compression:
Stored size: 1001 Bytes
Contents
if (typeof tax === "undefined") { var tax = {}; } tax.NONTAXABLE = 1; // 非課税 tax.INCLUSIVE = 2; // 内税 tax.EXCLUSIVE = 3; // 外税 tax.consumptionTaxes = [ {date: Date.parse('2014-04-01'), rate: 0.08}, {date: Date.parse('1997-04-01'), rate: 0.05}, {date: Date.parse('1989-04-01'), rate: 0.03}, ]; tax.getRateOn = function(date, options) { if (typeof date === 'string') { date = Date.parse(date); } options = options || {}; var ret = 0; for (var i = 0; this.consumptionTaxes.length; i ++) { ret = this.consumptionTaxes[i].rate; if (date >= this.consumptionTaxes[i].date) { break; } } if (options.percent) { ret *= 100; } return ret; }; tax.calcTaxAmount = function(taxType, rate, amount) { if ( isNaN( amount ) ) { return ''; } if ( taxType == tax.INCLUSIVE ) { return parseInt(amount * rate / (1 + rate)); } else if ( taxType == tax.EXCLUSIVE ) { return parseInt(amount * rate); } return ''; };
Version data entries
37 entries across 37 versions & 1 rubygems