Skip to content

ebbsagar/CashbackCalculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cashback Calculator

A Flask-based web application for analyzing credit card transactions, calculating cashback rewards, and comparing against bank statements.

Features

  • PDF Parsing: Extract transactions from credit card PDF statements
  • Cashback Calculation: Automatically calculate cashback based on spending categories
  • CSV/Excel Import: Upload transaction sheets in CSV or Excel format
  • Multi-Card Support: Track multiple credit cards/issuers
  • Spending Analytics: View spending breakdown by category, issuer, and month
  • Cashback Comparison: Compare calculated cashback vs. stated amounts

UI Overview

The application features a dark-themed interface with four main tabs:

Overview Tab

Displays a summary dashboard with key metrics:

  • Total transactions count
  • Purchases (DR) and Credits (CR) breakdown
  • Total spend amount
  • Earned cashback amount
  • Number of statements processed

Each card issuer can be expanded to show transactions grouped by month, with spend and cashback summaries per month.

Dashboard Tab

Interactive visual analytics:

  • Spending by Category: Pie chart showing spending distribution across categories
  • Monthly Cashback Trend: Line chart tracking cashback earnings over time
  • Top Spending Categories: Bar chart ranking categories by spending
  • Category Details: Expandable table with per-category statistics

Cards Tab

View all credit cards in one place:

  • Each card shows total transactions, spending, and cashback
  • Click to expand and see monthly breakdown
  • Per-month statistics with spend and cashback totals

Transactions Tab

Complete transaction history with advanced filtering:

  • Date range filter (From/To month selectors)
  • Year-based filtering for each card
  • Expandable month groups showing individual transactions
  • Cashback comparison columns: Calculated vs Earned vs Credited
  • Percentage difference indicator for each month
  • Detailed transaction table with date, type, description, amount, category, rate, and cashback

UI Functionality

Navigation

  • Overview: High-level summary with expandable issuer/month groups
  • Dashboard: Visual charts and analytics
  • Cards: Per-card transaction views
  • Transactions: Complete transaction list with filtering

Header Actions

  • Upload PDF: Drag and drop or click to upload credit card statements
  • Clear All: Remove all data from the system
  • Reload: Re-process all uploaded PDFs

Date Filtering

  • Select From/To months to filter all views
  • Click "All" to show complete transaction history
  • Filters apply across Overview, Dashboard, and Transactions tabs

Transaction Details

Each transaction displays:

  • Date and description
  • Transaction type (DR = Purchase, CR = Credit)
  • Amount in local currency
  • Auto-detected category
  • Cashback rate applied
  • Calculated cashback amount

Cashback Rates

Category Rate
Grocery 10%
Dining 10%
Utilities 10%
Airtel 25%
Fuel 1%
Travel 1%
Entertainment 1%
Shopping 1%
Default 1%

Note: Airtel cashback is capped at Rs. 250 per month.

Project Structure

Cashback Calculator/
├── app.py              # Flask application and API endpoints
├── requirements.txt    # Python dependencies
├── backend/
│   ├── pdf_parser.py         # PDF statement parser
│   ├── cashback_calculator.py # Cashback calculation logic
│   └── data_manager.py        # Data storage and organization
├── data/
│   └── transactions.json      # Transaction data storage
├── uploads/             # Uploaded PDF files
└── static/              # Frontend files

Setup

  1. Create virtual environment:

    python -m venv venv
  2. Activate virtual environment:

    • Windows: venv\Scripts\activate
    • Mac/Linux: source venv/bin/activate
  3. Install dependencies:

    pip install -r requirements.txt

Run

python app.py

The application runs at http://localhost:5000

API Endpoints

Method Endpoint Description
GET /api/transactions Get all transactions with organized data
GET /api/transactions/csv Get transactions from JSON file
POST /api/upload-pdf Upload and parse a PDF statement
POST /api/upload-sheet Upload CSV/Excel sheet
POST /api/reload-data Reload all transactions from PDFs
GET /api/compare Compare calculated vs stated cashback
POST /api/clear Clear all stored data
GET /api/debug Debug info about stored data

Transaction Data Format

Transactions are stored in data/transactions.json:

{
  "date": "2026-03-15",
  "description": "AMAZON MARKETPLACE",
  "amount": 45.99,
  "transaction_type": "DR",
  "card_issuer": "Chase Sapphire",
  "category": "Shopping",
  "is_credit": false,
  "calculated_cashback": 0.46
}

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors