Skip to content

Kudzaishe109/Payslip_generator-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงพ Payslip Generator

This is a Python script that automates the process of generating and emailing monthly payslips to employees. It reads data from an Excel file, calculates net salaries, generates PDF payslips, and sends them via email.


๐Ÿ“Œ Features

  • Reads employee data from an Excel file using pandas
  • Calculates net salary:

Net Salary = Basic Salary + Allowances - Deductions

  • Generates a professional PDF payslip using fpdf
  • Emails the payslip to each employee using smtplib
  • Uses .env for secure email credentials

๐Ÿ› ๏ธ Requirements

  • Python 3.x
  • Required libraries:
  • pandas
  • fpdf
  • openpyxl
  • python-dotenv

Install them using:

pip install pandas fpdf openpyxl python-dotenv ๐Ÿ“ Files and Folders . โ”œโ”€โ”€ payslip_generator.py # Main script โ”œโ”€โ”€ employees.xlsx # Input Excel file with employee details โ”œโ”€โ”€ payslips/ # Folder where PDF payslips will be saved โ”œโ”€โ”€ .env # Hidden file for email credentials โ””โ”€โ”€ README.md # This file

๐Ÿ” Environment Variables

Create a .env file in the root directory with the following content:

SMTP_SERVER=smtp.yourmail.com SMTP_PORT=587 EMAIL_USER=[email protected] EMAIL_PASS=your_email_password_or_app_password โš ๏ธ Never share your .env file or commit it to Git.

๐Ÿง‘โ€๐Ÿ’ผ Excel File Format

The employees.xlsx file should include the following columns:

Employee ID Name Email Basic Salary Allowances Deductions 001 Jane Doe [email protected] 1000 200 100 002 John Smith [email protected] 1200 300 150

โ–ถ๏ธ How to Run the Script Make sure your .env and employees.xlsx are ready.

Open your terminal in the project folder.

Run the script:

python payslip_generator.py ๐Ÿ“ง Email Details Subject: Your Payslip for This Month

Body:

Dear [Employee Name],

Please find attached your payslip for this month.

Best regards,
Uncommon.org Attachment: The employeeโ€™s PDF payslip

โœ… Output

Payslips will be saved in the payslips/ folder.

Each file is named by Employee ID (e.g., 001.pdf).

The PDF includes employee info, salary breakdown, and a professional layout.

๐Ÿง‘โ€๐Ÿ’ป Author

Created by Kudzaishe Chikowore For the Python Programming Assignment: Payslip Generator

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages