cit model commit.
This commit is contained in:
74
AppCode/CITHandler.py
Normal file
74
AppCode/CITHandler.py
Normal file
@@ -0,0 +1,74 @@
|
||||
from AppCode.Config import DBConfig
|
||||
import mysql.connector
|
||||
|
||||
class CITHandler:
|
||||
|
||||
def __init__(self):
|
||||
db = DBConfig()
|
||||
self.conn = db.get_db_connection()
|
||||
self.cursor = self.conn.cursor(dictionary=True)
|
||||
|
||||
# GET ALL CIT RECORDS
|
||||
def get_all_cit(self):
|
||||
self.cursor.callproc("GetAllCIT")
|
||||
records = []
|
||||
|
||||
for result in self.cursor.stored_results():
|
||||
records = result.fetchall()
|
||||
|
||||
return records
|
||||
|
||||
# GET CIT BY ID
|
||||
def get_cit_by_id(self, id):
|
||||
self.cursor.callproc("GetCITById", [id])
|
||||
records = []
|
||||
|
||||
for result in self.cursor.stored_results():
|
||||
records = result.fetchall()
|
||||
|
||||
if records:
|
||||
return records[0]
|
||||
|
||||
return None
|
||||
|
||||
# INSERT CIT RECORD
|
||||
def add_cit(self, data):
|
||||
columns = [
|
||||
"year", "gross_total_income", "deduction_80ia_business", "deduction_sec37_disallowance",
|
||||
"deduction_80g", "net_taxable_income", "tax_30_percent", "tax_book_profit_18_5",
|
||||
"tax_payable", "surcharge_12", "edu_cess_3", "total_tax_payable", "mat_credit",
|
||||
"interest_234c", "total_tax", "advance_tax", "tds", "tcs", "tax_on_assessment", "refund"
|
||||
]
|
||||
|
||||
values = [data.get(col, 0) for col in columns]
|
||||
|
||||
self.cursor.callproc("InsertCIT", values)
|
||||
self.conn.commit()
|
||||
|
||||
# UPDATE CIT RECORD
|
||||
# def update_cit(self, id, data):
|
||||
# columns = [
|
||||
# "year", "gross_total_income", "deduction_80ia_business", "deduction_sec37_disallowance",
|
||||
# "deduction_80g", "net_taxable_income", "tax_30_percent", "tax_book_profit_18_5",
|
||||
# "tax_payable", "surcharge_12", "edu_cess_3", "total_tax_payable", "mat_credit",
|
||||
# "interest_234c", "total_tax", "advance_tax", "tds", "tcs", "tax_on_assessment", "refund"
|
||||
# ]
|
||||
|
||||
# set_clause = ", ".join([f"{col}=%s" for col in columns])
|
||||
# query = f"UPDATE cit SET {set_clause} WHERE id=%s"
|
||||
|
||||
# values = [data.get(col, 0) for col in columns]
|
||||
# values.append(id)
|
||||
|
||||
# self.cursor.execute(query, tuple(values))
|
||||
# self.conn.commit()
|
||||
|
||||
# DELETE CIT RECORD
|
||||
def delete_cit(self, id):
|
||||
self.cursor.callproc("DeleteCITById", [id])
|
||||
self.conn.commit()
|
||||
|
||||
# CLOSE CONNECTION
|
||||
def close(self):
|
||||
self.cursor.close()
|
||||
self.conn.close()
|
||||
Reference in New Issue
Block a user