<?php

declare(strict_types=1);

namespace ApiModel\Domain\Repository;

interface BudgetRepositoryInterface
{
    // Años Fiscales
    public function findFiscalYearById(string $id): ?array;
    public function findFiscalYearByYear(int $year): ?array;
    public function listFiscalYears(): array;
    public function insertFiscalYear(string $id, int $year, string $status): void;
    public function updateFiscalYearStatus(string $id, string $status): void;

    // Clasificadores Presupuestarios
    public function findClassifierById(string $id): ?array;
    public function findClassifierByCode(string $code): ?array;
    public function listClassifiers(): array;
    public function insertClassifier(string $id, string $code, string $name, string $type, ?string $parentId, ?string $accountId): void;
    public function updateClassifier(string $id, string $name, bool $isActive, ?string $accountId): void;

    // Unidades Organizacionales
    public function findOrgUnitById(string $id): ?array;
    public function findOrgUnitByCode(string $code): ?array;
    public function listOrgUnits(): array;
    public function insertOrgUnit(string $id, string $code, string $name, ?string $parentId): void;
    public function updateOrgUnit(string $id, string $name, bool $isActive): void;

    // Formulación (PIA / PIM)
    public function findFormulation(string $fiscalYearId, string $orgUnitId, string $classifierId): ?array;
    public function listFormulations(string $fiscalYearId, ?string $orgUnitId): array;
    public function saveFormulation(string $id, string $fiscalYearId, string $orgUnitId, string $classifierId, float $requestedAmount, float $approvedAmount, float $currentAmount, string $status): void;
    public function updateFormulationCurrentAmount(string $fiscalYearId, string $orgUnitId, string $classifierId, float $delta): void;

    // Modificaciones
    public function findModificationById(string $id): ?array;
    public function listModifications(string $fiscalYearId): array;
    public function insertModification(string $id, string $fiscalYearId, string $type, string $documentNumber, ?string $description, string $approvedAt, string $status, string $createdBy): void;
    public function insertModificationEntry(string $id, string $modificationId, string $orgUnitId, string $classifierId, float $amount): void;
    public function updateModificationStatus(string $id, string $status): void;
    public function getModificationEntries(string $modificationId): array;

    // Ejecuciones
    public function insertExecution(string $id, string $fiscalYearId, string $orgUnitId, string $classifierId, string $phase, string $sourceDocumentType, string $sourceDocumentId, ?string $refExecutionId, float $amount, ?string $description, string $createdBy): void;
    public function listExecutions(string $fiscalYearId, ?string $orgUnitId, ?string $classifierId, ?string $startDate = null, ?string $endDate = null): array;
    public function deleteExecutionsBySource(string $sourceDocumentType, string $sourceDocumentId): void;
    
    // Disponibilidad y Reporte Consolidado
    public function getAvailability(string $fiscalYearId, string $orgUnitId, string $classifierId): array;
    public function getExecutionSummary(string $fiscalYearId, ?string $orgUnitId, ?string $startDate = null, ?string $endDate = null): array;
}
