SmartAI_Tax_Assessor2 / modules /rules_engine.py
Ahmed12322's picture
Update modules/rules_engine.py
b1d9d53 verified
raw
history blame contribute delete
669 Bytes
import json
import os
def load_tax_rates():
""" Load tax rates from JSON file safely """
file_path = "tax_data.json"
if not os.path.exists(file_path):
raise FileNotFoundError(f"Error: The tax rates file '{file_path}' was not found.")
with open(file_path, "r") as file:
data = json.load(file)
return data
def calculate_income_tax(income, business_type):
""" Calculate tax based on business type """
tax_rates = load_tax_rates()
if business_type not in tax_rates:
raise ValueError(f"Invalid business type: {business_type}")
tax_rate = tax_rates[business_type]
return float(income) * float(tax_rate)