WHMCS guide

Find the services WHMCS never invoices.

A missing invoice makes no noise: the client is not chased, nothing shows as overdue and the service keeps running. On one of our own installs the first query below found four active add-ons whose last due date was in 2016 to 2018, with no invoice anyone could pay.

DMS.S2 — Before you start

Before you run anything.

Read only

Every query below is a SELECT. It changes nothing. Run it in phpMyAdmin or the mysql client, on a copy of the database if you have one.

Free and one-time items are left out

Only active, recurring items with a price are listed, and domains set to Do Not Renew stay out. A cancelled invoice does not count as something to pay.

Tested on sample rows

We ran each query on a test database with rows that should match and rows that should not: an open invoice, a Payment Pending renewal, a free add-on, a suspended service, a one-time product. Queries 2 and 3 return nothing on our two live installs.

DMS.S3 — The queries

Three ways to find them.

Due date passed, nothing to pay

Active and past due, but no Unpaid or Payment Pending invoice for the item. Usually the invoice was deleted or cancelled: WHMCS does not create a second invoice for a due date it already invoiced. If the invoice is Paid, see the suspended-after-paying guide instead.

SELECT 'service' AS kind, h.id, h.userid, h.domain AS item, h.nextduedate, h.amount
FROM tblhosting h
WHERE h.domainstatus = 'Active' AND h.amount > 0
  AND h.billingcycle NOT IN ('Free Account', 'One Time')
  AND h.nextduedate > '1000-01-01' AND h.nextduedate < CURDATE()
  AND NOT EXISTS (SELECT 1 FROM tblinvoiceitems ii JOIN tblinvoices i ON i.id = ii.invoiceid
                  WHERE ii.type = 'Hosting' AND ii.relid = h.id
                    AND i.status IN ('Unpaid', 'Payment Pending'))
UNION ALL
SELECT 'addon', a.id, a.userid, a.name, a.nextduedate, a.recurring
FROM tblhostingaddons a
WHERE a.status = 'Active' AND a.recurring > 0
  AND a.billingcycle NOT IN ('Free', 'Free Account', 'One Time', 'onetime')
  AND a.nextduedate > '1000-01-01' AND a.nextduedate < CURDATE()
  AND NOT EXISTS (SELECT 1 FROM tblinvoiceitems ii JOIN tblinvoices i ON i.id = ii.invoiceid
                  WHERE ii.type = 'Addon' AND ii.relid = a.id
                    AND i.status IN ('Unpaid', 'Payment Pending'))
UNION ALL
SELECT 'domain', d.id, d.userid, d.domain, d.nextduedate, d.recurringamount
FROM tbldomains d
WHERE d.status = 'Active' AND d.donotrenew = 0 AND d.recurringamount > 0
  AND d.nextduedate > '1000-01-01' AND d.nextduedate < CURDATE()
  AND NOT EXISTS (SELECT 1 FROM tblinvoiceitems ii JOIN tblinvoices i ON i.id = ii.invoiceid
                  WHERE ii.type IN ('Domain', 'DomainRegister', 'DomainRenew', 'DomainTransfer')
                    AND ii.relid = d.id AND i.status IN ('Unpaid', 'Payment Pending'));

No next due date at all

An import, a manual edit or the API left the date empty. The cron bills by that date, so the item is never invoiced and never shows as overdue either.

SELECT 'service' AS kind, id, userid, domain AS item, amount
FROM tblhosting
WHERE domainstatus = 'Active' AND amount > 0
  AND billingcycle NOT IN ('Free Account', 'One Time')
  AND (nextduedate IS NULL OR nextduedate < '1000-01-01')
UNION ALL
SELECT 'addon', id, userid, name, recurring
FROM tblhostingaddons
WHERE status = 'Active' AND recurring > 0
  AND billingcycle NOT IN ('Free', 'Free Account', 'One Time', 'onetime')
  AND (nextduedate IS NULL OR nextduedate < '1000-01-01')
UNION ALL
SELECT 'domain', id, userid, domain, recurringamount
FROM tbldomains
WHERE status = 'Active' AND donotrenew = 0 AND recurringamount > 0
  AND (nextduedate IS NULL OR nextduedate < '1000-01-01');

Next due date years away

2062 typed for 2026: the cron will not reach that date for decades, so the client uses the service for free until someone notices.

SELECT 'service' AS kind, id, userid, domain AS item, nextduedate, amount
FROM tblhosting
WHERE domainstatus = 'Active' AND amount > 0
  AND billingcycle NOT IN ('Free Account', 'One Time')
  AND nextduedate > CURDATE() + INTERVAL 5 YEAR
UNION ALL
SELECT 'addon', id, userid, name, nextduedate, recurring
FROM tblhostingaddons
WHERE status = 'Active' AND recurring > 0
  AND billingcycle NOT IN ('Free', 'Free Account', 'One Time', 'onetime')
  AND nextduedate > CURDATE() + INTERVAL 5 YEAR;

DMS.S4 — The addon

Or get the list inside the WHMCS admin.

Brasa Billing Audit runs these checks with the rest of its billing checks, links each finding to the service or domain and e-mails admins when a new one appears. It never creates an invoice or changes a due date.

Brasa Billing Audit screen in the WHMCS admin, with sample data

Brasa Billing Audit

$39 per year

Finds the billing records that do not add up.

  • Payment booked twice, and more money than the invoice was worth
  • Credit with no money behind it, and invoices marked Paid with nothing allocated or with every payment refunded
  • Client billed twice for one period, and a period that will never be billed
  • Suspended but paid up, a domain set to renew at 0 on a paid extension, a next due date after the registrar expiry, a late fee charged before the due date, a payment booked to no invoice or to a deleted one, a payment dated before its invoice was created, 48 checks in all
First run in 16 seconds, on sample data: the summary, then each finding with what to do about it. Brasa Billing Audit on the WHMCS Marketplace
Buy for $39

DMS.S5 — Questions

Getting the invoice out.

Why did WHMCS not generate the invoice?

The daily cron invoices by the next due date on each service, add-on and domain. It skips items that are not Active, items with no due date or a date far ahead, and a due date it already invoiced even if that invoice was later deleted. Also check under Utilities > Automation Status that the cron runs every day.

How do I bill a service the cron skipped?

Correct the next due date on the service, add-on or domain and save. Then open the client Summary tab and click Generate Due Invoices. If WHMCS already invoiced that date and the invoice was deleted, set the date one day earlier, as the WHMCS documentation advises.

Should I bill the client for years that were never invoiced?

That is a decision for you and the client, not for the query. Often the add-on is no longer in use and the right fix is to cancel it, so it stops showing as active.