<?php

namespace App\Services;

use App\Models\JurnalTrans;
use App\Repositories\JurnalRepository;
use App\Validator\JurnalValidator;
use Illuminate\Database\Eloquent\Collection;

class JurnalService
{
    protected $jurnalRepository;

    public function __construct(JurnalRepository $jurnalRepository)
    {
        $this->jurnalRepository = $jurnalRepository;
    }

    public function findByTransId($id): Collection
    {
        return $this->jurnalRepository->findById($id);
    }

    public function createJurnal($data): JurnalTrans
    {
        JurnalValidator::validate($data);
        return $this->jurnalRepository->createJurnal($data);
    }

    public function deleteJurnal($id)
    {
        return $this->jurnalRepository->deleteJurnal($id);
    }

    public function saldoAkun($id, $tanggal) {
        return $this->jurnalRepository->saldoAkun($id, $tanggal);
    }
}
