2025-11-30 16:24:49 +05:30
|
|
|
from AppCode.Config import DBConfig
|
|
|
|
|
import mysql.connector
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AOHandler:
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.conn = DBConfig.get_db_connection()
|
|
|
|
|
self.cursor = self.conn.cursor(dictionary=True)
|
|
|
|
|
|
|
|
|
|
# GET ALL AO RECORDS using stored procedure "GetAllItr"
|
|
|
|
|
def get_all_ao(self):
|
|
|
|
|
self.cursor.callproc("GetAllAO")
|
|
|
|
|
records = []
|
|
|
|
|
|
|
|
|
|
for result in self.cursor.stored_results():
|
|
|
|
|
records = result.fetchall()
|
|
|
|
|
|
|
|
|
|
return records
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_ao_by_id(self, id):
|
|
|
|
|
# Call stored procedure
|
2025-12-01 12:04:07 +05:30
|
|
|
self.cursor.callproc('GetAOById', [id])
|
2025-11-30 16:24:49 +05:30
|
|
|
# Fetch result
|
|
|
|
|
records = []
|
|
|
|
|
for result in self.cursor.stored_results():
|
|
|
|
|
records = result.fetchall()
|
|
|
|
|
|
|
|
|
|
if records:
|
|
|
|
|
return records[0] # return single record
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
2025-11-30 20:38:41 +05:30
|
|
|
""" variable of AO model
|
|
|
|
|
year, gross_total_income, disallowance_14a, disallowance_37,
|
|
|
|
|
deduction_80ia_business, deduction_sec37_disallowance, deduction_80g,
|
|
|
|
|
net_taxable_income, tax_30_percent, tax_book_profit_18_5,
|
|
|
|
|
surcharge_12, edu_cess_3, total_tax_payable, mat_credit,
|
|
|
|
|
interest_234c, total_tax, advance_tax, tds, tcs,
|
|
|
|
|
tax_on_assessment, refund
|
|
|
|
|
|
|
|
|
|
"""
|
2025-11-30 16:24:49 +05:30
|
|
|
|
|
|
|
|
|
2025-11-30 20:38:41 +05:30
|
|
|
def add_ao(self, data):
|
|
|
|
|
fields = [
|
|
|
|
|
"year","gross_total_income", "disallowance_14a", "disallowance_37",
|
|
|
|
|
"deduction_80ia_business", "deduction_sec37_disallowance", "deduction_80g",
|
|
|
|
|
"net_taxable_income", "tax_30_percent", "tax_book_profit_18_5",
|
|
|
|
|
"surcharge_12", "edu_cess_3", "total_tax_payable", "mat_credit",
|
|
|
|
|
"interest_234c", "total_tax", "advance_tax", "tds", "tcs",
|
|
|
|
|
"tax_on_assessment", "refund"
|
|
|
|
|
]
|
2025-11-30 16:24:49 +05:30
|
|
|
|
2025-11-30 20:38:41 +05:30
|
|
|
values = [data.get(f, 0) for f in fields]
|
2025-11-30 16:24:49 +05:30
|
|
|
|
2025-11-30 20:38:41 +05:30
|
|
|
self.cursor.callproc("InsertAO", values)
|
|
|
|
|
self.conn.commit()
|
2025-11-30 16:24:49 +05:30
|
|
|
|
|
|
|
|
|
2025-11-30 20:38:41 +05:30
|
|
|
# UPDATE ITR RECORD by AO id
|
2025-12-01 17:45:16 +05:30
|
|
|
def update_ao(self, id, data):
|
2025-11-30 16:24:49 +05:30
|
|
|
|
2025-12-01 17:45:16 +05:30
|
|
|
fields = [
|
|
|
|
|
"year","gross_total_income", "disallowance_14a", "disallowance_37",
|
|
|
|
|
"deduction_80ia_business", "deduction_sec37_disallowance", "deduction_80g",
|
|
|
|
|
"net_taxable_income", "tax_30_percent", "tax_book_profit_18_5",
|
|
|
|
|
"surcharge_12", "edu_cess_3", "total_tax_payable", "mat_credit",
|
|
|
|
|
"interest_234c", "total_tax", "advance_tax", "tds", "tcs",
|
|
|
|
|
"tax_on_assessment", "refund"
|
|
|
|
|
]
|
2025-11-30 16:24:49 +05:30
|
|
|
|
2025-12-01 17:45:16 +05:30
|
|
|
values = [id] + [data.get(f, 0) for f in fields]
|
2025-11-30 16:24:49 +05:30
|
|
|
|
2025-12-01 17:45:16 +05:30
|
|
|
print("AO update values:", values)
|
2025-11-30 16:24:49 +05:30
|
|
|
|
2025-12-01 17:45:16 +05:30
|
|
|
self.cursor.callproc("UpdateAOById", values)
|
|
|
|
|
self.conn.commit()
|
2025-11-30 16:24:49 +05:30
|
|
|
|
|
|
|
|
|
2025-11-30 20:38:41 +05:30
|
|
|
# DELETE RECORD by AO id
|
|
|
|
|
def delete_ao_by_id(self, id):
|
|
|
|
|
# Call the stored procedure
|
|
|
|
|
self.cursor.callproc('DeleteAOById', [id])
|
|
|
|
|
self.conn.commit()
|
2025-11-30 16:24:49 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
# CLOSE CONNECTION
|
|
|
|
|
def close(self):
|
|
|
|
|
self.cursor.close()
|
|
|
|
|
self.conn.close()
|