【2023+年度收入个税计算方法】

用法:

根据社保公积金缴存比例,自行统计出应税收入,带入函数即可
年度应税收入 = (全年累计社保公积金总额 + 全年累计附加专项扣除)
年终奖单独计税

#include 
struct tax_info
{
	double threshold;
	double rate;
};

static tax_info tax_tab[]{
	{960000, 0.45},
	{660000, 0.35},
	{420000, 0.30},
	{300000, 0.25},
	{144000, 0.20},
	{36000, 0.10},
	{0, 0.03},
};


/* 
* @summary: 计算年收入算法
* @param total_salary: 应税收入毛收入减去附加专项扣除和社保公积金
* @return: 税后收入和个税
*/
std::tuple<double, double> compute_salary_year(double total_salary) {
	double total = total_salary;

	double tax = 0;
	double last_value = 0;

	for (auto& taxinfo : tax_tab) {
		if (total > taxinfo.threshold) {
			auto store_value = last_value;
			last_value = (total - taxinfo.threshold) - store_value;
			tax += last_value * taxinfo.rate;
			last_value += store_value;
		}
	}
	return std::tuple<double, double>(total - tax, tax);
}

你可能感兴趣的:(c++)