October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

Build a Sri Lankan Salary and APIT Simulator with Python and Streamlit

Build a Python and Streamlit prototype that estimates annual tax from Sri Lanka’s 2025/2026 chart while making clear why that is not the same as exact APIT withholding or complete take-home pay.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can build a useful Sri Lankan salary simulator with Python and Streamlit, but there is an important distinction: the code below estimates annual income tax from the Inland Revenue Department’s 2025/2026 tax chart and converts that estimate to a monthly equivalent. It does not reproduce an employer’s APIT withholding from the IRD tables, so its result is not an exact payroll deduction or guaranteed take-home pay.

The prototype is a starting point for modelling regular salary income. It shows the assumptions alongside the estimate and keeps any other deductions separate. To calculate actual APIT, replace the annual-tax approximation with the verified table and rules for the employee’s situation.

As an Amazon Associate I earn from qualifying purchases.

What the simulator calculates—and what it does not

Advance Personal Income Tax (APIT) is tax withheld from employment income when remuneration is paid. Under Section 83A, employers deduct it using tables specified by the Commissioner General of Inland Revenue, then remit the deductions by the 15th of the following month. See the IRD’s APIT guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The example app instead calculates an annual tax estimate from the IRD’s 2025/2026 individual rates, subtracts LKR 1,800,000 of personal relief when the user says they qualify, and divides the result by 12 to show a monthly equivalent. That division is a modelling shortcut; it is not a claim that it matches an APIT table deduction in any particular month.

The IRD’s APIT publications distinguish regular monthly employment income from cases such as secondary employment, lump sums, terminal benefits, non-resident non-citizens, cumulative gains and foreign-employer income. A tool should claim to cover one of those cases only after its matching table and rules have been implemented and checked.

Which tax rules should the prototype use?

The IRD tax chart for Year of Assessment 2025/2026, last updated 2025-08-28, gives personal relief of LKR 1,800,000 for residents and non-resident citizens of Sri Lanka. It applies the following marginal rates to taxable income, not directly to gross salary:

Taxable-income slice Rate
First LKR 1,000,000 6%
Next LKR 500,000 18%
Next LKR 500,000 24%
Next LKR 500,000 30%
Balance 36%

These bands are encoded in the function below. The example treats annual gross salary as the income being modelled and applies the relief only when selected. It does not account for other income, exemptions, adjustments or special circumstances. Confirm a person’s taxable income and relief eligibility under the applicable rules before relying on the estimate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build the Streamlit prototype

1. Install the packages

Use a Python environment for the project, then install Streamlit:

python -m pip install streamlit

2. Save the app

Create a file named app.py. This version accepts monthly gross salary, annualizes it for the tax-chart estimate, and lets the reader enter other monthly deductions separately. Its result labels make clear that the monthly tax figure is only an annualized estimate.

import streamlit as st

RELIEF_LKR = 1_800_000


def annual_tax_estimate(taxable_income: float) -> float:
    """Estimate annual tax using the IRD Y/A 2025/2026 marginal bands."""
    remaining = max(0.0, taxable_income)
    tax = 0.0

    bands = [
        (1_000_000, 0.06),
        (500_000, 0.18),
        (500_000, 0.24),
        (500_000, 0.30),
    ]

    for band_width, rate in bands:
        slice_amount = min(remaining, band_width)
        tax += slice_amount * rate
        remaining -= slice_amount
        if remaining <= 0:
            return tax

    # The balance above the listed fixed-width bands is taxed at 36%.
    return tax + remaining * 0.36


st.set_page_config(page_title="Sri Lanka Salary Simulator", page_icon="💼")
st.title("Sri Lanka salary and tax estimate")
st.caption("Annual-tax estimate based on the IRD Y/A 2025/2026 chart; not an APIT-table calculation.")

st.subheader("Your pay assumptions")
monthly_gross = st.number_input(
    "Regular monthly gross salary (LKR)", min_value=0, value=200_000, step=10_000
)
relief_eligible = st.checkbox(
    "Assume I qualify for LKR 1,800,000 personal relief", value=True
)
other_deductions = st.number_input(
    "Other monthly deductions to subtract (LKR)", min_value=0, value=0, step=1_000,
    help="Enter only deductions you want shown in this estimate. This app does not determine their legal or payroll treatment."
)

annual_gross = monthly_gross * 12
relief = RELIEF_LKR if relief_eligible else 0
estimated_taxable_income = max(0, annual_gross - relief)
annual_tax = annual_tax_estimate(estimated_taxable_income)
monthly_tax_equivalent = annual_tax / 12
estimated_monthly_remainder = max(
    0, monthly_gross - monthly_tax_equivalent - other_deductions
)

st.subheader("Estimate")
col1, col2 = st.columns(2)
col1.metric("Annual taxable income used", f"LKR {estimated_taxable_income:,.0f}")
col2.metric("Estimated annual tax", f"LKR {annual_tax:,.0f}")
col1.metric("Annual tax divided by 12", f"LKR {monthly_tax_equivalent:,.0f}")
col2.metric("Remainder after entered deductions", f"LKR {estimated_monthly_remainder:,.0f}")

st.warning(
    "The monthly tax figure is annual estimated tax divided by 12, not verified APIT "
    "withholding. This estimate does not model every tax rule or payroll deduction. "
    "Check the applicable IRD APIT table and your employer's calculation."
)
st.caption("Tax-chart basis: Inland Revenue Department, Year of Assessment 2025/2026.")

3. Run it locally

  1. In a terminal opened in the folder containing app.py, run streamlit run app.py.

  2. Open the local address Streamlit prints in the terminal. Enter regular monthly gross salary, indicate whether the relief assumption applies, and enter any other monthly deductions you want the display to subtract.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  3. Check the displayed annual taxable income and annual tax estimate before interpreting the monthly figures. The app presents the latter as annual tax divided by 12, not as an APIT-table result.

How the calculation works

Annualize the regular monthly salary

The prototype multiplies monthly gross pay by 12. This is an explicit assumption that the same regular salary is paid for all 12 months. It is unsuitable without modification for irregular earnings, bonuses, one-off payments or partial-year employment.

Apply the relief assumption and marginal bands

The function first subtracts relief from annual gross salary, floors taxable income at zero, then taxes each slice at its corresponding rate. Only the income in a slice receives that slice’s rate; for example, crossing into the 18% band does not make the first band taxable at 18%.

Keep deductions distinct

The separate “other monthly deductions” input changes only the displayed remainder. It does not alter taxable income or estimated tax. The cited IRD materials establish the APIT component, not a complete net-pay formula covering employee-side EPF or every employer-specific deduction. Treat the displayed remainder as a scenario estimate, not an authoritative payslip figure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What to change for genuine APIT withholding

The IRD’s APIT tables page publishes table sets, and the Y/A 2025/2026 APIT guideline identifies its applicability for that assessment year and onwards. To move from an annual chart estimate to a payroll withholding calculator:

How to present the result responsibly

Put the currency, pay period, assessment year, employment case and calculation basis in the interface—not only in an about page. For the example above, “LKR” and “monthly gross salary” are explicit; the caption identifies Y/A 2025/2026 and warns that the estimate is not APIT-table withholding. If you later implement a table-based route, replace that wording with the specific table and case it supports.

A community forum search result describes a Streamlit project using a salary/APIT framing, but its page was unavailable for verification. That does not establish the code’s tax accuracy, current library usage, security, testing or deployment. Treat the implementation here as an independent educational prototype, not a claim about that project.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.