Sha256: c5fb9627c4ebe2756bcc5ee5ddd925f15eadd7bd9284fb5daa2b8f63c22da93e
Contents?: true
Size: 1.19 KB
Versions: 25
Compression:
Stored size: 1.19 KB
Contents
if (typeof tax === "undefined") { var tax = {}; } tax.NONTAXABLE = 1; // 非課税 tax.INCLUSIVE = 2; // 内税 tax.EXCLUSIVE = 3; // 外税 tax.consumptionTaxes = [ {date: Date.parse('2019-10-01'), rate: 0.1, reduced_rate: 0.08}, {date: Date.parse('2014-04-01'), rate: 0.08, reduced_rate: 0}, {date: Date.parse('1997-04-01'), rate: 0.05, reduced_rate: 0}, {date: Date.parse('1989-04-01'), rate: 0.03, reduced_rate: 0}, ]; 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 ++) { if (options.reduced) { ret = this.consumptionTaxes[i].reduced_rate; } else { 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 amount - Math.ceil(amount / (1 + rate)); } else if ( taxType == tax.EXCLUSIVE ) { return Math.floor(amount * rate); } return ''; };
Version data entries
25 entries across 25 versions & 1 rubygems