<?php

namespace App\Http\Controllers;

use App\Services\AccountReceivableService;
use App\Traits\HasResponse;
use Illuminate\Http\Request;

class AccountReceivableController extends Controller
{
    use HasResponse;

    /** @var AccountReceivableService */
    private $accountReceivableService;

    public function __construct(AccountReceivableService $accountReceivableService)
    {
        $this->accountReceivableService = $accountReceivableService;
    }

    public function list(Request $request)
    {
        $withPagination = $this->validatePagination($request->only('perPage', 'page'));
        return $this->accountReceivableService->list($request->all(), $withPagination);
    }

    public function register(Request $request)
    {
        return $this->accountReceivableService->register($request->all());
    }

    public function pay(Request $request)
    {
        return $this->accountReceivableService->pay($request->all());
    }
    public function createOrUpdatePDF($id)
    {
        return $this->accountReceivableService->createOrUpdatePDF($id);
    }

    public function downloadExcel($id)
    {
        return $this->accountReceivableService->downloadExcel($id);
    }

    public function downloadPDF($id)
    {
        return $this->accountReceivableService->downloadPDF($id);
    }
}
