| 1 |
<?php |
| 2 |
/** |
| 3 |
* Invoice Repository Interface |
| 4 |
* |
| 5 |
* @package EasyInvoice |
| 6 |
* @since 1.0.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace EasyInvoice\Interfaces; |
| 10 |
|
| 11 |
use EasyInvoice\Models\Invoice; |
| 12 |
|
| 13 |
/** |
| 14 |
* Invoice Repository Interface |
| 15 |
* |
| 16 |
* Defines the contract for invoice repositories with extensibility for pro features. |
| 17 |
* |
| 18 |
* @since 1.0.0 |
| 19 |
*/ |
| 20 |
interface InvoiceRepositoryInterface { |
| 21 |
/** |
| 22 |
* Find invoice by ID |
| 23 |
* |
| 24 |
* @param int $id Invoice ID |
| 25 |
* @return Invoice|null |
| 26 |
*/ |
| 27 |
public function find($id); |
| 28 |
|
| 29 |
/** |
| 30 |
* Get all invoices |
| 31 |
* |
| 32 |
* @param array $args Optional arguments to filter the results |
| 33 |
* @return array Array of Invoice models |
| 34 |
*/ |
| 35 |
public function all($args = []); |
| 36 |
|
| 37 |
/** |
| 38 |
* Create a new invoice |
| 39 |
* |
| 40 |
* @param array $data Invoice data |
| 41 |
* @return Invoice|false The created invoice or false on failure |
| 42 |
*/ |
| 43 |
public function create($data); |
| 44 |
|
| 45 |
/** |
| 46 |
* Update an existing invoice |
| 47 |
* |
| 48 |
* @param int $id The invoice ID |
| 49 |
* @param array $data The invoice data |
| 50 |
* @return Invoice|null The updated invoice model or null if not found |
| 51 |
*/ |
| 52 |
public function update($id, $data); |
| 53 |
|
| 54 |
/** |
| 55 |
* Delete an invoice |
| 56 |
* |
| 57 |
* @param int $id The invoice ID |
| 58 |
* @return bool True if successful, false otherwise |
| 59 |
*/ |
| 60 |
public function delete($id); |
| 61 |
|
| 62 |
/** |
| 63 |
* Find invoices by customer ID |
| 64 |
* |
| 65 |
* @param int $customer_id The customer ID |
| 66 |
* @return array Array of Invoice models |
| 67 |
*/ |
| 68 |
public function findByCustomer($customer_id); |
| 69 |
|
| 70 |
/** |
| 71 |
* Find invoices by status |
| 72 |
* |
| 73 |
* @param string $status The invoice status |
| 74 |
* @return array Array of Invoice models |
| 75 |
*/ |
| 76 |
public function findByStatus($status); |
| 77 |
|
| 78 |
/** |
| 79 |
* Find invoices due within a date range |
| 80 |
* |
| 81 |
* @param string $start_date The start date in 'Y-m-d' format |
| 82 |
* @param string $end_date The end date in 'Y-m-d' format |
| 83 |
* @return array Array of Invoice models |
| 84 |
*/ |
| 85 |
public function findByDueDate($start_date, $end_date = null); |
| 86 |
|
| 87 |
/** |
| 88 |
* Count invoices |
| 89 |
* |
| 90 |
* @param array $args Optional arguments to filter the results |
| 91 |
* @return int Number of invoices |
| 92 |
*/ |
| 93 |
public function count($args = []); |
| 94 |
|
| 95 |
/** |
| 96 |
* Find published invoice by ID |
| 97 |
* |
| 98 |
* @param int $id The invoice ID |
| 99 |
* @return Invoice|null The invoice model or null if not found |
| 100 |
*/ |
| 101 |
public function findPublished(int $id); |
| 102 |
|
| 103 |
/** |
| 104 |
* Update all existing draft invoices to published status for proper permalinks |
| 105 |
* |
| 106 |
* @return int Number of invoices updated |
| 107 |
*/ |
| 108 |
public function updateAllExistingInvoices(): int; |
| 109 |
} |