<?php
namespace Incoviba\Service\Contabilidad\Informe;

use DateTimeInterface;
use DateInterval;
use Psr\Log\LoggerInterface;
use Incoviba\Common\Ideal;
use Incoviba\Repository;
use Incoviba\Service;

class Semanal extends Ideal\Service
{
    public function __construct(LoggerInterface $logger, protected Repository\Inmobiliaria $repositoryRepository,
                                protected Service\Inmobiliaria\Cuenta $cuentaService,
                                protected Repository\Contabilidad\Deposito $depositoRepository,
                                protected Service\Contabilidad\Cartola $cartolaService,
                                protected Service\Contabilidad\Movimiento $movimientoService,
                                protected Service\Contabilidad\Informe\Tesoreria\Input\Excel $excelService,
                                protected Service\Contabilidad\Informe\Tesoreria\Output\PDF $pdfService)
    {
        parent::__construct($logger);
    }

    public function getAnterior(DateTimeInterface $fecha): DateTimeInterface
    {
        if (!isset($this->anterior)) {
            $this->anterior = $fecha->sub(new DateInterval('P1D'));
            if ($this->anterior->format('N') === '7') {
                $this->anterior = $fecha->sub(new DateInterval('P3D'));
            }
        }
        return $this->anterior;
    }
    /*public function build(DateTimeInterface $fecha): array
    {}*/
}
