<?php
/**
 * Invoice Item Repository Interface
 *
 * @package Easy_Invoice
 * @subpackage Interfaces
 */

namespace EasyInvoice\Interfaces;

/**
 * InvoiceItemRepositoryInterface
 * 
 * Defines the contract for invoice item repository classes.
 * Invoice items are stored as meta fields within invoice posts.
 */
interface InvoiceItemRepositoryInterface {
    /**
     * Find all items for a specific invoice
     *
     * @param int $invoice_id The invoice ID
     * @return array Array of invoice item data
     */
    public function findByInvoice($invoice_id);
    
    /**
     * Find a specific item by index
     *
     * @param int $invoice_id The invoice ID
     * @param int $item_index The item index (0-based)
     * @return array|null The item data or null if not found
     */
    public function find($invoice_id, $item_index = null);
    
    /**
     * Get all items (for interface compatibility)
     *
     * @param array $args Optional arguments (ignored for meta-based items)
     * @return array Array of invoice item data
     */
    public function all($args = []);
    
    /**
     * Add a new item to an invoice
     *
     * @param int $invoice_id The invoice ID
     * @param array $data The item data
     * @return bool True if successful, false otherwise
     */
    public function create($invoice_id, $data);
    
    /**
     * Update an existing item
     *
     * @param int $invoice_id The invoice ID
     * @param int $item_index The item index (0-based)
     * @param array $data The item data
     * @return bool True if successful, false otherwise
     */
    public function update($invoice_id, $item_index, $data);
    
    /**
     * Delete an item
     *
     * @param int $invoice_id The invoice ID
     * @param int $item_index The item index (0-based)
     * @return bool True if successful, false otherwise
     */
    public function delete($invoice_id, $item_index);
    
    /**
     * Delete all items for an invoice
     *
     * @param int $invoice_id The invoice ID
     * @return bool True if successful, false otherwise
     */
    public function deleteAll($invoice_id);
    
    /**
     * Count items for an invoice
     *
     * @param int $invoice_id The invoice ID
     * @return int The count of items
     */
    public function count($invoice_id);
    
    /**
     * Get total amount for all items in an invoice
     *
     * @param int $invoice_id The invoice ID
     * @return float The total amount
     */
    public function getTotalAmount($invoice_id);
    
    /**
     * Replace all items for an invoice
     *
     * @param int $invoice_id The invoice ID
     * @param array $items Array of item data
     * @return bool True if successful, false otherwise
     */
    public function replaceAll($invoice_id, $items);
} 