1
📥
Extract taxable amountsFrom GL, AP, AR entries
🧮
Calculate allowancesDepreciation & capital allowances
3
📊
Generate TB/TC formatTrial balance & tax computation
4
📤
Export CSVTax supporting schedules ready
import pandas as pd, csv
def extract_taxable_entries(gl_data):
df = pd.DataFrame(gl_data)
taxable = df[df['account_type'].isin(['revenue','expense'])]
return taxable
def calculate_allowances(entries):
depreciation = entries[entries['category']=='depreciation']['amount'].sum()
capital_allow = entries[entries['category']=='capital_allowance']['amount'].sum()
transfer_pricing = entries[entries['category']=='transfer_pricing']['amount'].sum()
return {'depreciation':depreciation,'capital_allow':capital_allow,'transfer_pricing':transfer_pricing}
def generate_schedule(allowances):
schedule = pd.DataFrame([{
'category':'Depreciation','amount':allowances['depreciation'],'rate':0,'tax_impact':0
},{
'category':'Capital Allow','amount':allowances['capital_allow'],'rate':0,'tax_impact':0
},{
'category':'Transfer Pricing','amount':allowances['transfer_pricing'],'rate':0,'tax_impact':0
}])
return schedule
def export_csv(schedule, filename='tax_schedule.csv'):
schedule.to_csv(filename, index=False)
return filename
entries = extract_taxable_entries(gl_data)
allowances = calculate_allowances(entries)
schedule = generate_schedule(allowances)
export_csv(schedule)
print('Tax supporting schedules generated')