If you're building HR or payroll software for Vietnam, the gross-to-net calculation looks simple until it isn't. Four rules cause most of the bugs I've seen.
1. Insurance uses a different base than tax
Employee social, health and unemployment insurance are calculated on the insured salary, which has a floor (regional minimum wage) and a ceiling. Tax is calculated on income after insurance. Two different bases, so keep two fields.
2. Deductions come before brackets
Taxable income = gross − employee insurance − personal deduction − dependant deductions − exempt allowances. Only registered dependants count.
3. Brackets are progressive, slice by slice
Apply each rate only to the slice within its bracket. Applying the top marginal rate to everything is the classic bug.
function pit(taxable, brackets) { let tax = 0, prev = 0; for (const { upTo, rate } of brackets) { if (taxable <= prev) break; tax += (Math.min(taxable, upTo) - prev) * rate; prev = upTo; } return Math.round(tax); } Keep brackets, deductions and insurance caps in dated config: they change by law, and Vietnam's PIT rules were revised for 2026.
4. Residents vs non-residents
Non-residents pay a flat rate on Vietnam-sourced income with no deductions. Branch early.
Test against a reference
Pick 10 salaries (including one above the insurance cap and one with dependants) and compare your output to an independent tool. I use VNEN's PIT calculator for spot checks before each release.
