# easy-invoice/2.4.0/includes/Helpers/InvoiceStatus.php

Easy Invoice – Invoice Generator, PDF Quotes &amp; Payments, version 2.4.0. 102 lines.

- Page: https://pluginprobe.com/plugins/easy-invoice/2.4.0/code/includes/Helpers/InvoiceStatus.php
- Raw: https://pluginprobe.com/plugins/easy-invoice/2.4.0/raw/includes/Helpers/InvoiceStatus.php
- Modified: 2026-09-15T12:31:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/easy-invoice/2.4.0/code/includes/Helpers/InvoiceStatus.php#L10-L20`.

```php
<?php
/**
 * How an invoice's status is shown.
 *
 * The stored status is what the workflow set (draft, available, partial,
 * paid, cancelled…). "Overdue" is a condition — still owed after the due
 * date — that nothing writes, so it is derived here for display, and the
 * labels and badge colours live in one place.
 *
 * @package EasyInvoice\Helpers
 * @since 2.4.0
 */

namespace EasyInvoice\Helpers;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class InvoiceStatus {

	/** Statuses on which money is still expected. */
	const OPEN = [ 'available', 'unpaid', 'partial', 'sent', 'pending', 'overdue' ];

	/**
	 * Status key to show for an invoice: the stored one, or 'overdue' when an
	 * open invoice is past its due date.
	 *
	 * @param string      $status   Stored status.
	 * @param string|null $due_date Y-m-d (or anything strtotime reads).
	 * @return string
	 */
	public static function displayKey( string $status, ?string $due_date ): string {
		$status = strtolower( trim( $status ) );
		if ( in_array( $status, self::OPEN, true ) && $due_date ) {
			$due = strtotime( $due_date );
			if ( $due && gmdate( 'Y-m-d', $due ) < gmdate( 'Y-m-d', current_time( 'timestamp' ) ) ) {
				return 'overdue';
			}
		}
		return $status;
	}

	/**
	 * Same, from a model.
	 *
	 * @param object $invoice Invoice model.
	 * @return string
	 */
	public static function displayKeyFor( $invoice ): string {
		$status = is_callable( [ $invoice, 'getStatus' ] ) ? (string) $invoice->getStatus() : '';
		$due    = is_callable( [ $invoice, 'getDueDate' ] ) ? (string) $invoice->getDueDate() : '';
		return self::displayKey( $status, $due );
	}

	/**
	 * Human label for a status key.
	 *
	 * @param string $key Status key.
	 * @return string
	 */
	public static function label( string $key ): string {
		$labels = [
			'available' => __( 'Available', 'easy-invoice' ),
			'paid'      => __( 'Paid', 'easy-invoice' ),
			'partial'   => __( 'Partially paid', 'easy-invoice' ),
			'unpaid'    => __( 'Unpaid', 'easy-invoice' ),
			'overdue'   => __( 'Overdue', 'easy-invoice' ),
			'draft'     => __( 'Draft', 'easy-invoice' ),
			'cancelled' => __( 'Cancelled', 'easy-invoice' ),
			'canceled'  => __( 'Cancelled', 'easy-invoice' ),
			'sent'      => __( 'Sent', 'easy-invoice' ),
			'pending'   => __( 'Pending', 'easy-invoice' ),
		];
		return $labels[ strtolower( $key ) ] ?? ucfirst( $key );
	}

	/**
	 * Tailwind badge classes for a status key.
	 *
	 * @param string $key Status key.
	 * @return string
	 */
	public static function badgeClass( string $key ): string {
		switch ( strtolower( $key ) ) {
			case 'paid':
				return 'bg-green-100 text-green-800 ring-1 ring-green-200';
			case 'partial':
			case 'unpaid':
			case 'pending':
				return 'bg-yellow-100 text-yellow-800 ring-1 ring-yellow-200';
			case 'overdue':
				return 'bg-red-100 text-red-800 ring-1 ring-red-200';
			case 'available':
			case 'sent':
				return 'bg-blue-100 text-blue-800 ring-1 ring-blue-200';
			default:
				return 'bg-gray-100 text-gray-800 ring-1 ring-gray-200';
		}
	}
}

```
