<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rasindu Pramith</title>
    <description>The latest articles on DEV Community by Rasindu Pramith (@rasindupramithoss).</description>
    <link>https://dev.to/rasindupramithoss</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4135490%2F427da5e8-4ec5-4042-8d7a-42ab657c4d2e.jpg</url>
      <title>DEV Community: Rasindu Pramith</title>
      <link>https://dev.to/rasindupramithoss</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rasindupramithoss"/>
    <language>en</language>
    <item>
      <title>Building an Interactive Salary, APIT Tax &amp; Take-Home Pay Simulator with Python and Streamlit</title>
      <dc:creator>Rasindu Pramith</dc:creator>
      <pubDate>Mon, 21 Sep 2026 10:33:37 +0000</pubDate>
      <link>https://dev.to/rasindupramithoss/building-an-interactive-salary-apit-tax-take-home-pay-simulator-with-python-and-streamlit-idm</link>
      <guid>https://dev.to/rasindupramithoss/building-an-interactive-salary-apit-tax-take-home-pay-simulator-with-python-and-streamlit-idm</guid>
      <description>&lt;p&gt;When negotiating job offers or evaluating compensation packages, one common headache employees face is calculating their exact net cashflow. In Sri Lanka, macroeconomic reforms and progressive personal income tax (APIT) brackets often lead to misunderstandings—with many professionals mistakenly assuming their entire earnings are taxed at the highest marginal rate.&lt;/p&gt;

&lt;p&gt;To solve this everyday financial challenge, I engineered an interactive web simulator using Python, Streamlit, and Plotly, calibrated with the official Inland Revenue Department (IRD) tax tables.&lt;/p&gt;




&lt;h3&gt;
  
  
  Live Application &amp;amp; Source Code
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Live Web App: &lt;a href="https://sri-lanka-salary-tax-simulator.streamlit.app" rel="noopener noreferrer"&gt;https://sri-lanka-salary-tax-simulator.streamlit.app&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub Repository: &lt;a href="https://github.com/rasindupramith-oss/sri-lanka-salary-tax-simulator" rel="noopener noreferrer"&gt;https://github.com/rasindupramith-oss/sri-lanka-salary-tax-simulator&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  1. The Mathematical Engine: Progressive Tax Slabs
&lt;/h3&gt;

&lt;p&gt;Under current Sri Lankan tax legislation (effective for Year of Assessment 2025/2026 onwards), the first Rs. 150,000 per month (Rs. 1.8M per year) is 100% tax-free personal relief. &lt;/p&gt;

&lt;p&gt;Earnings above this threshold are taxed progressively across structured tiers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Next Rs. 83,333.33 at 6%&lt;/li&gt;
&lt;li&gt;Next Rs. 41,666.67 at 18%&lt;/li&gt;
&lt;li&gt;Next Rs. 41,666.67 at 24%&lt;/li&gt;
&lt;li&gt;Next Rs. 41,666.67 at 30%&lt;/li&gt;
&lt;li&gt;Balance above Rs. 358,333.33 at 36%&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Additionally, statutory retirement funds are modeled accurately:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Employee EPF (8%): Deducted from basic pay.&lt;/li&gt;
&lt;li&gt;Employer EPF (12%) + ETF (3%): Paid by the company on top of gross salary.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. Core Python Implementation
&lt;/h3&gt;

&lt;p&gt;Here is the core logic calculating the progressive tax slabs:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def calculate_apit_tax(gross_salary):
    tax = 0.0
    if gross_salary &amp;gt; 150000:
        excess = gross_salary - 150000

        # Tier 1: Next 83,333.33 at 6%
        slab1 = min(excess, 83333.33)
        tax += slab1 * 0.06
        excess -= slab1

        # Subsequent progressive tiers (18%, 24%, 30%, 36%)
        rates = [0.18, 0.24, 0.30]
        for rate in rates:
            if excess &amp;gt; 0:
                slab = min(excess, 41666.67)
                tax += slab * rate
                excess -= slab

        if excess &amp;gt; 0:
            tax += excess * 0.36
    return tax
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h3&gt;
  
  
  3. Visualizing Cashflow with Plotly Waterfall Charts
&lt;/h3&gt;

&lt;p&gt;Rather than displaying flat numbers, I used Plotly Graph Objects to render an interactive Waterfall Chart mapping the journey from Gross Salary down to final In-Pocket Cash:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import plotly.graph_objects as go

fig_waterfall = go.Figure(go.Waterfall(
    name="Salary Flow",
    orientation="v",
    measure=["absolute", "relative", "relative", "relative", "total"],
    x=["Gross Salary", "Employee EPF (8%)", "APIT Tax", "Other Deductions", "Net Take-Home"],
    textposition="outside",
    y=[gross_salary, -employee_epf, -tax, -other_deductions, 0],
    decreasing={"marker": {"color": "#ef4444"}},
    totals={"marker": {"color": "#0ea5e9"}}
))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h3&gt;
  
  
  4. Key Takeaways from the Data
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;The Marginal Tax Reality: On a typical gross salary of Rs. 240,000, the effective tax rate is only 2.6% (Rs. 6,200), completely debunking the fear of double-digit percentage losses.&lt;/li&gt;
&lt;li&gt;Hidden Retirement Compounding: While 8% employee EPF is deducted, the 15% employer contribution (EPF+ETF) quietly adds over Rs. 46,000 monthly in wealth accumulation into central bank accounts.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Feel free to test out the live simulator and share your feedback!&lt;/p&gt;




&lt;p&gt;Author: Rasindu Pramith — Undergraduate in Applied Statistics, Faculty of Science, University of Colombo&lt;br&gt;&lt;br&gt;
Connect on LinkedIn: &lt;a href="https://www.linkedin.com/in/rasindu-pramith" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/rasindu-pramith&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Portfolio Website: &lt;a href="https://rasindupramith-oss.github.io" rel="noopener noreferrer"&gt;https://rasindupramith-oss.github.io&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>datascience</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
