96 lines
2.8 KiB
Python
96 lines
2.8 KiB
Python
|
|
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
|
||
|
|
self.cursor.callproc('GetAORById', [id])
|
||
|
|
|
||
|
|
# Fetch result
|
||
|
|
records = []
|
||
|
|
for result in self.cursor.stored_results():
|
||
|
|
records = result.fetchall()
|
||
|
|
|
||
|
|
if records:
|
||
|
|
print(records[0])
|
||
|
|
return records[0] # return single record
|
||
|
|
|
||
|
|
return None
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
# INSERT ITR RECORD using procedure "add_itr"
|
||
|
|
# def add_itr(self, data):
|
||
|
|
|
||
|
|
# columns = [
|
||
|
|
# 'year', 'gross_total_income', 'disallowance_14a', 'disallowance_37',
|
||
|
|
# 'deduction_80ia_business', 'deduction_80ia_misc', 'deduction_80ia_other',
|
||
|
|
# '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]
|
||
|
|
|
||
|
|
# # Call your stored procedure
|
||
|
|
# self.cursor.callproc("InsertITR", values)
|
||
|
|
# self.conn.commit()
|
||
|
|
|
||
|
|
|
||
|
|
# UPDATE ITR RECORD by ITR id
|
||
|
|
# def update(self, id, data):
|
||
|
|
|
||
|
|
# columns = [
|
||
|
|
# 'year', 'gross_total_income', 'disallowance_14a', 'disallowance_37',
|
||
|
|
# 'deduction_80ia_business', 'deduction_80ia_misc', 'deduction_80ia_other',
|
||
|
|
# '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 itr 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 RECORD by ITR id
|
||
|
|
# def delete_itr_by_id(self, id):
|
||
|
|
# # Call the stored procedure
|
||
|
|
# self.cursor.callproc('DeleteITRById', [id])
|
||
|
|
# self.conn.commit()
|
||
|
|
|
||
|
|
|
||
|
|
# CLOSE CONNECTION
|
||
|
|
def close(self):
|
||
|
|
self.cursor.close()
|
||
|
|
self.conn.close()
|