| 1 |
<?php |
| 2 |
/** |
| 3 |
* Invoice Item Repository Interface |
| 4 |
* |
| 5 |
* @package Easy_Invoice |
| 6 |
* @subpackage Interfaces |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace EasyInvoice\Interfaces; |
| 10 |
|
| 11 |
/** |
| 12 |
* InvoiceItemRepositoryInterface |
| 13 |
* |
| 14 |
* Defines the contract for invoice item repository classes. |
| 15 |
* Invoice items are stored as meta fields within invoice posts. |
| 16 |
*/ |
| 17 |
interface InvoiceItemRepositoryInterface { |
| 18 |
/** |
| 19 |
* Find all items for a specific invoice |
| 20 |
* |
| 21 |
* @param int $invoice_id The invoice ID |
| 22 |
* @return array Array of invoice item data |
| 23 |
*/ |
| 24 |
public function findByInvoice($invoice_id); |
| 25 |
|
| 26 |
/** |
| 27 |
* Find a specific item by index |
| 28 |
* |
| 29 |
* @param int $invoice_id The invoice ID |
| 30 |
* @param int $item_index The item index (0-based) |
| 31 |
* @return array|null The item data or null if not found |
| 32 |
*/ |
| 33 |
public function find($invoice_id, $item_index = null); |
| 34 |
|
| 35 |
/** |
| 36 |
* Get all items (for interface compatibility) |
| 37 |
* |
| 38 |
* @param array $args Optional arguments (ignored for meta-based items) |
| 39 |
* @return array Array of invoice item data |
| 40 |
*/ |
| 41 |
public function all($args = []); |
| 42 |
|
| 43 |
/** |
| 44 |
* Add a new item to an invoice |
| 45 |
* |
| 46 |
* @param int $invoice_id The invoice ID |
| 47 |
* @param array $data The item data |
| 48 |
* @return bool True if successful, false otherwise |
| 49 |
*/ |
| 50 |
public function create($invoice_id, $data); |
| 51 |
|
| 52 |
/** |
| 53 |
* Update an existing item |
| 54 |
* |
| 55 |
* @param int $invoice_id The invoice ID |
| 56 |
* @param int $item_index The item index (0-based) |
| 57 |
* @param array $data The item data |
| 58 |
* @return bool True if successful, false otherwise |
| 59 |
*/ |
| 60 |
public function update($invoice_id, $item_index, $data); |
| 61 |
|
| 62 |
/** |
| 63 |
* Delete an item |
| 64 |
* |
| 65 |
* @param int $invoice_id The invoice ID |
| 66 |
* @param int $item_index The item index (0-based) |
| 67 |
* @return bool True if successful, false otherwise |
| 68 |
*/ |
| 69 |
public function delete($invoice_id, $item_index); |
| 70 |
|
| 71 |
/** |
| 72 |
* Delete all items for an invoice |
| 73 |
* |
| 74 |
* @param int $invoice_id The invoice ID |
| 75 |
* @return bool True if successful, false otherwise |
| 76 |
*/ |
| 77 |
public function deleteAll($invoice_id); |
| 78 |
|
| 79 |
/** |
| 80 |
* Count items for an invoice |
| 81 |
* |
| 82 |
* @param int $invoice_id The invoice ID |
| 83 |
* @return int The count of items |
| 84 |
*/ |
| 85 |
public function count($invoice_id); |
| 86 |
|
| 87 |
/** |
| 88 |
* Get total amount for all items in an invoice |
| 89 |
* |
| 90 |
* @param int $invoice_id The invoice ID |
| 91 |
* @return float The total amount |
| 92 |
*/ |
| 93 |
public function getTotalAmount($invoice_id); |
| 94 |
|
| 95 |
/** |
| 96 |
* Replace all items for an invoice |
| 97 |
* |
| 98 |
* @param int $invoice_id The invoice ID |
| 99 |
* @param array $items Array of item data |
| 100 |
* @return bool True if successful, false otherwise |
| 101 |
*/ |
| 102 |
public function replaceAll($invoice_id, $items); |
| 103 |
} |