コード例 #1
0
ファイル: tax.py プロジェクト: HenryHerrera3/tax-tools
def taxFromEarnings(rates, earn):
	tax = 0

	for (rate, level) in orderedRates(rates):
		left = earn - level
		if left > 0:
			earn = left
			tax += level * rate
		else:	# they're in this band
			tax += earn * rate
			break

	return tax
コード例 #2
0
ファイル: earnings.py プロジェクト: HenryHerrera3/tax-tools
def earningsFromTax(rates, tax):
	if tax == 0:
		return "Up to %s" % rates[0]

	earn = 0

	for (rate, level) in orderedRates(rates):
		max_tax = level * rate	# at this band

#		print rate, level, max_tax, tax

		if tax > max_tax:
			tax -= max_tax
			earn += level
		else:	# they're in this band
			earn += tax / rate
			break

	return earn