PHP/Laravel

Laravel Invoice SaaS

About this project

Invoice SaaS is a complete invoicing and expense management system built with Laravel 11. Each business gets its own isolated workspace, so one account never sees another’s data.

Owners can create invoices with multiple line items, tax and discounts, then download them as PDFs or email them to customers. Payments and refunds are recorded against each invoice, and the status updates automatically from the net paid amount. Emails go through a queue with automatic retries, and every invoice shows whether its email was sent or failed.

The app also includes customers, a product and service catalog, expense tracking with receipt uploads, a revenue dashboard, financial reports, and Owner and Staff roles.

Objectives

Small businesses and freelancers often manage invoices in spreadsheets, which makes it hard to track who has paid, what is overdue and what was refunded. Emailing invoices by hand is slow, and a failed email goes unnoticed. The goal was to build a multi-tenant invoicing platform where many businesses can safely use the same installation, create professional PDF invoices, record payments and refunds accurately, send emails reliably, and see their finances at a glance.

Key Features

  • Multi-tenant workspaces with strict data isolation
  • Self-service registration that creates a business workspace
  • Invoices with multiple line items, tax rate and discount
  • Automatic invoice numbering with a custom prefix
  • PDF invoice download and preview
  • Queued email delivery with automatic retries
  • Email status tracking (queued, sent, failed) on every invoice
  • Partial and full payments
  • Partial and full refunds with automatic status updates
  • Customer directory with soft delete
  • Product and service catalog
  • Expense tracking with categories and receipt uploads
  • Dashboard with 12-month revenue chart
  • Revenue, expense, profit, outstanding and customer reports
  • Owner and Staff roles
  • Business settings with logo, currency, tax and invoice defaults
  • Daily automatic overdue marking
  • Automated tests for tenant isolation, calculations and payment status

Development Process

The project started with the database design: businesses, users, customers, products, invoices, payments and expenses, each with its own migration. Next came the tenant-aware models, then service classes for calculations, PDFs, statistics and reports. Controllers, form requests and policies followed, and then the Blade interface built with Bootstrap. Features were added step by step: refunds, email tracking, and the email queue with retries were later extensions built as separate migrations on top of a working invoicing core. Automated tests were written for the most sensitive parts, namely tenant isolation, invoice totals and payment status.

Challenges & Solutions

Data isolation between businesses: a global scope trait automatically filters every query by business and fills business_id on create. Policies add a second layer, and automated tests confirm one business cannot access another's records. Duplicate invoice numbers: numbers are reserved inside a database transaction with a row lock, so two simultaneous requests never get the same number. Accurate status after payments and refunds: the invoice status is recalculated from total payments minus total refunds, so it can never drift out of sync. Reliable and correct emails: emails are queued with three retries and increasing delays. Each email carries a token, so if a newer email is queued, older pending ones are skipped instead of sending outdated information. Overdue invoices: a daily scheduled command marks unpaid invoices as overdue once the due date has passed. Different databases: the dashboard revenue query detects the database driver, so the same code works on both SQLite and MySQL.

Technologies & Frameworks

Laravel 11Laravel BreezeEloquent ORMBootstrap 5Alpine.jsChart.jsVitePHPUnitMySQLSQLite

Integrations & APIs

DomPDFSMTP emailLaravel QueueLaravel Task SchedulerChart.js

Architecture & Libraries

MVC architecture with a dedicated service layer for invoice calculation, PDF generation, dashboard statistics and reports. Multi-tenancy is handled by a reusable global scope trait, with Laravel Policies and Form Requests for authorization and validation. Background work uses queued jobs and the Laravel scheduler. Libraries: barryvdh/laravel-dompdf, spatie/laravel-permission, Bootstrap Icons, Chart.js, Alpine.js.

Backend & Database

The backend runs on PHP 8.2 and Laravel 11. The database is SQLite by default, with full MySQL and MariaDB support, and the schema is built through versioned migrations with a demo seeder. Invoice numbers are generated inside a database transaction with row locking to avoid duplicates under concurrent requests. Queue, session and cache use the database driver, and customers use soft deletes.

Outcomes & Results

A complete, working invoicing platform that supports multiple businesses on a single installation. Invoices, payments, refunds, expenses and reports work together, and invoice statuses stay accurate automatically. The project ships with demo data and a seeder for quick testing, automated tests for its critical logic, full setup documentation on GitHub, and a video walkthrough on YouTube.

Need something similar?

Farhan Saeed · Available for new projects