|
""" |
|
Rent Receipt Generator (Income Tax Dept. format – India) |
|
|
|
Generates rent receipts in the exact format commonly accepted for: |
|
- HRA claims |
|
- Income Tax filings |
|
- CA / scrutiny purposes |
|
|
|
Features: |
|
- Exact ITD wording & layout |
|
- No watermark |
|
- No revenue stamp |
|
- One receipt per page |
|
- Combined PDF output |
|
|
|
Dependency: |
|
pip install reportlab |
|
""" |
|
|
|
from reportlab.platypus import ( |
|
SimpleDocTemplate, |
|
Paragraph, |
|
Spacer, |
|
PageBreak |
|
) |
|
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle |
|
from reportlab.lib.pagesizes import A4 |
|
from reportlab.lib.enums import TA_CENTER, TA_LEFT |
|
|
|
|
|
def generate_rent_receipts_pdf( |
|
output_path: str, |
|
tenant_name: str, |
|
landlord_name: str, |
|
landlord_pan: str, |
|
rented_property_address: str, |
|
landlord_address: str, |
|
items: list[dict], |
|
): |
|
""" |
|
Generate a combined PDF with one rent receipt per page. |
|
|
|
Parameters: |
|
---------- |
|
output_path : str |
|
Output PDF file path |
|
|
|
tenant_name : str |
|
Name of the tenant |
|
|
|
landlord_name : str |
|
Name of the landlord |
|
|
|
landlord_pan : str |
|
PAN of the landlord (mandatory if annual rent > 1L) |
|
|
|
rented_property_address : str |
|
Full address of the rented house |
|
|
|
landlord_address : str |
|
Full postal address of the landlord |
|
|
|
items : list of dict |
|
Each item must contain: |
|
{ |
|
"date": "01 Jul 2025", |
|
"amount": "49,140/-", |
|
"rent_period": "July 2025", |
|
"monthly_rent": "50,000/-" |
|
} |
|
""" |
|
|
|
# ---------------------------- |
|
# Styles (ITD-like) |
|
# ---------------------------- |
|
styles = getSampleStyleSheet() |
|
|
|
styles.add(ParagraphStyle( |
|
name="TITLE", |
|
alignment=TA_CENTER, |
|
fontSize=16, |
|
spaceAfter=6 |
|
)) |
|
|
|
styles.add(ParagraphStyle( |
|
name="SUBTITLE", |
|
alignment=TA_CENTER, |
|
fontSize=10, |
|
spaceAfter=24 |
|
)) |
|
|
|
styles.add(ParagraphStyle( |
|
name="BODY", |
|
alignment=TA_LEFT, |
|
fontSize=11, |
|
leading=18 |
|
)) |
|
|
|
# ---------------------------- |
|
# PDF setup |
|
# ---------------------------- |
|
doc = SimpleDocTemplate(output_path, pagesize=A4) |
|
elements = [] |
|
|
|
for idx, item in enumerate(items): |
|
|
|
# Header |
|
elements.append( |
|
Paragraph("RECEIPT OF HOUSE RENT", styles["TITLE"]) |
|
) |
|
elements.append( |
|
Paragraph( |
|
"(Under Section 10 (13A) of Income Tax Act)", |
|
styles["SUBTITLE"] |
|
) |
|
) |
|
|
|
# Body |
|
elements.append( |
|
Paragraph( |
|
f"Received a sum of Rs. <b>{item['amount']}</b> from " |
|
f"<b>{tenant_name}</b> towards<br/>" |
|
f"rent at <b>{item['monthly_rent']}</b> per month for " |
|
f"<b>{item['rent_period']}</b> in respect of the house situated at:", |
|
styles["BODY"] |
|
) |
|
) |
|
|
|
elements.append(Spacer(1, 10)) |
|
elements.append( |
|
Paragraph(rented_property_address, styles["BODY"]) |
|
) |
|
|
|
# Date |
|
elements.append(Spacer(1, 30)) |
|
elements.append( |
|
Paragraph(f"Date: {item['date']}", styles["BODY"]) |
|
) |
|
|
|
# Signature section |
|
elements.append(Spacer(1, 30)) |
|
elements.append( |
|
Paragraph("Signature of the House Owner", styles["BODY"]) |
|
) |
|
|
|
# Space for physical signature |
|
elements.append(Spacer(1, 50)) |
|
|
|
# Owner details |
|
elements.append( |
|
Paragraph(landlord_name, styles["BODY"]) |
|
) |
|
elements.append(Spacer(1, 10)) |
|
elements.append( |
|
Paragraph(landlord_address, styles["BODY"]) |
|
) |
|
elements.append( |
|
Paragraph(f"PAN - {landlord_pan}", styles["BODY"]) |
|
) |
|
|
|
if idx < len(items) - 1: |
|
elements.append(PageBreak()) |
|
|
|
doc.build(elements) |